예제 #1
0
        private void worker_QueryInfo(object sender, DoWorkEventArgs e)
        {
            try {
                Ping      ping      = new Ping();
                PingReply pingReply = null;

                try {
                    pingReply = ping.Send((string)e.Argument, 1000);
                }
                catch (PingException pingException) {
                    Console.WriteLine("Error! Bad hostname: " + (string)e.Argument + ". Skipping...");
                    ping.Dispose();
                    return;
                }

                if (pingReply.Status != IPStatus.Success)
                {
                    ping.Dispose();
                    return;
                }
                ping.Dispose();

                InfoGetter infoGetter = new InfoGetter();
                infoGetter.USBIDSPath = globalArgs.usbIDSPath;
                if (!infoGetter.connectionTest((string)e.Argument))
                {
                    Console.WriteLine("WMI/CIM query failed on " + (string)e.Argument + ". Skipping...");
                    return;
                }

                if (!infoGetter.registryTest((string)e.Argument))
                {
                    Console.WriteLine("Registry query failed on " + (string)e.Argument + ". Skipping...");
                    return;
                }

                string computer = (string)e.Argument;

                ComputerInfo       computerInfo = infoGetter.GetComputerInfo(computer);
                List <MonitorInfo> monitorInfos = infoGetter.GetMonitorInfo(computer);
                monitorInfos = infoGetter.FilterMonitorInfo(monitorInfos, globalArgs);
                List <DeviceInfo> deviceInfos = infoGetter.GetDeviceInfoRegistry(computer);
                deviceInfos = infoGetter.FilterDeviceInfo(deviceInfos, globalArgs);

                List <CSVInfo> returnInfo = writer.IngestData(computerInfo, monitorInfos, deviceInfos);
                e.Result = returnInfo;
            }
            catch {
                Console.WriteLine("Unknown unhandled error querying " + e.Argument + ". Aborting...");
                e.Result = null;
            }
        }
예제 #2
0
        private List <MonitorInfo> DisplayMonitorInfo(List <MonitorInfo> info)
        {
            MonitorInfoStackPanel.Children.Clear();

            List <MonitorInfo> monitorInfoListModified = infoGetter.FilterMonitorInfo(info, globalArgs);

            int monitorCount = 1;

            foreach (MonitorInfo monitor in monitorInfoListModified)
            {
                MonitorInfoUserControl monitorInfo = new MonitorInfoUserControl(monitor);
                monitorInfo.Title = "Monitor " + monitorCount;
                monitorCount++;
                MonitorInfoStackPanel.Children.Add(monitorInfo);
            }

            return(monitorInfoListModified);
        }