private void btnRestore_Click(object sender, EventArgs e) { ArrayList arQuery = new ArrayList(); GTRLibrary.clsConnection clsCon = new GTRLibrary.clsConnection(); string sqlQuery = "", DeviceIP = "", GetDeviceIP = ""; Int32 NewId = 0; Int32 RowID; string DeviceIp = "", pDate = "", pTime = ""; int Count = 0; int idwErrorCode = 0; foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.gridDetails.Rows) { if (row.Cells["Id"].Text.ToString().Length != 0 && row.Cells["isChecked"].Value.ToString() == "1" && row.Cells["Active"].Value.ToString() == "1") { GetDeviceIP = "" + row.Cells["IpAddress"].Text.ToString() + ""; bIsConnected = axCZKEM1.Connect_Net(GetDeviceIP, 4370); if (bIsConnected == true) { iMachineNumber = 1; axCZKEM1.RegEvent(iMachineNumber, 65535); } Count = Convert.ToInt32(txtRestore.Text); axCZKEM1.EnableDevice(iMachineNumber, false); //disable the device if (axCZKEM1.RestoreLogData(iMachineNumber, Count)) //Here we use the function "RestoreLogData" and Restore Number. { MessageBox.Show("There have Restore " + Count.ToString(), " Attendance Data"); } else { axCZKEM1.GetLastError(ref idwErrorCode); MessageBox.Show("Operation failed,Attendance Data not Restore,Please input less number.ErrorCode=" + idwErrorCode.ToString(), "Error"); } axCZKEM1.EnableDevice(iMachineNumber, true); //enable the device } axCZKEM1.Disconnect(); } // for }
private void configureConnectionStateMachine() { connectionState.Configure(State.Disconnected) .Permit(Trigger.ConnectRequested, State.Connecting) .OnEntryFrom(Trigger.ConnectionDropped, () => { lock (syncRoot) { axCZKEM1.Disconnect(); } }); connectionState.Configure(State.Connecting) .Permit(Trigger.ConnectFailed, State.Disconnected) .Permit(Trigger.ConnectSucceeded, State.Connected); connectionState.Configure(State.Connected) .Permit(Trigger.ConnectionDropped, State.Disconnected) .OnEntry(() => { lock (syncRoot) { //Here you can register the realtime events that you want to be triggered //(the parameters 65535 means registering all) if (axCZKEM1.RegEvent(dwMachineNumber, 1 ^ 8)) { Console.WriteLine("Events registered successfully"); //only for color device axCZKEM1.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx); axCZKEM1.OnEnrollFingerEx += new _IZKEMEvents_OnEnrollFingerExEventHandler(axCZKEM1_OnEnrollFingerEx); } } }); }
public static int GrabDataAbsen(string IPAdd, int portNum, int iPass, int machineNumber) { CZKEM mesinabsen = new CZKEM(); int b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, iCount = 0; mesinabsen.SetCommPassword(iPass); string a = ""; //Only when connected successfully if (mesinabsen.Connect_Net(IPAdd, portNum)) { //read all data and store in database using (fingermachDataSetTableAdapters.tdatafingerTableAdapter tbl = new fingermachDataSetTableAdapters.tdatafingerTableAdapter()) { while (mesinabsen.SSR_GetGeneralLogData(machineNumber, out a, out b, out c, out d, out e, out f, out g, out h, out i, ref j)) { tbl.Replace(1, int.Parse(a), b, c, d, e, f, g, h, DateTime.Now); iCount++; } } } else { //Connection Exception throw (new Exception("Fail to connect to fingerprint machine.")); } //clean data //mesinabsen.ClearGLog(machineNumber); //close connection mesinabsen.Disconnect(); return(iCount); }
private void Disconnect(object sender, RoutedEventArgs e) { // IF THERE IS AN EXISTING CONNECTION, DISCONNECT FROM FIGNERPRINT SCANNER if (ConnectionStatus.Text == "Connected") { zk.Disconnect(); Logs.Items.Add("Device connection terminated."); ConnectionStatus.Text = "Disconnected"; ConnectionStatus.Foreground = Brushes.Red; } zk.Disconnect(); Logs.Items.Add("Device connection terminated."); ConnectionStatus.Text = "Disconnected"; ConnectionStatus.Foreground = Brushes.Red; }
public void Discoonect() { if (isConnected) { device.Disconnect(); } isConnected = false; }
public void Disconnect() { // [ Unregister events objCZKEM.OnConnected -= ObjCZKEM_OnConnected; objCZKEM.OnDisConnected -= objCZKEM_OnDisConnected; objCZKEM.OnEnrollFinger -= ObjCZKEM_OnEnrollFinger; objCZKEM.OnFinger -= ObjCZKEM_OnFinger; objCZKEM.OnAttTransactionEx -= new _IZKEMEvents_OnAttTransactionExEventHandler(zkemClient_OnAttTransactionEx); objCZKEM.Disconnect(); }
public void ConnectViaNet(List <string> messages) { if (ValidateIpAddress()) { Settings.Default._machineNo = 1; var port = Settings.Default._devicePort; if (port <= 0 || port > 65535) { messages.Add(Resources.LABEL_ILLEGAL_PORT); } var iCommkey = Convert.ToInt32(Settings.Default._commKey); _czkem.SetCommPassword(iCommkey); if (Settings.Default._connected) { _czkem.Disconnect(); UnRegisterEvents(); SetConnected(false); messages.Add(WriteLog(Resources.LABEL_DISCONNECT_WITH_DEVICE)); } if (_czkem.Connect_Net(Settings.Default._deviceIpAddress, Settings.Default._devicePort)) { RegisterEvents(messages); SetConnected(true); messages.Add(WriteLog(Resources.LABEL_DEVICE_CONNECTED)); } else { var idwErrorCode = 0; _czkem.GetLastError(ref idwErrorCode); messages.Add(WriteLog(Resources.LABEL_UNABLE_TO_CONNECT_VIA_NET + idwErrorCode)); } } else { messages.Add(WriteLog(Resources.LABEL_INVALID_DEVICE_IP_ADDRESS)); } }
public static bool RegisterUserName(string IPAdd, int portNum, int iPass, int machineNumber, string enrollNum, string userName) { CZKEM mesinabsen = new CZKEM(); mesinabsen.SetCommPassword(iPass); if (mesinabsen.Connect_Net(IPAdd, portNum)) { mesinabsen.SSR_SetUserInfo(machineNumber, enrollNum, userName, null, 0, true); } { //Connection Exception throw (new Exception("Fail to connect to fingerprint machine.")); } //close connection mesinabsen.Disconnect(); return(true); }
private void pullData() { zk = new CZKEM(); bool isConnected = zk.Connect_Net(ipAddress, port); if (!isConnected) { log("Unable to Connect " + DateTime.Now); return; } string enrollNO; int verifyMode; int inoutMode; int year; int month; int DayOfWeek; int hour; int minute; int second; int workerCode = 1; if (zk.ReadGeneralLogData(1)) { bool canDelete = true; while (zk.SSR_GetGeneralLogData(branch, out enrollNO, out verifyMode, out inoutMode, out year, out month, out DayOfWeek, out hour, out minute, out second, ref workerCode)) { string date = year + "-" + month + "-" + DayOfWeek + " " + hour + ":" + minute + ":" + second; if (!saveRecord(enrollNO, date, inoutMode)) { log("Unable to SaveData " + DateTime.Now); canDelete = false; } } bool deleteAllowed = Properties.Settings.Default.delete; if (canDelete && deleteAllowed) { zk.ClearGLog(branch); } } zk.Disconnect(); }
private void GetAllLogs() { foreach (KeyValuePair <int, string> machine in lstMachines) { CZKEM axCZKEM = new CZKEM(); axCZKEM.Disconnect(); if (axCZKEM.Connect_Net(machine.Value, 4370)) { axCZKEM.MachineNumber = machine.Key; GetLogData(axCZKEM); if (lstDevices.ContainsKey(machine.Key)) { lstDevices.Remove(machine.Key); } } } MethodInvoker lbl = delegate { lblText.Text = "Last Update " + DateTime.Now.ToString(); }; Invoke(lbl); PingMachines(); }
public void Disconnect() { _czkem.Disconnect(); }
private void prcExecuteDownload() { gridInfo.DataSource = null; ArrayList arQuery = new ArrayList(); GTRLibrary.clsConnection clsCon = new GTRLibrary.clsConnection(); try { string sqlQuery = "", DeviceIP = "", GetDeviceIP = ""; Int32 NewId = 0; Int32 RowID; string sdwEnrollNumber = "", DeviceIp = "", pDate = "", pTime = "", CardNo = "", EnrollID = ""; int idwTMachineNumber = 0, idwEMachineNumber = 0; int idwVerifyMode = 0, idwInOutMode = 0, idwEnrollNumber = 0, EnrollData = 0; int idwYear = 0, idwMonth = 0, idwDay = 0; int idwHour = 0, idwMinute = 0, idwSecond = 0; int idwWorkcode = 0, idwErrorCode = 0; int iGLCount = 0, iIndex = 0; //Raw Data Clear sqlQuery = "Truncate Table tblRawdataMIGTR_Temp"; arQuery.Add(sqlQuery); sqlQuery = "Update tblMachineNo_GTR set Status = 'Disconnect'"; arQuery.Add(sqlQuery); clsCon.GTRSaveDataWithSQLCommand(arQuery); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.gridDetails.Rows) { if (row.Cells["Id"].Text.ToString().Length != 0 && row.Cells["isChecked"].Value.ToString() == "1" && row.Cells["Active"].Value.ToString() == "1") { GetDeviceIP = "" + row.Cells["IpAddress"].Text.ToString() + ""; bIsConnected = axCZKEM1.Connect_Net(GetDeviceIP, 4370); if (bIsConnected == true) { iMachineNumber = 1; axCZKEM1.RegEvent(iMachineNumber, 65535); } else { axCZKEM1.GetLastError(ref idwErrorCode); MessageBox.Show("Device not connected. Please check your device or network connection.Problem IP Address = " + GetDeviceIP.ToString(), "Error"); } //ZK Black & White Device Download Code if (row.Cells["BlackWhite"].Value.ToString() == "1") { sqlQuery = "Update tblMachineNo_GTR set Status = 'Connect' where IpAddress ='" + row.Cells["IpAddress"].Text.ToString() + "'"; arQuery.Add(sqlQuery); clsCon.GTRSaveDataWithSQLCommand(arQuery); Cursor = Cursors.WaitCursor; //lvLogs.Items.Clear(); axCZKEM1.EnableDevice(iMachineNumber, false); //disable the device if (axCZKEM1.ReadGeneralLogData(iMachineNumber)) //read all the attendance records to the memory { while (axCZKEM1.GetGeneralLogData(iMachineNumber, ref idwTMachineNumber, ref idwEnrollNumber, ref idwEMachineNumber, ref idwVerifyMode, ref idwInOutMode, ref idwYear, ref idwMonth, ref idwDay, ref idwHour, ref idwMinute))//get records from the memory { //iGLCount++; DeviceIp = GetDeviceIP.Substring(7); //CardNo = idwEnrollNumber.ToString(); //CardNo = GTRDecToHexCon(CardNo); EnrollData = int.Parse(sdwEnrollNumber); //EnrollID = EnrollData.ToString("0000000000"); //pDate = idwDay + "-" + idwMonth + "-" + idwYear; pDate = idwYear + "-" + idwMonth + "-" + idwDay; pTime = idwHour + ":" + idwMinute + ":" + idwSecond; sqlQuery = "Insert into tblRawdataMIGTR_Temp(ComId,DeviceNo,CardNo,dtPunchDate,dtPunchTime) values(" + Common.Classes.clsMain.intComId + ",'" + DeviceIp + "','" + sdwEnrollNumber + "','" + pDate + "','" + pTime + "')"; arQuery.Add(sqlQuery); sqlQuery = "Insert into tblRawdata(ComId,DeviceNo,CardNo,dtPunchDate,dtPunchTime,LUserID,PCName) values(" + Common.Classes.clsMain.intComId + ",'" + DeviceIp + "','" + sdwEnrollNumber + "','" + pDate + "','" + pTime + "'," + GTRHRIS.Common.Classes.clsMain.intUserId + ",'" + Common.Classes.clsMain.strComputerName + "')"; arQuery.Add(sqlQuery); //iIndex++; } //while } //if if (chkClear.Checked == true) { axCZKEM1.EnableDevice(iMachineNumber, false);//disable the device if (axCZKEM1.ClearGLog(iMachineNumber)) { axCZKEM1.RefreshData(iMachineNumber);//the data in the device should be refreshed //MessageBox.Show("All att Logs have been cleared from teiminal!", "Success"); } } axCZKEM1.EnableDevice(iMachineNumber, true);//enable the device Cursor = Cursors.Default; axCZKEM1.Disconnect(); } //if //ZK Color Device Download Code else { sqlQuery = "Update tblMachineNo_GTR set Status = 'Connect' where IpAddress ='" + row.Cells["IpAddress"].Text.ToString() + "'"; arQuery.Add(sqlQuery); clsCon.GTRSaveDataWithSQLCommand(arQuery); Cursor = Cursors.WaitCursor; //lvLogs.Items.Clear(); axCZKEM1.EnableDevice(iMachineNumber, false); //disable the device if (axCZKEM1.ReadGeneralLogData(iMachineNumber)) //read all the attendance records to the memory { while (axCZKEM1.SSR_GetGeneralLogData(iMachineNumber, out sdwEnrollNumber, out idwVerifyMode, out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode))//get records from the memory { //iGLCount++; DeviceIp = GetDeviceIP.Substring(7); //CardNo = sdwEnrollNumber; //CardNo = GTRDecToHexCon(CardNo); EnrollData = int.Parse(sdwEnrollNumber); EnrollID = EnrollData.ToString("0000000000"); //pDate = idwDay + "-" + idwMonth + "-" + idwYear; pDate = idwYear + "-" + idwMonth + "-" + idwDay; pTime = idwHour + ":" + idwMinute + ":" + idwSecond; sqlQuery = "Insert into tblRawdataMIGTR_Temp(ComId,DeviceNo,CardNo,dtPunchDate,dtPunchTime) values(" + Common.Classes.clsMain.intComId + ",'" + DeviceIp + "','" + EnrollID + "','" + pDate + "','" + pTime + "')"; arQuery.Add(sqlQuery); sqlQuery = "Insert into tblRawdata(ComId,DeviceNo,CardNo,dtPunchDate,dtPunchTime,LUserID,PCName) values(" + Common.Classes.clsMain.intComId + ",'" + DeviceIp + "','" + EnrollID + "','" + pDate + "','" + pTime + "'," + GTRHRIS.Common.Classes.clsMain.intUserId + ",'" + Common.Classes.clsMain.strComputerName + "')"; arQuery.Add(sqlQuery); //iIndex++; } //while } //if if (chkClear.Checked == true) { axCZKEM1.EnableDevice(iMachineNumber, false);//disable the device if (axCZKEM1.ClearGLog(iMachineNumber)) { axCZKEM1.RefreshData(iMachineNumber);//the data in the device should be refreshed //MessageBox.Show("All att Logs have been cleared from teiminal!", "Success"); } } axCZKEM1.EnableDevice(iMachineNumber, true);//enable the device Cursor = Cursors.Default; axCZKEM1.Disconnect(); } //else } //if } //foreach // Insert Information To Log File sqlQuery = "Insert Into tblUser_Trans_Log (LUserId, formName, tranStatement, PCName, tranType)" + " Values (" + GTRHRIS.Common.Classes.clsMain.intUserId + ", '" + this.Name.ToString() + "','" + sqlQuery.Replace("'", "|") + "','" + Common.Classes.clsMain.strComputerName + "','Download')"; arQuery.Add(sqlQuery); clsCon.GTRSaveDataWithSQLCommand(arQuery); prcLoadList(); prcRawData(); } //try catch (Exception ex) { throw (ex); } finally { clsCon = null; } }
protected override void OnStop() { // timer1.Enabled = false; this.objCZKEM.OnAttTransactionEx -= new _IZKEMEvents_OnAttTransactionExEventHandler(zkemClient_OnAttTransactionEx); objCZKEM.Disconnect(); }
/// <summary> /// Desconecta el dispositivo biometrico. /// </summary> /// public bool Desconectar() { lectorObject.Disconnect(); return(false); }
private bool clkZKSoft(int pRid, int pNro, string pDes, string pDir, int pPor, long pPsw) { bool clkZKSoft = false; try { string sdwEnrollNumber = ""; int idwVerifyMode; int idwInOutMode; int idwYear; int idwMonth; int idwDay; int idwHour; int idwMinute; int idwSecond; int idwWorkcode = 0; string vFic; bool vClean = false; CZKEM Reloj = new CZKEM(); DevOps devolucionOperacion = new DevOps(); RelojesIngresos objFichada = new RelojesIngresos(); List <RelojResponse> relojResponse = new List <RelojResponse>(); //DevOps devolucionOperacion = new DevOps(); //if (pDir == "192.168.0.241") // pDir = "192.168.5.111"; // Reloj Pilar // If pDir = "192.168.0.241" Then pDir = "200.49.156.125" // If pDir = "200.85.127.22" Then pDir = "192.168.5.125" // If pDir = "192.168.4.240" Then // pDir = "661705e2a569.sn.mynetname.net" // pPor = 64370 // End If //FuncionPrueba(pRid); Logger.GetInstance().AddLog(true, "clkZKSoft()", "Conectandose " + pDir + ":" + pPor); if (Reloj.Connect_Net(pDir, pPor))/* && false)*/ { Logger.GetInstance().AddLog(true, "clkZKSoft()", "Conectado a " + pDir + ":" + pPor); Reloj.EnableDevice(pNro, false); // ----> Leo Datos if (Reloj.ReadGeneralLogData(pNro)) { // SSR_GetGeneralLogData // ----> Leo Datos while (Reloj.SSR_GetGeneralLogData(pNro, out sdwEnrollNumber, out idwVerifyMode, out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode)) { if (!vClean) { Logger.GetInstance().AddLog(true, "clkZKSoft()", "Procesando registros de " + pDir + ":" + pPor); } vClean = true; //Logger.GetInstance().AddLog(true, "clkZKSoft()", "Revisando Legajo: " + sdwEnrollNumber); if (idwYear == DateTime.Now.Year) { RelojResponse relojResponseItem = new RelojResponse(); vFic = string.Format(idwYear.ToString("0000")) + "-" + string.Format(idwMonth.ToString("00")) + "-" + string.Format(idwDay.ToString("00")) + " " + String.Format(idwHour.ToString("00")) + ":" + String.Format(idwMinute.ToString("00")) + ":" + String.Format(idwSecond.ToString("00")); //Logger.GetInstance().AddLog(true, "clkZKSoft()", "Fecha del Registro: " + vFic); relojResponseItem.Fich = vFic; relojResponseItem.Nro = pNro; relojResponseItem.SdwEnrollNumber = sdwEnrollNumber; relojResponseItem.IdwVerifyMode = idwVerifyMode; relojResponseItem.IdwInOutMode = idwInOutMode; relojResponseItem.IdwWorkcode = idwWorkcode; relojResponse.Add(relojResponseItem); } } if (relojResponse.Count > 0) { if (ConnectServer(dBServer1)) { Logger.GetInstance().AddLog(true, "clkZKSoft()", "Envios a Server1: " + dBServer1); Logger.GetInstance().AddLog(true, "clkZKSoft()", "Cantidad de Registros: " + relojResponse.Count); foreach (RelojResponse item in relojResponse) { Logger.GetInstance().AddLog(true, "clkZKSoft()", "Revisando Legajo: " + item.SdwEnrollNumber); Logger.GetInstance().AddLog(true, "clkZKSoft()", "Fecha del Registro: " + item.Fich); try { devolucionOperacion = objFichada.SetFichada(pRid, item.SdwEnrollNumber, item.Fich, "CLOCK"); Logger.GetInstance().AddLog(true, "clkZKSoft()", "SetFichada CacheDebug: " + devolucionOperacion.CacheDebug); if (devolucionOperacion.Resultado) { Logger.GetInstance().AddLog(true, "clkZKSoft()", "SetFichada OK"); } else { Logger.GetInstance().AddLog(false, "clkZKSoft()", "SetFichada Error: " + devolucionOperacion.DescripcionError); } } catch (Exception ex) { Logger.GetInstance().AddLog(false, "clkZKSoft()", "Excepción en SetFichada: " + ex.Message); } } modDeclares.ShamanSession.Cerrar(modDeclares.ShamanSession.PID); } if (ConnectServer(dBServer2)) { Logger.GetInstance().AddLog(true, "clkZKSoft()", "Envios a Server2: " + dBServer2); Logger.GetInstance().AddLog(true, "clkZKSoft()", "Cantidad de Registros: " + relojResponse.Count); foreach (RelojResponse item in relojResponse) { Logger.GetInstance().AddLog(true, "clkZKSoft()", "Revisando Legajo: " + item.SdwEnrollNumber); Logger.GetInstance().AddLog(true, "clkZKSoft()", "Fecha del Registro: " + item.Fich); try { devolucionOperacion = objFichada.SetFichada(pRid, item.SdwEnrollNumber, item.Fich, "CLOCK"); Logger.GetInstance().AddLog(true, "clkZKSoft()", "SetFichada CacheDebug: " + devolucionOperacion.CacheDebug); if (devolucionOperacion.Resultado) { Logger.GetInstance().AddLog(true, "clkZKSoft()", "SetFichada OK"); } else { Logger.GetInstance().AddLog(false, "clkZKSoft()", "SetFichada Error: " + devolucionOperacion.DescripcionError); } } catch (Exception ex) { Logger.GetInstance().AddLog(false, "clkZKSoft()", "Excepción en SetFichada: " + ex.Message); } } modDeclares.ShamanSession.Cerrar(modDeclares.ShamanSession.PID); } if (ConnectServer(dBServer3)) { Logger.GetInstance().AddLog(true, "clkZKSoft()", "Envios a Server3: " + dBServer3); Logger.GetInstance().AddLog(true, "clkZKSoft()", "Cantidad de Registros: " + relojResponse.Count); foreach (RelojResponse item in relojResponse) { Logger.GetInstance().AddLog(true, "clkZKSoft()", "Revisando Legajo: " + item.SdwEnrollNumber); Logger.GetInstance().AddLog(true, "clkZKSoft()", "Fecha del Registro: " + item.Fich); try { devolucionOperacion = objFichada.SetFichada(pRid, item.SdwEnrollNumber, item.Fich, "CLOCK"); Logger.GetInstance().AddLog(true, "clkZKSoft()", "SetFichada CacheDebug: " + devolucionOperacion.CacheDebug); if (devolucionOperacion.Resultado) { Logger.GetInstance().AddLog(true, "clkZKSoft()", "SetFichada OK"); } else { Logger.GetInstance().AddLog(false, "clkZKSoft()", "SetFichada Error: " + devolucionOperacion.DescripcionError); } } catch (Exception ex) { Logger.GetInstance().AddLog(false, "clkZKSoft()", "Excepción en SetFichada: " + ex.Message); } } modDeclares.ShamanSession.Cerrar(modDeclares.ShamanSession.PID); } } if (vClean) { Logger.GetInstance().AddLog(true, "clkZKSoft()", "Vaciar Reloj " + pNro + " Ip: " + pDir + ":" + pPor); if (Reloj.ClearGLog(pNro)) { Reloj.RefreshData(pNro); Logger.GetInstance().AddLog(true, "clkZKSoft()", "Se vació RelojId " + pNro + " Ip: " + pDir + ":" + pPor); } else { int idwErrorCode = 0; Reloj.GetLastError(idwErrorCode); Logger.GetInstance().AddLog(false, "clkZKSoft()", "Error al vaciar " + pDir + ":" + pPor + " " + idwErrorCode); } vClean = false; } else { Logger.GetInstance().AddLog(true, "clkZKSoft()", "No hay fichadas en " + pDir + ":" + pPor); } } else { Logger.GetInstance().AddLog(true, "clkZKSoft()", "No hay fichadas en " + pDir + ":" + pPor); } Logger.GetInstance().AddLog(true, "clkZKSoft()", "Desconectar Reloj " + pDir + ":" + pPor); Reloj.Disconnect(); clkZKSoft = true; } else { Logger.GetInstance().AddLog(true, "clkZKSoft()", "Sin conexión a " + pDir + ":" + pPor); } } catch (Exception ex) { Logger.GetInstance().AddLog(false, "clkZKSoft()", ex.Message); } return(clkZKSoft); }
private bool clkZKSoft(int pRid, int pNro, string pDes, string pDir, int pPor, long pPsw, bool vClean = false, int pCommPassword = 0) { bool clkZKSoft = false; try { string sdwEnrollNumber = ""; int idwVerifyMode; int idwInOutMode; int idwYear; int idwMonth; int idwDay; int idwHour; int idwMinute; int idwSecond; int idwWorkcode = 0; string vFic; CZKEM Reloj = new CZKEM(); DevOps devolucionOperacion = new DevOps(); RelojesIngresos objFichada = new RelojesIngresos(); List <RelojResponse> relojResponse = new List <RelojResponse>(); Logger.GetInstance().AddLog(true, "clkZKSoft()", "Conectandose " + pDir + ":" + pPor); if (pCommPassword > 0) { Reloj.SetCommPassword(pCommPassword); } if (Reloj.Connect_Net(pDir, pPor)) { Logger.GetInstance().AddLog(true, "clkZKSoft()", "Conectado a " + pDir + ":" + pPor); Reloj.EnableDevice(pNro, false); // ----> Leo Datos if (Reloj.ReadGeneralLogData(pNro)) { // SSR_GetGeneralLogData // ----> Leo Datos while (Reloj.SSR_GetGeneralLogData(pNro, out sdwEnrollNumber, out idwVerifyMode, out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode)) { if (idwYear == DateTime.Now.Year) { RelojResponse relojResponseItem = new RelojResponse(); vFic = string.Format(idwYear.ToString("0000")) + "-" + string.Format(idwMonth.ToString("00")) + "-" + string.Format(idwDay.ToString("00")) + " " + String.Format(idwHour.ToString("00")) + ":" + String.Format(idwMinute.ToString("00")) + ":" + String.Format(idwSecond.ToString("00")); //Logger.GetInstance().AddLog(true, "clkZKSoft()", "Fecha del Registro: " + vFic); relojResponseItem.Fich = vFic; relojResponseItem.Nro = pNro; relojResponseItem.SdwEnrollNumber = sdwEnrollNumber; relojResponseItem.IdwVerifyMode = idwVerifyMode; relojResponseItem.IdwInOutMode = idwInOutMode; relojResponseItem.IdwWorkcode = idwWorkcode; relojResponse.Add(relojResponseItem); } } //SAVE IN DATABASE. SaveInDataBase(pRid, relojResponse); if (vClean) { //Logger.GetInstance().AddLog(true, "clkZKSoft()", "BLOQUE COMENTADO: Vaciar Reloj " + pNro + " Ip: " + pDir + ":" + pPor); Logger.GetInstance().AddLog(true, "clkZKSoft()", "Vaciar Reloj " + pNro + " Ip: " + pDir + ":" + pPor); if (Reloj.ClearGLog(pNro)) { Reloj.RefreshData(pNro); Logger.GetInstance().AddLog(true, "clkZKSoft()", "Se vació RelojId " + pNro + " Ip: " + pDir + ":" + pPor); } else { int idwErrorCode = 0; Reloj.GetLastError(idwErrorCode); Logger.GetInstance().AddLog(false, "clkZKSoft()", "Error al vaciar " + pDir + ":" + pPor + " " + idwErrorCode); } } } else { Logger.GetInstance().AddLog(true, "clkZKSoft()", "No hay fichadas en " + pDir + ":" + pPor); } Logger.GetInstance().AddLog(true, "clkZKSoft()", "Desconectar Reloj " + pDir + ":" + pPor); Reloj.Disconnect(); clkZKSoft = true; } else { Logger.GetInstance().AddLog(true, "clkZKSoft()", "Sin conexión a " + pDir + ":" + pPor); } } catch (Exception ex) { Logger.GetInstance().AddLog(false, "clkZKSoft()", ex.Message); } return(clkZKSoft); }