public static List <AttLogs> obtieneChecadas()
        {
            List <AttLogs> result = new List <AttLogs>();
            AttLogs        ent;

            string sdwEnrollNumber = "";

            int idwVerifyMode = 0;
            int idwInOutMode  = 0;
            int idwYear       = 0;
            int idwMonth      = 0;
            int idwDay        = 0;
            int idwHour       = 0;
            int idwMinute     = 0;
            int idwSecond     = 0;
            int idwWorkcode   = 0;

            int idwErrorCode = 0;

            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
                {
                    ent = new AttLogs();

                    ent.enrolIdNumber = Convert.ToInt16(sdwEnrollNumber);

                    string fecha =
                        idwYear.ToString() + "-" +
                        idwMonth.ToString() + "-" +
                        idwDay.ToString() + " " +
                        idwHour.ToString() + ":" +
                        idwMinute.ToString();

                    ent.fecha = Convert.ToDateTime(fecha);

                    result.Add(ent);
                }
            }
            else
            {
                axCZKEM1.GetLastError(ref idwErrorCode);

                if (idwErrorCode != 0)
                {
                    throw new Exception("Lectura de información del checador falló. ErrorCode: " + idwErrorCode.ToString());
                }
                else
                {
                    throw new Exception("No hay informacion en el Checador");
                }
            }

            axCZKEM1.EnableDevice(iMachineNumber, true);//enable the device

            return(result);
        }
Beispiel #2
0
        // obtiene checadas BlackWhite
        private List <Modelos.AttLogs> obtieneChecadas()
        {
            List <Modelos.AttLogs> result = new List <Modelos.AttLogs>();

            Modelos.AttLogs ent;

            int    idwEnrollNumber = 0;
            int    idwVerifyMode   = 0;
            int    idwInOutMode    = 0;
            string dwTimestr       = string.Empty;

            int idwErrorCode = 0;

            Cursor = Cursors.WaitCursor;

            axCZKEM1.EnableDevice(iMachineNumber, false);                                                                                      // disable the device

            if (axCZKEM1.ReadGeneralLogData(iMachineNumber))                                                                                   // read all the attendance records to the memory
            {
                while (axCZKEM1.GetGeneralLogDataStr(iMachineNumber, ref idwEnrollNumber, ref idwVerifyMode, ref idwInOutMode, ref dwTimestr)) // get records from the memory
                {
                    ent = new Modelos.AttLogs();

                    ent.enrolIdNumber = idwEnrollNumber;
                    ent.fecha         = Convert.ToDateTime(dwTimestr);

                    result.Add(ent);
                }
            }
            else
            {
                Cursor = Cursors.Default;
                axCZKEM1.GetLastError(ref idwErrorCode);

                if (idwErrorCode != 0)
                {
                    this.agregarDetalle("Lectura de información del checador falló. ErrorCode: " + idwErrorCode.ToString());
                    throw new Exception("Lectura de información del checador falló. ErrorCode: " + idwErrorCode.ToString());
                }
                else
                {
                    this.agregarDetalle("No hay informacion en el Checador");
                    throw new Exception("No hay informacion en el Checador");
                }
            }

            axCZKEM1.EnableDevice(iMachineNumber, true);//enable the device
            Cursor = Cursors.Default;

            return(result);
        }
