Example #1
0
        public List <FingerPrintRecord> GetDataFromDevice()
        {
            if (!isConnected)
            {
                return(null);
            }

            List <FingerPrintRecord> records = new List <FingerPrintRecord>();

            if (isZkBW)
            {
                int dwMachineNumber  = 1;
                int dwTMachineNumber = 0;
                int dwEnrollNumber   = 0;
                int dwEMachineNumber = 0;
                int dwVerifyMode     = 0;
                int dwInOutMode      = 0;
                int dwYear           = 0;
                int dwMonth          = 0;
                int dwDay            = 0;
                int dwHour           = 0;
                int dwMinute         = 0;
                while (device.GetGeneralLogData(dwMachineNumber, ref dwTMachineNumber, ref dwEnrollNumber, ref dwEMachineNumber, ref dwVerifyMode, ref dwInOutMode, ref dwYear, ref dwMonth, ref dwDay, ref dwHour, ref dwMinute))
                {
                    FingerPrintRecord i = new FingerPrintRecord
                    {
                        IdUser = dwEnrollNumber,
                        Date   = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, 0)
                    };

                    if (i.Date.ToShortDateString() == DateTime.Now.ToShortDateString())
                    {
                        records.Add(i);
                    }
                }
            }
            else
            {
                int    dwMachineNumber = 1;
                string dwEnrollNumber;
                int    dwVerifyMode;
                int    dwInOutMode;
                int    dwYear;
                int    dwMonth;
                int    dwDay;
                int    dwHour;
                int    dwMinute;
                int    dwSecond;
                int    dwWorkCode = 0;
                while (device.SSR_GetGeneralLogData(dwMachineNumber, out dwEnrollNumber, out dwVerifyMode,
                                                    out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond,
                                                    ref dwWorkCode))
                {
                    FingerPrintRecord i = new FingerPrintRecord
                    {
                        IdUser = Convert.ToInt32(dwEnrollNumber),
                        Date   = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond)
                    };

                    if (i.Date.ToShortDateString() == DateTime.Now.ToShortDateString())
                    {
                        records.Add(i);
                    }
                }
            }

            return(records);
        }
Example #2
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;
            }
        }
Example #3
0
 public bool GetGeneralLogData(int dwMachineNumber, ref int dwTMachineNumber, ref int dwEnrollNumber, ref int dwEMachineNumber, ref int dwVerifyMode, ref int dwInOutMode, ref int dwYear, ref int dwMonth, ref int dwDay, ref int dwHour, ref int dwMinute)
 {
     return(objCZKEM.GetGeneralLogData(dwMachineNumber, ref dwTMachineNumber, ref dwEnrollNumber, ref dwEMachineNumber, ref dwVerifyMode, ref dwInOutMode, ref dwYear, ref dwMonth, ref dwDay, ref dwHour, ref dwMinute));
 }
Example #4
0
 public bool GetGeneralLogData(int dwMachineNumber, ref int dwTMachineNumber, ref int dwEnrollNumber, ref int dwEMachineNumber, ref int dwVerifyMode, ref int dwInOutMode, ref int dwYear, ref int dwMonth, ref int dwDay, ref int dwHour, ref int dwMinute)
 {
     return(objCZKEM.GetGeneralLogData(dwMachineNumber, dwMachineNumber, dwEnrollNumber, dwEMachineNumber, dwVerifyMode, dwInOutMode, dwYear, dwMonth, dwDay, dwHour, dwMinute));
     //throw new NotImplementedException();
 }