Exemplo n.º 1
0
        public void GetGeneratLog(ZkemClient objZkeeper, int machineNumber, string enrollNo)
        {
            string name      = null;
            string password  = null;
            int    previlage = 0;
            bool   enabled   = false;

            byte[] byTmpData  = new byte[2000];
            int    tempLength = 0;

            int idwFingerIndex = 0;// [ <--- Enter your fingerprint index here ]
            int iFlag          = 0;

            objZkeeper.ReadAllTemplate(machineNumber);

            while (objZkeeper.SSR_GetUserInfo(machineNumber, enrollNo, out name, out password, out previlage, out enabled))
            {
                if (objZkeeper.GetUserTmpEx(machineNumber, enrollNo, idwFingerIndex, out iFlag, out byTmpData[0], out tempLength))
                {
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private void addUser(ZkemClient objZkeeper, Device device)
        {
            // manipulator.PushUserDataToDevice(objZkeeper, int.Parse(device.DeviceId), "xxxsssxxx");

            //ICollection<UserIDInfo> lstUserIDInfo = manipulator.GetAllUserID(objZkeeper, int.Parse(device.DeviceId));
            ICollection <UserInfo> lstUserInfo = manipulator.GetAllUserInfo(objZkeeper, int.Parse(device.DeviceId));

            //Console.WriteLine("-> user id count: " + lstUserIDInfo.Count);
            Console.WriteLine("-> user count: " + lstUserInfo.Count);

            UserInfo sinfo = new UserInfo();

            sinfo.EnrollNumber  = "40";
            sinfo.Name          = "Erfan";
            sinfo.FingerIndex   = 0;
            sinfo.TmpData       = "";
            sinfo.Privelage     = 0;
            sinfo.Password      = "******";
            sinfo.Enabled       = true;
            sinfo.iFlag         = "1";
            sinfo.MachineNumber = 1;

            List <UserInfo> lstUserInfo2 = new List <UserInfo>();

            lstUserInfo2.Add(sinfo);
            try
            {
                manipulator.UploadFTPTemplate(objZkeeper, 1, lstUserInfo2);
            }
            catch (Exception rrr) {
                Console.WriteLine("----------------error------------");
                Console.WriteLine(rrr);
            }
            lstUserInfo = manipulator.GetAllUserInfo(objZkeeper, int.Parse(device.DeviceId));
            //Console.WriteLine("-> user id count: " + lstUserIDInfo.Count);
            Console.WriteLine("-> user count: " + lstUserInfo.Count);
        }
Exemplo n.º 3
0
        //public bool ClearGLog(ZkemClient objZkeeper, int machineNumber)
        public ICollection <MachineInfo> GetLogData(ZkemClient objZkeeper, int machineNumber)
        {
            string dwEnrollNumber1 = "";
            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;

            ICollection <MachineInfo> lstEnrollData = new List <MachineInfo>();

            objZkeeper.ReadAllGLogData(machineNumber);

            try
            {
                var SL = GetSerialNumber(objZkeeper, machineNumber);
                while (objZkeeper.SSR_GetGeneralLogData(machineNumber, out dwEnrollNumber1, out dwVerifyMode, out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond, ref dwWorkCode))
                {
                    string inputDate = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond).ToString();

                    MachineInfo objInfo = new MachineInfo();
                    objInfo.MachineNumber  = machineNumber;
                    objInfo.IndRegID       = int.Parse(dwEnrollNumber1);
                    objInfo.DateTimeRecord = inputDate;
                    objInfo.SerialNumber   = SL;
                    lstEnrollData.Add(objInfo);
                }
            }
            catch (Exception ex)
            {
            }
            return(lstEnrollData);
        }
Exemplo n.º 4
0
        ///Getting All the User's Info
        public ICollection <UserInfo> GetAllUserInfo(ZkemClient objZkeeper, int machineNumber)
        {
            string sdwEnrollNumber = string.Empty, sName = string.Empty, sPassword = string.Empty, sTmpData = string.Empty;
            int    iPrivilege = 0, iTmpLength = 0, iFlag = 0, idwFingerIndex;
            bool   bEnabled = false;

            ICollection <UserInfo> lstFPTemplates = new List <UserInfo>();

            objZkeeper.ReadAllUserID(machineNumber);
            objZkeeper.ReadAllTemplate(machineNumber);

            while (objZkeeper.SSR_GetAllUserInfo(machineNumber, out sdwEnrollNumber, out sName, out sPassword, out iPrivilege, out bEnabled))
            {
                for (idwFingerIndex = 0; idwFingerIndex <= 10; idwFingerIndex++)
                {
                    if (objZkeeper.GetUserTmpExStr(machineNumber, sdwEnrollNumber, idwFingerIndex, out iFlag, out sTmpData, out iTmpLength))
                    {
                        UserInfo fpInfo = new UserInfo();

                        fpInfo.MachineNumber = machineNumber;
                        fpInfo.EnrollNumber  = sdwEnrollNumber;
                        fpInfo.Name          = sName;
                        fpInfo.FingerIndex   = idwFingerIndex;
                        fpInfo.TmpData       = sTmpData;
                        fpInfo.Privelage     = iPrivilege;
                        fpInfo.Password      = sPassword;
                        fpInfo.Enabled       = bEnabled;
                        fpInfo.iFlag         = iFlag.ToString();

                        lstFPTemplates.Add(fpInfo);
                    }
                }
            }

            return(lstFPTemplates);
        }
Exemplo n.º 5
0
        // Get All User's ID
        public ICollection <UserIDInfo> GetAllUserID(ZkemClient objZkeeper, int machineNumber)
        {
            int dwEnrollNumber     = 0;
            int dwEMachineNumber   = 0;
            int dwBackUpNumber     = 0;
            int dwMachinePrivelage = 0;
            int dwEnabled          = 0;

            ICollection <UserIDInfo> lstUserIDInfo = new List <UserIDInfo>();

            objZkeeper.ReadAllUserID(machineNumber);

            while (objZkeeper.GetAllUserID(machineNumber, ref dwEnrollNumber, ref dwEMachineNumber, ref dwBackUpNumber, ref dwMachinePrivelage, ref dwEnabled))
            {
                UserIDInfo userID = new UserIDInfo();
                userID.BackUpNumber  = dwBackUpNumber;
                userID.Enabled       = dwEnabled;
                userID.EnrollNumber  = dwEnrollNumber;
                userID.MachineNumber = dwEMachineNumber;
                userID.Privelage     = dwMachinePrivelage;
                lstUserIDInfo.Add(userID);
            }
            return(lstUserIDInfo);
        }
        public ICollection <MachineInfo> GetLogData(ZkemClient objZkeeper, int machineNumber)
        {
            string dwEnrollNumber1 = "";
            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;

            ICollection <MachineInfo> lstEnrollData = new List <MachineInfo>();

            objZkeeper.ReadAllGLogData(machineNumber);
            cnx.Open();
            SqlCommand    cmd2 = new SqlCommand("select * from atdrecord", cnx);
            SqlDataReader dr   = cmd2.ExecuteReader();
            DataTable     tb   = new DataTable();

            tb.Load(dr);

            while (objZkeeper.SSR_GetGeneralLogData(machineNumber, out dwEnrollNumber1, out dwVerifyMode, out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond, ref dwWorkCode))
            {
                string   inputDate = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond).ToString();
                string   recDate = dwYear + "-" + dwMonth + "-" + dwDay, recTime = dwHour + ":" + dwMinute + ":" + dwSecond;
                string   RecDate2 = dwYear + "-" + dwMonth + "-" + dwDay + ' ' + dwHour + ":" + dwMinute + ":" + dwSecond;
                DateTime dateP    = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
                // DateTime d = new DateTime(0,0,0,dwHour, dwMinute, dwSecond);
                MachineInfo objInfo = new MachineInfo();
                objInfo.MachineNumber  = machineNumber;
                objInfo.IndRegID       = int.Parse(dwEnrollNumber1);
                objInfo.DateTimeRecord = inputDate;
                // MessageBox.Show(d.ToShortTimeString());
                if (cnx.State == ConnectionState.Open)
                {
                    if (tb.Rows.Count == 0)
                    {
                        DateTime datetime = DateTime.ParseExact(RecDate2, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);


                        cmd = new SqlCommand("insert into AtdRecord values('" + datetime.ToShortDateString() + "','" + datetime.ToShortTimeString() + "','" + datetime + "','" + dwEnrollNumber1 + "')", cnx);
                        cmd.ExecuteNonQuery();
                    }
                    else
                    {
                        bool b = true;
                        for (int i = 0; i < tb.Rows.Count; i++)
                        {
                            if ((tb.Rows[i][2].ToString() == dwEnrollNumber1.ToString() && tb.Rows[i][5].ToString() == inputDate.ToString()))
                            {
                                b = false;
                            }
                        }
                        if (b)
                        {
                            //cmd = new SqlCommand("insert into AtdRecord values('" + dwVerifyMode + "','" + dwEnrollNumber1 + "','" + recDate + "','" + recTime + "','" + RecDate2 + "')", cnx);
                            cmd = new SqlCommand("insert into AtdRecord values('" + datetime.ToShortDateString() + "','" + datetime.ToShortTimeString() + "','" + datetime + "','" + dwEnrollNumber1 + "')", cnx);
                            cmd.ExecuteNonQuery();
                            cmd2 = new SqlCommand("select * from AtdRecord", cnx);
                            dr   = cmd2.ExecuteReader();
                            tb   = new DataTable();
                            tb.Load(dr);
                        }
                    }
                }
                else
                {
                }


                lstEnrollData.Add(objInfo);
            }
            cnx.Close();

            return(lstEnrollData);
        }
Exemplo n.º 7
0
        private void tsm_baglan_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                ShowStatusBar("Bağlantı Kuruluyor.", true);

                if (IsDeviceConnected)
                {
                    IsDeviceConnected = false;
                    this.Cursor       = Cursors.Default;
                    //enable device
                    if (checkBox1.Checked)
                    {
                        bool deviceEnabled = objZkeeper.EnableDevice(int.Parse(toolStripTextBox3.Text.Trim()), true);
                    }
                    return;
                }

                string ipAddress = toolStripTextBox1.Text.Trim();
                string port      = toolStripTextBox2.Text.Trim();
                if (ipAddress == string.Empty || port == string.Empty)
                {
                    throw new Exception("The Device IP Address and Port is mandotory !!");
                }

                int portNumber = 4370;
                if (!int.TryParse(port, out portNumber))
                {
                    throw new Exception("Not a valid port number");
                }

                bool isValidIpA = UniversalStatic.ValidateIP(ipAddress);
                if (!isValidIpA)
                {
                    throw new Exception("The Device IP is invalid !!");
                }

                isValidIpA = UniversalStatic.PingTheDevice(ipAddress);
                if (!isValidIpA)
                {
                    throw new Exception("The device at " + ipAddress + ":" + port + " did not respond!!");
                }

                objZkeeper        = new ZkemClient(RaiseDeviceEvent);
                IsDeviceConnected = objZkeeper.Connect_Net(ipAddress, portNumber);

                if (IsDeviceConnected)
                {
                    string deviceInfo = manipulator.FetchDeviceInfo(objZkeeper, int.Parse(toolStripTextBox3.Text.Trim()));
                    this.Text = "Ana Menü - " + deviceInfo;
                }
                machineNumber = toolStripTextBox3.Text;

                //disable device
                if (checkBox1.Checked)
                {
                    bool deviceDisabled = objZkeeper.DisableDeviceWithTimeOut(int.Parse(toolStripTextBox3.Text.Trim()), 3000);
                }
            }
            catch (Exception ex)
            {
                ShowStatusBar(ex.Message, false);
            }
            this.Cursor = Cursors.Default;
        }
