/// <summary> /// Retrieves the data of all MPS Systems marked for gathereing information /// </summary> /// <returns></returns> public List <OidData> GainData() { FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "RetrieveDeviceInformation", "GainData"); var dt = Config.GetInstance().Query("select * from Devices where active='1' or active='True'"); // DataTable resultTable = null; var data = new List <OidData>(); for (var i = 0; i < dt.Rows.Count; i++) { if (DeviceTools.IdentDevice(dt.Rows[i].Field <string>("Ip")).Length > 0) { if (FnPing.PingAndCheckSuccess(IPAddress.Parse(dt.Rows[i].Field <string>("Ip")))) { if (SnmpClient.ReadDeviceOiDs(dt.Rows[i].Field <string>("Ip"), DeviceTools.IdentDevice(dt.Rows[i].Field <string>("Ip")), out OidData oidData)) { if (oidData != null) { data.Add(oidData); } } } } } return(data); }
/// <summary> /// Inserts the in devices via thread. /// </summary> /// <param name="param">The parameter.</param> private void InsertInDevicesViaThread(object param) { var obj = (object[])param; var ipAddress = (string)obj[0]; var aktiv = (string)obj[1]; try { var ident = DeviceTools.IdentDevice(ipAddress); var modell = ""; var serial = ""; var asset = ""; FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "EditDevices", "InsertDevicesViaThread " + ipAddress); var ip = IPAddress.Parse(ipAddress); ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(adjustProgress)); if (ident.Length > 0) { var dt = Config.GetInstance().GetOidRowByPrivateId(ident); ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(adjustProgress)); modell = SnmpClient.GetOidValue(ipAddress, dt.Rows[0].Field <string>("Model")); ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(adjustProgress)); serial = SnmpClient.GetOidValue(ipAddress, dt.Rows[0].Field <string>("SerialNumber")); ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(adjustProgress)); asset = SnmpClient.GetOidValue(ipAddress, dt.Rows[0].Field <string>("AssetNumber")); ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(adjustProgress)); } else { ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(adjustProgress)); ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(adjustProgress)); ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(adjustProgress)); ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(adjustProgress)); } Config.GetInstance().InsertInDeviceTable( aktiv, ip.GetAddressBytes(), modell, serial, asset ); } catch (SnmpIdentNotFoundException) { } DataGridDevices.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(LoadGridData)); }
private void RefreshVideoDevices() { this.VideoDevices.Clear(); foreach (var devcie in DeviceTools.GetVideoDevices()) { this.VideoDevices.Add(devcie); } this.SelectedVideoDevice = this.VideoDevices[0]; }
/// <summary> /// Searches for printer. /// </summary> /// <param name="state">The state.</param> private void SearchForPrinter(object state) { FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "SearchForDevices", "SearchForPrinter"); var fp = new FnPing(StartIpAddress, EndIpAddress); var pingResultsIps = fp.RangePing(); FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "SearchForDevices", "SearchForPrinter - pingResultsIps Success Count:" + pingResultsIps.SuccessIpAddresses.Count); foreach (var ipAddress in pingResultsIps.SuccessIpAddresses) { try { var ident = DeviceTools.IdentDevice(ipAddress.ToString()); var modell = ""; var serial = ""; var asset = ""; if (ident.Length > 0) { if (Config.GetInstance().Query( "Select * from Devices where IP='" + ipAddress.ToString() + "';").Rows.Count > 0) { var dts = Config.GetInstance().GetOidRowByPrivateId(ident); modell = SnmpClient.GetOidValue(ipAddress.ToString(), dts.Rows[0].Field <string>("Model")); serial = SnmpClient.GetOidValue(ipAddress.ToString(), dts.Rows[0].Field <string>("SerialNumber")); asset = SnmpClient.GetOidValue(ipAddress.ToString(), dts.Rows[0].Field <string>("AssetNumber")); Config.GetInstance().UpdateDeviceTable( "1", ipAddress.GetAddressBytes(), modell, serial, asset, ipAddress.GetAddressBytes() ); FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "SearchForDevices", "SearchForPrinter Found: " + ipAddress.ToString() + " Type: " + ident); } else { var dts = Config.GetInstance().GetOidRowByPrivateId(ident); if (dts.Rows.Count > 0) { modell = SnmpClient.GetOidValue(ipAddress.ToString(), dts.Rows[0].Field <string>("Model")); serial = SnmpClient.GetOidValue(ipAddress.ToString(), dts.Rows[0].Field <string>("SerialNumber")); asset = SnmpClient.GetOidValue(ipAddress.ToString(), dts.Rows[0].Field <string>("AssetNumber")); Config.GetInstance().Query("Delete from Devices where IP = '" + ipAddress.ToString() + "'; "); Config.GetInstance().InsertInDeviceTable( "1", ipAddress.GetAddressBytes(), modell, serial, asset ); } } } } catch (SnmpIdentNotFoundException) { } } DataGridDevices.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(LoadGridData)); ButtonSearch.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(ShowStartButton)); }