Beispiel #3
0
        /************************************
        *   get all record/log/attendance method
        ************************************/
        public List <Biometik> GetAttLogAll()
        {
            var lBio = new List <Biometik>();


            if (!_bConnected)
            {
                return(lBio);
            }
            //disable the device
            axCZKEM1.EnableDevice(_con.MachineNo, false);

            if (axCZKEM1.ReadGeneralLogData(_con.MachineNo))
            {
                while (axCZKEM1.SSR_GetGeneralLogData(_con.MachineNo, 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
                {
                    var bio = new Biometik
                    {
                        MachineNo    = _con.MachineNo,
                        EnrollNo     = _sdwEnrollNumber,
                        VerifyMethod = _idwVerifyMode,
                        InOutMode    = _idwInOutMode,
                        Year         = _idwYear,
                        Month        = _idwMonth,
                        Day          = _idwDay,
                        Hour         = _idwHour,
                        Minute       = _idwMinute,
                        Second       = _idwSecond,
                        WorkCode     = _idwWorkcode
                    };
                    lBio.Add(bio);
                }
            }
            else
            {
                axCZKEM1.GetLastError(ref _idwErrorCode);
            }
            //enable device
            axCZKEM1.EnableDevice(_con.MachineNo, true);
            return(lBio);
        }
Beispiel #4
0
        // THREAD FUNCTIONS
        private void PollDevice()
        {
            string sdwEnrollNumber = "";
            int    idwVerifyMode   = 0;
            int    idwInOutMode    = 0;
            int    idwYear         = 0;
            int    idwMonth        = 0;
            int    idwDay          = 0;
            int    idwHour         = 0;
            int    idwMinute       = 0;
            int    idwSecond       = 0;
            int    idwWorkcode     = 0;

            int geekdom_id;

            while (poll_loop)
            {
                while (user_registering)
                {
                    ListBoxAdd(lbLog, "User is regstering, sleeping...");
                    Thread.Sleep(10000);
                }

                ListBoxAdd(lbLog, "Polling...");

                // Disable the device to avoid any problems getting the logs
                ListBoxAdd(lbLog, "Disabled the device...");
                Device.EnableDevice(1, false);
                ListBoxAdd(lbLog, "Device disabled");

                ListBoxAdd(lbLog, "Loading logs...");
                if (Device.ReadGeneralLogData(1))
                {
                    ListBoxAdd(lbLog, "Logs loaded");
                    ListBoxAdd(lbLog, "Enabling device...");
                    // We only need the device disabled when getting the access log
                    Device.EnableDevice(1, true);
                    ListBoxAdd(lbLog, "Device enabled");

                    ListBoxAdd(lbLog, "Checking users in...");
                    int counter = 0;
                    while (Device.SSR_GetGeneralLogData(1, out sdwEnrollNumber, out idwVerifyMode,
                                                        out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode))
                    {
                        // Get a geekdom_id
                        geekdom_id = db.GetGeekdomID(Int32.Parse(sdwEnrollNumber));

                        if (geekdom_id != -1)
                        {
                            // Check the user in
                            api.CheckUserIn(geekdom_id, api_key);
                            counter++;
                        }
                    }
                    ListBoxAdd(lbLog, counter + " users checked in");
                }
                else
                {
                    ListBoxAdd(lbLog, "No Logs found");
                }

                ListBoxAdd(lbLog, "Clearing logs...");
                Device.ClearData(1, 1);
                ListBoxAdd(lbLog, "Logs cleared");
                ListBoxAdd(lbLog, "Enabling device...");
                Device.EnableDevice(1, true);
                ListBoxAdd(lbLog, "Device enabled");

                ListBoxAdd(lbLog, "Sleeping...");
                Thread.Sleep(poll_interval);
            }
        }
Beispiel #5
0
        private bool SSRDownloadLogData()
        {
            bool   result          = true;
            String idwEnrollNumber = "";
            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    idWorkCode      = 0;
            int    idwErrorCode    = 0;
            int    iGLCount        = 0;

            axCZKEM1.EnableDevice(iMachineNumber, false);    //disable the device
            if (axCZKEM1.ReadGeneralLogData(iMachineNumber)) //read all the attendance records to the memory
            {
                var device = context.Devices
                             .Where(w => w.IP == this.Device.IP).FirstOrDefault();

                while (axCZKEM1.SSR_GetGeneralLogData(iMachineNumber, out idwEnrollNumber,
                                                      out idwVerifyMode, out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idWorkCode))//get records from the memory
                {
                    iGLCount++;
                    var dtStr = idwYear.ToString() + '-' + idwMonth.ToString() + '-' + idwDay.ToString() + ' ' + idwHour.ToString() + ':' + idwMinute.ToString() + ':' + idwSecond.ToString();
                    var dt    = DateTime.Parse(dtStr);

                    if (dt != null)
                    {
                        var employee = context.Employees
                                       .Where(w => w.EmployeeCode == idwEnrollNumber)
                                       .FirstOrDefault();

                        if (employee != null)
                        {
                            AttendanceRecord record = new AttendanceRecord()
                            {
                                EmployeeId = employee.EmployeeId,
                                Date       = dt,
                                DeviceId   = device.DeviceId,
                                InsertedAt = DateTime.Now
                            };

                            try
                            {
                                context.AttendanceRecords.Add(record);
                                context.SaveChanges();
                            }
                            catch (Exception e)
                            {
                                result = false;
                                MyLogger.GetInstance.Error(string.Format("ZKDevice.SSRDownloadLogData() - Error on device Ip: {0} ", this.Device.IP), e);
                            }

                            MyLogger.GetInstance.Info(string.Format("ZKDevice.SSRDownloadLogData() - Insert into dbo.AttendanceRecord(DeviceId,EmployeeId,Date,InsertedDate) Values({0},{1},'{2}','{3}')", this.Device.DeviceId, idwEnrollNumber.ToString(), dt.ToString("yyyy-MM-dd HH:mm"), DateTime.Now.ToString("yyyy-MM-dd HH:mm")));
                        }
                        else
                        {
                            MyLogger.GetInstance.Error(string.Format("ZKDevice.SSRDownloadLogData() - Employee Not Exist - Insert into dbo.AttendanceRecord(DeviceId,EmployeeId,Date,InsertedDate) Values({0},{1},'{2}','{3}')", this.Device.DeviceId, idwEnrollNumber.ToString(), dt.ToString("yyyy-MM-dd HH:mm"), DateTime.Now.ToString("yyyy-MM-dd HH:mm")));
                        }
                    }
                    else
                    {
                        result = false;
                        MyLogger.GetInstance.Error(string.Format("ZKDevice.SSRDownloadLogData() - Time Error - Insert into dbo.AttendanceRecord(DeviceId,EmployeeId,Date,InsertedDate) Values({0},{1},'{2}','{3}')", this.Device.DeviceId, idwEnrollNumber.ToString(), dtStr, DateTime.Now.ToString("yyyy-MM-dd HH:mm")));
                    }
                }
            }
            else
            {
                axCZKEM1.GetLastError(ref idwErrorCode);
                result = false;

                if (idwErrorCode != 0)
                {
                    MyLogger.GetInstance.Error("ZKDevice.SSRDownloadLogData() - Reading data from terminal failed,ErrorCode: " + idwErrorCode.ToString());
                }
                else
                {
                    MyLogger.GetInstance.Error("ZKDevice.SSRDownloadLogData() - No data from terminal returns!");
                }
            }
            axCZKEM1.EnableDevice(iMachineNumber, true); //enable the device
            MyLogger.GetInstance.Debug("ZKDevice.SSRDownloadLogData() - Download: " + iGLCount + " records");

            return(result);
        }