Version final funcional v2

This commit is contained in:
Ernesto Abarca Ortiz 2018-07-26 16:16:13 +02:00
commit f76331f3e7
35 changed files with 1755 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
LectorVerdnatura/bin
LectorVerdnatura/obj

26
LectorVerdnatura.sln Normal file
View File

@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LectorVerdnatura", "LectorVerdnatura\LectorVerdnatura.csproj", "{7292E028-689E-4650-BEBE-718882EB25A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7292E028-689E-4650-BEBE-718882EB25A3}.Debug|Any CPU.ActiveCfg = Debug|x86
{7292E028-689E-4650-BEBE-718882EB25A3}.Debug|x86.ActiveCfg = Debug|x86
{7292E028-689E-4650-BEBE-718882EB25A3}.Debug|x86.Build.0 = Debug|x86
{7292E028-689E-4650-BEBE-718882EB25A3}.Release|Any CPU.ActiveCfg = Release|x86
{7292E028-689E-4650-BEBE-718882EB25A3}.Release|x86.ActiveCfg = Release|x86
{7292E028-689E-4650-BEBE-718882EB25A3}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

BIN
LectorVerdnatura.suo Normal file

Binary file not shown.

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,161 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7292E028-689E-4650-BEBE-718882EB25A3}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LectorVerdnatura</RootNamespace>
<AssemblyName>LectorVerdnatura</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>\\windows\e%24\LectorVerdnaturaV2\Solo-Ejecutable\</PublishUrl>
<Install>true</Install>
<InstallFrom>Unc</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ProductName>Lector Verdnatura</ProductName>
<PublisherName>VerdNatura Levante</PublisherName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>2.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;CODE_ANALYSIS;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>DEBUG;CODE_ANALYSIS;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>847E694540E6C79E6E19C76EBC8E2CCE81737DB1</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>LectorVerdnatura_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="database.cs" />
<Compile Include="frmPrincipal.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmPrincipal.Designer.cs">
<DependentUpon>frmPrincipal.cs</DependentUpon>
</Compile>
<Compile Include="logevent.cs" />
<Compile Include="mail.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="sdklector.cs" />
<EmbeddedResource Include="frmPrincipal.resx">
<DependentUpon>frmPrincipal.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="ClassDiagram1.cd" />
<None Include="LectorVerdnatura_TemporaryKey.pfx" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<COMReference Include="zkemkeeper">
<Guid>{FE9DED34-E159-408E-8490-B720A5E632C7}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 y x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>C:\Users\ernesto\Desktop\test-publicar\|publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>es-ES</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
<PropertyGroup>
<EnableSecurityDebugging>false</EnableSecurityDebugging>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<EnableSQLServerDebugging>false</EnableSQLServerDebugging>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<EnableSQLServerDebugging>false</EnableSQLServerDebugging>
</PropertyGroup>
</Project>

