コード例 #1
0
        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);
        }
コード例 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            string sdwEnrollNumber = "";
            string sName           = "";
            int    idwFingerIndex  = 0;
            string sTmpData        = "";
            int    iPrivilege      = 0;
            string sPassword       = "";
            string sEnabled        = "";
            bool   bEnabled        = false;
            int    iFlag           = 1;

            int iUpdateFlag = 1;

            axCZKEM1.EnableDevice(iMachineNumber, false);
            if (axCZKEM1.BeginBatchUpdate(iMachineNumber, iUpdateFlag))//create memory space for batching data
            {
                sdwEnrollNumber = "9999";
                sName           = "ADMINISTRADOR";
                sPassword       = "******";
                iPrivilege      = 1;
                bEnabled        = true;



                if (axCZKEM1.SSR_SetUserInfo(iMachineNumber, sdwEnrollNumber, sName, sPassword, iPrivilege, bEnabled))
                {
                    axCZKEM1.BatchUpdate(iMachineNumber); //upload all the information in the memory
                    axCZKEM1.RefreshData(iMachineNumber); //the data in the device should be refreshed
                    Cursor = Cursors.Default;
                    axCZKEM1.EnableDevice(iMachineNumber, true);
                    MessageBox.Show("Revisa caeza de chancho");
                }
            }
        }
コード例 #3
0
        private bool Connect(string ip, int port = 4370)
        {
            int  i      = 0;
            bool result = true;

            try
            {
                log.Info(string.Format("Try connection to ZK Device ({0})", ip));

                log.Info(string.Format("ZKSoftware API :  axCZKEM1.Connect_Net=>1"));
                if (!axCZKEM1.Connect_Net(ip, port))
                {
                    for (i = 2; i < 4; i++)
                    {
                        log.Info(string.Format("ZKSoftware API :  axCZKEM1.Connect_Net=>{0}", i));
                        if (!axCZKEM1.Connect_Net(ip, port))
                        {
                            result = false;
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (!result)
                    {
                        axCZKEM1.GetLastError(ref ErrorCode);
                        ErrorMessage = "Unable to connect the device,ErrorCode= " + ErrorCode;
                        log.Warn(ErrorMessage);
                    }
                }

                if (result)
                {
                    log.Info(string.Format("ZKSoftware API :  axCZKEM1.EnableDevice: false"));
                    axCZKEM1.EnableDevice(iMachineNumber, false);
                    log.Info(string.Format("ZK Device ({0}) is Connected", ip));
                }
            }
            catch (AccessViolationException aex)
            {
                log.Fatal(aex);
                result = false;
                throw new Exception(aex.Message);
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
                result = false;
                throw ex;
            }
            catch
            {
                throw;
            }

            return(result);
        }
コード例 #4
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);
        }
コード例 #5
0
        public int sta_SetSMS(List <string> lblOutputInfo, string txtSMSID, string cbTag, string txtValidMin,
                              string txtContent)
        {
            if (GetConnectState() == false)
            {
                lblOutputInfo.Add("*Please connect first!");
                return(-1024);
            }

            if (txtSMSID.Trim() == "" || cbTag.Trim() == "" || txtValidMin.Trim() == "" || txtContent.Trim() == "")
            {
                lblOutputInfo.Add("*Please input data first!");
                return(-1023);
            }

            if (Convert.ToInt32(txtSMSID.Trim()) <= 0)
            {
                lblOutputInfo.Add("*SMS ID error!");
                return(-1023);
            }

            if (Convert.ToInt32(txtValidMin.Trim()) < 0 || Convert.ToInt32(txtValidMin.Trim()) > 65535)
            {
                lblOutputInfo.Add("*Expired time error!");
                return(-1023);
            }

            int    idwErrorCode = 0;
            int    iSMSID       = Convert.ToInt32(txtSMSID.Trim());
            int    iTag         = 0;
            int    iValidMins   = Convert.ToInt32(txtValidMin.Trim());
            string sStartTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm").Trim();
            string sContent     = txtContent.Trim();
            string sTag         = cbTag.Trim();

            for (iTag = 253; iTag <= 255; iTag++)
            {
                if (sTag.IndexOf(iTag.ToString()) > -1)
                {
                    break;
                }
            }

            axCZKEM1.EnableDevice(iMachineNumber, false);
            if (axCZKEM1.SetSMS(iMachineNumber, iSMSID, iTag, iValidMins, sStartTime, sContent))
            {
                axCZKEM1.RefreshData(iMachineNumber);//After you have set the short message,you should refresh the data of the device
                lblOutputInfo.Add("Successfully set SMS! SMSType=" + iTag.ToString());
            }
            else
            {
                axCZKEM1.GetLastError(ref idwErrorCode);
                lblOutputInfo.Add("*Operation failed,ErrorCode=" + idwErrorCode.ToString());
            }
            axCZKEM1.EnableDevice(iMachineNumber, true);

            return(idwErrorCode != 0 ? idwErrorCode : 1);
        }
