Beispiel #1
0
        public void Connect()
        {
            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;
                }
            }
            catch (Exception ex)
            {
                ShowStatusBar(ex.Message, false);
            }
            this.Cursor = Cursors.Default;
        }
Beispiel #2
0
        public Master()
        {
            InitializeComponent();
            ToggleControls(false);
            ShowStatusBar(string.Empty, true);
            DisplayEmpty();
            string ipAddress = "192.168.0.201";
            int    port      = 4370;

            objZkeeper        = new ZkemClient(RaiseDeviceEvent);
            isDeviceConnected = objZkeeper.Connect_Net(ipAddress, port);
        }
Beispiel #3
0
        private void conectar(int index)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                ShowStatusBar(string.Empty, true);

                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);
                objZkeeper.Connect_Net(ipAddress, portNumber);

                string deviceInfo = manipulator.FetchDeviceInfo(objZkeeper, 1);
                lblDeviceInfo.Text = deviceInfo;

                pullData();
                ToggleControls(true);
            }
            catch (Exception ex)
            {
                ShowStatusBar(ex.Message, false);
            }
            this.Cursor = Cursors.Default;
        }
Beispiel #4
0
        private void connectToDevice(Device device)
        {
            if (device.officeCode.Equals(config) && PingDevice(device))
            {
                ZkemClient objZkeeper = null;
                try
                {
                    string ipAddress  = device.IP;
                    string port       = device.Port;
                    int    portNumber = 4370;

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

                    if (device.status)
                    {
                        string deviceInfo = manipulator.FetchDeviceInfo(objZkeeper, int.Parse(device.DeviceId));
                        Console.WriteLine("Device at: " + ipAddress + " is now Connected");
                    }

                    Combination combination = new Combination();
                    combination.device     = device;
                    combination.objZkeeper = objZkeeper;
                    devices.Add(combination);
                    devices2.Add(device);
                    Boolean status  = GetLogsToMySql(combination);
                    Boolean status2 = GetUsersToMySql(combination);

                    if (!status && !status2)
                    {
                        Console.WriteLine("---------------------------->Restart required. Device Restarting..." + device.DeviceId);
                        Boolean returned = objZkeeper.RestartDevice(Int32.Parse(device.DeviceId.Trim()));
                        Console.WriteLine(returned);
                        objZkeeper.RestartDevice(Int32.Parse(device.DeviceId));
                    }
                    objZkeeper.Disconnect();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Beispiel #5
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;
        }
Beispiel #6
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;
        }
        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);
            }
        }