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 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; }
public void BindToGridView(object list) { dgvSyncedData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; UniversalStatic.ChangeGridProperties(dgvSyncedData); }
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); } }
public void BindToGridView1() { dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; UniversalStatic.ChangeGridProperties(dataGridView1); }