Esempio n. 1
0
 private void BindToGridView(object list)
 {
     ClearGrid();
     dgvRecords.DataSource          = list;
     dgvRecords.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
     UniversalStatic.ChangeGridProperties(dgvRecords);
 }
Esempio n. 2
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);
            }
        }
Esempio n. 3
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;
        }
Esempio n. 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);
        }
Esempio n. 5
0
        static string GetReq(string url)
        {
            string htmlResponse = string.Empty;

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.AutomaticDecompression = DecompressionMethods.GZip;

                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    using (Stream stream = response.GetResponseStream())
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            htmlResponse = reader.ReadToEnd();
                        }
            }
            catch (Exception ex)
            {
                WriteToErrorLog("Something wrong with GetReq()", ex.ToString());

                //var doesConnectionExist = UniversalStatic.PingTheDevice(setting.IpAddress);

                if (UniversalStatic.PingTheDevice(setting.IpAddress))
                {
                    Stopwatch sw1 = new Stopwatch();
                    sw1.Start();
                    while (true)
                    {
                        if (sw1.ElapsedMilliseconds > 5000)
                        {
                            sw1.Stop();
                            if (!UniversalStatic.PingTheDevice(setting.IpAddress))
                            {
                                sw1.Start();
                                while (true)
                                {
                                    if (sw1.ElapsedMilliseconds > 5000)
                                    {
                                        sw1.Stop();
                                        if (!UniversalStatic.PingTheDevice(setting.IpAddress))
                                        {
                                            WriteToErrorLog("Something wrong with GetReq() \r\n Probably doen\'t connect to fingerprint machine", ex.ToString());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(htmlResponse);
        }
Esempio n. 6
0
        public string CheckingConnectionStatus(string ipAddress, string port)
        {
            string status = string.Empty;

            try
            {
                #region Validating
                if (ipAddress == string.Empty || port == string.Empty)
                {
                    status = "The Device IP Address and Port is mandotory !!";
                }


                int portNumber = 0;
                if (!int.TryParse(port, out portNumber))

                {
                    status = "Not a valid port number";
                }
                bool isValidIpA = UniversalStatic.ValidateIP(ipAddress);
                if (!isValidIpA)
                {
                    status = "The Device IP is invalid !!";
                }
                isValidIpA = UniversalStatic.PingTheDevice(ipAddress);
                if (!isValidIpA)
                {
                    status = "The device at " + ipAddress + ":" + port + " did not respond!!";
                }
                #endregion
                ZkemClient objZkeeper        = new ZkemClient();
                bool       IsDeviceConnected = objZkeeper.Connect_Net(ipAddress, portNumber);

                if (IsDeviceConnected)
                {
                    status = "Device Is Online";
                }
            }
            catch (Exception ex)
            {
                status = ex.Message.ToString();
                //ShowStatusBar(ex.Message, false);
            }
            return(status);
        }
Esempio n. 7
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);
            }
        }
Esempio n. 8
0
        private void BtnPingDevice_Click(object sender, EventArgs e)
        {
            ShowStatusBar(string.Empty, true);

            string ipAddress = tbxDeviceIP.Text.Trim();

            bool isValidIpA = UniversalStatic.ValidateIP(ipAddress);

            if (!isValidIpA)
            {
                throw new Exception("The Device IP is invalid !!");
            }

            isValidIpA = UniversalStatic.PingTheDevice(ipAddress);
            if (isValidIpA)
            {
                ShowStatusBar("The device is active", true);
            }
            else
            {
                ShowStatusBar("Could not read any response", false);
            }
        }
Esempio n. 9
0
 private void TbxMachineNumber_TextChanged(object sender, EventArgs e)
 {
     UniversalStatic.ValidateInteger(tbxMachineNumber);
 }
Esempio n. 10
0
 private void TbxPort_TextChanged(object sender, EventArgs e)
 {
     UniversalStatic.ValidateInteger(tbxPort);
 }
Esempio n. 11
0
 private void PnlHeader_Paint(object sender, PaintEventArgs e)
 {
     UniversalStatic.DrawLineInFooter(pnlHeader, Color.FromArgb(204, 204, 204), 2);
 }