se añade control navegador
parent
e7a053c1c8
commit
1ed021a50c
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||||
|
</startup>
|
||||||
|
<appSettings>
|
||||||
|
<add key="MensajeAviso" value="Este ordenador es propiedad del Colegio La Inmaculada Concepción de San lorenzo de El Escorial. No debe salir de las instalaciones de dicho colegio. Por favor, devuélvalo a su lugar cuanto antes. El sistema se apagará mientras se encuentre fuera."/>
|
||||||
|
<!--
|
||||||
|
<add key="tiempoComprovacion" value="300"/>
|
||||||
|
<add key="tiempoNotificacion" value="120"/>
|
||||||
|
-->
|
||||||
|
<add key="tiempoComprovacionPrime" value="0"/>
|
||||||
|
<add key="tiempoComprovacion" value="1200"/>
|
||||||
|
<add key="tiempoNotificacion" value="30"/>
|
||||||
|
|
||||||
|
|
||||||
|
<add key="tiempoComprovacionNavegador" value="10"/>
|
||||||
|
<add key="NombreProcesosNavegador" value="chrome;"/>
|
||||||
|
<add key="CarpetasBorrarNavegacion" value="C:\Users\hercules\AppData\Local\Google\Chrome\User Data"/>
|
||||||
|
<add key="CarpetasCopiarNavegacion" value="C:\Program Files\Narvaling.monitor\User Data?C:\Users\hercules\AppData\Local\Google\Chrome\User Data"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<add key="url" value="http://10.0.100.5:8002"/>
|
||||||
|
<add key="urlExtern" value="http://sololan.narvaling.com"/>
|
||||||
|
|
||||||
|
<add key="notifica.exe" value="F:\desa\v2022\Notifica\Notifica\bin\Release\notifica.exe"/>
|
||||||
|
<add key="consola" value="1"/>
|
||||||
|
</appSettings>
|
||||||
|
</configuration>
|
||||||
|
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.10.35013.160
|
VisualStudioVersion = 17.10.35013.160
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoloEnLan", "SoloEnLan\SoloEnLan.csproj", "{E15ED562-973B-41AB-B45E-3F7944570CAA}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Narvaling.monitor", "SoloEnLan\Narvaling.monitor.csproj", "{E15ED562-973B-41AB-B45E-3F7944570CAA}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
@ -4,14 +4,24 @@
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||||
</startup>
|
</startup>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<add key="MensajeAviso" value="Este ordenador es propiedad del Colegio Las concepcionistas de San lorenzo de el Escorial. Por favor llevelo a su propietario. El sistema se apagara."/>
|
<add key="MensajeAviso" value="Este ordenador es propiedad del Colegio La Inmaculada Concepción de San lorenzo de El Escorial. No debe salir de las instalaciones de dicho colegio. Por favor, devuélvalo a su lugar cuanto antes. El sistema se apagará mientras se encuentre fuera."/>
|
||||||
<!--
|
<!--
|
||||||
<add key="tiempoComprovacion" value="300"/>
|
<add key="tiempoComprovacion" value="300"/>
|
||||||
<add key="tiempoNotificacion" value="120"/>
|
<add key="tiempoNotificacion" value="120"/>
|
||||||
-->
|
-->
|
||||||
<add key="tiempoComprovacionPrime" value="10"/>
|
<add key="tiempoComprovacionPrime" value="0"/>
|
||||||
<add key="tiempoComprovacion" value="1200"/>
|
<add key="tiempoComprovacion" value="1200"/>
|
||||||
<add key="tiempoNotificacion" value="30"/>
|
<add key="tiempoNotificacion" value="30"/>
|
||||||
|
|
||||||
|
|
||||||
|
<add key="tiempoComprovacionNavegador" value="10"/>
|
||||||
|
<add key="NombreProcesosNavegador" value="edge;"/>
|
||||||
|
<add key="CarpetasBorrarNavegacion" value="C:\Temp\aa\User Data"/>
|
||||||
|
<add key="CarpetasCopiarNavegacion" value="C:\Temp\User Data?C:\Temp\aa\User Data"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<add key="url" value="http://10.0.100.5:8002"/>
|
<add key="url" value="http://10.0.100.5:8002"/>
|
||||||
<add key="urlExtern" value="http://sololan.narvaling.com"/>
|
<add key="urlExtern" value="http://sololan.narvaling.com"/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<ProjectGuid>{E15ED562-973B-41AB-B45E-3F7944570CAA}</ProjectGuid>
|
<ProjectGuid>{E15ED562-973B-41AB-B45E-3F7944570CAA}</ProjectGuid>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>SoloEnLan</RootNamespace>
|
<RootNamespace>SoloEnLan</RootNamespace>
|
||||||
<AssemblyName>SoloEnLan</AssemblyName>
|
<AssemblyName>Narvaling.monitor</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
|
@ -52,6 +52,7 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="model\monitorNavegacion.cs" />
|
||||||
<Compile Include="model\monitor.cs" />
|
<Compile Include="model\monitor.cs" />
|
||||||
<Compile Include="ProjectInstaller.cs">
|
<Compile Include="ProjectInstaller.cs">
|
||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
|
|
@ -68,6 +69,7 @@
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="service\conexionService.cs" />
|
<Compile Include="service\conexionService.cs" />
|
||||||
|
<Compile Include="service\IdService.cs" />
|
||||||
<Compile Include="service\logService.cs" />
|
<Compile Include="service\logService.cs" />
|
||||||
<Compile Include="service\NotificacionService.cs" />
|
<Compile Include="service\NotificacionService.cs" />
|
||||||
<Compile Include="service\shutdownService.cs" />
|
<Compile Include="service\shutdownService.cs" />
|
||||||
|
|
@ -81,11 +83,6 @@
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
|
|
||||||
<Version>7.1.3</Version>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="solologo_ico.ico" />
|
<Content Include="solologo_ico.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
@ -39,9 +39,9 @@
|
||||||
//
|
//
|
||||||
// serviceInstaller1
|
// serviceInstaller1
|
||||||
//
|
//
|
||||||
this.serviceInstaller1.Description = "Control de seguridad en lan";
|
this.serviceInstaller1.Description = "Monitor de procesos narvaling";
|
||||||
this.serviceInstaller1.DisplayName = "SoloEnLan";
|
this.serviceInstaller1.DisplayName = "Narvaling.monitor";
|
||||||
this.serviceInstaller1.ServiceName = "SoloEnLan";
|
this.serviceInstaller1.ServiceName = "Narvaling.monitor";
|
||||||
this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
|
this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
|
||||||
//
|
//
|
||||||
// ProjectInstaller
|
// ProjectInstaller
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using SoloEnLan.model;
|
using Narvaling.monitor.model;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
@ -9,13 +9,15 @@ using System.ServiceProcess;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using SoloEnLan.service;
|
using Narvaling.monitor.service;
|
||||||
namespace SoloEnLan
|
namespace SoloEnLan
|
||||||
{
|
{
|
||||||
public partial class SoloEnLan : ServiceBase
|
public partial class SoloEnLan : ServiceBase
|
||||||
{
|
{
|
||||||
monitor m;
|
monitor m;
|
||||||
private string nombreService = "SoloEnLan";
|
monitorNavegacion mn;
|
||||||
|
|
||||||
|
private string nombreService = "Narvaling.monitor";
|
||||||
public SoloEnLan()
|
public SoloEnLan()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
@ -27,21 +29,25 @@ namespace SoloEnLan
|
||||||
eventLog1.Source = nombreService;
|
eventLog1.Source = nombreService;
|
||||||
eventLog1.Log = "Application";
|
eventLog1.Log = "Application";
|
||||||
m =new monitor();
|
m =new monitor();
|
||||||
|
mn= new monitorNavegacion();
|
||||||
}
|
}
|
||||||
public void inicia()
|
public void inicia()
|
||||||
{
|
{
|
||||||
m.start();
|
m.start();
|
||||||
|
mn.start();
|
||||||
}
|
}
|
||||||
protected override void OnStart(string[] args)
|
protected override void OnStart(string[] args)
|
||||||
{
|
{
|
||||||
logService.log("Se inicia " + nombreService);
|
logService.log("Se inicia " + nombreService);
|
||||||
//eventLog1.WriteEntry("Se inicia " + nombreService);
|
//eventLog1.WriteEntry("Se inicia " + nombreService);
|
||||||
inicia();
|
inicia();
|
||||||
|
logService.log("Fin Inicio " + nombreService);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnStop()
|
protected override void OnStop()
|
||||||
{
|
{
|
||||||
m.fin();
|
m.fin();
|
||||||
|
mn.fin();
|
||||||
logService.log("Finaliza" + nombreService);
|
logService.log("Finaliza" + nombreService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using SoloEnLan.service;
|
using Narvaling.monitor.service;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
|
|
@ -6,9 +6,8 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Windows.Web.UI;
|
|
||||||
|
|
||||||
namespace SoloEnLan.model
|
namespace Narvaling.monitor.model
|
||||||
{
|
{
|
||||||
|
|
||||||
public class monitor
|
public class monitor
|
||||||
|
|
@ -19,10 +18,15 @@ namespace SoloEnLan.model
|
||||||
private int tiempoMensaje;
|
private int tiempoMensaje;
|
||||||
public monitor()
|
public monitor()
|
||||||
{
|
{
|
||||||
t = new Thread(runMonitor);
|
|
||||||
pirate = false;
|
|
||||||
tiempoComprobacion = int.Parse(ConfigurationManager.AppSettings["tiempoComprovacionPrime"]);
|
tiempoComprobacion = int.Parse(ConfigurationManager.AppSettings["tiempoComprovacionPrime"]);
|
||||||
tiempoMensaje = int.Parse(ConfigurationManager.AppSettings["tiempoNotificacion"]);
|
tiempoMensaje = int.Parse(ConfigurationManager.AppSettings["tiempoNotificacion"]);
|
||||||
|
if(tiempoComprobacion>0)
|
||||||
|
t = new Thread(runMonitor);
|
||||||
|
else
|
||||||
|
t = null;
|
||||||
|
|
||||||
|
pirate = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void runMonitor(object m)
|
private static void runMonitor(object m)
|
||||||
|
|
@ -45,6 +49,8 @@ namespace SoloEnLan.model
|
||||||
}
|
}
|
||||||
private void run()
|
private void run()
|
||||||
{
|
{
|
||||||
|
string aa = IdService.GetMEI();
|
||||||
|
aa = aa;
|
||||||
while (!pirate)
|
while (!pirate)
|
||||||
{
|
{
|
||||||
DateTime currentDate = DateTime.Now;
|
DateTime currentDate = DateTime.Now;
|
||||||
|
|
@ -56,7 +62,18 @@ namespace SoloEnLan.model
|
||||||
//Thread.Sleep(tiempoComprobacion*1000);
|
//Thread.Sleep(tiempoComprobacion*1000);
|
||||||
//revisa lan
|
//revisa lan
|
||||||
logService.log("Se comprueba Autorización");
|
logService.log("Se comprueba Autorización");
|
||||||
if (!ConectaSRV())
|
var res = ConectaSRV();
|
||||||
|
|
||||||
|
if(res==1)
|
||||||
|
{
|
||||||
|
logService.log("Pc autorizado");
|
||||||
|
}
|
||||||
|
else if(res<0)
|
||||||
|
{
|
||||||
|
logService.log("Pc sin conexión");
|
||||||
|
//se intentara mas adelante
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
logService.log("Pc sin autorizacion");
|
logService.log("Pc sin autorizacion");
|
||||||
if (pirate)
|
if (pirate)
|
||||||
|
|
@ -72,44 +89,44 @@ namespace SoloEnLan.model
|
||||||
logService.log("Se apaga maquina");
|
logService.log("Se apaga maquina");
|
||||||
shutdownService.apagaPc();
|
shutdownService.apagaPc();
|
||||||
}
|
}
|
||||||
|
if(res<0)
|
||||||
|
int.Parse(ConfigurationManager.AppSettings["tiempoComprovacionPrime"]);
|
||||||
else
|
else
|
||||||
{
|
|
||||||
logService.log("Pc autorizado");
|
|
||||||
}
|
|
||||||
tiempoComprobacion = int.Parse(ConfigurationManager.AppSettings["tiempoComprovacion"]);
|
tiempoComprobacion = int.Parse(ConfigurationManager.AppSettings["tiempoComprovacion"]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ConectaSRV()
|
private int ConectaSRV()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
if (pirate)
|
if (pirate)
|
||||||
return false;
|
return -1;
|
||||||
//intenta a srv lan
|
//intenta a srv lan
|
||||||
var res= conexionService.ConectLanSRV();
|
var res= conexionService.ConectLanSRV();
|
||||||
if( res<0)
|
if( res<0)
|
||||||
espera(5);
|
espera(5);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return res == 1;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
if (pirate)
|
if (pirate)
|
||||||
return false;
|
return -1;
|
||||||
//intenta a srv lan
|
//intenta a srv lan
|
||||||
var res = conexionService.ConectExternSRV();
|
var res = conexionService.ConectExternSRV();
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
espera(5);
|
espera(5);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return res == 1;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -117,7 +134,7 @@ namespace SoloEnLan.model
|
||||||
public void start()
|
public void start()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!t.IsAlive)
|
if (t!=null &&!t.IsAlive)
|
||||||
{
|
{
|
||||||
pirate = false;
|
pirate = false;
|
||||||
t.Start(this);
|
t.Start(this);
|
||||||
|
|
@ -127,6 +144,7 @@ namespace SoloEnLan.model
|
||||||
public void fin()
|
public void fin()
|
||||||
{
|
{
|
||||||
pirate = true;
|
pirate = true;
|
||||||
|
if(t != null)
|
||||||
t.Join();
|
t.Join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,185 @@
|
||||||
|
using Narvaling.monitor.service;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Narvaling.monitor.model
|
||||||
|
{
|
||||||
|
|
||||||
|
public class monitorNavegacion
|
||||||
|
|
||||||
|
{
|
||||||
|
private Thread t;
|
||||||
|
private bool pirate;
|
||||||
|
private int tiempoComprobacion;
|
||||||
|
private bool reiniciaNavegador;
|
||||||
|
public monitorNavegacion()
|
||||||
|
{
|
||||||
|
tiempoComprobacion = int.Parse(ConfigurationManager.AppSettings["tiempoComprovacionNavegador"]);
|
||||||
|
reiniciaNavegador = true;
|
||||||
|
if(tiempoComprobacion>0)
|
||||||
|
t = new Thread(runMonitorNavegador);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
t = null;
|
||||||
|
}
|
||||||
|
pirate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void runMonitorNavegador(object m)
|
||||||
|
{
|
||||||
|
|
||||||
|
((monitorNavegacion)m).run();
|
||||||
|
}
|
||||||
|
private void espera(int nseg)
|
||||||
|
{
|
||||||
|
DateTime currentDate = DateTime.Now;
|
||||||
|
//espera
|
||||||
|
while (!pirate)
|
||||||
|
{
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
long elapsedTicks = DateTime.Now.Ticks- currentDate.Ticks;
|
||||||
|
TimeSpan elapsedSpan = new TimeSpan(elapsedTicks);
|
||||||
|
if (elapsedSpan.TotalSeconds > nseg)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void run()
|
||||||
|
{
|
||||||
|
logService.log("Se inicia monitor de navegador");
|
||||||
|
while (!pirate)
|
||||||
|
{
|
||||||
|
DateTime currentDate = DateTime.Now;
|
||||||
|
//espera
|
||||||
|
espera(tiempoComprobacion);
|
||||||
|
if (pirate)
|
||||||
|
continue;
|
||||||
|
CompruebaNavegador();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CompruebaNavegador()
|
||||||
|
{
|
||||||
|
if(IsNavRun())
|
||||||
|
{
|
||||||
|
reiniciaNavegador = true;
|
||||||
|
}
|
||||||
|
else if(reiniciaNavegador)
|
||||||
|
{
|
||||||
|
logService.log("Se ReiniciaNavegador");
|
||||||
|
reiniciaNavegador = false;
|
||||||
|
reiniciaNav();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void reiniciaNav()
|
||||||
|
{
|
||||||
|
borraDatosNavegacion();
|
||||||
|
copiaPaths();
|
||||||
|
}
|
||||||
|
private bool IsNavRun()
|
||||||
|
{
|
||||||
|
var st = ConfigurationManager.AppSettings["NombreProcesosNavegador"];
|
||||||
|
if (String.IsNullOrWhiteSpace(st))
|
||||||
|
return false;
|
||||||
|
var procesos=st.Split(';');
|
||||||
|
var res = false;
|
||||||
|
foreach(var p in procesos)
|
||||||
|
{
|
||||||
|
res = res || IsProceso(p);
|
||||||
|
if (res)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
private bool IsProceso(string nombreProceso)
|
||||||
|
{
|
||||||
|
Process[] procesos = Process.GetProcessesByName(nombreProceso);
|
||||||
|
|
||||||
|
return procesos.Length > 0;
|
||||||
|
}
|
||||||
|
private void borraDatosNavegacion()
|
||||||
|
{
|
||||||
|
var st = ConfigurationManager.AppSettings["CarpetasBorrarNavegacion"];
|
||||||
|
if (String.IsNullOrWhiteSpace(st))
|
||||||
|
return ;
|
||||||
|
var carpetas = st.Split(';');
|
||||||
|
foreach (var c in carpetas)
|
||||||
|
borraPath(c);
|
||||||
|
}
|
||||||
|
private void borraPath(string path)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(path))
|
||||||
|
return ;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Directory.Exists(path))
|
||||||
|
Directory.Delete(path, recursive: true);
|
||||||
|
if (File.Exists(path))
|
||||||
|
File.Delete(path);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void copiaPaths()
|
||||||
|
{
|
||||||
|
var st = ConfigurationManager.AppSettings["CarpetasCopiarNavegacion"];
|
||||||
|
if (String.IsNullOrWhiteSpace(st))
|
||||||
|
return;
|
||||||
|
var carpetas = st.Split(';');
|
||||||
|
foreach (var c in carpetas)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(c))
|
||||||
|
continue;
|
||||||
|
var dat=c.Split('?');
|
||||||
|
if (dat.Length == 2)
|
||||||
|
copiaDir(dat[0], dat[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void copiaDir(string origen, string destino)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(destino);
|
||||||
|
|
||||||
|
// Copiar archivos
|
||||||
|
foreach (string archivo in Directory.GetFiles(origen))
|
||||||
|
{
|
||||||
|
string nombreArchivo = Path.GetFileName(archivo);
|
||||||
|
string destinoArchivo = Path.Combine(destino, nombreArchivo);
|
||||||
|
File.Copy(archivo, destinoArchivo, overwrite: true); // overwrite opcional
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copiar subdirectorios recursivamente
|
||||||
|
foreach (string subdir in Directory.GetDirectories(origen))
|
||||||
|
{
|
||||||
|
string nombreSubdir = Path.GetFileName(subdir);
|
||||||
|
string destinoSubdir = Path.Combine(destino, nombreSubdir);
|
||||||
|
copiaDir(subdir, destinoSubdir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void start()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (t!=null && !t.IsAlive)
|
||||||
|
{
|
||||||
|
pirate = false;
|
||||||
|
t.Start(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public void fin()
|
||||||
|
{
|
||||||
|
pirate = true;
|
||||||
|
if(t != null)
|
||||||
|
t.Join();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
mkdir "C:\Program Files\Narvaling.monitor"
|
||||||
|
xcopy "%~dp0..\*" "C:\Program Files\Narvaling.monitor"
|
||||||
|
|
||||||
cd c:\Windows\Microsoft.NET\Framework64\v4.0.30319
|
cd c:\Windows\Microsoft.NET\Framework64\v4.0.30319
|
||||||
installutil.exe "C:\Program Files\soloEnLan\soloEnLan.exe"
|
installutil.exe "C:\Program Files\Narvaling.monitor\Narvaling.monitor.exe"
|
||||||
pause
|
pause
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
cd c:\Windows\Microsoft.NET\Framework64\v4.0.30319
|
cd c:\Windows\Microsoft.NET\Framework64\v4.0.30319
|
||||||
installutil /uninstall "C:\Program Files\soloEnLan\soloEnLan.exe"
|
installutil /uninstall "C:\Program Files\Narvaling.monitor\Narvaling.monitor.exe"
|
||||||
pause
|
pause
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Management;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Narvaling.monitor.service
|
||||||
|
{
|
||||||
|
internal class IdService
|
||||||
|
{
|
||||||
|
private static string id=null;
|
||||||
|
private static string ObtenerCPUId()
|
||||||
|
{
|
||||||
|
string cpuInfo = String.Empty;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
System.Management.ManagementClass mgmt = new System.Management.ManagementClass("Win32_Processor");
|
||||||
|
System.Management.ManagementObjectCollection objCol = mgmt.GetInstances();
|
||||||
|
foreach (System.Management.ManagementObject obj in objCol)
|
||||||
|
{
|
||||||
|
if (cpuInfo == String.Empty)
|
||||||
|
{
|
||||||
|
cpuInfo = obj.Properties["ProcessorId"].Value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cpuInfo == String.Empty)
|
||||||
|
cpuInfo = "CPUID";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception exp)
|
||||||
|
{
|
||||||
|
cpuInfo = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return cpuInfo.Trim();
|
||||||
|
|
||||||
|
}
|
||||||
|
private static string ObtenerMotherBoardID()
|
||||||
|
{
|
||||||
|
string serial = "MBID";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard");
|
||||||
|
ManagementObjectCollection moc = mos.Get();
|
||||||
|
|
||||||
|
foreach (ManagementObject mo in moc)
|
||||||
|
{
|
||||||
|
serial = (string)mo["SerialNumber"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exp)
|
||||||
|
{
|
||||||
|
|
||||||
|
serial = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return serial.Trim();
|
||||||
|
}
|
||||||
|
private static string MEI_CODE(int longitud)
|
||||||
|
{
|
||||||
|
string st = ObtenerCPUId() + ObtenerMotherBoardID();
|
||||||
|
var resul = "";
|
||||||
|
|
||||||
|
char[] code = new char[longitud];
|
||||||
|
|
||||||
|
int minus = 'z'-'a'+1;
|
||||||
|
int num = '9' - '0'+1;
|
||||||
|
int mayus = 'Z' - 'A'+1;
|
||||||
|
int maxi = minus + num + mayus;
|
||||||
|
int pos = 0;
|
||||||
|
foreach (char c in st)
|
||||||
|
{
|
||||||
|
code[pos] = (char)(code[pos] ^ c);
|
||||||
|
pos=(pos+1) %longitud;
|
||||||
|
}
|
||||||
|
|
||||||
|
int e;
|
||||||
|
foreach (char c in code)
|
||||||
|
{
|
||||||
|
e = c % maxi;
|
||||||
|
if (e < minus)
|
||||||
|
resul = resul + (char)('a' + (e));
|
||||||
|
else if (e < minus + mayus)
|
||||||
|
resul = resul + (char)('A' + (e - minus));
|
||||||
|
else
|
||||||
|
resul = resul + (char)('0' + (e - minus - mayus));
|
||||||
|
}
|
||||||
|
|
||||||
|
return resul;
|
||||||
|
|
||||||
|
}
|
||||||
|
public static string GetMEI()
|
||||||
|
{
|
||||||
|
if (id == null)
|
||||||
|
id = MEI_CODE(16);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using Microsoft.Toolkit.Uwp.Notifications;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
@ -7,7 +6,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SoloEnLan.service
|
namespace Narvaling.monitor.service
|
||||||
{
|
{
|
||||||
internal class NotificacionService
|
internal class NotificacionService
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ using System.Security.Policy;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SoloEnLan.service
|
namespace Narvaling.monitor.service
|
||||||
{
|
{
|
||||||
internal class conexionService
|
internal class conexionService
|
||||||
{
|
{
|
||||||
|
|
@ -26,7 +26,7 @@ namespace SoloEnLan.service
|
||||||
client.BaseAddress = new Uri(sURL);
|
client.BaseAddress = new Uri(sURL);
|
||||||
client.DefaultRequestHeaders.Accept.Clear();
|
client.DefaultRequestHeaders.Accept.Clear();
|
||||||
var res = client.GetAsync(
|
var res = client.GetAsync(
|
||||||
"?nombre="+ nombre).Result;
|
"?nombre="+ nombre + "&mei=" + IdService.GetMEI()).Result;
|
||||||
|
|
||||||
if (res.IsSuccessStatusCode)
|
if (res.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
|
|
@ -64,9 +64,6 @@ namespace SoloEnLan.service
|
||||||
var ex = e.ToString();
|
var ex = e.ToString();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int ConectExternSRV()
|
public static int ConectExternSRV()
|
||||||
|
|
@ -81,9 +78,6 @@ namespace SoloEnLan.service
|
||||||
var ex = e.ToString();
|
var ex = e.ToString();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SoloEnLan.service
|
namespace Narvaling.monitor.service
|
||||||
{
|
{
|
||||||
internal class logService
|
internal class logService
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SoloEnLan.service
|
namespace Narvaling.monitor.service
|
||||||
{
|
{
|
||||||
internal class shutdownService
|
internal class shutdownService
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,13 @@ if(isset($_GET))
|
||||||
{
|
{
|
||||||
$res=$res_default;
|
$res=$res_default;
|
||||||
$sel=0;
|
$sel=0;
|
||||||
$nombre=isset($_GET['nombre']) ? trim($_GET['nombre']): null;
|
$nombre=isset($_GET['nombre']) ? trim($_GET['nombre']): '';
|
||||||
|
$mei=isset($_GET['mei']) ? trim($_GET['mei']): '';
|
||||||
//isset($_GET['nombre']) ? trim($_GET['nombre']): null;
|
//isset($_GET['nombre']) ? trim($_GET['nombre']): null;
|
||||||
|
|
||||||
foreach ($denegados as $pc)
|
foreach ($denegados as $pc)
|
||||||
{
|
{
|
||||||
if($pc==$nombre)
|
if($pc==$mei)
|
||||||
{ $res='NO';
|
{ $res='NO';
|
||||||
$sel=1;
|
$sel=1;
|
||||||
break;
|
break;
|
||||||
|
|
@ -22,7 +23,7 @@ if(isset($_GET))
|
||||||
{
|
{
|
||||||
foreach ($permitidos as $pc)
|
foreach ($permitidos as $pc)
|
||||||
{
|
{
|
||||||
if($pc==$nombre)
|
if($pc==$mei)
|
||||||
{ $res='OK';
|
{ $res='OK';
|
||||||
$sel=1;
|
$sel=1;
|
||||||
break;
|
break;
|
||||||
|
|
@ -30,7 +31,7 @@ if(isset($_GET))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$datos=date('Y-m-d H:i:s').';'.getUserIP().';'.$nombre.';'.$res. PHP_EOL;
|
$datos=date('Y-m-d H:i:s').';'.getUserIP().';'.$nombre.';'.$mei.';'.$res. PHP_EOL;
|
||||||
|
|
||||||
$logfile = date('Y-m-d') . '.csv';
|
$logfile = date('Y-m-d') . '.csv';
|
||||||
$file1 = fopen("log/" . $logfile, "a");
|
$file1 = fopen("log/" . $logfile, "a");
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,7 @@
|
||||||
|
mkdir "C:\Program Files\Narvaling.monitor"
|
||||||
|
mkdir "C:\Program Files\Narvaling.monitor\UserData(chrome)"
|
||||||
|
xcopy "%~dp0..\*" "C:\Program Files\Narvaling.monitor"
|
||||||
|
xcopy "%~dp0..\UserData(chrome)" "C:\Program Files\Narvaling.monitor\UserData(chrome)" /E /I /H /Y
|
||||||
|
cd c:\Windows\Microsoft.NET\Framework64\v4.0.30319
|
||||||
|
installutil.exe "C:\Program Files\Narvaling.monitor\Narvaling.monitor.exe"
|
||||||
|
pause
|
||||||
Loading…
Reference in New Issue