Exemplo n.º 8
0
        private void opendoorBtn_Click(object sender, EventArgs e)
        {
            ZkemClient client = new ZkemClient(null);

            client.ACUnlock(int.Parse(tbxMachineNumber.Text), 0);
        }
Exemplo n.º 9
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                ShowStatusBar(string.Empty, true);

                if (IsDeviceConnected)
                {
                    IsDeviceConnected = false;
                    this.Cursor       = Cursors.Default;

                    return;
                }

                string ipAddress = tbxDeviceIP.Text.Trim();
                string port      = tbxPort.Text.Trim();

                if (ipAddress == string.Empty || port == string.Empty)
                {
                    throw new Exception("The Device IP Address and Port is mandatory !!");
                }

                int portNumber = 4370;
                if (!int.TryParse(port, out portNumber))
                {
                    throw new Exception("Not a valid port number");
                }

                bool isValidIpA = UniversalStatic.ValidateIP(ipAddress);
                if (!isValidIpA)
                {
                    throw new Exception("The Device IP is invalid !!");
                }

                isValidIpA = UniversalStatic.PingTheDevice(ipAddress);
                if (!isValidIpA)
                {
                    throw new Exception("The device at " + ipAddress + ":" + port + " did not respond!!");
                }

                objZkeeper        = new ZkemClient(RaiseDeviceEvent);
                IsDeviceConnected = objZkeeper.Connect_Net(ipAddress, portNumber);

                getTodayRec();

                //Send Without Click
                timerAuto();

                if (IsDeviceConnected)
                {
                    string deviceInfo = manipulator.FetchDeviceInfo(objZkeeper, int.Parse(tbxMachineNumber.Text.Trim()));
                    lblDeviceInfo.Text = deviceInfo;
                }
            }
            catch (Exception ex)
            {
                ShowStatusBar(ex.Message, false);
            }

            this.Cursor = Cursors.Default;
        }
