Compare commits

...

5 Commits

Author SHA1 Message Date
Gerardo 1ed021a50c se añade control navegador 2025-07-10 14:13:49 +02:00
Gerardo e7a053c1c8 cambios en git ignore 2024-09-12 08:46:06 +02:00
Gerardo 072777d466 servidor php 2024-09-12 08:45:45 +02:00
Gerardo 9d539eb9da arreglos varios 2024-09-12 08:43:34 +02:00
Gerardo 275fc75e9d configurar gitignore 2024-09-09 11:07:15 +02:00
30 changed files with 1081 additions and 42 deletions

4
.gitignore vendored
View File

@ -1,3 +1,7 @@
/.vs/*
/SoloEnLan/bin/*
/SoloEnLan/obj/*
/packages/*
/MigrationBackup/*
/SoloEnLan/.vs/*
/SoloEnLanServer/log/*

View File

@ -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>

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35013.160
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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -3,4 +3,29 @@
<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="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="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>

View File

@ -7,11 +7,13 @@
<ProjectGuid>{E15ED562-973B-41AB-B45E-3F7944570CAA}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>SoloEnLan</RootNamespace>
<AssemblyName>SoloEnLan</AssemblyName>
<AssemblyName>Narvaling.monitor</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -32,10 +34,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>solologo_ico.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@ -45,7 +52,14 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="model\monitorNavegacion.cs" />
<Compile Include="model\monitor.cs" />
<Compile Include="ProjectInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ProjectInstaller.Designer.cs">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</Compile>
<Compile Include="Service1.cs">
<SubType>Component</SubType>
</Compile>
@ -55,11 +69,30 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="service\conexionService.cs" />
<Compile Include="service\IdService.cs" />
<Compile Include="service\logService.cs" />
<Compile Include="service\NotificacionService.cs" />
<Compile Include="service\shutdownService.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="script\install.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="script\unista.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="solologo_ico.ico" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ProjectInstaller.resx">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Service1.resx">
<DependentUpon>Service1.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>

View File

@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace SoloEnLan
@ -15,11 +18,24 @@ namespace SoloEnLan
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
if (int.Parse(ConfigurationManager.AppSettings["consola"]) == 1)
{
new Service1()
};
ServiceBase.Run(ServicesToRun);
var s = new SoloEnLan();
s.inicia();
while(true)
{
Thread.Sleep(100);
}
}
else
{
ServicesToRun = new ServiceBase[]
{
new SoloEnLan()
};
ServiceBase.Run(ServicesToRun);
}
}
}
}

60
SoloEnLan/ProjectInstaller.Designer.cs generated Normal file
View File

@ -0,0 +1,60 @@
namespace SoloEnLan
{
partial class ProjectInstaller
{
/// <summary>
/// Variable del diseñador necesaria.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Limpiar los recursos que se estén usando.
/// </summary>
/// <param name="disposing">true si los recursos administrados se deben desechar; false en caso contrario.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Código generado por el Diseñador de componentes
/// <summary>
/// Método necesario para admitir el Diseñador. No se puede modificar
/// el contenido de este método con el editor de código.
/// </summary>
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
//
// serviceInstaller1
//
this.serviceInstaller1.Description = "Monitor de procesos narvaling";
this.serviceInstaller1.DisplayName = "Narvaling.monitor";
this.serviceInstaller1.ServiceName = "Narvaling.monitor";
this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1});
}
#endregion
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
private System.ServiceProcess.ServiceInstaller serviceInstaller1;
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Threading.Tasks;
namespace SoloEnLan
{
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="serviceProcessInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="serviceInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>194, 17</value>
</metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@ -1,6 +1,6 @@
namespace SoloEnLan
{
partial class Service1
partial class SoloEnLan
{
/// <summary>
/// Variable del diseñador necesaria.
@ -28,10 +28,18 @@
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.ServiceName = "Service1";
this.eventLog1 = new System.Diagnostics.EventLog();
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
//
// SoloEnLan
//
this.ServiceName = "SoloEnLan";
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();
}
#endregion
private System.Diagnostics.EventLog eventLog1;
}
}

View File

@ -1,4 +1,4 @@
using SoloEnLan.model;
using Narvaling.monitor.model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -8,27 +8,47 @@ using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using Narvaling.monitor.service;
namespace SoloEnLan
{
public partial class Service1 : ServiceBase
public partial class SoloEnLan : ServiceBase
{
monitor m;
public Service1()
monitorNavegacion mn;
private string nombreService = "Narvaling.monitor";
public SoloEnLan()
{
InitializeComponent();
m=new monitor();
if(!EventLog.SourceExists(nombreService))
{
EventLog.CreateEventSource(nombreService,"Application");
}
logService.EventLog = eventLog1;
eventLog1.Source = nombreService;
eventLog1.Log = "Application";
m =new monitor();
mn= new monitorNavegacion();
}
protected override void OnStart(string[] args)
public void inicia()
{
m.start();
mn.start();
}
protected override void OnStart(string[] args)
{
logService.log("Se inicia " + nombreService);
//eventLog1.WriteEntry("Se inicia " + nombreService);
inicia();
logService.log("Fin Inicio " + nombreService);
}
protected override void OnStop()
{
m.fin();
mn.fin();
logService.log("Finaliza" + nombreService);
}
}
}

126
SoloEnLan/Service1.resx Normal file
View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="eventLog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@ -1,4 +1,4 @@
using SoloEnLan.service;
using Narvaling.monitor.service;
using System;
using System.Collections.Generic;
using System.Configuration;
@ -7,7 +7,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace SoloEnLan.model
namespace Narvaling.monitor.model
{
public class monitor
@ -18,10 +18,15 @@ namespace SoloEnLan.model
private int tiempoMensaje;
public monitor()
{
t = null;
pirate = false;
tiempoComprobacion = int.Parse(ConfigurationManager.AppSettings["tiempoComprovacion"]);
tiempoComprobacion = int.Parse(ConfigurationManager.AppSettings["tiempoComprovacionPrime"]);
tiempoMensaje = int.Parse(ConfigurationManager.AppSettings["tiempoNotificacion"]);
if(tiempoComprobacion>0)
t = new Thread(runMonitor);
else
t = null;
pirate = false;
}
private static void runMonitor(object m)
@ -29,32 +34,107 @@ namespace SoloEnLan.model
((monitor)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()
{
while(!pirate)
string aa = IdService.GetMEI();
aa = aa;
while (!pirate)
{
DateTime currentDate = DateTime.Now;
//espera
Thread.Sleep(tiempoComprobacion);
espera(tiempoComprobacion);
if (pirate)
continue;
//Thread.Sleep(tiempoComprobacion*1000);
//revisa lan
if (conexionService.Getestas())
logService.log("Se comprueba Autorización");
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");
if (pirate)
continue;
//manda mensaje
NotificacionService.Notifica();
//espera despues de mensaje
Thread.Sleep(tiempoMensaje);
//Thread.Sleep(tiempoMensaje*1000);
espera(tiempoMensaje);
if (pirate)
continue;
//apaga
logService.log("Se apaga maquina");
shutdownService.apagaPc();
}
Thread.Sleep(60);
if(res<0)
int.Parse(ConfigurationManager.AppSettings["tiempoComprovacionPrime"]);
else
tiempoComprobacion = int.Parse(ConfigurationManager.AppSettings["tiempoComprovacion"]);
}
}
private int ConectaSRV()
{
for (int i = 0; i < 3; i++)
{
if (pirate)
return -1;
//intenta a srv lan
var res= conexionService.ConectLanSRV();
if( res<0)
espera(5);
else
{
return res;
}
}
for (int i = 0; i < 3; i++)
{
if (pirate)
return -1;
//intenta a srv lan
var res = conexionService.ConectExternSRV();
if (res < 0)
espera(5);
else
{
return res;
}
}
return -1;
}
public void start()
{
if (!t.IsAlive)
if (t!=null &&!t.IsAlive)
{
pirate = false;
t.Start(this);
@ -64,7 +144,8 @@ namespace SoloEnLan.model
public void fin()
{
pirate = true;
t.Join();
if(t != null)
t.Join();
}
}

View File

@ -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();
}
}
}

View File

@ -0,0 +1,6 @@
mkdir "C:\Program Files\Narvaling.monitor"
xcopy "%~dp0..\*" "C:\Program Files\Narvaling.monitor"
cd c:\Windows\Microsoft.NET\Framework64\v4.0.30319
installutil.exe "C:\Program Files\Narvaling.monitor\Narvaling.monitor.exe"
pause

View File

@ -0,0 +1,3 @@
cd c:\Windows\Microsoft.NET\Framework64\v4.0.30319
installutil /uninstall "C:\Program Files\Narvaling.monitor\Narvaling.monitor.exe"
pause

View File

@ -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;
}
}
}

View File

@ -1,26 +1,30 @@
//using Microsoft.Toolkit.Uwp.Notifications;
using System;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloEnLan.service
namespace Narvaling.monitor.service
{
internal class NotificacionService
{
public static void Notifica()
{
/*string mens = ConfigurationManager.AppSettings["MensajeAviso"];
string mens = ConfigurationManager.AppSettings["MensajeAviso"];
string exe = ConfigurationManager.AppSettings["notifica.exe"];
if(exe!="")
Process.Start(exe, " \"" + mens + "\"");
/*
new ToastContentBuilder()
.AddArgument("action", "viewConversation")
.AddArgument("conversationId", 9813)
.AddText("Aviso")
.AddText(mens)
.Show(); // Not seeing the Show() method? Make sure you have version 7.0, and if you're using .NET 6 (or later), then your TFM must be net6.0-windows10.0.17763.0 or greater
}
*/
*/
}
}
}

View File

@ -1,17 +1,83 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
namespace SoloEnLan.service
namespace Narvaling.monitor.service
{
internal class conexionService
{
public static bool Getestas()
private static int GetPermisoSRV(string sURL)
{
return true;
var resf = -1;
try
{
HttpClient client = new HttpClient();
int.Parse(ConfigurationManager.AppSettings["tiempoComprovacion"]);
var nombre = System.Environment.MachineName;
client.BaseAddress = new Uri(sURL);
client.DefaultRequestHeaders.Accept.Clear();
var res = client.GetAsync(
"?nombre="+ nombre + "&mei=" + IdService.GetMEI()).Result;
if (res.IsSuccessStatusCode)
{
if (res.StatusCode == HttpStatusCode.OK)
{
var jsonResponse = res.Content.ReadAsStringAsync().Result;
if (jsonResponse != null && jsonResponse.Contains("OK"))
resf=1;
else
resf= 0;
}
}
client.Dispose();
res.Dispose();
}
catch (Exception e)
{
var ex = e.ToString();
return -1;
}
return resf;
}
public static int ConectLanSRV()
{
try
{
var sURL = ConfigurationManager.AppSettings["url"];
return GetPermisoSRV(sURL);
}
catch(Exception e)
{
var ex = e.ToString();
return -1;
}
}
public static int ConectExternSRV()
{
try
{
var sURL = ConfigurationManager.AppSettings["urlExtern"];
return GetPermisoSRV(sURL);
}
catch (Exception e)
{
var ex = e.ToString();
return -1;
}
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Narvaling.monitor.service
{
internal class logService
{
public static EventLog EventLog=null;
public static void log(string msg)
{
;if(EventLog!=null)
{
EventLog.WriteEntry(msg);
}
}
}
}

View File

@ -1,16 +1,17 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloEnLan.service
namespace Narvaling.monitor.service
{
internal class shutdownService
{
public static void apagaPc()
{
Process.Start("shutdown", "/s /f /t 0");
}
}
}

BIN
SoloEnLan/solologo_ico.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

View File

@ -0,0 +1,42 @@
<?php
require_once 'config.php';
require_once 'helper.php';
if(isset($_GET))
{
$res=$res_default;
$sel=0;
$nombre=isset($_GET['nombre']) ? trim($_GET['nombre']): '';
$mei=isset($_GET['mei']) ? trim($_GET['mei']): '';
//isset($_GET['nombre']) ? trim($_GET['nombre']): null;
foreach ($denegados as $pc)
{
if($pc==$mei)
{ $res='NO';
$sel=1;
break;
}
}
if($sel == 0)
{
foreach ($permitidos as $pc)
{
if($pc==$mei)
{ $res='OK';
$sel=1;
break;
}
}
}
$datos=date('Y-m-d H:i:s').';'.getUserIP().';'.$nombre.';'.$mei.';'.$res. PHP_EOL;
$logfile = date('Y-m-d') . '.csv';
$file1 = fopen("log/" . $logfile, "a");
fwrite($file1, $datos);
fclose($file1);
echo $res;
}

View File

@ -0,0 +1,7 @@
<?php
$res_default="NO";
//$res_default="NO"
#$denegados= array("batman", "spiderman", "spirit");
$denegados= array();
#$permitidos= array("pepe", "manuel");
$permitidos= array();

View File

@ -0,0 +1,27 @@
<?php
function getUserIP()
{
// Get real visitor IP behind CloudFlare network
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
$_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if(filter_var($client, FILTER_VALIDATE_IP))
{
$ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
else
{
$ip = $remote;
}
return $ip;
}

View File

@ -0,0 +1,3 @@
<?php
require_once 'autoriza.php';

View File

@ -0,0 +1,6 @@
<?php
echo "<h1>".$_POST['nombre']."<h1>";
echo "<h1>".$_POST['apellidos']."<h1>";
var_dump($_POST);

BIN
User Data(chrome).zip Normal file

Binary file not shown.

7
install.bat Normal file
View File

@ -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