public void RunSNMPNetworkDiscovery()
 {
     if (discoverer == null || discoverer.IsDiscoverComplete)
     {
         SNMPDiscovery snmpDiscovery = new SNMPDiscovery(Utility.GetSNMPIpRanges());
         FireNetworkDiscoveryStarted();
         BeginThreadedNetworkDiscovery(snmpDiscovery);
     }
     else
     {
         MessageBox.Show("There is another Network Discovery in progress. Please wait until Network Discovery is complete before starting another.", "Network Discovery", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
示例#2
0
        private void ReauditAssets()
        {
            System.Collections.Specialized.NameValueCollection ipRanges = new System.Collections.Specialized.NameValueCollection();

            foreach (Asset asset in GetSelectedAssets())
            {
                if (asset.IPAddress != String.Empty)
                {
                    ipRanges.Add(asset.IPAddress, asset.IPAddress);
                }
            }

            SNMPDiscovery discoverer = new SNMPDiscovery(ipRanges);

            discoverer.Start();

            // Yes - we need to check whether or not the current scanner is configured to upload audits to an FTP
            // site as in this case we need to create audit files for any assets discovered
            AuditScannerDefinition auditScannerDefinition = null;

            try
            {
                string scannerPath = Path.Combine(Application.StartupPath, "scanners") + "\\default.xml";
                auditScannerDefinition = AuditWizardSerialization.DeserializeObject(scannerPath);
            }
            catch (Exception)
            {
            }


            // 8.3.4 - CMD
            //
            // If we found a scanner and it defines an FTP upload of audit files then process this
            // Note that we support either Upload to FTP Location or Audit to FTP which are flagged differently in the scanner
            if ((auditScannerDefinition != null) &&
                (auditScannerDefinition.FTPCopyToNetwork || auditScannerDefinition.UploadSetting == AuditScannerDefinition.eUploadSetting.ftp))
            {
                discoverer.UploadDiscoveredAssets(auditScannerDefinition);
            }
        }
        private void RunThreadedNetworkDiscovery()
        {
            if (discoverer.CanRunInOwnThread)
            {
                // start the discovery
                NetworkDiscoveryTabView tabView = workItem.Items[Properties.Settings.Default.NetworkDiscoveryTabView] as NetworkDiscoveryTabView;
                if (tabView != null)
                {
                    tabView.ShowStart();
                }
                discoverer.Start();

                if (runBothDiscovery)
                {
                    SNMPDiscovery snmpDiscovery = new SNMPDiscovery(Utility.GetSNMPIpRanges());
                    discoverer = snmpDiscovery;

                    //tabView.ShowStart();
                    discoverer.Start();
                }

                // discover has completed...update subscribers and TabView
                if (tabView != null)
                {
                    tabView.ShowComplete();
                }

                // +8.3.3
                // Did we complete an SNMP Discovery?
                if (discoverer is SNMPDiscovery)
                {
                    // Yes - we need to check whether or not the current scanner is configured to upload audits to an FTP
                    // site as in this case we need to create audit files for any assets discovered
                    AuditScannerDefinition auditScannerDefinition = null;
                    try
                    {
                        string scannerPath = Path.Combine(Application.StartupPath, "scanners") + "\\default.xml";
                        auditScannerDefinition = AuditWizardSerialization.DeserializeObject(scannerPath);
                    }
                    catch (Exception)
                    {
                    }

                    // 8.3.4 - CMD
                    //
                    // If we found a scanner and it defines an FTP upload of audit files then process this
                    // Note that we support either Upload to FTP Location or Audit to FTP which are flagged differently in the scanner
                    if ((auditScannerDefinition != null) &&
                        (auditScannerDefinition.FTPCopyToNetwork || auditScannerDefinition.UploadSetting == AuditScannerDefinition.eUploadSetting.ftp))
                    {
                        ((SNMPDiscovery)discoverer).UploadDiscoveredAssets(auditScannerDefinition);
                    }
                }

                // -8.3.3
                FireNetworkDiscoveryComplete(discoverer.ComputerList);
                discoveryThread = new Thread(new ThreadStart(RunThreadedNetworkDiscovery));
                discoverer.NetworkDiscoveryUpdate -= discoverer_NetworkDiscoveryUpdate;
                discoverer = null;
            }
        }