Exemple #1
0
        public List <ScanResult> GetResults()
        {
            Logging.Verbose("[" + workerID + "] Hostcount: " + hostsList.Count);
            foreach (var host in hostsList)
            {
                var pingReply = PingHost(host);

                // Errors during ping method returns a null, check for that first.
                if (pingReply != null)
                {
                    var pingResult = host + " - " + pingReply.Address.ToString() + " - " + pingReply.Status.ToString();
                    Logging.Verbose("[" + workerID + "] Result: " + pingResult);

                    // Add only successful pings to the reply list.
                    if (pingReply.Status == IPStatus.Success)
                    {
                        // Get the device GUID from the hostname.
                        var deviceGUID = DBFunctions.DeviceGUID(host);

                        // Make sure a GUID was found.
                        if (!string.IsNullOrEmpty(deviceGUID))
                        {
                            pingResults.Add(new ScanResult(deviceGUID, pingReply.Address.ToString(), true, host));
                        }
                    }
                }
            }
            Logging.Verbose("[" + workerID + "]  ##### DONE. Results: " + pingResults.Count);
            return(pingResults);
        }