Exemplo n.º 10
0
 private void DisableDevice(ZkemClient objZkeeper, Device device)
 {
     // This is of no use since i implemented zkemKeeper the other way
     bool deviceDisabled = objZkeeper.DisableDeviceWithTimeOut(int.Parse(device.DeviceId), 3000);
 }
Exemplo n.º 11
0
        private Boolean GetLogsToMySql(Combination combination)
        {
            Device     device     = combination.device;
            ZkemClient objZkeeper = combination.objZkeeper;
            Boolean    status     = false;

            if (device.status)
            {
                try
                {
                    ShowStatusBar(string.Empty, true);

                    ICollection <MachineInfo> lstMachineInfo = manipulator.GetLogData(objZkeeper, int.Parse(device.DeviceId));

                    if (lstMachineInfo != null && lstMachineInfo.Count > 0)
                    {
                        Boolean clearedLog = false;

                        ShowStatusBar(device.IP + " -> " + lstMachineInfo.Count + " records found !!", true);

                        Console.WriteLine("---");
                        Console.WriteLine(lstMachineInfo.Count);
                        IEnumerator enumerator = lstMachineInfo.GetEnumerator();
                        string      theCommand = "INSERT INTO log (MachineNumber, IndRegID, DateTimeRecord ) VALUES ";
                        int         count      = 0;
                        while (enumerator.MoveNext())
                        {
                            MachineInfo item = (MachineInfo)enumerator.Current;
                            theCommand += "('" + item.MachineNumber + "', '" + item.IndRegID + "', '" + item.DateTimeRecord + "')";
                            count++;
                            if (count < lstMachineInfo.Count)
                            {
                                theCommand += ", ";
                            }
                        }

                        Console.WriteLine(theCommand);
                        MySqlCommand command = conn.CreateCommand();
                        command.CommandText = theCommand;
                        Boolean mysqlInsertSuccess = false;
                        try
                        {
                            int o = command.ExecuteNonQuery();
                            mysqlInsertSuccess = true;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                            mysqlInsertSuccess = false;
                        }

                        if (mysqlInsertSuccess)
                        {
                            clearedLog = manipulator.ClearGLog(objZkeeper, int.Parse(device.DeviceId));
                        }
                        status = true;
                    }
                    else
                    {
                        DisplayListOutput("No records found");
                        status = false;
                    }
                }
                catch (Exception ex)
                {
                    DisplayListOutput(ex.Message);
                }
            }
            return(status);
        }