Binary file not shown.

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace LectorVerdnatura
{
static class Program
{
/// <summary>
/// Punto de entrada principal para la aplicación.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmPrincipal());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// La información general sobre un ensamblado se controla mediante el siguiente
// conjunto de atributos. Cambie estos atributos para modificar la información
// asociada con un ensamblado.
[assembly: AssemblyTitle("LectorVerdnatura")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Verdnatura Levante")]
[assembly: AssemblyProduct("LectorVerdnatura")]
[assembly: AssemblyCopyright("Verdnatura Levante")]
[assembly: AssemblyTrademark("Verdnatura Levante")]
[assembly: AssemblyCulture("")]
// Si establece ComVisible como false, los tipos de este ensamblado no estarán visibles
// para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde
// COM, establezca el atributo ComVisible como true en este tipo.
[assembly: ComVisible(false)]
// El siguiente GUID sirve como identificador de typelib si este proyecto se expone a COM
[assembly: Guid("e80665ae-7d44-4501-8712-99dbd5630754")]
// La información de versión de un ensamblado consta de los cuatro valores siguientes:
//
// Versión principal
// Versión secundaria
// Número de compilación
// Revisión
//
// Puede especificar todos los valores o establecer como predeterminados los números de versión de compilación y de revisión
// mediante el asterisco ('*'), como se muestra a continuación:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]

View File

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Este código fue generado por una herramienta.
// Versión de runtime: 4.0.30319.586
//
// Los cambios de este archivo pueden provocar un comportamiento inesperado y se perderán si
// el código se vuelve a generar.
// </auto-generated>
//------------------------------------------------------------------------------
namespace LectorVerdnatura.Properties
{
/// <summary>
/// Clase de recurso con establecimiento inflexible de tipos para buscar cadenas traducidas, etc.
/// </summary>
// StronglyTypedResourceBuilder generó automáticamente esta clase
// a través de una herramienta como ResGen o Visual Studio.
// Para agregar o quitar un miembro, edite el archivo .ResX y, a continuación, vuelva a ejecutar ResGen
// con la opción /str o vuelva a generar su proyecto de VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Devuelve la instancia ResourceManager almacenada en caché utilizada por esta clase.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LectorVerdnatura.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Invalida la propiedad CurrentUICulture del subproceso actual para todas las
/// búsquedas de recursos usando esta clase de recursos con establecimiento inflexible de tipos.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.586
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace LectorVerdnatura.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,16 @@
@echo off
echo.
echo. Instalacion librerias SDK para Fichador con Lector de huellas...
echo.
echo.
echo.
echo Recordatorio: ¿Estas ejecutando este archivo como Administrador?
echo.
echo Recuerda copiar tu mismo estas librerias a c:\windows\system\...
echo (No funciona en c:\windows\system32\ ni creo que en otras carpetas)
echo.
regsvr32 %windir%\system32\zkemkeeper.dll
pause

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,198 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Odbc;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Globalization;
namespace LectorVerdnatura
{
class database
{
private OdbcConnection conn = new OdbcConnection();
//private const String serverdb = "db.verdnatura.es";
//private const String serverport = "3306";
//private const String databasedb = "vn";
private const String serverdb = ""; // "test-db.verdnatura.es";
private const String serverport = ""; // "3307";
private const String databasedb = ""; // "postgresql";
//private const String usuariodb = "root";
//private const String passworddb = "";
private OdbcTransaction myCommit;
private Boolean hayconexion = false;
public database()
{
try
{
if (conn.State == ConnectionState.Closed){
//conn.ConnectionString = "Driver={PostgreSQL Unicode};Connection Reset = True;Connection Lifetime = 600;integrated security=SSPI;Pooling=true;Min Pool Size=1;Max Pool Size=1;Server=" + serverdb + ";database=" + databasedb + ";username=" + usuariodb + ";password=" + passworddb;
//conn.ConnectionString = "Driver={MySQL ODBC 5.1 Driver};Connection Reset = True;Connection Lifetime = 600;integrated security=SSPI;Pooling=true;Min Pool Size=1;Max Pool Size=1;Server=" + serverdb + ";port=" + serverport + ";database=" + databasedb + ";username=" + usuariodb + ";password=" + passworddb;
conn.ConnectionString = "DSN=LectorVerdnaturaV2";
conn.Open();
hayconexion = true;
}
}
catch (Exception ex)
{
logevent.logeventwritefile("Error al conectar al Server " + serverdb + " Puerto: " + serverport + " o DSN: " + conn.ConnectionString);
logevent.logeventwritefile("Error: " + ex.ToString());
hayconexion = false;
}
}
public Boolean Gethayconexion()
{
return this.hayconexion;
}
public Boolean insertarbd(int idemple_lector, String fecha, int warehouseFk) // Esta funcion ya no se debe usar, se inserta directamente la fichada con TODOS los datos.
{
Boolean retorno = false;
if (!hayconexion) return retorno;
String Sql = "INSERT INTO transfer_reader_tmp (nis, date, warehouseFk) VALUES (" + idemple_lector + ", '" + fecha + "'," + warehouseFk + ");";
OdbcCommand cmd = new OdbcCommand(Sql, conn);
myCommit = conn.BeginTransaction();
cmd.Transaction=myCommit;
try
{
cmd.ExecuteNonQuery();
myCommit.Commit();
retorno = true;
}
catch (OdbcException ex) when (ex.Errors[0].NativeError == 1062)
{
logevent.logeventwritefile("Error SQL 2601: Registro con clave duplicada. Ignorando!. SQL: " + Sql);
myCommit.Rollback();
return true;
}
catch (Exception ex)
{
logevent.logeventwritefile("error al ejecutar " + Sql + " Transaccion cancelada!");
logevent.logeventwritefile("Error: " + ex.ToString());
try
{
myCommit.Rollback();
}
catch (OdbcException excommit)
{
if (myCommit.Connection == null)
{
logevent.logeventwritefile("error Commit insertar fichajes ");
logevent.logeventwritefile("Error: " + excommit.ToString());
}
}//catch
}//catch
return retorno;
}//function
public void ejecutarsql(String Sql)
{
if (!hayconexion) return;
//try
//{
OdbcCommand cmd = new OdbcCommand(Sql, conn);
cmd.ExecuteNonQuery();
//}
//catch (OdbcException ex) when (ex.Errors[0].NativeError == 1062)
//{
// Ignoramos el error, la base de datos esta preparada para esto.
// logevent.logeventwritefile("Error SQL 2601: Registro con clave duplicada. Ignorando!. SQL: " + Sql);
//}
//catch (Exception ex)
//{
// logevent.logeventwritefile("Error al ejecutar " + Sql);
// logevent.logeventwritefile("Error: " + ex.ToString());
//}
}
public int proximotimer(String horapc){
const int intervalsinconexion = 600000; //si no hay conexion intervalo 10 minutos.
if (!hayconexion)
{
logevent.logeventwritefile("Sin conexion a la BDD, próxima ejecución a las " + System.DateTime.Now.AddMilliseconds(intervalsinconexion).ToString()); //+ intervalsinconexion/1000 + " segundos");
return intervalsinconexion;
}
String Sql = " SELECT time FROM vn.workerTimeControlSchedule WHERE time > '" + horapc + "' ORDER BY time ASC LIMIT 1;";
try {
OdbcCommand cmd = new OdbcCommand(Sql, conn);
OdbcDataReader reader = cmd.ExecuteReader();
if (reader.HasRows) {
reader.Read();
int interval;
DateTime hora = reader.GetDateTime(0);
logevent.logeventwritefile("Próxima ejecución a las: " + hora.TimeOfDay.ToString());
DateTime ahora = System.DateTime.Now;
TimeSpan diferencia = hora.Subtract(ahora);
interval = (diferencia.Hours * 3600 + diferencia.Minutes * 60 + diferencia.Seconds) * 1000;
reader.Close();
return interval;
} else
{
logevent.logeventwritefile("Aviso: No se ha encontrado proxima ejecucion con hora > " + horapc + ". Tabla vacia o no existe registro '23:59': reintentando en 10 minutos...");
return intervalsinconexion;
}
}
catch (Exception ex) {
logevent.logeventwritefile("error al ejecutar " + Sql);
logevent.logeventwritefile("Error: " + ex.ToString());
logevent.logeventwritefile("Error: reintentando en 10 minutos...");
return intervalsinconexion;
}
}
public void CargarFichadoresDesdeBDD(ref String[,] Fichadores)
{
if (!hayconexion)
{
logevent.logeventwritefile("Error: No esta conectado a la BDD!");
}
else
{
String Sql = ("SELECT WH.id, WH.name, WTCC.host FROM vn.workerTimeControlConfig AS WTCC INNER JOIN vn.warehouse AS WH ON (WTCC.warehouseFk= WH.id) ORDER BY WH.id");
try
{
OdbcCommand cmd = new OdbcCommand(Sql, conn);
OdbcDataReader reader = cmd.ExecuteReader();
for (int a = 0; a <= reader.RecordsAffected - 1; a++)
{
reader.Read();
Fichadores[a, 0] = reader.GetString(0);
Fichadores[a, 1] = reader.GetString(1);
Fichadores[a, 2] = reader.GetString(2);
}
reader.Close();
}
catch (Exception ex)
{
logevent.logeventwritefile("error al ejecutar " + Sql);
logevent.logeventwritefile("Error: " + ex.ToString());
}
}
}
public void CerrarConexion()
{
try { conn.Dispose(); }
catch (Exception ex)
{
logevent.logeventwritefile("Error al cerrar la conexión al Server " + serverdb);
logevent.logeventwritefile("Error: " + ex.ToString());
}
}
} //class
}//namespace

266
LectorVerdnatura/frmPrincipal.Designer.cs generated Normal file
View File

@ -0,0 +1,266 @@
using System.ComponentModel;
namespace LectorVerdnatura
{
partial class frmPrincipal
{
/// <summary>
/// Variable del diseñador requerida.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Limpiar los recursos que se estén utilizando.
/// </summary>
/// <param name="disposing">true si los recursos administrados se deben eliminar; false en caso contrario, false.</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 Windows Forms
/// <summary>
/// Método necesario para admitir el Diseñador. No se puede modificar
/// el contenido del método con el editor de código.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmPrincipal));
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.RecogerFichajes = new System.Windows.Forms.ToolStripMenuItem();
this.comprobarHoraLectorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.Salir = new System.Windows.Forms.ToolStripMenuItem();
this.dataGrid1 = new System.Windows.Forms.DataGridView();
this.Texto = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.btnComprobarConexion = new System.Windows.Forms.Button();
this.btnActualizarLog = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.label1 = new System.Windows.Forms.Label();
this.lvFichadores = new System.Windows.Forms.ListView();
this.workcenter_id = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.name = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.fichador_ip = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.btnDescargarFichajes = new System.Windows.Forms.Button();
this.contextMenuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// notifyIcon1
//
this.notifyIcon1.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info;
this.notifyIcon1.BalloonTipText = "Lector Verdnatura";
this.notifyIcon1.BalloonTipTitle = "Lector Verdnatura";
this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "Lector Verdnatura";
this.notifyIcon1.Visible = true;
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.RecogerFichajes,
this.comprobarHoraLectorToolStripMenuItem,
this.Salir});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(196, 70);
//
// RecogerFichajes
//
this.RecogerFichajes.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.RecogerFichajes.Name = "RecogerFichajes";
this.RecogerFichajes.Size = new System.Drawing.Size(195, 22);
this.RecogerFichajes.Text = "Recoger Fichajes";
this.RecogerFichajes.Click += new System.EventHandler(this.timer1_Tick);
//
// comprobarHoraLectorToolStripMenuItem
//
this.comprobarHoraLectorToolStripMenuItem.Name = "comprobarHoraLectorToolStripMenuItem";
this.comprobarHoraLectorToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.comprobarHoraLectorToolStripMenuItem.Text = "Comprobar hora lector";
this.comprobarHoraLectorToolStripMenuItem.Click += new System.EventHandler(this.comprobarHoraLectorToolStripMenuItem_Click);
//
// Salir
//
this.Salir.Name = "Salir";
this.Salir.Size = new System.Drawing.Size(195, 22);
this.Salir.Text = "Salir";
this.Salir.Click += new System.EventHandler(this.Salir_Click);
//
// dataGrid1
//
this.dataGrid1.AllowUserToAddRows = false;
this.dataGrid1.AllowUserToDeleteRows = false;
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle4.NullValue = "Texto";
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGrid1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
this.dataGrid1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGrid1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Texto});
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dataGrid1.DefaultCellStyle = dataGridViewCellStyle5;
this.dataGrid1.Location = new System.Drawing.Point(12, 142);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGrid1.RowHeadersDefaultCellStyle = dataGridViewCellStyle6;
this.dataGrid1.Size = new System.Drawing.Size(612, 429);
this.dataGrid1.TabIndex = 0;
//
// Texto
//
this.Texto.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Texto.HeaderText = "";
this.Texto.Name = "Texto";
this.Texto.ReadOnly = true;
this.Texto.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// btnComprobarConexion
//
this.btnComprobarConexion.Location = new System.Drawing.Point(486, 12);
this.btnComprobarConexion.Name = "btnComprobarConexion";
this.btnComprobarConexion.Size = new System.Drawing.Size(138, 28);
this.btnComprobarConexion.TabIndex = 2;
this.btnComprobarConexion.Text = "Comprobar Conexión";
this.btnComprobarConexion.UseVisualStyleBackColor = true;
this.btnComprobarConexion.Click += new System.EventHandler(this.button1_Click);
//
// btnActualizarLog
//
this.btnActualizarLog.Location = new System.Drawing.Point(486, 109);
this.btnActualizarLog.Name = "btnActualizarLog";
this.btnActualizarLog.Size = new System.Drawing.Size(138, 27);
this.btnActualizarLog.TabIndex = 3;
this.btnActualizarLog.Text = "Actualizar log";
this.btnActualizarLog.UseVisualStyleBackColor = true;
this.btnActualizarLog.Click += new System.EventHandler(this.button2_Click);
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 5000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 113);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(228, 13);
this.label1.TabIndex = 4;
this.label1.Text = "Ultimas 1000 lineas de c:\\temp\\logfichajes.txt :";
//
// lvFichadores
//
this.lvFichadores.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.workcenter_id,
this.name,
this.fichador_ip});
this.lvFichadores.FullRowSelect = true;
this.lvFichadores.GridLines = true;
this.lvFichadores.Location = new System.Drawing.Point(12, 12);
this.lvFichadores.Name = "lvFichadores";
this.lvFichadores.Size = new System.Drawing.Size(468, 87);
this.lvFichadores.TabIndex = 6;
this.lvFichadores.UseCompatibleStateImageBehavior = false;
this.lvFichadores.View = System.Windows.Forms.View.Details;
//
// workcenter_id
//
this.workcenter_id.Text = "warehouseFk";
this.workcenter_id.Width = 100;
//
// name
//
this.name.Text = "name";
this.name.Width = 150;
//
// fichador_ip
//
this.fichador_ip.Text = "fichador_ip";
this.fichador_ip.Width = 150;
//
// btnDescargarFichajes
//
this.btnDescargarFichajes.Location = new System.Drawing.Point(486, 46);
this.btnDescargarFichajes.Name = "btnDescargarFichajes";
this.btnDescargarFichajes.Size = new System.Drawing.Size(138, 28);
this.btnDescargarFichajes.TabIndex = 7;
this.btnDescargarFichajes.Text = "Descargar Fichajes ahora";
this.btnDescargarFichajes.UseVisualStyleBackColor = true;
this.btnDescargarFichajes.Click += new System.EventHandler(this.btnDescargarFichajes_Click);
//
// frmPrincipal
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(636, 580);
this.Controls.Add(this.btnDescargarFichajes);
this.Controls.Add(this.lvFichadores);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnActualizarLog);
this.Controls.Add(this.btnComprobarConexion);
this.Controls.Add(this.dataGrid1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "frmPrincipal";
this.Text = "Lector Verdnatura";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmPrincipal_FormClosing);
this.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.frmPrincipal_MouseDoubleClick);
this.Resize += new System.EventHandler(this.frmPrincipal_Resize);
this.contextMenuStrip1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.DataGridView dataGrid1;
private System.Windows.Forms.Button btnComprobarConexion;
private System.Windows.Forms.Button btnActualizarLog;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem RecogerFichajes;
private System.Windows.Forms.ToolStripMenuItem Salir;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.ToolStripMenuItem comprobarHoraLectorToolStripMenuItem;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListView lvFichadores;
private System.Windows.Forms.ColumnHeader workcenter_id;
private System.Windows.Forms.ColumnHeader name;
private System.Windows.Forms.ColumnHeader fichador_ip;
private System.Windows.Forms.Button btnDescargarFichajes;
private System.Windows.Forms.DataGridViewTextBoxColumn Texto;
public CancelEventHandler contextMenuStrip1_Opening { get; private set; }
}
}

