// Token: 0x06000620 RID: 1568 RVA: 0x00024D7C File Offset: 0x00022F7C
 public void DeleteHiddenOrionDiscoveryProfilesByName(string profileName)
 {
     DiscoveryLogic.log.DebugFormat("Deleting hidden profile '{0}'", profileName);
     foreach (DiscoveryProfileEntry profile in from x in DiscoveryProfileEntry.GetProfilesByName(profileName)
              where x.IsHidden
              select x)
     {
         this.DeleteDiscoveryProfileInternal(profile);
     }
 }
Exemplo n.º 2
0
        public void DeleteOrionDiscoveryProfile(int profileID)
        {
            DiscoveryLogic.log.DebugFormat("Deleting profile {0}", (object)profileID);
            DiscoveryProfileEntry profileById = DiscoveryProfileEntry.GetProfileByID(profileID);

            if (profileById == null)
            {
                throw new ArgumentNullException(string.Format("Profile {0} not found.", (object)profileID));
            }
            this.DeleteDiscoveryProfileInternal(profileById);
        }
Exemplo n.º 3
0
 private void DeleteDiscoveryProfileInternal(DiscoveryProfileEntry profile)
 {
     if (profile.get_JobID() != Guid.Empty)
     {
         DiscoveryLogic.log.DebugFormat("Deleting job for profile {0}", (object)profile.get_ProfileID());
         try
         {
             if (this.JobFactory.DeleteJob(profile.get_JobID()))
             {
                 DiscoveryLogic.log.ErrorFormat("Error when deleting job {0}.", (object)profile.get_ProfileID());
             }
             DiscoveryLogic.log.DebugFormat("Job for profile {0} deleted.", (object)profile.get_ProfileID());
         }
         catch (Exception ex)
         {
             DiscoveryLogic.log.ErrorFormat("Exception when deleting job {0}. Exception: {1}", (object)profile.get_ProfileID(), (object)ex);
         }
     }
     DiscoveryLogic.log.DebugFormat("Removing profile {0} from database.", (object)profile.get_ProfileID());
     DiscoveryDatabase.DeleteProfile(profile);
     DiscoveryLogic.log.DebugFormat("Profile {0} removed from database.", (object)profile.get_ProfileID());
 }
Exemplo n.º 4
0
        public static DiscoveryResultBase GetDiscoveryResult(
            int profileId,
            IList <IDiscoveryPlugin> discoveryPlugins)
        {
            if (discoveryPlugins == null)
            {
                throw new ArgumentNullException(nameof(discoveryPlugins));
            }
            if (profileId <= 0)
            {
                throw new ArgumentException(string.Format("Invalid profile ID [{0}]", (object)profileId));
            }
            DiscoveryResultBase discoveryResultBase = new DiscoveryResultBase();

            try
            {
                DiscoveryProfileEntry profileById = DiscoveryProfileEntry.GetProfileByID(profileId);
                discoveryResultBase.set_EngineId(profileById.get_EngineID());
                discoveryResultBase.set_ProfileID(profileById.get_ProfileID());
            }
            catch (Exception ex)
            {
                string message = string.Format("Unable to load profile {0}", (object)profileId);
                DiscoveryResultManager.log.Error((object)message, ex);
                throw new Exception(message, ex);
            }
            if (((ICollection <IDiscoveryPlugin>)discoveryPlugins).Count == 0)
            {
                return(discoveryResultBase);
            }
            int  millisecondsTimeout = 300000;
            bool flag = Environment.StackTrace.Contains("ServiceModel");

            if (flag)
            {
                try
                {
                    System.Configuration.Configuration configuration = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.Load(configuration.FilePath);
                    XmlNode xmlNode = xmlDocument.SelectSingleNode("/configuration/system.serviceModel/bindings/netTcpBinding/binding[@name=\"Core.NetTcpBinding\"]");
                    if (xmlNode != null)
                    {
                        if (xmlNode.Attributes != null)
                        {
                            millisecondsTimeout = (int)TimeSpan.Parse(xmlNode.Attributes["receiveTimeout"].Value).TotalMilliseconds;
                        }
                    }
                }
                catch (Exception ex)
                {
                    DiscoveryResultManager.log.Warn((object)"Unable to read WCF timeout from Config file.");
                }
            }
            Thread thread = new Thread(new ParameterizedThreadStart(DiscoveryResultManager.LoadResults));

            DiscoveryResultManager.LoadResultsArgs loadResultsArgs = new DiscoveryResultManager.LoadResultsArgs()
            {
                discoveryPlugins = discoveryPlugins,
                profileId        = profileId,
                result           = discoveryResultBase
            };
            thread.Start((object)loadResultsArgs);
            if (flag)
            {
                if (!thread.Join(millisecondsTimeout))
                {
                    DiscoveryResultManager.log.Error((object)"Loading results takes more time than WCF timeout is set. Enable debug logging to see which plugin takes too long.");
                    return(discoveryResultBase);
                }
            }
            else
            {
                thread.Join();
            }
            DiscoveryResultBase result = loadResultsArgs.result;

            DiscoveryFilterResultByTechnology.FilterByPriority(result, TechnologyManager.Instance);
            Stopwatch stopwatch = Stopwatch.StartNew();
            List <DiscoveryPluginResultBase> list = ((IEnumerable <DiscoveryPluginResultBase>)result.get_PluginResults()).ToList <DiscoveryPluginResultBase>();

            result.get_PluginResults().Clear();
            using (List <DiscoveryPluginResultBase> .Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    DiscoveryPluginResultBase current = enumerator.Current;
                    result.get_PluginResults().Add(current.GetFilteredPluginResult());
                }
            }
            DiscoveryResultManager.log.DebugFormat("Filtering results took {0} milliseconds.", (object)stopwatch.ElapsedMilliseconds);
            GC.Collect();
            return(result);
        }