Exemplo n.º 12
0
 private void Beep(ZkemClient objZkeeper)
 {
     objZkeeper.Beep(100);
 }
Exemplo n.º 13
0
        private Boolean GetUsersToMySql(Combination combination)
        {
            Device     device     = combination.device;
            ZkemClient objZkeeper = combination.objZkeeper;
            Boolean    status     = false;

            if (device.status)
            {
                Console.WriteLine("Getting users for Device at: " + device.IP);
                ICollection <UserInfo> lstUserInfo = manipulator.GetAllUserInfo(objZkeeper, int.Parse(device.DeviceId));

                if (lstUserInfo != null && lstUserInfo.Count > 0)
                {
                    Boolean clearedLog = false;

                    Console.WriteLine(lstUserInfo.Count);
                    IEnumerator enumerator = lstUserInfo.GetEnumerator();
                    string      theCommand = "INSERT INTO user_info (tmp_data, privilege, password, name, machine_number, i_flag, finger_index, enroll_number, enabled , officeCode) VALUES ";
                    int         count      = 0;
                    int         countShouldTheCommandBeExecuted = 0;
                    while (enumerator.MoveNext())
                    {
                        UserInfo item           = (UserInfo)enumerator.Current;
                        string   checkStatement = "SELECT * FROM user_info WHERE machine_number=" + item.MachineNumber + " AND enroll_number='" + item.EnrollNumber + "' AND tmp_data='" + item.TmpData + "'";
                        // Console.WriteLine(checkStatement);
                        var cmd    = new MySql.Data.MySqlClient.MySqlCommand(checkStatement, conn);
                        var reader = cmd.ExecuteReader();
                        int c      = 0;
                        while (reader.Read())
                        {
                            c++;
                        }
                        reader.Close();

                        if (c > 0)
                        {
                            Console.WriteLine("----------------->");
                        }
                        else
                        {
                            countShouldTheCommandBeExecuted++;

                            int shit = 0;
                            if (item.Enabled)
                            {
                                shit = 1;
                            }
                            theCommand += "('" + item.TmpData + "', '" + item.Privelage + "', '" + item.Password + "', '" + item.Name + "', '" + item.MachineNumber + "', '" + item.iFlag + "', '" + item.FingerIndex + "', '" + item.EnrollNumber + "', '" + shit + "', '" + config + "' )";
                            count++;
                            if (count < lstUserInfo.Count)
                            {
                                theCommand += ", ";
                            }
                        }
                    }


                    if (countShouldTheCommandBeExecuted > 0)
                    {
                        theCommand = theCommand.TrimEnd(' ');
                        theCommand = theCommand.TrimEnd(',');
                        // Console.WriteLine(theCommand);
                        MySqlCommand command = conn.CreateCommand();
                        command.CommandText = theCommand;
                        Boolean mysqlInsertSuccess = false;
                        try
                        {
                            int o = command.ExecuteNonQuery();
                            mysqlInsertSuccess = true;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                            mysqlInsertSuccess = false;
                        }

                        if (mysqlInsertSuccess)
                        {
                            clearedLog = manipulator.ClearGLog(objZkeeper, int.Parse(device.DeviceId));
                        }
                    }
                    status = true;
                }
                else
                {
                    Console.WriteLine("changes 0");
                    // status = false;
                }



                pushToMachine(combination);
            }



            return(status);
        }
Exemplo n.º 14
0
        private Boolean GetLogsToMySql(Combination combination)
        {
            Device     device     = combination.device;
            ZkemClient objZkeeper = combination.objZkeeper;
            Boolean    status     = false;

            if (device.status)
            {
                Console.WriteLine("Getting logs for Device at: " + device.IP);

                try
                {
                    ICollection <MachineInfo> lstMachineInfo = manipulator.GetLogData(objZkeeper, int.Parse(device.DeviceId));

                    if (lstMachineInfo != null && lstMachineInfo.Count > 0)
                    {
                        Boolean clearedLog = false;

                        Console.WriteLine(lstMachineInfo.Count);
                        IEnumerator enumerator = lstMachineInfo.GetEnumerator();
                        string      theCommand = "INSERT INTO logs (machine_number, ind_reg_id, date_time_record ) VALUES ";
                        int         count      = 0;
                        while (enumerator.MoveNext())
                        {
                            MachineInfo item = (MachineInfo)enumerator.Current;
                            theCommand += "('" + item.MachineNumber + "', '" + item.IndRegID + "', '" + item.DateTimeRecord + "')";
                            count++;
                            if (count < lstMachineInfo.Count)
                            {
                                theCommand += ", ";
                            }
                        }

                        // Console.WriteLine(theCommand);
                        MySqlCommand command = conn.CreateCommand();
                        command.CommandText = theCommand;
                        Boolean mysqlInsertSuccess = false;
                        try
                        {
                            int o = command.ExecuteNonQuery();
                            mysqlInsertSuccess = true;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                            mysqlInsertSuccess = false;
                        }

                        if (mysqlInsertSuccess)
                        {
                            clearedLog = manipulator.ClearGLog(objZkeeper, int.Parse(device.DeviceId));
                        }
                        status = true;
                    }
                    else
                    {
                        Console.WriteLine("changes 0");
                        status = false;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
            return(status);
        }
Exemplo n.º 15
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                ShowStatusBar(string.Empty, true);

                if (IsDeviceConnected)
                {
                    IsDeviceConnected = false;
                    this.Cursor       = Cursors.Default;

                    return;
                }

                string ipAddress = tbxDeviceIP.Text.Trim();
                string port      = tbxPort.Text.Trim();
                if (ipAddress == string.Empty || port == string.Empty)
                {
                    throw new Exception("The Device IP Address and Port is mandotory !!");
                }

                int portNumber = 4370;
                if (!int.TryParse(port, out portNumber))
                {
                    throw new Exception("Not a valid port number");
                }

                bool isValidIpA = UniversalStatic.ValidateIP(ipAddress);
                if (!isValidIpA)
                {
                    throw new Exception("The Device IP is invalid !!");
                }

                isValidIpA = UniversalStatic.PingTheDevice(ipAddress);
                if (!isValidIpA)
                {
                    throw new Exception("The device at " + ipAddress + ":" + port + " did not respond!!");
                }

                objZkeeper        = new ZkemClient(RaiseDeviceEvent);
                IsDeviceConnected = objZkeeper.Connect_Net(ipAddress, portNumber);

                if (IsDeviceConnected)
                {
                    string deviceInfo = manipulator.FetchDeviceInfo(objZkeeper, int.Parse(tbxMachineNumber.Text.Trim()));
                    lblDeviceInfo.Text = deviceInfo;

                    /*  objZkeeper.OnAttTransaction(string EnrollNumber, int IsInValid, int AttState, int VerifyMethod, int Year, int Month, int Day, int Hour, int Minute, int Second, int WorkCode)
                     * {
                     *    string time = Year + "-" + Month + "-" + Day + " " + Hour + ":" + Minute + ":" + Second;
                     *
                     *    gRealEventListBox.Items.Add("Verify OK.UserID=" + EnrollNumber + " isInvalid=" + IsInValid.ToString() + " state=" + AttState.ToString() + " verifystyle=" + VerifyMethod.ToString() + " time=" + time);
                     *
                     *    throw new NotImplementedException();
                     * }*/
                }
            }
            catch (Exception ex)
            {
                ShowStatusBar(ex.Message, false);
            }
            this.Cursor = Cursors.Default;
        }
Exemplo n.º 16
0
 public bool ClearGLog(ZkemClient objZkeeper, int machineNumber)
 {
     return(objZkeeper.ClearGLog(machineNumber));
 }
Exemplo n.º 17
0
 private void EnableDevice(ZkemClient objZkeeper, Device device)
 {
     // This is of no use since i implemented zkemKeeper the other way
     bool deviceEnabled = objZkeeper.EnableDevice(int.Parse(device.DeviceId), true);
 }
Exemplo n.º 18
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            try
            {
                using (FingerPrintDB db = new FingerPrintDB())
                {
                    foreach (var machine in machines)
                    {
                        string ipAddress = machine.IP;
                        string port      = machine.Port;
                        if (ipAddress == string.Empty || port == string.Empty)
                        {
                            throw new Exception("The Device IP Address and Port is mandotory !!");
                        }

                        int portNumber = 4370;
                        if (!int.TryParse(port, out portNumber))
                        {
                            throw new Exception("Not a valid port number");
                        }

                        bool isValidIpA = UniversalStatic.ValidateIP(ipAddress);
                        if (!isValidIpA)
                        {
                            throw new Exception("The Device IP is invalid !!");
                        }

                        isValidIpA = UniversalStatic.PingTheDevice(ipAddress);
                        if (!isValidIpA)
                        {
                            throw new Exception("The device at " + ipAddress + ":" + port + " did not respond!!");
                        }

                        objZkeeper = new ZkemClient(RaiseDeviceEvent);
                        objZkeeper.Connect_Net(ipAddress, portNumber);

                        ICollection <MachineInfo> lstMachineInfo = manipulator.GetLogData(objZkeeper, machine.Number);

                        foreach (var log in lstMachineInfo)
                        {
                            string timeOnly = Convert.ToDateTime(log.DateTimeRecord).ToShortTimeString();
                            if (db.Logs.Any(f => f.IndRegID == log.IndRegID && f.DateOnlyRecord == log.DateOnlyRecord && f.TimeOnlyRecord == timeOnly) != true)
                            {
                                db.Logs.Add(new Log
                                {
                                    Status         = machine.Type,
                                    MachineNumber  = machine.Number,
                                    IndRegID       = log.IndRegID,
                                    DateTimeRecord = Convert.ToDateTime(log.DateTimeRecord),
                                    DateOnlyRecord = log.DateOnlyRecord,
                                    TimeOnlyRecord = Convert.ToDateTime(log.DateTimeRecord).ToShortTimeString()
                                });
                                db.SaveChanges();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }