public void Enroll(long deviceId, string userId, int finger) { var device = Devices(DeviceType.Imputed).FirstOrDefault(d => d.id == deviceId); if (device == null) return; _service = new CZKEMClass(); Connect(device); _service.CancelOperation(); _service.SSR_DelUserTmpExt(MachineNumber, userId, finger);//If the specified index of user's templates has existed ,delete it first.(SSR_DelUserTmp is also available sometimes) _service.OnEnrollFinger += (number, index, result, length) => { int flag, tmpLength; string tmpData; var enroll = _service.GetUserTmpExStr(MachineNumber, userId, finger, out flag, out tmpData, out tmpLength) ? new EnrollEventArgs(true, finger, tmpData) : new EnrollEventArgs(false, -1, null); OnEnrollCompleted(enroll); if (!enroll.Result) return; var userInfo = UsersInfo.FirstOrDefault(u => u.EnrollNumber == userId); if (userInfo == null) return; var fingerPrint = userInfo.FingerPrints.FirstOrDefault(f => f.Finger == finger); if (fingerPrint == null) userInfo.FingerPrints.Add(new FingerPrint { Finger = finger, Data = tmpData }); else fingerPrint.Data = tmpData; }; if (_service.StartEnrollEx(userId, finger, 0)) { _service.StartIdentify();//After enrolling templates,you should let the device into the 1:N verification condition } else { var idwErrorCode = 0; _service.GetLastError(ref idwErrorCode); MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode, "Error"); } }
private void Form_Load(object sender, EventArgs e) { lblIpAddress.Text = _ipAddress; _czkemClass = new CZKEMClass(); _employeeCodes = new Dictionary <string, int>(); Rebind(); }
public xucReg(CZKEMClass czkemClass) { this.InitializeComponent(); this.Init(); this.czkem = czkemClass; this.czkem.OnEnrollFinger += new _IZKEMEvents_OnEnrollFingerEventHandler(this.czkem_OnEnrollFinger); }
public AxDeviceWrapper(CZKEMClass axCZKEM, DeviceConfig config) : this(axCZKEM) { IP = config.IP; Port = config.Port; DeviceName = config.DeviceName; DeviceType = config.Type; }
private AxDeviceWrapper(CZKEMClass axCZKEM) { Device = axCZKEM; _logger = HostLogger.Get <AxDeviceWrapper>(); _timer = new System.Timers.Timer(1000); _timer.Elapsed += OnElapsed; }
public void Enroll(long deviceId, string userId, int finger) { var device = Devices(DeviceType.Imputed).FirstOrDefault(d => d.id == deviceId); if (device == null) { return; } _service = new CZKEMClass(); Connect(device); _service.CancelOperation(); _service.SSR_DelUserTmpExt(MachineNumber, userId, finger);//If the specified index of user's templates has existed ,delete it first.(SSR_DelUserTmp is also available sometimes) _service.OnEnrollFinger += (number, index, result, length) => { int flag, tmpLength; string tmpData; var enroll = _service.GetUserTmpExStr(MachineNumber, userId, finger, out flag, out tmpData, out tmpLength) ? new EnrollEventArgs(true, finger, tmpData) : new EnrollEventArgs(false, -1, null); OnEnrollCompleted(enroll); if (!enroll.Result) { return; } var userInfo = UsersInfo.FirstOrDefault(u => u.EnrollNumber == userId); if (userInfo == null) { return; } var fingerPrint = userInfo.FingerPrints.FirstOrDefault(f => f.Finger == finger); if (fingerPrint == null) { userInfo.FingerPrints.Add(new FingerPrint { Finger = finger, Data = tmpData }); } else { fingerPrint.Data = tmpData; } }; if (_service.StartEnrollEx(userId, finger, 0)) { _service.StartIdentify();//After enrolling templates,you should let the device into the 1:N verification condition } else { var idwErrorCode = 0; _service.GetLastError(ref idwErrorCode); MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode, "Error"); } }
private CZKEMClass GetAPI() { if (api == null) { api = new CZKEMClass(); } return(api); }
public APIForm(ManualResetEvent manualresetevent) { InitializeComponent(); this.manualresetevent = manualresetevent; API = new CZKEMClass(); API.OnHIDNum += API_OnHIDNum; this.FormClosed += APIForm_FormClosed; }
public xfmMachineInformation(CZKEMClass czkemClass, string MachineName, string IP, int MachineNumber) { this.InitializeComponent(); this.Text = string.Concat("Thông Tin Thiết Bị - ", MachineName); this.txtDeviceIP.Text = IP; this.m_MachineNumber = MachineNumber; this.axCZKEM = czkemClass; this.GetInformation(); }
public xfmReg(CZKEMClass czkemClass) { this.InitializeComponent(); xucReg _xucReg = new xucReg(czkemClass) { Dock = DockStyle.Fill }; base.Controls.Add(_xucReg); }
public Machine(string ip, int prt, int mn, int pwd) { this.ipAddress = ip; this.port = prt; this.machineNUmber = mn; this.password = pwd; this.zk = new CZKEMClass(); connect(); }
private void RegisterLibrary() { this.m_IsRegister = false; try { this.axCZKEM = new CZKEMClass(); this.m_IsRegister = true; } catch { this.m_IsRegister = false; } }
public DeviceConnector() { try { axCZKEM = new CZKEMClass(); Console.WriteLine("Zkem object initiated"); } catch (Exception ex) { axCZKEM = new CZKEMClass(); Console.WriteLine("Exception : " + ex.Message); } }
private void APIForm_FormClosed(object sender, FormClosedEventArgs e) { try { API.OnHIDNum -= API_OnHIDNum; API.Disconnect(); API = null; GC.Collect(); } catch (Exception ex) { Logger.Writer.Write(ex); } }
//public DeviceUserManager Users { get; set; } //public AttendanceManager Attendance { get; set; } public Device(string ipAddress) { MachineId = 1; ZApi = new CZKEMClass(); Settings = new DeviceSetting(this); //Users = new DeviceUserManager(this); //Attendance = new AttendanceManager(this); //RegisterEvent(); ZApi.BASE64 = 0; IpAddress = ipAddress; }
//public zkemkeeper.CZKEM deviceConnection = new zkemkeeper.CZKEM(); private void Connect_Click(object sender, EventArgs e) { result.AppendText(DateTime.Now.ToString() + " " + "Application Started."); result.AppendText(Environment.NewLine); myCZKEMClass = new CZKEMClass(); try { bIsConnected = myCZKEMClass.Connect_Net(ipTextbox.Text.Trim(), Convert.ToInt32(portText.Text)); // 4370 is port no of attendance machine if (bIsConnected == true) { Connect.Enabled = false; DisconnetBtn.Enabled = true; StatusText.Text = "Connected"; result.AppendText(DateTime.Now.ToString() + " " + "Device Connected Successfully"); result.AppendText(Environment.NewLine); //Download and display data ========================================================================================================= //result.AppendText(DateTime.Now.ToString() + " " + "Data Download End"); //result.AppendText(Environment.NewLine); //register realtime event handler ==================================================================================================== result.AppendText(DateTime.Now.ToString() + " " + "Registerinig for realtime In/Out update"); result.AppendText(Environment.NewLine); //if (myCZKEMClass.RegEvent(1, 65535)) //{ // myCZKEMClass.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(handleAtt); // myCZKEMClass.OnConnected += new zkemkeeper._IZKEMEvents_OnConnectedEventHandler(HandleConnect); // myCZKEMClass.OnDisConnected += new zkemkeeper._IZKEMEvents_OnDisConnectedEventHandler(HandleConnect); // result.AppendText(DateTime.Now.ToString() + " " + "Registration Successfull"); // result.AppendText(Environment.NewLine); // result.AppendText(DateTime.Now.ToString() + " " + "Please try test finger to realtime test"); // result.AppendText(Environment.NewLine); //} //else //{ // result.AppendText(DateTime.Now.ToString() + " " + "Registration Not Successfull"); // result.AppendText(Environment.NewLine); //} } else { result.AppendText(DateTime.Now.ToString() + " " + "Device Not Conneted"); result.AppendText(Environment.NewLine); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
public void ImportRecordsFromDevice() { string connectionString = @"Data Source=10.10.10.26\PRI;Initial Catalog=CrisTime;Persist Security Info=True;User ID=tabula;Password=tabula~!2"; connectionString = ConfigurationManager.ConnectionStrings["Cnn"].ConnectionString; string str = ConfigurationManager.ConnectionStrings["IP"].ConnectionString; Console.WriteLine(connectionString); CZKEMClass cZKEMClass = new CZKEMClass(); int num = 1; int num1 = 0; num = 1; ImportRecords(cZKEMClass, num, connectionString); }
async void Save_Clicked(object sender, EventArgs e) { Item Attempt = (Item)sender; Client = new CZKEMClass(); bool connected = Client.Connect_Net(Attempt.IP, int.Parse(Attempt.Port)); if (connected) { await Navigation.PushAsync(new NewItemPage(Client)); } else { await DisplayAlert("Not Connected", "We were unable to connect to the door lock", "Ok"); } }
public void Start() { _log.Debug("Iniciando el servicio"); if (controller == null) { controller = new CZKEMClass(); controller.Connect_Net(ConfigManager.ServiceBiometricIPDevice, int.Parse(ConfigManager.ServiceBiometricPortDevice)); } // Activa la recepción de los eventos del dispositivo biométrico controller.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(controller_OnAttTransactionEx); _log.Debug("El servicio inició de manera satisfactoria"); }
private static int GetNumOfRecords(CZKEMClass axCZKEM1, int iMachineNumber, int idwErrorCode) { int num = 0; axCZKEM1.EnableDevice(iMachineNumber, false); if (!axCZKEM1.GetDeviceStatus(iMachineNumber, 6, ref num)) { axCZKEM1.GetLastError(ref idwErrorCode); Console.WriteLine(string.Concat("Operation failed,ErrorCode=", idwErrorCode.ToString()), "Error"); } else { Console.WriteLine(string.Concat("The count of the AttLogs in the device is ", num.ToString()), "Success"); } axCZKEM1.EnableDevice(iMachineNumber, true); return(idwErrorCode); }
private bool conectToDevice(string str, CZKEMClass cZKEMClass, ref int num1) { bool ok; if (!cZKEMClass.Connect_Net(str.ToString(), 4370)) { cZKEMClass.GetLastError(ref num1); this.msg = string.Concat(msg, @"<br />Unable to connect the device,ErrorCode=", num1.ToString()); ok = false; } else { this.msg = string.Concat(msg, @"<br />Connected to device!"); cZKEMClass.RegEvent(1, 65535); ok = true; } return(ok); }
private static bool conectToDevice(string str, CZKEMClass cZKEMClass, ref int num1) { bool ok; if (!cZKEMClass.Connect_Net(str.ToString(), 4370)) { cZKEMClass.GetLastError(ref num1); Console.WriteLine(string.Concat("Unable to connect the device,ErrorCode=", num1.ToString())); ok = false; } else { Console.WriteLine("Current State:Connected"); cZKEMClass.RegEvent(1, 65535); ok = true; } return(ok); }
private static void Main(string[] args) { string connectionString = ConfigurationManager.ConnectionStrings["Cnn"].ConnectionString; string str = ConfigurationManager.ConnectionStrings["IP"].ConnectionString; Console.WriteLine(connectionString); CZKEMClass cZKEMClass = new CZKEMClass(); int num = 1; int num1 = 0; num = 1; Program.DisplayRecords(cZKEMClass, num, connectionString); //Console.WriteLine("Progream ended... press any key"); //Console.ReadKey(); }
public NewItemPage(CZKEMClass client) { InitializeComponent(); axCZKEM1 = client; BindingContext = this; MobileBarcodeScanningOptions options = new MobileBarcodeScanningOptions(); options.UseFrontCameraIfAvailable = true; var scan = new ZXingScannerPage(options); Navigation.PushAsync(scan); scan.OnScanResult += (result) => { QrCode = result.Text; if (ValidateQrCode()) { axCZKEM1.ACUnlock(1, 5); } }; }
public void Connect(bool force, Func <CZKEMClass, bool, bool> onConnected) { try { if (string.IsNullOrEmpty(ConnectionConfig.IP) || ConnectionConfig.Port == 0) { throw new Exception("IP and Port cannot be null or empty"); } logger = LogManager.GetLogger(ToString()); iClockClient = iClockClient ?? new CZKEMClass(); if (IsConnected == true && force) { iClockClient.Disconnect(); iClockClient.OnConnected += IClockClient_OnConnected; iClockClient.OnDisConnected += IClockClient_OnDisConnected; IsConnected = iClockClient.Connect_Net(ConnectionConfig.IP, ConnectionConfig.Port); } if (IsConnected == false) { iClockClient.OnConnected += IClockClient_OnConnected; iClockClient.OnDisConnected += IClockClient_OnDisConnected; IsConnected = iClockClient.Connect_Net(ConnectionConfig.IP, ConnectionConfig.Port); } if (IsConnected == true) { RegisterEvents(); Status = STATUS_CONNECTED; } else { int idwErrorCode = 0; iClockClient.GetLastError(ref idwErrorCode); throw new Exception(idwErrorCode.ToString()); } onConnected(iClockClient, IsConnected); } catch (Exception ex) { logger.Error(ex.Message, ex); } }
//If your device supports the TCP/IP communications, you can refer to this. //when you are using the tcp/ip communication,you can distinguish different devices by their IP address. public void Connect() { int idwErrorCode = 0; _axCZKEM1 = new CZKEMClass(); _bIsConnected = _axCZKEM1.Connect_Net(ApplicationSettings.ATT_IP, ApplicationSettings.ATT_Port); if (_bIsConnected == true) { _iMachineNumber = 1; if (!_axCZKEM1.RegEvent(_iMachineNumber, 65535))//Here you can register the realtime events that you want to be triggered(the parameters 65535 means registering all) { _axCZKEM1.GetLastError(ref idwErrorCode); Disconnect(); throw new Exception("Unable to register to evetns, ErrorCode=" + idwErrorCode.ToString()); } } else { _axCZKEM1.GetLastError(ref idwErrorCode); throw new Exception("Unable to connect the device, ErrorCode=" + idwErrorCode.ToString()); } }
public void InsertFingerDevice(CZKEMClass FingerDevice) { fingerDeviceList.Add(FingerDevice); }
protected void BtnAceptar_Click(object sender, EventArgs e) { // Validamos que se haya seleccionado un control fuente if (!ValidarObjeto(txtPlantilla.SelectedValue)) { MostrarExcepcion(Constantes.MENSAJE_CAMPO_REQUERIDO_TITULO, "Es requerido Seleccionar la plantilla fuente"); return; } // Validamos que se haya seleccionado un control de destino if (!ValidarObjeto(txtControlDestino.SelectedValue)) { MostrarExcepcion(Constantes.MENSAJE_CAMPO_REQUERIDO_TITULO, "Es requerido Seleccionar el Control de Acceso de destino"); return; } // Validamos que el control de destino no sea el mismo que el seleccionado en la fuente if (txtControlDestino.SelectedValue.Equals(txtPlantilla.SelectedValue)) { MostrarExcepcion(Constantes.MENSAJE_CAMPO_CON_ERROR_TITULO, "El Control de Acceso de Destino es el Mismo que el de la fuente de Datos"); } // Obtenemos y validamos el control fuente ControlAcceso controlFuente = null; try { controlFuente = controlAccesoDao.GetById(Int32.Parse(txtPlantilla.SelectedValue)); } catch (Exception ex) { log.Error(String.Format("Error en el Proceso Obtener Control Fuente. Mensaje: [{0}]", ex.Message)); ManejarExcepcion(ex); } if (controlFuente == null) { MostrarExcepcion(Constantes.MENSAJE_CAMPO_CON_ERROR_TITULO, "El control fuente es nulo"); return; } // Obtenemos y validamos el control de destino ControlAcceso controlDestino = null; try { controlDestino = controlAccesoDao.GetById(Int32.Parse(txtControlDestino.SelectedValue)); } catch (Exception ex) { log.Error(String.Format("Error en el Proceso Obtener Control Destino. Mensaje: [{0}]", ex.Message)); ManejarExcepcion(ex); } if (controlDestino == null) { MostrarExcepcion(Constantes.MENSAJE_CAMPO_CON_ERROR_TITULO, "El control de destino es nulo"); return; } // Obtenemos y validamos la lista de plantillas a cargar List <DbDominio.Plantilla> listaPlantilla = null; try { listaPlantilla = plantillaDao.GetListado(null, controlFuente); } catch (Exception ex) { log.Error(String.Format("Error en el Proceso Obtener La plantilla desde el Control Fuente. Mensaje: [{0}]", ex.Message)); ManejarExcepcion(ex); } if (listaPlantilla == null || listaPlantilla.Count == 0) { MostrarExcepcion(Constantes.MENSAJE_CAMPO_CON_ERROR_TITULO, "La plantilla seleccionada es nula o vacia"); return; } // Al parecer todo va bien, iniciarmos el proceso int idwErrorCode = 0; string sdwEnrollNumber = Constantes.TEXTO_BLANCO; string sName = Constantes.TEXTO_BLANCO; int idwFingerIndex = 0; string sTmpData = Constantes.TEXTO_BLANCO; int iPrivilege = 0; string sPassword = Constantes.TEXTO_BLANCO; bool bEnabled = false; int iFlag = 1; int iUpdateFlag = 1; int iMachineNumber = 1; try { log.Info(String.Format("Se Intentará conectar con el control de acceso con ID: [{0}]. El control tiene la direccion ip: [{1}] y el puerto: [{2}]", txtControlDestino.SelectedValue, controlDestino.DireccionIp, controlDestino.Puerto)); CZKEMClass _control = new CZKEMClass(); // _control.PullMode = 1; if (_control.Connect_Net(controlDestino.DireccionIp, Int32.Parse(controlDestino.Puerto.Value.ToString()))) { log.Info(String.Format("Se logro correctamente la conexion con el control con direccion ip: [{0}] y el puerto: [{1}]", controlDestino.DireccionIp, controlDestino.Puerto)); _control.RegEvent(iMachineNumber, 65535); _control.EnableDevice(iMachineNumber, false); if (_control.BeginBatchUpdate(iMachineNumber, iUpdateFlag))//create memory space for batching data { log.Info(String.Format("Inicia el Proceso BeginBatchUpdate Con ImachineNumber : [{0}] iUpdateFlag: [{1}]", iMachineNumber, iUpdateFlag)); string sLastEnrollNumber = "";//the former enrollnumber you have upload(define original value as 0) foreach (DbDominio.Plantilla planti in listaPlantilla) { sdwEnrollNumber = planti.Enrollnumber; sName = planti.Nombre; idwFingerIndex = planti.Fingerindex != null ? planti.Fingerindex.Value : 0; sTmpData = planti.Tmpdata; iPrivilege = planti.Privilege != null ? planti.Privilege.Value : 0; sPassword = planti.Password; bEnabled = planti.Enabled != null ? planti.Enabled.Value : false; iFlag = planti.Flag != null ? planti.Flag.Value : 1; log.Info(String.Format("Se Carga la Siguiente sdwEnrollNumber: [{0}] sName: [{1}], idwFingerIndex: [{2}], sTmpData: [{3}], iPrivilege : [{4}], sPassword : [{5}], bEnabled : [{6}], iFlag: [{7}]", sdwEnrollNumber, sName, idwFingerIndex, sTmpData, iPrivilege, sPassword, bEnabled, iFlag)); if (sdwEnrollNumber != sLastEnrollNumber) //identify whether the user information(except fingerprint templates) has been uploaded { if (_control.SSR_SetUserInfo(iMachineNumber, sdwEnrollNumber, sName, sPassword, iPrivilege, bEnabled)) //upload user information to the memory { log.Info(String.Format("Se Completa El ProcesoS SR_SetUserInfo con la siguiente Informacion_ iMachineNumber [{0}] sdwEnrollNumber: [{1}] sName: [{2}], sPassword: [{3}], iPrivilege : [{4}], bEnabled: [{5}]", iMachineNumber, sdwEnrollNumber, sName, sPassword, iPrivilege, bEnabled)); _control.SetUserTmpExStr(iMachineNumber, sdwEnrollNumber, idwFingerIndex, iFlag, sTmpData);//upload templates information to the memory log.Info(String.Format("Se Completa El Proceso SetUserTmpExStr con la siguiente Informacion_ iMachineNumber [{0}] sdwEnrollNumber: [{1}] idwFingerIndex: [{2}], iFlag: [{3}], sTmpData : [{4}]", iMachineNumber, sdwEnrollNumber, idwFingerIndex, iFlag, sTmpData)); } else { _control.GetLastError(ref idwErrorCode); _control.EnableDevice(iMachineNumber, true); log.Error(String.Format("Error en el Proceso Distribuir La plantilla Al Control de Destino. Codigo de Error: [{0}]", idwErrorCode)); MostrarExcepcion("Error en el proceso", String.Format("Error en el Proceso Distribuir La plantilla Al Control de Destino. Codigo de Error: [{0}]", idwErrorCode)); return; } } else { _control.SetUserTmpExStr(iMachineNumber, sdwEnrollNumber, idwFingerIndex, iFlag, sTmpData); log.Info(String.Format("Se Completa El Proceso SetUserTmpExStr (sdwEnrollNumber != sLastEnrollNumber) con la siguiente Informacion_ iMachineNumber [{0}] sdwEnrollNumber: [{1}] idwFingerIndex: [{2}], iFlag: [{3}], sTmpData : [{4}]", iMachineNumber, sdwEnrollNumber, idwFingerIndex, iFlag, sTmpData)); } sLastEnrollNumber = sdwEnrollNumber; try { Empleado empleado = empleadoDao.GetByNumeroEmpleado(Int32.Parse(sdwEnrollNumber)); if (empleado != null && controlDestino != null) { EmpleadoControlAcceso eca = empleadoControlAccesoDao.GetByControlAcceso(controlDestino, empleado); if (eca == null) { eca = new EmpleadoControlAcceso(); } eca.ControlAcceso = controlDestino; eca.Empleado = empleado; empleadoControlAccesoDao.SaveOrUpdate(eca); } } catch (Exception ex) { log.Error(String.Format("Error en el Proceso Guardar Empleado Control de Acceso en la base de Datos. Mensaje: [{0}]", ex.Message)); log.Error(ex); } } } _control.BatchUpdate(iMachineNumber); //upload all the information in the memory _control.RefreshData(iMachineNumber); //the data in the device should be refreshed _control.EnableDevice(iMachineNumber, true); _control.Disconnect(); MostrarExito("Proceso Completo", "Se completo el proceso exitosamente"); } else { _control.GetLastError(ref idwErrorCode); log.Error(String.Format("Error en el Proceso de Conexion al control con ID [{0}], Direccion IP [{1}] y Puerto [{2}]. Codigo de Error [{3}]", controlDestino.IdControl, controlDestino.DireccionIp, controlDestino.Puerto, idwErrorCode)); MostrarExcepcion("Conexion Invalida", String.Format("Error en el Proceso de Conexion con el Control con Direccion IP: {0} y Puerto {1}", controlDestino.DireccionIp, controlDestino.Puerto)); } } catch (Exception ex) { log.Error(String.Format("Error en el Proceso de Conexion con el control. Mensaje: [{0}]", ex.Message)); ManejarExcepcion(ex); } }
private void ImportRecords(CZKEMClass axCZKEM1, int iMachineNumber, string con) { string str = ""; int num = 0, num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0, num6 = 0, num7 = 0, num8 = 0, num9 = 0, num10 = 0; List <linie> ListReccords = new List <linie>(); List <linie> ListReccordsImported = new List <linie>(); HashSet <ulong> HSetImportedKeys = new HashSet <ulong>(); SqlConnection sqlConnection0 = new SqlConnection(con); sqlConnection0.Open(); string str2 = string.Concat(new string[] { "select year(DATAORA),MONTH(DATAORA),DAY(DATAORA), DATEPART(Hh, DATAORA), DATEPART(n, DATAORA), DATEPART(s, DATAORA) FROM ATTLOG" }); SqlCommand sqlCommand1 = new SqlCommand(str2, sqlConnection0); SqlDataReader reader = sqlCommand1.ExecuteReader(); this.msg = string.Concat(msg, @"<br /> reader ok (already imported keys) "); bool hr = reader.HasRows; int year = 0, month = 0; if (hr) { while (reader.Read()) { linie ir = new linie(); ir.num2 = reader.GetInt32(0); ir.num3 = reader.GetInt32(1); ir.num4 = reader.GetInt32(2); ir.num5 = reader.GetInt32(3); ir.num6 = reader.GetInt32(4); ir.num7 = reader.GetInt32(5); ulong key = (ulong)(ir.num2 * 10000000000 + ir.num3 * 100000000 + ir.num4 * 1000000 + ir.num5 * 10000 + ir.num6 * 100 + ir.num7 * 1); if (year * 100 + month < ir.num2 * 100 + ir.num3) { year = ir.num2; month = ir.num3; } HSetImportedKeys.Add(key); } } this.msg = string.Concat(msg, @"<br /> Already imported keys loaded "); reader.Close(); //this.msg = string.Concat(msg, @"<br /> reader closed "); month -= 6; if (month < 1) { month = +12; year--; } sqlConnection0.Close(); int n1 = 0; bool ok; string strConn = ConfigurationManager.ConnectionStrings["IP"].ConnectionString; ok = conectToDevice(strConn, axCZKEM1, ref n1); if (ok) { axCZKEM1.EnableDevice(iMachineNumber, false); bool flag = axCZKEM1.ReadLastestLogData(iMachineNumber, 1, year, month, 1, 0, 0, 0); this.msg = string.Concat(msg, @"<br /> read finished"); axCZKEM1.EnableDevice(iMachineNumber, true); if (flag) { SqlConnection sqlConnection = new SqlConnection(con); try { while (axCZKEM1.SSR_GetGeneralLogData(iMachineNumber, out str, out num, out num1, out num2, out num3, out num4, out num5, out num6, out num7, ref num8)) { num9++; linie l = new linie(); l.str = str; l.num = num; l.num1 = num1; l.num2 = num2; l.num3 = num3; l.num4 = num4; l.num5 = num5; l.num6 = num6; l.num7 = num7; l.num8 = num8; l.num9 = num9; l.num10 = num10; num10++; ulong key = (ulong)(l.num2 * 10000000000 + l.num3 * 100000000 + l.num4 * 1000000 + l.num5 * 10000 + l.num6 * 100 + l.num7 * 1); bool ex = HSetImportedKeys.Contains(key); if (!ex) { ListReccords.Add(l); } } axCZKEM1.Disconnect(); this.msg = string.Concat(msg, @"<br /> New log list ready, device disconnected! "); if (!ListReccords.Any()) { this.msg = string.Concat(msg, @"<br /> Log list empty. Nothing to import! "); return; } sqlConnection.Open(); this.msg = string.Concat(msg, @"<br /> Connection Open ! (SQL) "); foreach (linie li in ListReccords) { str = li.str; num = li.num; num1 = li.num1; num2 = li.num2; num3 = li.num3; num4 = li.num4; num5 = li.num5; num6 = li.num6; num7 = li.num7; num8 = li.num8; num9 = li.num9; num10 = li.num10; string str1 = string.Concat(new string[] { "INSERT INTO ATTLOG (MARCA,DATAORA,TIP) VALUES (", str, ",'", num2.ToString(), "-", num3.ToString().PadLeft(2, '0'), "-", num4.ToString().PadLeft(2, '0'), " ", num5.ToString(), ":", num6.ToString(), ":", num7.ToString(), "',", num1.ToString(), ") " }); string strMsg = string.Concat(new string[] { @"<br /> -->", str, ",'", num2.ToString(), "-", num3.ToString().PadLeft(2, '0'), "-", num4.ToString().PadLeft(2, '0'), " ", num5.ToString(), ":", num6.ToString(), ":", num7.ToString(), "',", num1.ToString() }); SqlCommand sqlCommand = new SqlCommand(str1, sqlConnection); if (num2 * 10000 + num3 * 100 + num4 > 20161103) { Console.WriteLine(str1); try { sqlCommand.ExecuteNonQuery(); this.msg = string.Concat(msg, strMsg); } catch (Exception exception) { this.msg = string.Concat(msg, exception.Message.ToString()); } } } sqlConnection.Close(); msg = string.Concat(msg, @"<br /> Connection closed (SQL)"); } catch (Exception exception2) { Exception exception1 = exception2; this.msg = string.Concat(msg, @"<br />Can not open connection ! "); this.msg = string.Concat(msg, exception1.Message.ToString()); } } } }
protected void BtnDescargar_Click(object sender, EventArgs e) { log.Info(String.Format("El usuario [{0}] presiono el boton para descargar la plantilla del Control de Acceso con ID: [{1}]", UsuarioActual.Nombre, txtControlAcceso.SelectedValue)); // Validar si se selecciono un control de acceso if (!ValidarObjeto(txtControlAcceso.SelectedValue)) { MostrarAdvertencia(Constantes.MENSAJE_CAMPO_REQUERIDO_TITULO, "Por favor seleccione un control del listado"); return; } ControlAcceso control = null; try { control = controlAccesoDao.GetById(Int32.Parse(txtControlAcceso.SelectedValue)); } catch (Exception ex) { log.Error(String.Format("Error en el Proceso de Conexion con el control. Mensaje: [{0}]", ex.Message)); ManejarExcepcion(ex); } if (control == null) { MostrarAdvertencia("Control de Acceso No Encontrado", String.Format("No fue Posible encontrar el Control de Acceso con identificador [0]", txtControlAcceso.SelectedValue)); return; } // Variables de cajon int iMachineNumber = 1; string sdwEnrollNumber = Constantes.TEXTO_BLANCO; string sName = Constantes.TEXTO_BLANCO; string sPassword = Constantes.TEXTO_BLANCO; int iPrivilege = 0; bool bEnabled = false; int idwErrorCode = 0; int idwFingerIndex; string sTmpData = Constantes.TEXTO_BLANCO; int iTmpLength = 0; int iFlag = 0; try { log.Info(String.Format("Se Intentará conectar con el control de acceso con ID: [{0}]. El control tiene la direccion ip: [{1}] y el puerto: [{2}]", txtControlAcceso.SelectedValue, control.DireccionIp, control.Puerto)); CZKEMClass _control = new CZKEMClass(); if (_control.Connect_Net(control.DireccionIp, Int32.Parse(control.Puerto.Value.ToString()))) { log.Info(String.Format("Se logro correctamente la conexion con el control con direccion ip: [{0}] y el puerto: [{1}]", control.DireccionIp, control.Puerto)); _control.EnableDevice(iMachineNumber, false); _control.ReadAllUserID(iMachineNumber); //read all the user information to the memory _control.ReadAllTemplate(iMachineNumber); //read all the users' fingerprint templates to the memory while (_control.SSR_GetAllUserInfo(iMachineNumber, out sdwEnrollNumber, out sName, out sPassword, out iPrivilege, out bEnabled))//get all the users' information from the memory { log.Info(String.Format("Se obtienen los datos iMachineNumber: [{0}], sdwEnrollNumber: [{1}], sName: [{2}], sPassword: [{3}], iPrivilege: [{4}], bEnabled: [{5}]", iMachineNumber, sdwEnrollNumber, sName, sPassword, iPrivilege, bEnabled)); for (idwFingerIndex = 0; idwFingerIndex < 10; idwFingerIndex++) { if (_control.GetUserTmpExStr(iMachineNumber, sdwEnrollNumber, idwFingerIndex, out iFlag, out sTmpData, out iTmpLength))//get the corresponding templates string and length from the memory { log.Info(String.Format("Se obtienen los datos idwFingerIndex: [{0}], iFlag: [{1}], sTmpData: [{2}], iTmpLength: [{3}]", idwFingerIndex, iFlag, sTmpData, iTmpLength)); try { DbDominio.Plantilla planti = plantillaDao.GetByControlAccesoEnrollNumberFingerIndex(control, sdwEnrollNumber, idwFingerIndex); if (planti == null) { planti = new DbDominio.Plantilla(); planti.ControlAcceso = control; planti.Usuario_creado_por = UsuarioActual; log.Info("Se creará una plantilla nueva a partir de estos datos"); } else { log.Info("Esta es una plantilla nueva que se insertara"); } planti.FechaModificacion = DateTime.Now; planti.Usuario_modificado_por = UsuarioActual; planti.Enabled = bEnabled; planti.Enrollnumber = sdwEnrollNumber; planti.Fingerindex = idwFingerIndex; planti.Flag = iFlag; planti.IpControlTemplate = control.DireccionIp; planti.Nombre = sName; planti.Password = sPassword; planti.Privilege = iPrivilege; planti.Status = true; planti.Tmpdata = sTmpData; plantillaDao.SaveOrUpdate(planti); try { Empleado empleado = empleadoDao.GetByNumeroEmpleado(Int32.Parse(sdwEnrollNumber)); if (empleado != null && control != null) { EmpleadoControlAcceso eca = empleadoControlAccesoDao.GetByControlAcceso(control, empleado); if (eca == null) { eca = new EmpleadoControlAcceso(); } eca.CveEmpleado = empleado.CveEmpleado; eca.CveControlAcceso = control.CveControlAcceso; eca.ControlAcceso = control; eca.Empleado = empleado; empleadoControlAccesoDao.SaveOrUpdate(eca); } } catch (Exception ex) { log.Error(String.Format("Error en el Proceso Guardar Empleado Control de Acceso en la base de Datos. Mensaje: [{0}]", ex.Message)); log.Error(ex); } } catch (Exception ex) { log.Error(String.Format("Error en el Proceso Guardar Plantilla en la base de Datos. Mensaje: [{0}]", ex.Message)); log.Error(ex); } } } } _control.Disconnect(); MostrarExito("Proceso Completo", "Se completo el proceso exitosamente"); } else { _control.GetLastError(ref idwErrorCode); log.Error(String.Format("Error en el Proceso de Conexion al control con ID [{0}], Direccion IP [{1}] y Puerto [{2}]. Codigo de Error [{3}]", control.IdControl, control.DireccionIp, control.Puerto, idwErrorCode)); MostrarExcepcion("Conexion Invalida", String.Format("Error en el Proceso de Conexion con el Control con Direccion IP: {0} y Puerto {1}", control.DireccionIp, control.Puerto)); } } catch (Exception ex) { log.Error(String.Format("Error en el Proceso de Conexion con el control. Mensaje: [{0}]", ex.Message)); ManejarExcepcion(ex); } }
public static void iniciarColeccion() { // Variables de Cajon int iMachineNumber = 1; int idwErrorCode = 0; string sdwEnrollNumber = Constantes.TEXTO_BLANCO; 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; // Variables de acceso a la base de datos IControlAccesoDao controlAccesoDao = daoFactory.GetControlAccesoDao(); IColectorMovimientoDao colectorMovimientoDao = daoFactory.GetColectorMovimientosDao(); IColectorMovimientoIncidenciaDao colectorMovimientoIncidenciaDao = daoFactory.GetColectorMovimientosIncidenciaDao(); IEmpleadoDao empleadoDao = daoFactory.GetEmpleadoDao(); IIncidenciaDao incidenciaDao = daoFactory.GetIncidenciaDao(); logger.Info("PROCESO COLECTOR: Ejecucion automatica de la tarea de coleccion"); List <ControlAcceso> lista = null; try { lista = controlAccesoDao.GetListado(true, null, DbDao.ControlAccesoDao.Ordenamiento.FechaUltimaConexion); } catch (Exception ex) { logger.Error(String.Format("Error al intentar obtener la lista de Controles de Acceso. Detalles: [{0}]", ex.Message), ex); } if (lista != null && lista.Count > 0) { foreach (ControlAcceso control in lista) { logger.Info(String.Format("Procesando control con Nombre: [{0}], Direccion IP: [{1}] y Puerto: [{2}]", control.Nombre, control.DireccionIp, control.Puerto)); try { CZKEMClass _control = new CZKEMClass(); if (_control.Connect_Net(control.DireccionIp, Int32.Parse(control.Puerto.Value.ToString()))) { // Deshabilitanos el control _control.EnableDevice(iMachineNumber, false); logger.Info(String.Format("Conectado al control con Nombre: [{0}], Direccion IP: [{1}] y Puerto: [{2}]", control.Nombre, control.DireccionIp, control.Puerto)); try { control.FechaUltimaConexion = DateTime.Now; controlAccesoDao.SaveOrUpdate(control); } catch (Exception ex) { logger.Warn(String.Format("Error al actualizar la Fecha de Ultima Conexionc del Control con Nombre: [{0}], Direccion IP: [{1}] y Puerto: [{2}]. Codigo de Error: [{3}]", control.Nombre, control.DireccionIp, control.Puerto, idwErrorCode)); logger.Warn(ex); } if (_control.ReadGeneralLogData(iMachineNumber)) { logger.Info(String.Format("Lectura de Datos Generales con EXITO control con Nombre: [{0}], Direccion IP: [{1}] y Puerto: [{2}]", control.Nombre, control.DireccionIp, control.Puerto)); while (_control.SSR_GetGeneralLogData(iMachineNumber, out sdwEnrollNumber, out idwVerifyMode, out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode)) { logger.Info(String.Format("Datos Obtenidos: CveControlAcceso: [{0}], sdwEnrollNumber: [{1}], idwVerifyMode: [{2}], idwInOutMode: [{3}], idwYear: [{4}], idwMonth: [{5}], idwDay: [{6}], idwHour: [{7}], idwMinute: [{8}], idwSecond: [{9}], idwWorkcode: [{10}]", control.CveControlAcceso, sdwEnrollNumber, idwVerifyMode, idwInOutMode, idwYear, idwMonth, idwDay, idwHour, idwMinute, idwSecond, idwWorkcode)); ColectorMovimiento colector = new ColectorMovimiento(control.IdControl, control.CveControlAcceso, sdwEnrollNumber, idwVerifyMode, idwInOutMode, idwYear, idwMonth, idwDay, idwHour, idwMinute, idwSecond, idwWorkcode); ColectorMovimiento up = colectorMovimientoDao.SaveOrUpdate(colector); colector = up; } } else { _control.GetLastError(ref idwErrorCode); if (idwErrorCode != 0) { String strError = String.Format("ERROR de conexion al control con Nombre: [{0}], Direccion IP: [{1}] y Puerto: [{2}]. Codigo de Error [{3}]", control.Nombre, control.DireccionIp, control.Puerto, idwErrorCode); logger.Error(strError); try { ColectorMovimientoIncidencia coleMovIncidencia = new ColectorMovimientoIncidencia(); coleMovIncidencia.ControlAcceso = control; coleMovIncidencia.Detalles = strError; colectorMovimientoIncidenciaDao.Save(coleMovIncidencia); } catch (Exception ex) { logger.Warn(String.Format("No se pudo guardar la incidencia de coleccion de movimientos. Mensaje: [{0}]", ex.Message)); } } else { logger.Info(String.Format("OK. El control Reporta que NO existen movimientos. Datos de conexion son Nombre: [{0}], Direccion IP: [{1}] y Puerto: [{2}]. Codigo de Mensaje: [{3}]", control.Nombre, control.DireccionIp, control.Puerto, idwErrorCode)); } } // Limpiamos el log if (_control.ClearGLog(iMachineNumber)) { _control.RefreshData(iMachineNumber); } else { _control.GetLastError(ref idwErrorCode); logger.Error(String.Format("Error en el Proceso de Limpiar el LOG del Control con Nombre: [{0}], Direccion IP: [{1}] y Puerto: [{2}]. Codigo de Error: [{3}]", control.Nombre, control.DireccionIp, control.Puerto, idwErrorCode)); } _control.EnableDevice(iMachineNumber, true); _control.Disconnect(); } else { _control.GetLastError(ref idwErrorCode); String strError = String.Format("Error en el Proceso de Conexion al control con Nombre: [{0}], Direccion IP: [{1}] y Puerto: [{2}]. Codigo de Error: [{3}]", control.Nombre, control.DireccionIp, control.Puerto, idwErrorCode); logger.Error(strError); try { ColectorMovimientoIncidencia coleMovIncidencia = new ColectorMovimientoIncidencia(); coleMovIncidencia.ControlAcceso = control; coleMovIncidencia.Detalles = strError; colectorMovimientoIncidenciaDao.Save(coleMovIncidencia); } catch (Exception ex) { logger.Warn(String.Format("No se pudo guardar la incidencia de coleccion de movimientos. Mensaje: [{0}]", ex.Message)); } } } catch (Exception ex) { String strError = String.Format("Error en el Proceso de Procesar Control con Nombre: [{0}], Direccion IP: [{1}] y Puerto: [{2}]. Codigo de Error: [{3}]", control.Nombre, control.DireccionIp, control.Puerto, idwErrorCode); logger.Error(strError); logger.Error(ex); try { ColectorMovimientoIncidencia coleMovIncidencia = new ColectorMovimientoIncidencia(); coleMovIncidencia.ControlAcceso = control; coleMovIncidencia.Detalles = strError; colectorMovimientoIncidenciaDao.Save(coleMovIncidencia); } catch (Exception except) { logger.Warn(String.Format("No se pudo guardar la incidencia de coleccion de movimientos. Mensaje: [{0}]", except.Message)); } } } // Se inicia el purrun de la tabla de inicidencias List <ColectorMovimiento> listaColector = colectorMovimientoDao.GetListado(); if (listaColector != null && listaColector.Count > 0) { foreach (ColectorMovimiento movimiento in listaColector) { try { Empleado empleado = empleadoDao.GetByNumeroEmpleado(Int32.Parse(movimiento.EnrollNumber)); ControlAcceso control = controlAccesoDao.GetById(movimiento.CveControlAcceso); DateTime fechaAlta = DateTime.Now; DateTime fechaIncidencia = new DateTime(movimiento.Year != null ? movimiento.Year.Value : fechaAlta.Year, movimiento.Month != null ? movimiento.Month.Value : fechaAlta.Month, movimiento.Day != null ? movimiento.Day.Value : fechaAlta.Day, movimiento.Hour != null ? movimiento.Hour.Value : fechaAlta.Hour, movimiento.Minute != null ? movimiento.Minute.Value : fechaAlta.Minute, movimiento.Second != null ? movimiento.Second.Value : fechaAlta.Second); if (empleado == null) { String strError = String.Format("ADVERTENCIA: El Empleado con clave [{0}] no fue encontrado en la base de datos. Esta incidencia no se guardara", movimiento.EnrollNumber); logger.Warn(strError); try { ColectorMovimientoIncidencia coleMovIncidencia = new ColectorMovimientoIncidencia(); coleMovIncidencia.ControlAcceso = control; coleMovIncidencia.Detalles = strError; coleMovIncidencia.CveEmpleado = movimiento.EnrollNumber; colectorMovimientoIncidenciaDao.Save(coleMovIncidencia); } catch (Exception except) { logger.Warn(String.Format("No se pudo guardar la incidencia de coleccion de movimientos. Mensaje: [{0}]", except.Message)); } } if (control == null) { logger.Warn(String.Format("ADVERTENCIA: El Control de Acceso con Clave: [{0}] no fue encontrado en la base de datos. Esta incidencia no se guardara", movimiento.CveControlAcceso)); } if (empleado != null && control != null) { try { Incidencia validacion = incidenciaDao.GetByEmpleadoControlFechaInOutMode(empleado, control, fechaIncidencia, movimiento.InOutMode.HasValue ? movimiento.InOutMode.Value : 0); if (empleado != null) { try { empleado.UltimaColeccion = String.Format("Fecha: [{0}] en el Control: [{1}]", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), control.Nombre); empleadoDao.SaveOrUpdate(empleado); } catch { } } if (validacion == null) { Incidencia incidencia = new Incidencia(); incidencia.ControlAcceso = control; incidencia.Empleado = empleado; incidencia.EnviadoWs = 0; incidencia.FechaAlta = fechaAlta; incidencia.FechaHoraIncidencia = fechaIncidencia; incidencia.InOutMode = movimiento.InOutMode; Incidencia up = incidenciaDao.SaveOrUpdate(incidencia); incidencia = up; } else { logger.Warn(String.Format("ADVERTENCIA: Esta incidencia ya estaba dada de alta con la clave [{0}]", validacion.CveIncidencia)); } } catch (Exception ex) { logger.Error(String.Format("Error: Al intentar guardar la incidencia con Control: [{0}], Empleado: [{1}], Fecha Hora [{2}]. Mensaje: [{3}]", control.Nombre, empleado.Nombre, fechaIncidencia, ex.Message)); logger.Error(ex); } } } catch (Exception ex) { logger.Error(String.Format("Error al momento de intentar procesar los colectores de movimiento. Mensaje: [{0}] ", ex.Message)); logger.Error(ex); } } } // Se borra la tabla del colector de movimientos if (listaColector != null && listaColector.Count > 0) { foreach (ColectorMovimiento movimiento in listaColector) { try { colectorMovimientoDao.Delete(movimiento); } catch (Exception ex) { logger.Error(String.Format("Error al momento de intentar limpiar los colectores de movimiento. Mensaje: [{0}] ", ex.Message)); logger.Error(ex); } } } } else { logger.Info("La lista de controles de acceso a procesar está vacia o nula de controles de acceso activos en la base de datos."); } }
public HomeController() { var c = new CZKEMClass(); }
private void Form1_Load(object sender, EventArgs e) { Thread createComAndMessagePumpThread = new Thread(() => { axCZKEM1 = new CZKEMClass(); connSatus = axCZKEM1.Connect_Net("162.36.2.24", 4370); using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.WriteLine("HR Machine is connected at the" + "Date :" + DateTime.Now.ToString() + "status" + connSatus); writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } if (connSatus == true) { axCZKEM1.OnVerify -= new _IZKEMEvents_OnVerifyEventHandler(OnVerify); axCZKEM1.OnConnected -= new _IZKEMEvents_OnConnectedEventHandler(OnConnected); axCZKEM1.OnAttTransaction -= new _IZKEMEvents_OnAttTransactionEventHandler(OnAttTransaction); axCZKEM1.OnAttTransactionEx -= new _IZKEMEvents_OnAttTransactionExEventHandler(OnAttTransactionEx); axCZKEM1.OnDisConnected -= new _IZKEMEvents_OnDisConnectedEventHandler(OnDisConnected); if (axCZKEM1.RegEvent(1, 65535))//Here you can register the realtime events that you want to be triggered(the parameters 65535 means registering all) { axCZKEM1.OnVerify += new _IZKEMEvents_OnVerifyEventHandler(OnVerify); axCZKEM1.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(OnAttTransactionEx2; axCZKEM1.OnAttTransaction += new _IZKEMEvents_OnAttTransactionEventHandler(OnAttTransaction); axCZKEM1.OnConnected += new _IZKEMEvents_OnConnectedEventHandler(OnConnected); axCZKEM1.OnDisConnected += new _IZKEMEvents_OnDisConnectedEventHandler(OnDisConnected); using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.WriteLine("attendnce transaction Events are registered... "); writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } } } Application.Run(); }); createComAndMessagePumpThread.SetApartmentState(ApartmentState.STA); createComAndMessagePumpThread.Start(); Thread createComAndMessagePumpThread = new Thread(() => { axCZKEM2 = new CZKEMClass(); connSatus = axCZKEM2.Connect_Net("162.36.2.22", 4370); using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.WriteLine("HR Machine is connected at the" + "Date :" + DateTime.Now.ToString() + "status" + connSatus); writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } if (connSatus == true) { axCZKEM2.OnVerify -= new _IZKEMEvents_OnVerifyEventHandler(OnVerify); axCZKEM2.OnConnected -= new _IZKEMEvents_OnConnectedEventHandler(OnConnected); axCZKEM2.OnAttTransaction -= new _IZKEMEvents_OnAttTransactionEventHandler(OnAttTransaction); axCZKEM2.OnAttTransactionEx -= new _IZKEMEvents_OnAttTransactionExEventHandler(OnAttTransactionEx); axCZKEM2.OnDisConnected -= new _IZKEMEvents_OnDisConnectedEventHandler(OnDisConnected); if (axCZKEM2.RegEvent(1, 65535))//Here you can register the realtime events that you want to be triggered(the parameters 65535 means registering all) { axCZKEM2.OnVerify += new _IZKEMEvents_OnVerifyEventHandler(OnVerify); axCZKEM2.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(OnAttTransactionEx2; axCZKEM2.OnAttTransaction += new _IZKEMEvents_OnAttTransactionEventHandler(OnAttTransaction); axCZKEM2.OnConnected += new _IZKEMEvents_OnConnectedEventHandler(OnConnected); axCZKEM2.OnDisConnected += new _IZKEMEvents_OnDisConnectedEventHandler(OnDisConnected); using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.WriteLine("attendnce transaction Events are registered... "); writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } } } Application.Run(); }); createComAndMessagePumpThread.SetApartmentState(ApartmentState.STA); createComAndMessagePumpThread.Start(); }
private bool fdconnect(string ip, int port, int password, ref CZKEMClass FDevice) { FDevice.SetCommPassword(password); bool isConnected = FDevice.Connect_Net(ip, port); return isConnected; }
private void ApplyConfigFile(dynamic configJson) { configParam = new DataTable(); configParam.Columns.Add("AppID"); configParam.Columns.Add("Host"); //configParam.Columns.Add("devices", typeof(System.Data.DataTable)); DataRow rowAdd = configParam.NewRow(); rowAdd["AppID"] = configJson.AppID; rowAdd["Host"] = configJson.Host; foreach (var device in configJson.devices) { DataRow rowDevice = dtDevices.NewRow(); rowDevice["serial_number"] = device.serial_number; rowDevice["ip_local"] = device.ip_local; rowDevice["port"] = device.port; rowDevice["comm_password"] = device.comm_password; rowDevice["fdid"] = device.fdid; rowDevice["zkclass"] = new CZKEMClass(); rowDevice["status"] = "not_connected"; rowDevice["assign_status"] = "not_match"; dtDevices.Rows.Add(rowDevice); } configParam.Rows.Add(rowAdd); }
private string GetDeviceSerialNumber(CZKEMClass fdevice, int iMachineNumber) { int idwErrorCode = 0; string sdwSerialNumber = ""; if (fdevice.GetSerialNumber(iMachineNumber, out sdwSerialNumber)) { return sdwSerialNumber; } else { fdevice.GetLastError(ref idwErrorCode); return idwErrorCode.ToString(); } }