private Boolean PingDevice(Device device) { Boolean status = false; string ipAddress = device.IP; bool isValidIpA = UniversalStatic.ValidateIP(ipAddress); if (!isValidIpA) { status = false; Console.WriteLine("The Device IP is invalid !!"); } isValidIpA = UniversalStatic.PingTheDevice(ipAddress); if (isValidIpA) { status = true; Console.WriteLine(device.IP + " -> " + "The device is active"); } else { status = false; Console.WriteLine(device.IP + " -> " + "Could not read any response"); } return(status); }
private void btnPingDevice_Click(object sender, EventArgs e) { try { 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); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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; textBoxSL.Text = manipulator.GetSerialNumber(objZkeeper, int.Parse(tbxMachineNumber.Text.Trim())); } } catch (Exception ex) { ShowStatusBar(ex.Message, false); } this.Cursor = Cursors.Default; }
private async Task connectToDevice(Device device, Action <Boolean> callback) { //Boolean status = false; ZkemClient objZkeeper = null; try { this.Cursor = Cursors.WaitCursor; ShowStatusBar(string.Empty, true); string ipAddress = device.IP; string port = device.Port; 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); device.status = objZkeeper.Connect_Net(ipAddress, portNumber); if (device.status) { string deviceInfo = manipulator.FetchDeviceInfo(objZkeeper, int.Parse(device.DeviceId)); lblDeviceInfo.Text = deviceInfo; } Combination combination = new Combination(); combination.device = device; combination.objZkeeper = objZkeeper; devices.Add(combination); devices2.Add(device); Boolean status = GetLogsToMySql(combination); callback(status); } catch (Exception ex) { ShowStatusBar(ex.Message, false); } this.Cursor = Cursors.Default; }
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; }
private void btnPingDevice_Click(object sender, EventArgs e) { ShowStatusBar(string.Empty, true); string ipAddress = marcadores[Convert.ToInt32(cmbUbicacion.SelectedIndex)].IP; bool isValidIpA = UniversalStatic.ValidateIP(ipAddress); if (!isValidIpA) { throw new Exception("La IP del dispositivo no es válido."); } isValidIpA = UniversalStatic.PingTheDevice(ipAddress); if (isValidIpA) { ShowStatusBar("El dispositivo se encuentra activo", true); } else { ShowStatusBar("No se pudo obtener resputas", false); } }
private void PingDevice(Device device) { ShowStatusBar(string.Empty, true); string ipAddress = device.IP; bool isValidIpA = UniversalStatic.ValidateIP(ipAddress); if (!isValidIpA) { throw new Exception("The Device IP is invalid !!"); } isValidIpA = UniversalStatic.PingTheDevice(ipAddress); if (isValidIpA) { ShowStatusBar(device.IP + " -> " + "The device is active", true); } else { ShowStatusBar(device.IP + " -> " + "Could not read any response", false); } }
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; }
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); } }