コード例 #6
0
ファイル: APITests.cs プロジェクト: jgera/ZKtech-API-Tests
        private void restore(int machineno = 1)
        {
            bool           stuts = CheckStatus(txt_ipaddress.Text);
            OpenFileDialog sf    = new OpenFileDialog();

            sf.DefaultExt = "*.csv";
            sf.FileName   = "backup.csv";
            if (sf.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string[] Lines = File.ReadAllLines(sf.FileName);


            Cursor = Cursors.WaitCursor;
            axCZKEM1.EnableDevice(machineno, false);

            //if (!axCZKEM1.BeginBatchUpdate(machineno, 1))
            //    return;

            int      iPrivilege  = 0;    //default previlege
            string   password    = "";
            bool     Enabled     = true; //Enabled by default
            int      FingerIndex = 0;
            DateTime start       = DateTime.Now;

            foreach (string usr in Lines)
            {
                string[] details = usr.Split(',');
                // SSR_SetUserInfo not working
                if (axCZKEM1.SSR_SetUserInfo(machineno, details[0], details[1], password, iPrivilege, Enabled))//upload user information to the memory
                {
                    axCZKEM1.SetUserTmpExStr(machineno, details[0], FingerIndex, 1, details[2].Trim());
                }
            }
            DateTime end  = DateTime.Now;
            TimeSpan span = (end - start);
            string   time = String.Format("it took {0} minutes, {1} seconds", span.Minutes, span.Seconds);


            //axCZKEM1.BatchUpdate(machineno);        //upload all the information in the memory
            //axCZKEM1.RefreshData(machineno);        //the data in the device should be refreshed
            //axCZKEM1.EnableDevice(machineno, true);
            Cursor = Cursors.Default;
            MessageBox.Show("Restore done!\n" + time);
        }
コード例 #7
0
        private void restore(int machineno = 1)
        {
            bool           stuts = CheckStatus(txt_ipaddress.Text);
            OpenFileDialog sf    = new OpenFileDialog();

            sf.DefaultExt = "*.csv";
            sf.FileName   = "backup.csv";
            if (sf.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string[] Lines = File.ReadAllLines(sf.FileName);


            Cursor = Cursors.WaitCursor;
            axCZKEM1.EnableDevice(machineno, false);

            if (axCZKEM1.BeginBatchUpdate(machineno, 1))
            {
                int    iPrivilege  = 0;    //default previlege
                string password    = "";
                bool   Enabled     = true; //Enabled by default
                int    FingerIndex = 6;
                foreach (string usr in Lines)
                {
                    string[] details = usr.Split(',');

                    if (axCZKEM1.SSR_SetUserInfo(machineno, details[0], details[0], password, iPrivilege, Enabled)) //upload user information to the memory
                    {
                        axCZKEM1.SSR_SetUserTmpStr(machineno, details[0], FingerIndex, details[2]);
                    }
                }
            }

            axCZKEM1.BatchUpdate(machineno);        //upload all the information in the memory
            axCZKEM1.RefreshData(machineno);        //the data in the device should be refreshed
            axCZKEM1.EnableDevice(machineno, true);
            Cursor = Cursors.Default;
            MessageBox.Show("Restore done!");
        }
コード例 #8
0
ファイル: AttLog.cs プロジェクト: techrepublik/biowrapper
        /************************************
        *   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);
        }
コード例 #9
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);
            }
        }
コード例 #10
0
ファイル: ZKDevice.cs プロジェクト: serpel/AttendanceRRHH
        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);
        }