예제 #1
0
        private void BtnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                ShowStatusBar(string.Empty, true);

                if (IsDeviceConnected)
                {
                    IsDeviceConnected = false;
                    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 !!");
                }

                if (!int.TryParse(port, out int 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)
                {
                    lblDeviceInfo.Text = manipulator.FetchDeviceInfo(objZkeeper, int.Parse(tbxMachineNumber.Text.Trim()));

                    manipulator.FetchDeviceInfo(objZkeeper, int.Parse(tbxMachineNumber.Text.Trim()));
                }
            }
            catch (Exception ex)
            {
                ShowStatusBar(ex.Message, false);
            }
            Cursor = Cursors.Default;
        }
 public List <Attendance_Record> fetchAttendance(AttendanceDataConfig config)
 {
     try
     {
         objZkeeper = new ZkemClient(RaiseDeviceEvent);
         bool IsDeviceConnected = objZkeeper.Connect_Net(config.IPAddress, config.PortNumber);
         int  todaysRecord      = 0;
         if (IsDeviceConnected)
         {
             string deviceInfo = manipulator.FetchDeviceInfo(objZkeeper, config.MachineNumber);                   ///tbxMachineNumber.Text.Trim()
             ///lblDeviceInfo.Text = deviceInfo;
             ICollection <MachineInfo> lstMachineInfo = manipulator.GetLogData(objZkeeper, config.MachineNumber); ///tbxMachineNumber.Text.Trim()
             var attendanceRecord = new List <Attendance_Record>();
             foreach (var item in lstMachineInfo)
             {
                 if (DateTime.Compare(item.DateOnlyRecord, config.DateTo) == 0)///DateTime.Parse(item.DateTimeRecord).Date
                 {
                     attendanceRecord.Add(new Attendance_Record()
                     {
                         Information_Id = item.IndRegID, Attendance_Timing = DateTime.Parse(item.DateTimeRecord)
                     });
                     todaysRecord++;
                 }
             }
             return(attendanceRecord);
         }
         return(new List <Attendance_Record>());
     }
     catch (Exception ex)
     {
         return(new List <Attendance_Record>());
     }
 }
예제 #3
0
        private static void conectar(int index)
        {
            try
            {
                string ipAddress = marcadores[index].IP;
                string port      = marcadores[index].PUERTO.ToString();
                if (ipAddress == string.Empty || port == string.Empty)
                {
                    throw new Exception("La dirección IP y el número de puerto son requeridos.");
                }

                int portNumber = 4370;
                if (!int.TryParse(port, out portNumber))
                {
                    throw new Exception("No es un número IP válido");
                }

                bool isValidIpA = UniversalStatic.ValidateIP(ipAddress);
                if (!isValidIpA)
                {
                    throw new Exception("La dirección IP no es una dirección IVP4 válida.");
                }

                isValidIpA = UniversalStatic.PingTheDevice(ipAddress);
                if (!isValidIpA)
                {
                    throw new Exception("La terminal con IP " + ipAddress + ":" + port + " no pudo ser alcanzada.");
                }

                objZkeeper = new ZkemClient(RaiseDeviceEvent);
                if (objZkeeper == null)
                {
                    Console.WriteLine("~> objZkeeper = null");
                }
                else
                {
                    Console.WriteLine("// objZkeeper ok!");
                }
                objZkeeper.Connect_Net(ipAddress, portNumber);
                if (manipulator == null)
                {
                    Console.WriteLine("~> manipulator = null");
                }
                else
                {
                    Console.WriteLine("// manipulator ok!");
                }

                string deviceInfo = manipulator.FetchDeviceInfo(objZkeeper, 1);
                Console.WriteLine(">>> Cargando: " + deviceInfo);
                pullData();
            }
            catch (Exception ex)
            {
                Console.WriteLine("~> Error: " + ex.Message + " - " + ex.StackTrace);
            }
        }
예제 #4
0
        public bool ConnectToZKTeco()
        {
            try
            {
                if (IsDeviceConnected)
                {
                    //IsDeviceConnected = false;

                    return(IsDeviceConnected);
                }

                if (this.DeviceIP == string.Empty || this.PortNumber < 1)
                {
                    throw new ZkTecoClientException("The Device IP Address and Port is mandotory !!");
                }


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

                isValidIpA = UniversalStatic.PingTheDevice(this.DeviceIP);
                if (!isValidIpA)
                {
                    //retry
                    isValidIpA = UniversalStatic.PingTheDevice(this.DeviceIP);

                    if (!isValidIpA)
                    {
                        throw new ZkTecoClientException("The device at " + this.DeviceIP + ":" + this.PortNumber + " did not respond!!");
                    }
                }
                objZkeeper        = new ZkemService(RaiseDeviceEvent);
                IsDeviceConnected = objZkeeper.Connect_Net(this.DeviceIP, this.PortNumber);

                if (IsDeviceConnected)
                {
                    this.DeviceInfo = manipulator.FetchDeviceInfo(objZkeeper, this.MachineNumber);
                }
                else
                {
                    throw new Exception("Failed to connect to the biometric device at " + this.DeviceIP + ":" + this.PortNumber + "!");
                }
            }
            catch (ZkTecoClientException ex)
            {
                throw ex;
            }

            return(IsDeviceConnected);
        }
예제 #5
0
        private static void conectar(int index)
        {
            try
            {
                string ipAddress = marcadores[index].IP; //cmbUbicacion.SelectedValue.ToString(); //tbxDeviceIP.Text.Trim();
                string port      = marcadores[index].PUERTO.ToString();
                if (ipAddress == string.Empty || port == string.Empty)
                {
                    throw new Exception("La dirección IP y el número de puerto son requeridos.");
                }

                int portNumber = 4370;
                if (!int.TryParse(port, out portNumber))
                {
                    throw new Exception("No es un número IP válido");
                }

                bool isValidIpA = UniversalStatic.ValidateIP(ipAddress);
                if (!isValidIpA)
                {
                    throw new Exception("La dirección IP no es una dirección IVP4 válida.");
                }

                isValidIpA = UniversalStatic.PingTheDevice(ipAddress);
                if (!isValidIpA)
                {
                    throw new Exception("La terminal con IP " + ipAddress + ":" + port + " no pudo ser alcanzada.");
                }

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

                string deviceInfo = manipulator.FetchDeviceInfo(objZkeeper, 1);
                Console.WriteLine("Se ha conectado a la terminal: " + deviceInfo + " - en ubicación: " + marcadores[index].UBICACION);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error! " + ex.Message);
            }
        }