View File

@ -0,0 +1,198 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;
using System.Diagnostics;
namespace LectorVerdnatura
{
public partial class frmPrincipal : Form
{
private sdklector lector;
private database db;
public frmPrincipal()
{
InitializeComponent();
Process aProcess = Process.GetCurrentProcess();
string aProcName = aProcess.ProcessName;
if (Process.GetProcessesByName(aProcName).Length > 1)
{
string mensaje = " ===== AVISO: LA APLICACION YA ESTA EN EJECUCION!! =====" + Environment.NewLine + "Verifique si hay un icono en la barra de tareas o un proceso anterior colgado." + Environment.NewLine + "Cerrando esta instancia...";
logevent.logeventwritefile(mensaje);
MessageBox.Show(mensaje);
// Application.Exit(); ESTA FORMA NO FUNCIONA EN ESTA APLICACION
Environment.Exit(1);
}
lector = new sdklector();
this.Text = this.Text + " v. " + Application.ProductVersion.ToString();
logevent.logeventwritefile(" ===== Aplicacion inicializada ===== En 10 segundos se intentaran descargar los registros de todos los fichadores de la lista...");
ActualizarLog();
CargarFichadores();
timer1.Interval = 10000;
timer1.Enabled = true;
timer1.Start();
notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
}
private void frmPrincipal_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Hide();
this.notifyIcon1.Visible = true;
}
if (this.WindowState != FormWindowState.Minimized )
{
dataGrid1.Width = this.ClientSize.Width - dataGrid1.Left - 20;
dataGrid1.Height = this.ClientSize.Height - dataGrid1.Top - 20;
dataGrid1.Columns[0].Width = dataGrid1.Width - 50;
}
}
private void frmPrincipal_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (!this.Visible){
this.Show();
this.WindowState = FormWindowState.Normal;
this.notifyIcon1.Visible = false;}
}
private void notifyIcon1_DoubleClick(object Sender, EventArgs e)
{
frmPrincipal_MouseDoubleClick(Sender, null);
}
private void frmPrincipal_FormClosing(object sender, FormClosingEventArgs e)
{
Application.Exit();
//e.Cancel = true;
//this.WindowState = FormWindowState.Minimized;
//frmPrincipal_Resize(this, null);
}
private void Salir_Click(object sender, EventArgs e)
{
this.notifyIcon1.Visible = false;
this.Dispose();
}
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
db=new database();
for (int i = 0; i <= lvFichadores.Items.Count-1; i++)
{
lector.Lipaddr = lvFichadores.Items[i].SubItems[2].Text;
lector.WarehouseFk = int.Parse(lvFichadores.Items[i].SubItems[0].Text);
logevent.logeventwritefile("Conectando a fichador: " + lvFichadores.Items[i].SubItems[2].Text + "...");
ActualizarLog();
if (lector.conexionlector() && db.Gethayconexion())
{
logevent.logeventwritefile("Descargando fichajes...");
ActualizarLog();
lector.ObtenerFichajes(dataGrid1);
if (Debugger.IsAttached)
{
logevent.logeventwritefile(" ===== Detectado Debugger.IsAttached, modo pruebas? no borramos los logs del lector!");
}
else
{
lector.BorrarLogLector();
}
lector.ActualizarFechaLector();
lector.DesconexionLector();
}
}
//obtengo la siguiente hora que se tiene que ejecutar para obtener los fichajes
String HoraActual = DateTime.Now.ToString("HH:mm");
timer1.Interval=db.proximotimer(HoraActual);
if (db.Gethayconexion()) db.CerrarConexion();
logevent.logeventwritefile("Procesados todos los fichadores de la lista.");
ActualizarLog();
timer1.Enabled = true;
}
private void comprobarHoraLectorToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!lector.conexionlector()) return;
lector.ActualizarFechaLector();
lector.DesconexionLector();
}
public void CargarFichadores()
{
db = new database();
String[,] Fichadores = new string[10, 3];
db.CargarFichadoresDesdeBDD(ref Fichadores);
for (int numfich = 0; Fichadores[numfich, 0] != null; numfich++)
{
ListViewItem lvi = new ListViewItem(Fichadores[numfich, 0]);
lvi.SubItems.Add(Fichadores[numfich, 1]);
lvi.SubItems.Add(Fichadores[numfich, 2]);
lvFichadores.Items.Add(lvi);
};
}
private void button1_Click(object sender, EventArgs e)
{
String mensajeterminal="CONEXIÓN ESTABLECIDA";
if (this.lvFichadores.SelectedItems.Count != 1) {
MessageBox.Show("Debe de seleccionar un lector para realizar la conexión"); return; }
lector.Lipaddr = this.lvFichadores.SelectedItems[0].SubItems[2].Text;
if (!lector.conexionlector()) mensajeterminal="No hay conexión con el terminal";
lector.DesconexionLector();
MessageBox.Show(mensajeterminal);
}
private void button2_Click(object sender, EventArgs e)
{
ActualizarLog();
}
public void ActualizarLog()
{
ArrayList arrText = new ArrayList();
int inicio=0;
arrText = logevent.leerlog(); // devuelve todas las lineas del fichero
dataGrid1.Rows.Clear();
if (arrText.Count > 1000) { inicio = arrText.Count - 1000; }
for (int i = inicio; i < arrText.Count; i++)
dataGrid1.Rows.Add(arrText[i]);
dataGrid1.Rows[dataGrid1.Rows.Count - 1].Selected = true;
dataGrid1.FirstDisplayedScrollingRowIndex = dataGrid1.Rows.Count - 1;
Application.DoEvents();
}
private void btnDescargarFichajes_Click(object sender, EventArgs e)
{
logevent.logeventwritefile("Descargando fichajes...");
ActualizarLog();
timer1_Tick(null,null);
}
}//lector
}//namespace

View File

@ -0,0 +1,185 @@
<?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="notifyIcon1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>217, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="notifyIcon1.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAEREAAAEAIADwBAAAFgAAACgAAAARAAAAIgAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8Azc3NAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wDNzc0AAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAANCMGgDSjikA1IoaAM2ODQDMjAb///8A/v7+AP///wD///8A////AObm
5gBmZmYAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0ox2ANGJ/wDRiv8A0InmANKO5wDPjC7///8A////AP//
/wD///8A8/PzAJqamgAAAAAAAAAAAAAAAAAAAAAAAAAAAADRjT8A0Yz/ANOP/wDTj/8A0o7/ANOO8f//
/wD///8AANKHBADJhgQAyIAC7/LxAJqamgAAAAAAAAAAAAAAAAAAAAAAAMyOGQDTjv0A04//ANOP/wDT
j/8A0In/ANCKWADMigoA0o/4ANGM/wDTj+wAz4wvAAAAAbOzswBmZmYAAAAAAAAAAAAAqlUBANKOnQDS
jv8A0o7/ANKO/wDSjP8A0ouTAM6PFADTj/8A04//ANKO/wDTjlD///8A////AP///wD///8A////AP//
/wAA25IEANGOfQDSj7MA0o27ANKN3ADSjr0A0YsQAM+H/wDQh+YAz4fmANGPOP///wD///8A////AP//
/wD///8A////AP///wD///8A////AP///wD+/v4A/v7+AP7+/gD+/v4AAM6MBQDNiwP///8A////AP7/
/wD///8A////AP///wAAzIwKANGOnwDPhf8A0479ANOO4ADSjssA0Y7EANCOCQDSj4QA0Y5sANKQRwDT
j0gA049MANCMJ////wD+/v4A////AADQjIMA0o3/ANOP/wDSjv8A0o7/ANKO/wDTj/0A0ocZANGN9QDS
jv8A0o7/ANKO/wDSjv8A0o7/ANKOnv///wD+/v4AANKO1ADSjv8A04//ANOP/wDTj/8A04//ANOP/wDS
jjAA0o5VANGM/wDTj/8A04//ANOP/wDTj/8A0Yv/ANGNbP///wAA04/aANKO/wDTj/8A04//ANOP/wDT
j/8A0o//ANKNLgDSjUsA0Yv/ANOP/wDTj/8A04//ANOP/wDTj/8A0o/uANONBgDRjbgA0o3/ANOP/wDT
j/8A04//ANOP/wDTj/8A0YwjAL9/AwDRjP8A0o7/ANOP/wDTj/8A04//ANOP/wDRiv8A0Y0zANKMnQDR
iv8A0oz/ANKN/wDSjv8A0o3/ANKPtff9+wD///8AANGNIQDSjv8A047/ANOP/wDTj/8A04//ANKN/wDS
jJQAzo0kANGPLwDQjD4A0o1mANKPdgDRjlcAyIAF////AP///wDt+/YAANKNjgDRi/8A0o3/ANKN/wDS
jf8A0oz/ANKMv////wD///8A////AP///wD///8A////AP///wD+/v4A////AP///wAAv4AFANKOSgDR
ipYA0YqhANKNsADRjr4A0o+///+AAP//gAD//4AAh/+AAIP/gACDH4AAgR+AAOEfgAD//4AAgX+AAAEB
gAABgYAAAYCAAAGAgAABwAAA/8AAAP/wAAA=
</value>
</data>
<metadata name="Texto.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>130, 17</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAEREAAAEAIADwBAAAFgAAACgAAAARAAAAIgAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8Azc3NAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wDNzc0AAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAANCMGgDSjikA1IoaAM2ODQDMjAb///8A/v7+AP///wD///8A////AObm
5gBmZmYAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0ox2ANGJ/wDRiv8A0InmANKO5wDPjC7///8A////AP//
/wD///8A8/PzAJqamgAAAAAAAAAAAAAAAAAAAAAAAAAAAADRjT8A0Yz/ANOP/wDTj/8A0o7/ANOO8f//
/wD///8AANKHBADJhgQAyIAC7/LxAJqamgAAAAAAAAAAAAAAAAAAAAAAAMyOGQDTjv0A04//ANOP/wDT
j/8A0In/ANCKWADMigoA0o/4ANGM/wDTj+wAz4wvAAAAAbOzswBmZmYAAAAAAAAAAAAAqlUBANKOnQDS
jv8A0o7/ANKO/wDSjP8A0ouTAM6PFADTj/8A04//ANKO/wDTjlD///8A////AP///wD///8A////AP//
/wAA25IEANGOfQDSj7MA0o27ANKN3ADSjr0A0YsQAM+H/wDQh+YAz4fmANGPOP///wD///8A////AP//
/wD///8A////AP///wD///8A////AP///wD+/v4A/v7+AP7+/gD+/v4AAM6MBQDNiwP///8A////AP7/
/wD///8A////AP///wAAzIwKANGOnwDPhf8A0479ANOO4ADSjssA0Y7EANCOCQDSj4QA0Y5sANKQRwDT
j0gA049MANCMJ////wD+/v4A////AADQjIMA0o3/ANOP/wDSjv8A0o7/ANKO/wDTj/0A0ocZANGN9QDS
jv8A0o7/ANKO/wDSjv8A0o7/ANKOnv///wD+/v4AANKO1ADSjv8A04//ANOP/wDTj/8A04//ANOP/wDS
jjAA0o5VANGM/wDTj/8A04//ANOP/wDTj/8A0Yv/ANGNbP///wAA04/aANKO/wDTj/8A04//ANOP/wDT
j/8A0o//ANKNLgDSjUsA0Yv/ANOP/wDTj/8A04//ANOP/wDTj/8A0o/uANONBgDRjbgA0o3/ANOP/wDT
j/8A04//ANOP/wDTj/8A0YwjAL9/AwDRjP8A0o7/ANOP/wDTj/8A04//ANOP/wDRiv8A0Y0zANKMnQDR
iv8A0oz/ANKN/wDSjv8A0o3/ANKPtff9+wD///8AANGNIQDSjv8A047/ANOP/wDTj/8A04//ANKN/wDS
jJQAzo0kANGPLwDQjD4A0o1mANKPdgDRjlcAyIAF////AP///wDt+/YAANKNjgDRi/8A0o3/ANKN/wDS
jf8A0oz/ANKMv////wD///8A////AP///wD///8A////AP///wD+/v4A////AP///wAAv4AFANKOSgDR
ipYA0YqhANKNsADRjr4A0o+///+AAP//gAD//4AAh/+AAIP/gACDH4AAgR+AAOEfgAD//4AAgX+AAAEB
gAABgYAAAYCAAAGAgAABwAAA/8AAAP/wAAA=
</value>
</data>
</root>

View File

@ -0,0 +1,49 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Collections;
namespace LectorVerdnatura
{
static class logevent
{
const string sSource="Lector";
const string sLog="Application";
const string fic = @"c:\temp\logfichajes.txt";
public static void logeventwrite(String sEvent)
{
if (!EventLog.SourceExists(sSource))
EventLog.CreateEventSource(sSource, sLog);
EventLog.WriteEntry(sSource, sEvent);
EventLog.WriteEntry(sSource, sEvent,
EventLogEntryType.Warning, 234);
}
public static void logeventwritefile (String texto)
{
System.IO.StreamWriter sw = new System.IO.StreamWriter(fic, true); //anexo al fichero
sw.WriteLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + " " + texto);
sw.Close();
}
public static ArrayList leerlog()
{
string sLine = "";
StreamReader objReader = new StreamReader(fic);
ArrayList arrText = new ArrayList();
while (sLine != null)
{
sLine = objReader.ReadLine();
if (sLine != null)
arrText.Add(sLine);
}
objReader.Close();
return arrText;
}
}//clase
}//namespace

40
LectorVerdnatura/mail.cs Normal file
View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Net.Mail;
using System.Web;
using System.Net;
namespace LectorVerdnatura
{
class mail
{
const string FromEmail = "vfalco@verdnatura.es";
const string From="vfalco";
const string FromPasswd="vyp";
const string To="vicente.falco@gmail.com";
const string smtpServer="smtp.verdnatura.es";
const int port=25;
static System.Net.Mail.MailMessage Email;
public static void enviaremail(String SubjectEmail, String BodyEmail)
{
MailMessage email = new MailMessage();
email.To.Add(new MailAddress(To));
email.From = new MailAddress(FromEmail);
email.Subject = SubjectEmail;
email.Body = BodyEmail;
SmtpClient clienteSmtp = new SmtpClient(smtpServer);
//smtpMail.UseDefaultCredentials = true;
clienteSmtp.UseDefaultCredentials = true;
clienteSmtp.Credentials = new NetworkCredential(From, FromPasswd);
try { clienteSmtp.Send(email); }
catch (Exception ex)
{
logevent.logeventwrite("Error al enviar email a "+To + "con la cuenta "+From + " al servidor "+smtpServer);
logevent.logeventwrite("Error: " + ex.ToString());
}
}
}
}

View File

@ -0,0 +1,241 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using zkemkeeper;
using System.Diagnostics;
using System.Data.Odbc;
namespace LectorVerdnatura
{
class sdklector
{
private CZKEM clector = new CZKEM();
private int iddevice=1;
private database db;
private Boolean hayconexion = false;
private String lipaddr; // = "172.16.252.4";
private int warehouseFk;
public String Lipaddr
{
get { return lipaddr; }
set { lipaddr = value; }
}
public int WarehouseFk
{
get { return warehouseFk; }
set { warehouseFk = value; }
}
private int nrecords = 0; //registro que hay en el lector
public sdklector() { }
public Boolean conexionlector(){
const int lport=4370;
hayconexion = true;
//clector.EnableDevice(iddevice, true);
if (!clector.Connect_Net(lipaddr, lport))
{
logevent.logeventwritefile("Error al conectar con el lector " + lipaddr + ":" + lport);
hayconexion = false;
//mail.enviaremail("Lector Verdnatura: Conexion", mensaje);
}
else clector.EnableDevice(iddevice, false);
return hayconexion;
}//conexionlector
public Boolean ObtenerFichajes(DataGridView dg)
{
Boolean retorno = false;
string sdwEnrollNumber = "";
int idwVerifyMode = 0;
int idwInOutMode = 0;
int idwYear = 0;
int idwMonth = 0;
int idwDay = 0;
int idwHour = 0;
int idwMinute = 0;
int idwSecond = 0;
int idwWorkcode = 0;
int idwErrorCode = 0;
if (hayconexion)
{
retorno = true;
if (ContarRecordsLector() > 0)
{
db = new database();
if (clector.ReadGeneralLogData(iddevice))
{
while (clector.SSR_GetGeneralLogData(iddevice, out sdwEnrollNumber, out idwVerifyMode,
out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode))
{
String FechaRegistro = idwYear.ToString() + "-" + String.Format("{0:0#}", idwMonth) + "-" + String.Format("{0:0#}", idwDay) + " " + String.Format("{0:0#}", idwHour) + ":" + String.Format("{0:0#}", idwMinute) + ":" + String.Format("{0:0#}", idwSecond);
string nuevoregistro = "Registro --> " + sdwEnrollNumber + " --> WH: " + warehouseFk.ToString() + " --> " + FechaRegistro;
logevent.logeventwritefile(nuevoregistro);
dg.Rows.Add(DateTime.Now.ToString() + " " + nuevoregistro);
dg.FirstDisplayedScrollingRowIndex = dg.Rows.Count - 1;
dg.Refresh();
DateTime fecha = DateTime.Parse(FechaRegistro);
String SqlInsert = "INSERT INTO vn.workerTimeControl (userFk, timed, warehouseFk, `order`) " +
" SELECT worker.userfk, '" + FechaRegistro + "', " + warehouseFk + ", " +
" ( " +
" SELECT COALESCE(max(`order`), 0) + 1 from vn.workerTimeControl as wtc " +
" INNER JOIN vn.worker " +
" ON worker.userfk = wtc.userFk " +
" INNER JOIN postgresql.person " +
" ON person.id_trabajador = worker.id " +
" WHERE person.nis = " + int.Parse(sdwEnrollNumber) + " and timed like '" + fecha.Year + "-" + fecha.Month.ToString().PadLeft(2,'0') + "-" + fecha.Day.ToString().PadLeft(2, '0') + "%' " +
" ) " +
" FROM vn.worker INNER JOIN postgresql.person " +
" ON person.id_trabajador = worker.id " +
" WHERE person.nis = " + int.Parse(sdwEnrollNumber) + "; ";
try
{
db.ejecutarsql(SqlInsert);
}
catch (OdbcException ex) when (ex.Errors[0].NativeError == 1062)
{
// Ignoramos el error, la base de datos esta preparada para esto.
// logevent.logeventwritefile("Error SQL 2601: Registro con clave duplicada. Ignorando!. SQL: " + SqlInsert);
}
catch (Exception ex)
{
logevent.logeventwritefile("error al ejecutar " + SqlInsert);
logevent.logeventwritefile("Error: " + ex.ToString());
}
}
Application.DoEvents();
}
else
{
clector.GetLastError(ref idwErrorCode);
if (idwErrorCode != 0)
logevent.logeventwritefile("ErrorCode: " + idwErrorCode.ToString());
else
logevent.logeventwritefile("El terminal " + Lipaddr + " no devuelve registros!");
}
}//contar
}//hayconexion
return retorno;
}
public void BorrarLogLector()
{
int idwErrorCode = 0;
if (nrecords == 0) { logevent.logeventwritefile("No hay Logs para borrar del terminal " + Lipaddr); return;}
if (!hayconexion) { logevent.logeventwritefile("No hay conexión con el lector " + Lipaddr); return; }
if (clector.ClearGLog(iddevice))
{
clector.RefreshData(iddevice);//se borrar los logs
logevent.logeventwritefile("Logs borrados del terminal " + Lipaddr);
}
else
{
clector.GetLastError(ref idwErrorCode);
logevent.logeventwritefile("Error al borrar los logs del terminal " + Lipaddr);
}
}//borrarloglector
private int ContarRecordsLector()
{
int contreglector=0;
int idwErrorCode = 0;
if (clector.GetDeviceStatus(iddevice, 6, ref contreglector))
{
logevent.logeventwritefile("Nº de registros del lector " + Lipaddr + "--> " + contreglector.ToString());
nrecords = contreglector;
return contreglector;
}
else
{
clector.GetLastError(ref idwErrorCode);
logevent.logeventwritefile("Error al contar registros lector " + Lipaddr + ". Error " + idwErrorCode.ToString());
nrecords = 0;
return 0;
}
}//contarrecordslector
public void ActualizarFechaLector()
{
int idwYear=0;
int idwMonth=0;
int idwDay=0;
int idwHour=0;
int idwMinute=0;
int idwSecond = 0;
//Obtengo la fecha, hora y minutos del pc
int PCYear=DateTime.Now.Year;
int PCDay=DateTime.Now.Day;
int PCMonth=DateTime.Now.Month;
int PCHour=DateTime.Now.Hour;
int PCMinute=DateTime.Now.Minute;
int PCSeconds=DateTime.Now.Second;
String PCFechaActual= DateTime.Now.ToString("yyyy-MM-dd");
String PCFechaHoraActual = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
// Obtengo la fecha, hora y minutos lector
clector.GetDeviceTime(iddevice,ref idwYear,ref idwMonth,ref idwDay,ref idwHour,ref idwMinute,ref idwSecond);
String FechaLector=idwYear.ToString()+"-"+String.Format("{0:00}",idwMonth)+"-"+String.Format("{0:00}",idwDay);
String FechaHoraLector = FechaLector + " " + String.Format("{0:00}", idwHour) + ":" + String.Format("{0:00}", idwMinute);
/*
if (PCFechaHoraActual!=FechaHoraLector) {
logevent.logeventwritefile ("Fecha del lector --> "+FechaHoraLector +" y del PC --> "+PCFechaHoraActual + " son distintas. A continuación se sincronizarán");
ProcesoSincronizarReloj(PCYear, PCMonth, PCDay, PCHour, PCMinute, PCSeconds);
return; }
*/
if (PCHour != idwHour){
logevent.logeventwritefile("Hora del lector --> " + String.Format("{0:0#}",idwHour) + ":" + String.Format("{0:0#}",idwMinute) + " y del PC --> " + String.Format("{0:0#}",PCHour) + ":" + String.Format("{0:0#}",PCMinute) + " son distintas. A continuación se sincronizarán");
ProcesoSincronizarReloj(PCYear, PCMonth, PCDay, PCHour, PCMinute, PCSeconds);
return; }
if ((idwMinute > (PCMinute + 5)) || (idwMinute < (PCMinute - 5))){
logevent.logeventwritefile("Hora del lector --> " + String.Format("{0:0#}", idwHour) + ":" + String.Format("{0:0#}", idwMinute) + " y del PC --> " + String.Format("{0:0#}", PCHour) + ":" + String.Format("{0:0#}", PCMinute) + " difieren en más de 5 minutos. A continuación se sincronizarán");
ProcesoSincronizarReloj(PCYear, PCMonth, PCDay, PCHour, PCMinute, PCSeconds);
}
}//ActualizarFechaLector()
private void ProcesoSincronizarReloj (int PCYear,int PCMonth,int PCDay,int PCHour,int PCMinute,int PCSeconds)
{
clector.EnableDevice(iddevice, false);//deshabilito el lector
if (clector.SetDeviceTime2(iddevice,PCYear,PCMonth,PCDay,PCHour,PCMinute,PCSeconds))
logevent.logeventwritefile("Fecha y hora del lector sincronizada con la del PC");
else
{
logevent.logeventwritefile("Error al sincronizar la fecha y hora en el lector");
}
clector.EnableDevice(iddevice, true);//habilito el lector
}// ProcesoSincronizarReloj()
public void DesconexionLector()
{
try {
clector.EnableDevice(iddevice, true);//habilito el lector
clector.Disconnect(); }
catch (Exception ex)
{
logevent.logeventwritefile("Error al desconectar el lector " + ex.ToString());
}
}
}//clase
}//namespace