Exemplo n.º 5
0
 public void DeleteHiddenOrionDiscoveryProfilesByName(string profileName)
 {
     DiscoveryLogic.log.DebugFormat("Deleting hidden profile '{0}'", (object)profileName);
     using (IEnumerator <DiscoveryProfileEntry> enumerator = ((IEnumerable <DiscoveryProfileEntry>)DiscoveryProfileEntry.GetProfilesByName(profileName)).Where <DiscoveryProfileEntry>((Func <DiscoveryProfileEntry, bool>)(x => x.get_IsHidden())).GetEnumerator())
     {
         while (((IEnumerator)enumerator).MoveNext())
         {
             this.DeleteDiscoveryProfileInternal(enumerator.Current);
         }
     }
 }
Exemplo n.º 6
0
        public void ImportDiscoveryResultsForConfiguration(
            DiscoveryImportConfiguration importCfg,
            Guid importID)
        {
            DiscoveryLogic.log.DebugFormat("Loading discovery results.", Array.Empty <object>());
            if (DiscoveryProfileEntry.GetProfileByID(importCfg.get_ProfileID()) == null)
            {
                throw new Exception(string.Format("Requested profile {0} not found.", (object)importCfg.get_ProfileID()));
            }
            DiscoveryImportManager.UpdateProgress(importID, "ImportDiscoveryResults Started", "Loading Plugins", false);
            IList <IDiscoveryPlugin> discoveryPlugins = DiscoveryHelper.GetOrderedDiscoveryPlugins();
            SortedDictionary <int, List <IDiscoveryPlugin> > orderedPlugins = DiscoveryPluginHelper.GetOrderedPlugins(discoveryPlugins, (IList <DiscoveryPluginInfo>)DiscoveryHelper.GetDiscoveryPluginInfos());
            DiscoveryResultBase discoveryResult = DiscoveryResultManager.GetDiscoveryResult(importCfg.get_ProfileID(), discoveryPlugins);
            DiscoveryResultBase result1;

            if (importCfg.get_NodeIDs().Count > 0)
            {
                DiscoveryLogic.log.DebugFormat("Nodes to be imported : {0}", (object)importCfg.get_NodeIDs().Count);
                using (List <DiscoveredNode> .Enumerator enumerator = ((CoreDiscoveryPluginResult)discoveryResult.GetPluginResultOfType <CoreDiscoveryPluginResult>()).get_DiscoveredNodes().GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        DiscoveredNode current = enumerator.Current;
                        if (importCfg.get_NodeIDs().Contains(current.get_NodeID()))
                        {
                            ((DiscoveredObjectBase)current).set_IsSelected(true);
                        }
                        else
                        {
                            ((DiscoveredObjectBase)current).set_IsSelected(false);
                        }
                    }
                }
                using (List <DiscoveryPluginResultBase> .Enumerator enumerator = this.Linearize((IEnumerable <DiscoveryPluginResultBase>)discoveryResult.get_PluginResults()).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        DiscoveryPluginResultBase current          = enumerator.Current;
                        DiscoveryPluginResultBase pluginResultBase = !(current is IDiscoveryPluginResultContextFiltering contextFiltering) ? current.GetFilteredPluginResult() : contextFiltering.GetFilteredPluginResultFromContext(discoveryResult);
                        discoveryResult.get_PluginResults().Remove(current);
                        discoveryResult.get_PluginResults().Add(pluginResultBase);
                        DiscoveryLogic.log.DebugFormat("Applying filters for pluggin - {0}.", (object)current.get_PluginTypeName());
                    }
                }
                result1 = this.FilterIgnoredItems(discoveryResult);
            }
            else
            {
                result1 = discoveryResult;
            }
            result1.set_ProfileID(importCfg.get_ProfileID());
            DiscoveryLogic.log.DebugFormat("Importing started.", Array.Empty <object>());
            if (importCfg.get_DeleteProfileAfterImport())
            {
                DiscoveryImportManager.StartImport(importID, result1, orderedPlugins, false, (DiscoveryImportManager.CallbackDiscoveryImportFinished)((result, importId, importStatus) => this.DeleteOrionDiscoveryProfile(result.get_ProfileID())));
            }
            else
            {
                DiscoveryImportManager.StartImport(importID, result1, orderedPlugins);
            }
        }
        // Token: 0x06000624 RID: 1572 RVA: 0x00024FD4 File Offset: 0x000231D4
        public void ImportDiscoveryResultsForConfiguration(DiscoveryImportConfiguration importCfg, Guid importID)
        {
            DiscoveryLogic.log.DebugFormat("Loading discovery results.", Array.Empty <object>());
            if (DiscoveryProfileEntry.GetProfileByID(importCfg.ProfileID) == null)
            {
                throw new Exception(string.Format("Requested profile {0} not found.", importCfg.ProfileID));
            }
            DiscoveryImportManager.UpdateProgress(importID, "ImportDiscoveryResults Started", "Loading Plugins", false);
            IList <IDiscoveryPlugin> orderedDiscoveryPlugins = DiscoveryHelper.GetOrderedDiscoveryPlugins();
            SortedDictionary <int, List <IDiscoveryPlugin> > orderedPlugins = DiscoveryPluginHelper.GetOrderedPlugins(orderedDiscoveryPlugins, DiscoveryHelper.GetDiscoveryPluginInfos());
            DiscoveryResultBase discoveryResult = DiscoveryResultManager.GetDiscoveryResult(importCfg.ProfileID, orderedDiscoveryPlugins);
            DiscoveryResultBase discoveryResultBase;

            if (importCfg.NodeIDs.Count > 0)
            {
                DiscoveryLogic.log.DebugFormat("Nodes to be imported : {0}", importCfg.NodeIDs.Count);
                foreach (DiscoveredNode discoveredNode in discoveryResult.GetPluginResultOfType <CoreDiscoveryPluginResult>().DiscoveredNodes)
                {
                    if (importCfg.NodeIDs.Contains(discoveredNode.NodeID))
                    {
                        discoveredNode.IsSelected = true;
                    }
                    else
                    {
                        discoveredNode.IsSelected = false;
                    }
                }
                foreach (DiscoveryPluginResultBase discoveryPluginResultBase in this.Linearize(discoveryResult.PluginResults))
                {
                    IDiscoveryPluginResultContextFiltering discoveryPluginResultContextFiltering = discoveryPluginResultBase as IDiscoveryPluginResultContextFiltering;
                    DiscoveryPluginResultBase discoveryPluginResultBase2;
                    if (discoveryPluginResultContextFiltering != null)
                    {
                        discoveryPluginResultBase2 = discoveryPluginResultContextFiltering.GetFilteredPluginResultFromContext(discoveryResult);
                    }
                    else
                    {
                        discoveryPluginResultBase2 = discoveryPluginResultBase.GetFilteredPluginResult();
                    }
                    discoveryResult.PluginResults.Remove(discoveryPluginResultBase);
                    discoveryResult.PluginResults.Add(discoveryPluginResultBase2);
                    DiscoveryLogic.log.DebugFormat("Applying filters for pluggin - {0}.", discoveryPluginResultBase.PluginTypeName);
                }
                discoveryResultBase = this.FilterIgnoredItems(discoveryResult);
            }
            else
            {
                discoveryResultBase = discoveryResult;
            }
            discoveryResultBase.ProfileID = importCfg.ProfileID;
            DiscoveryLogic.log.DebugFormat("Importing started.", Array.Empty <object>());
            if (importCfg.DeleteProfileAfterImport)
            {
                DiscoveryImportManager.StartImport(importID, discoveryResultBase, orderedPlugins, false, delegate(DiscoveryResultBase result, Guid importId, StartImportStatus importStatus)
                {
                    this.DeleteOrionDiscoveryProfile(result.ProfileID);
                });
                return;
            }
            DiscoveryImportManager.StartImport(importID, discoveryResultBase, orderedPlugins);
        }