Beispiel #1
0
 public void Disconnect()
 {
     if (Settings.Default._connected)
     {
         SetConnected(false);
         _czkem.Disconnect();
         UnRegisterEvents();
         _czkem.EnableDevice(Settings.Default._machineNo, false);
     }
 }
Beispiel #2
0
        private void GetLogData(CZKEM axCZKEM)
        {
            try
            {
                int    dwTMachineNumber = 0;
                string dwEnrollNumber   = "";
                int    dwEMachineNumber = 0;
                int    dwVerifyMode     = 0;
                int    dwInOutMode      = 0;
                int    dwYear           = 0;
                int    dwMonth          = 0;
                int    dwDay            = 0;
                int    dwHour           = 0;
                int    dwMinute         = 0;
                int    dwSecond         = 0;
                int    dwWorkCode       = 0;

                object BaudRate = GetBaudRate(axCZKEM.MachineNumber);
                string sTime    = BaudRate == DBNull.Value ? "2019-01-01 00:00:00" : BaudRate.ToString().Replace('/', '-');
                string eTime    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second).
                                  ToString("yyyy-MM-dd HH:mm:ss");

                axCZKEM.EnableDevice(axCZKEM.MachineNumber, false);
                if (axCZKEM.ReadTimeGLogData(axCZKEM.MachineNumber, sTime, eTime))
                {
                    while (axCZKEM.SSR_GetGeneralLogData(axCZKEM.MachineNumber, out dwEnrollNumber, out dwVerifyMode, out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond, ref dwWorkCode))
                    {
                        LogTransaction(axCZKEM.MachineNumber, dwTMachineNumber, int.Parse(dwEnrollNumber), dwEMachineNumber, dwVerifyMode, dwInOutMode, dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
                    }
                    UpdateBaudRate(axCZKEM.MachineNumber, eTime);
                }
                else
                {
                    if (axCZKEM.ReadNewGLogData(axCZKEM.MachineNumber))
                    {
                        while (axCZKEM.SSR_GetGeneralLogData(axCZKEM.MachineNumber, out dwEnrollNumber, out dwVerifyMode, out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond, ref dwWorkCode))
                        {
                            LogTransaction(axCZKEM.MachineNumber, dwTMachineNumber, int.Parse(dwEnrollNumber), dwEMachineNumber, dwVerifyMode, dwInOutMode, dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
                        }
                        UpdateBaudRate(axCZKEM.MachineNumber, eTime);
                    }
                }
                axCZKEM.EnableDevice(axCZKEM.MachineNumber, true);//enable the device
            }
            catch (Exception ex)
            {
                Loger(ex.Message);
            }
        }
Beispiel #3
0
        public Result AssignToDevice(int deviceNO, string cardID, string cardNumber)
        {
            string sName      = "Visitor";
            string sPassword  = "******";
            int    iPrivilege = 0;
            bool   bEnabled   = true;

            result.isSucess = objCZKEM.EnableDevice(deviceNO, false);

            objCZKEM.set_CardNumber(0, Convert.ToInt32(cardNumber));

            result.isSucess = objCZKEM.SSR_SetUserInfo(deviceNO, cardID, sName, sPassword, iPrivilege, bEnabled);

            result.isSucess = objCZKEM.EnableDevice(deviceNO, true);
            result.isSucess = objCZKEM.RefreshData(deviceNO);
            result.message  = "Successful";

            return(result);
        }
Beispiel #4
0
        public StatusReport <List <UserInfo> > GetAllUsers()
        {
            lock (syncRoot)
            {
                EnsureConnected();
                try
                {
                    List <UserInfo> users = new List <UserInfo>();

                    axCZKEM1.EnableDevice(dwMachineNumber, false);
                    if (axCZKEM1.ReadAllUserID(dwMachineNumber)) //read all user info to memory
                    {
                        while (axCZKEM1.SSR_GetAllUserInfo(dwMachineNumber, out string enrollNumber, out string name, out string password, out int privilege, out bool enabled))
                        {
                            users.Add(new UserInfo()
                            {
                                Enabled = enabled, EnrollmentNumber = enrollNumber, Password = password, Name = name, Privilege = (Privilege)privilege
                            });
                        }
                    }
                    else
                    {
                        int idwErrorCode = 0;
                        axCZKEM1.GetLastError(ref idwErrorCode);

                        if (idwErrorCode != 0)
                        {
                            return(StatusReport.Fail <List <UserInfo> >(idwErrorCode));
                        }
                    }

                    return(StatusReport.Success(users));
                }
                finally
                {
                    axCZKEM1.EnableDevice(dwMachineNumber, true);
                }
            }
        }
Beispiel #5
0
        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
        }
 public bool CapturarHuella(String usuarioID)
 {
     lectorObject.CancelOperation();
     if (lectorObject.StartEnrollEx(usuarioID, iFingerIndex, iFlag))
     {
         lectorObject.StartIdentify();
         lectorObject.RefreshData(Dispositivo);
         lectorObject.EnableDevice(Dispositivo, true);
         return(true);
     }
     lectorObject.RefreshData(Dispositivo);
     return(false);
 }
 public bool EnableDevice(int dwMachineNumber, bool bFlag)
 {
     return(objCZKEM.EnableDevice(dwMachineNumber, bFlag));
 }
 public bool EnableDevice(bool flag)
 {
     return(_czkem.EnableDevice(_czkem.MachineNumber, flag));
 }
Beispiel #9
0
        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;
            }
        }
Beispiel #10
0
        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);
        }
Beispiel #11
0
        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);
        }