66
README.md Normal file
View File

@ -0,0 +1,66 @@
Documentacion de instalacion:
https://www.zkteco.eu/index.php/faq-category/sdk/registering-sdk
=================================================================================================================
1. I am using 32 bit windows XP, how can i register the Standalone SDK?
Posted on 2/1/12
Copy all sdk *.dll files to %windir%\system32 folder , and then run cmd.exe ,enter the following command:
regsvr32.exe %windir%\system32\zkemkeeper.dll
If you want to unregister sdk , run cmd.exe ,enter the following command:
regsvr32.exe -u %windir%\system32\zkemkeeper.dll
=================================================================================================================
2. I am using 64 bit windows XP, how can i register the Standalone SDK?
Posted on 2/1/12
Copy all sdk *.dll files to %windir%\sysWOW64 folder , and then run cmd.exe ,enter the following command:
%windir%\syswow64\regsvr32.exe %windir%\syswow64\zkemkeeper.dll
If you want to unregister sdk , run cmd.exe ,enter the following command:
%windir%\syswow64\regsvr32.exe -u %windir%\syswow64\zkemkeeper.dll
=================================================================================================================
3. I am using 32 bit windows Vista/win 7/server 2008, how can i register the Standalone SDK?
Posted on 2/1/12
Copy all sdk *.dll files to %windir%\system32 folder , and then run cmd.exe with administrator previledge ,
enter the following command:
regsvr32.exe %windir%\system32\zkemkeeper.dll
If you want to unregister sdk , run cmd.exe with administrator previledge ,
enter the following command:
%windir%\system32\regsvr32.exe -u %windir%\system32\zkemkeeper.dll
=================================================================================================================
4. I am using 64 bit windows Vista/win 7/server 2008, how can i register the Standalone SDK?
Posted on 2/1/12
Copy all sdk *.dll files to %windir%\sysWOW64 folder , and then run cmd.exe with administrator previledge ,
enter the following command:
%windir%\syswow64\regsvr32.exe %windir%\syswow64\zkemkeeper.dll
If you want to unregister sdk , run cmd.exe with administrator previledge ,
enter the following command:
%windir%\syswow64\regsvr32.exe -u %windir%\syswow64\zkemkeeper.dll