Compare commits

..

No commits in common. "9d539eb9dae8ea8215e4bf436ff596e8c340c4b3" and "5cd825304c661dfaeef8154e9d8a4d3c32102b54" have entirely different histories.

19 changed files with 30 additions and 631 deletions

3
.gitignore vendored
View File

@ -1,6 +1,3 @@
/.vs/* /.vs/*
/SoloEnLan/bin/* /SoloEnLan/bin/*
/SoloEnLan/obj/* /SoloEnLan/obj/*
/packages/*
/MigrationBackup/*
/SoloEnLan/.vs/*

View File

@ -3,19 +3,4 @@
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup> </startup>
<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="tiempoComprovacion" value="300"/>
<add key="tiempoNotificacion" value="120"/>
-->
<add key="tiempoComprovacionPrime" value="10"/>
<add key="tiempoComprovacion" value="1200"/>
<add key="tiempoNotificacion" value="30"/>
<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> </configuration>

View File

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

View File

@ -1,60 +0,0 @@
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 = "Control de seguridad en lan";
this.serviceInstaller1.DisplayName = "SoloEnLan";
this.serviceInstaller1.ServiceName = "SoloEnLan";
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

@ -1,19 +0,0 @@
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

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

View File

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

View File

@ -1,126 +0,0 @@
<?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

@ -12,8 +12,6 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -34,15 +32,10 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<ApplicationIcon>solologo_ico.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@ -53,12 +46,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="model\monitor.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"> <Compile Include="Service1.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
@ -68,34 +55,11 @@
<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\logService.cs" />
<Compile Include="service\NotificacionService.cs" /> <Compile Include="service\NotificacionService.cs" />
<Compile Include="service\shutdownService.cs" /> <Compile Include="service\shutdownService.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
<None Include="script\install.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="script\unista.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
<Version>7.1.3</Version>
</PackageReference>
</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> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -1,6 +0,0 @@
<?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

@ -6,7 +6,6 @@ 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 SoloEnLan.model
{ {
@ -19,9 +18,9 @@ namespace SoloEnLan.model
private int tiempoMensaje; private int tiempoMensaje;
public monitor() public monitor()
{ {
t = new Thread(runMonitor); t = null;
pirate = false; pirate = false;
tiempoComprobacion = int.Parse(ConfigurationManager.AppSettings["tiempoComprovacionPrime"]); tiempoComprobacion = int.Parse(ConfigurationManager.AppSettings["tiempoComprovacion"]);
tiempoMensaje = int.Parse(ConfigurationManager.AppSettings["tiempoNotificacion"]); tiempoMensaje = int.Parse(ConfigurationManager.AppSettings["tiempoNotificacion"]);
} }
@ -30,89 +29,27 @@ namespace SoloEnLan.model
((monitor)m).run(); ((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() private void run()
{ {
while (!pirate) while(!pirate)
{ {
DateTime currentDate = DateTime.Now;
//espera //espera
espera(tiempoComprobacion); Thread.Sleep(tiempoComprobacion);
if (pirate)
continue;
//Thread.Sleep(tiempoComprobacion*1000);
//revisa lan //revisa lan
logService.log("Se comprueba Autorización"); if (conexionService.Getestas())
if (!ConectaSRV())
{ {
logService.log("Pc sin autorizacion");
if (pirate)
continue;
//manda mensaje //manda mensaje
NotificacionService.Notifica(); NotificacionService.Notifica();
//espera despues de mensaje //espera despues de mensaje
//Thread.Sleep(tiempoMensaje*1000); Thread.Sleep(tiempoMensaje);
espera(tiempoMensaje);
if (pirate)
continue;
//apaga //apaga
logService.log("Se apaga maquina");
shutdownService.apagaPc(); shutdownService.apagaPc();
} }
else Thread.Sleep(60);
{
logService.log("Pc autorizado");
}
tiempoComprobacion = int.Parse(ConfigurationManager.AppSettings["tiempoComprovacion"]);
}
}
private bool ConectaSRV()
{
for (int i = 0; i < 3; i++)
{
if (pirate)
return false;
//intenta a srv lan
var res= conexionService.ConectLanSRV();
if( res<0)
espera(5);
else
{
return res == 1;
}
}
for (int i = 0; i < 3; i++)
{
if (pirate)
return false;
//intenta a srv lan
var res = conexionService.ConectExternSRV();
if (res < 0)
espera(5);
else
{
return res == 1;
}
}
return false;
}
}
}
public void start() public void start()
{ {

View File

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

View File

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

View File

@ -1,8 +1,7 @@
using Microsoft.Toolkit.Uwp.Notifications; //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.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -13,19 +12,15 @@ namespace SoloEnLan.service
{ {
public static void Notifica() 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() new ToastContentBuilder()
.AddArgument("action", "viewConversation") .AddArgument("action", "viewConversation")
.AddArgument("conversationId", 9813) .AddArgument("conversationId", 9813)
.AddText("Aviso") .AddText("Aviso")
.AddText(mens) .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 .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,12 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq; using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Policy;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -14,76 +8,10 @@ namespace SoloEnLan.service
{ {
internal class conexionService internal class conexionService
{ {
private static int GetPermisoSRV(string sURL)
{
var resf = -1;
try public static bool Getestas()
{ {
HttpClient client = new HttpClient(); return true;
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).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;
}
return -1;
}
public static int ConectExternSRV()
{
try
{
var sURL = ConfigurationManager.AppSettings["urlExtern"];
return GetPermisoSRV(sURL);
}
catch (Exception e)
{
var ex = e.ToString();
return -1;
}
return -1;
} }
} }
} }

View File

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

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -11,7 +10,7 @@ namespace SoloEnLan.service
{ {
public static void apagaPc() public static void apagaPc()
{ {
Process.Start("shutdown", "/s /f /t 0");
} }
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB