예제 #1
0
 private DiscoveryResultBase FilterItems(
     DiscoveryResultBase discoveryResult,
     Func <IDiscoveryPlugin, DiscoveryResultBase, DiscoveryPluginResultBase> filterFunction)
 {
     using (IEnumerator <IDiscoveryPlugin> enumerator1 = ((IEnumerable <IDiscoveryPlugin>)DiscoveryHelper.GetOrderedDiscoveryPlugins()).GetEnumerator())
     {
         while (((IEnumerator)enumerator1).MoveNext())
         {
             IDiscoveryPlugin          current1         = enumerator1.Current;
             DiscoveryPluginResultBase pluginResultBase = filterFunction(current1, discoveryResult);
             if (pluginResultBase != null)
             {
                 pluginResultBase.set_PluginTypeName(((object)current1).GetType().FullName);
                 Type returnedType = ((object)pluginResultBase).GetType();
                 List <DiscoveryPluginResultBase> list = ((IEnumerable <DiscoveryPluginResultBase>)discoveryResult.get_PluginResults()).Where <DiscoveryPluginResultBase>((Func <DiscoveryPluginResultBase, bool>)(item => ((object)item).GetType() != returnedType)).ToList <DiscoveryPluginResultBase>();
                 discoveryResult.get_PluginResults().Clear();
                 discoveryResult.get_PluginResults().Add(pluginResultBase);
                 using (List <DiscoveryPluginResultBase> .Enumerator enumerator2 = list.GetEnumerator())
                 {
                     while (enumerator2.MoveNext())
                     {
                         DiscoveryPluginResultBase current2 = enumerator2.Current;
                         discoveryResult.get_PluginResults().Add(current2);
                     }
                 }
             }
         }
     }
     return(discoveryResult);
 }
        // Token: 0x06000622 RID: 1570 RVA: 0x00024EF0 File Offset: 0x000230F0
        public void ImportDiscoveryResultForProfile(int profileID, bool deleteProfileAfterImport, DiscoveryImportManager.CallbackDiscoveryImportFinished callback = null, bool checkLicenseLimits = false, Guid?importID = null)
        {
            IList <IDiscoveryPlugin> orderedDiscoveryPlugins = DiscoveryHelper.GetOrderedDiscoveryPlugins();
            SortedDictionary <int, List <IDiscoveryPlugin> > orderedPlugins = DiscoveryPluginHelper.GetOrderedPlugins(orderedDiscoveryPlugins, DiscoveryHelper.GetDiscoveryPluginInfos());
            DiscoveryResultBase discoveryResult = DiscoveryResultManager.GetDiscoveryResult(profileID, orderedDiscoveryPlugins);
            DiscoveryResultBase result2         = this.FilterIgnoredItems(discoveryResult);
            Guid importId = Guid.NewGuid();

            if (importID != null)
            {
                importId = importID.Value;
            }
            DiscoveryImportManager.CallbackDiscoveryImportFinished callbackAfterImport = callback;
            if (deleteProfileAfterImport)
            {
                callbackAfterImport = delegate(DiscoveryResultBase result, Guid id, StartImportStatus status)
                {
                    this.DeleteOrionDiscoveryProfile(result.ProfileID);
                    if (callback != null)
                    {
                        callback(result, id, status);
                    }
                };
            }
            DiscoveryImportManager.StartImport(importId, result2, orderedPlugins, checkLicenseLimits, callbackAfterImport);
        }
예제 #3
0
        public void ImportDiscoveryResultForProfile(
            int profileID,
            bool deleteProfileAfterImport,
            DiscoveryImportManager.CallbackDiscoveryImportFinished callback = null,
            bool checkLicenseLimits = false,
            Guid?importID           = null)
        {
            IList <IDiscoveryPlugin> discoveryPlugins = DiscoveryHelper.GetOrderedDiscoveryPlugins();
            SortedDictionary <int, List <IDiscoveryPlugin> > orderedPlugins = DiscoveryPluginHelper.GetOrderedPlugins(discoveryPlugins, (IList <DiscoveryPluginInfo>)DiscoveryHelper.GetDiscoveryPluginInfos());
            DiscoveryResultBase result1 = this.FilterIgnoredItems(DiscoveryResultManager.GetDiscoveryResult(profileID, discoveryPlugins));
            Guid importId = Guid.NewGuid();

            if (importID.HasValue)
            {
                importId = importID.Value;
            }
            DiscoveryImportManager.CallbackDiscoveryImportFinished callbackAfterImport = callback;
            if (deleteProfileAfterImport)
            {
                callbackAfterImport = (DiscoveryImportManager.CallbackDiscoveryImportFinished)((result, id, status) =>
                {
                    this.DeleteOrionDiscoveryProfile(result.get_ProfileID());
                    if (callback == null)
                    {
                        return;
                    }
                    callback(result, id, status);
                });
            }
            DiscoveryImportManager.StartImport(importId, result1, orderedPlugins, checkLicenseLimits, callbackAfterImport);
        }
예제 #4
0
        public static List <ElementLicenseInfo> GetLicensedStatus(
            DiscoveryResultBase discoveryResult)
        {
            if (discoveryResult == null)
            {
                throw new ArgumentNullException(nameof(discoveryResult));
            }
            List <ElementLicenseInfo> elementLicenseInfoList1 = new List <ElementLicenseInfo>();
            IFeatureManager           ifeatureManager         = (IFeatureManager) new FeatureManager();
            Dictionary <string, int>  dictionary           = new Dictionary <string, int>();
            Dictionary <string, int>  elementsManagedCount = LicenseSaturationLogic.GetElementsManagedCount();

            foreach (string key in elementsManagedCount.Keys)
            {
                dictionary[key] = ifeatureManager.GetMaxElementCount(key);
            }
            using (IEnumerator <DiscoveryPluginResultBase> enumerator = discoveryResult.get_PluginResults().GetEnumerator())
            {
                while (((IEnumerator)enumerator).MoveNext())
                {
                    List <ElementLicenseInfo> elementLicenseInfoList2;
                    if (!enumerator.Current.CheckLicensingStatusForImport(elementsManagedCount, dictionary, ref elementLicenseInfoList2))
                    {
                        elementLicenseInfoList1.AddRange((IEnumerable <ElementLicenseInfo>)elementLicenseInfoList2);
                    }
                }
            }
            return(elementLicenseInfoList1);
        }
예제 #5
0
 public static StartImportStatus StartImport(
     Guid importId,
     DiscoveryResultBase result,
     SortedDictionary <int, List <IDiscoveryPlugin> > importingPlugins)
 {
     return(DiscoveryImportManager.StartImport(importId, result, importingPlugins, false, (DiscoveryImportManager.CallbackDiscoveryImportFinished)null));
 }
        // Token: 0x06000666 RID: 1638 RVA: 0x00026794 File Offset: 0x00024994
        public static void Show(DiscoveryResultBase result, StartImportStatus status)
        {
            DiscoveryAutoImportNotificationItemDAL item = DiscoveryAutoImportNotificationItemDAL.GetItem();
            string description = string.Format(CultureInfo.InvariantCulture, "DiscoveryImportStatus:{0}", status);
            string title       = string.Empty;

            switch (status)
            {
            case StartImportStatus.Failed:
                title = Resources2.Notification_DiscoveryAutoImport_Failed;
                break;

            case StartImportStatus.LicenseExceeded:
                title = Resources2.Notification_DiscoveryAutoImport_LicenseExceeded;
                break;

            case StartImportStatus.Finished:
                title = Resources2.Notification_DiscoveryAutoImport_Succeeded;
                break;

            default:
                return;
            }
            if (item == null)
            {
                NotificationItemDAL.Insert(DiscoveryAutoImportNotificationItemDAL.DiscoveryAutoImportNotificationItemId, DiscoveryAutoImportNotificationItemDAL.DiscoveryAutoImportNotificationTypeGuid, title, description, false, DiscoveryAutoImportNotificationItemDAL.NetworkSonarDiscoveryURL, null, null);
                return;
            }
            item.SetNotAcknowledged();
            item.Title       = title;
            item.Description = description;
            item.Update();
        }
        // Token: 0x060002B1 RID: 689 RVA: 0x00010D88 File Offset: 0x0000EF88
        internal static void FillDiscoveryLogEntity(DiscoveryLogs discoveryLog, DiscoveryResultBase result, StartImportStatus status)
        {
            DateTime utcNow = DateTime.UtcNow;

            discoveryLog.FinishedTimeStamp = utcNow.AddTicks(-(utcNow.Ticks % 10000000L));
            discoveryLog.BatchID           = new Guid?(result.BatchID);
            discoveryLog.ProfileID         = result.ProfileID;
            switch (status)
            {
            case StartImportStatus.Failed:
                discoveryLog.Result            = 3;
                discoveryLog.ResultDescription = Resources2.DiscoveryLogResult_ImportFailed;
                discoveryLog.ErrorMessage      = Resources2.DiscoveryLogError_UnknownError;
                return;

            case StartImportStatus.LicenseExceeded:
                discoveryLog.Result            = 4;
                discoveryLog.ResultDescription = Resources2.DiscoveryLogResult_ImportFailedLicenseExceeded;
                return;

            case StartImportStatus.Finished:
                discoveryLog.Result            = 2;
                discoveryLog.ResultDescription = Resources2.DiscoveryLogResult_ImportFinished;
                return;

            default:
                return;
            }
        }
        // Token: 0x060002AF RID: 687 RVA: 0x00010BD4 File Offset: 0x0000EDD4
        public static List <ElementLicenseInfo> GetLicensedStatus(DiscoveryResultBase discoveryResult)
        {
            if (discoveryResult == null)
            {
                throw new ArgumentNullException("discoveryResult");
            }
            List <ElementLicenseInfo> list                 = new List <ElementLicenseInfo>();
            IFeatureManager           featureManager       = new FeatureManager();
            Dictionary <string, int>  dictionary           = new Dictionary <string, int>();
            Dictionary <string, int>  elementsManagedCount = LicenseSaturationLogic.GetElementsManagedCount();

            foreach (string text in elementsManagedCount.Keys)
            {
                dictionary[text] = featureManager.GetMaxElementCount(text);
            }
            using (IEnumerator <DiscoveryPluginResultBase> enumerator2 = discoveryResult.PluginResults.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    List <ElementLicenseInfo> collection;
                    if (!enumerator2.Current.CheckLicensingStatusForImport(elementsManagedCount, dictionary, ref collection))
                    {
                        list.AddRange(collection);
                    }
                }
            }
            return(list);
        }
예제 #9
0
        internal static void FillDiscoveryLogEntity(
            DiscoveryLogs discoveryLog,
            DiscoveryResultBase result,
            StartImportStatus status)
        {
            DateTime utcNow = DateTime.UtcNow;

            discoveryLog.set_FinishedTimeStamp(utcNow.AddTicks(-(utcNow.Ticks % 10000000L)));
            discoveryLog.set_BatchID(new Guid?(result.get_BatchID()));
            discoveryLog.set_ProfileID(result.get_ProfileID());
            switch (status - 4)
            {
            case 0:
                discoveryLog.set_Result(3);
                discoveryLog.set_ResultDescription(Resources2.get_DiscoveryLogResult_ImportFailed());
                discoveryLog.set_ErrorMessage(Resources2.get_DiscoveryLogError_UnknownError());
                break;

            case 1:
                discoveryLog.set_Result(4);
                discoveryLog.set_ResultDescription(Resources2.get_DiscoveryLogResult_ImportFailedLicenseExceeded());
                break;

            case 2:
                discoveryLog.set_Result(2);
                discoveryLog.set_ResultDescription(Resources2.get_DiscoveryLogResult_ImportFinished());
                break;
            }
        }
예제 #10
0
        private static void XmlSerializer(DiscoveryResultBase data)
        {
            Type type = typeof(DiscoveryResultBase);

            using (FileStream fileStream = new FileStream(DiscoveryResultManager.GetFilename(type), FileMode.Create))
            {
                new DataContractSerializer(type).WriteObject(XmlDictionaryWriter.CreateTextWriter((Stream)fileStream), (object)data);
                fileStream.Flush();
                fileStream.Close();
            }
        }
예제 #11
0
        public DiscoveryResultBase FilterIgnoredItems(
            DiscoveryResultBase discoveryResult)
        {
            DiscoveryResultBase    discoveryResult1 = this.FilterItems(discoveryResult, (Func <IDiscoveryPlugin, DiscoveryResultBase, DiscoveryPluginResultBase>)((plugin, result) => plugin.FilterOutItemsFromIgnoreList(result)));
            DiscoveryConfiguration config           = DiscoveryDatabase.GetDiscoveryConfiguration(((DiscoveryPluginResultBase)discoveryResult.GetPluginResultOfType <CoreDiscoveryPluginResult>()).get_ProfileId() ?? 0);

            if (config != null && config.get_IsAutoImport())
            {
                discoveryResult1 = this.FilterItems(discoveryResult1, (Func <IDiscoveryPlugin, DiscoveryResultBase, DiscoveryPluginResultBase>)((plugin, result) => !(plugin is ISupportAutoImport) ? (DiscoveryPluginResultBase)null : ((ISupportAutoImport)plugin).FilterAutoImportItems(result, (DiscoveryConfigurationBase)config)));
            }
            return(discoveryResult1);
        }
        // Token: 0x060002C3 RID: 707 RVA: 0x00011648 File Offset: 0x0000F848
        private static void XmlSerializer(DiscoveryResultBase data)
        {
            Type typeFromHandle = typeof(DiscoveryResultBase);
            DataContractSerializer dataContractSerializer = new DataContractSerializer(typeFromHandle);

            using (FileStream fileStream = new FileStream(DiscoveryResultManager.GetFilename(typeFromHandle), FileMode.Create))
            {
                XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(fileStream);
                dataContractSerializer.WriteObject(writer, data);
                fileStream.Flush();
                fileStream.Close();
            }
        }
예제 #13
0
        private static void BinarySerializer(DiscoveryResultBase data)
        {
            FileStream      fileStream      = new FileStream(DiscoveryResultManager.GetFilename(typeof(DiscoveryResultBase)), FileMode.Create);
            BinaryFormatter binaryFormatter = new BinaryFormatter();

            try
            {
                binaryFormatter.Serialize((Stream)fileStream, (object)data);
            }
            finally
            {
                fileStream.Close();
            }
        }
 // Token: 0x060002BE RID: 702 RVA: 0x000111C4 File Offset: 0x0000F3C4
 internal static void UpdateRoutine(int profileID)
 {
     if (profileID <= 0)
     {
         throw new ArgumentException("Invalid ProfileID", "profileID");
     }
     using (LocaleThreadState.EnsurePrimaryLocale())
     {
         try
         {
             IEnumerable <IScheduledDiscoveryPlugin> enumerable = DiscoveryHelper.GetOrderedDiscoveryPlugins().OfType <IScheduledDiscoveryPlugin>();
             if (enumerable.Count <IScheduledDiscoveryPlugin>() > 0)
             {
                 DiscoveryResultBase discoveryResult = DiscoveryResultManager.GetDiscoveryResult(profileID, enumerable.Cast <IDiscoveryPlugin>().ToList <IDiscoveryPlugin>());
                 using (IEnumerator <IScheduledDiscoveryPlugin> enumerator = enumerable.GetEnumerator())
                 {
                     Action <string, double> < > 9__0;
                     while (enumerator.MoveNext())
                     {
                         IScheduledDiscoveryPlugin scheduledDiscoveryPlugin = enumerator.Current;
                         DiscoveryResultBase       discoveryResultBase      = discoveryResult;
                         Action <string, double>   action;
                         if ((action = < > 9__0) == null)
                         {
                             action = (< > 9__0 = delegate(string message, double phaseProgress)
                             {
                                 if (DiscoveryNetObjectStatusManager.log.IsInfoEnabled)
                                 {
                                     DiscoveryNetObjectStatusManager.log.InfoFormat("Updating Discovered Net Object Statuses for profile {0}: {1} - {2}", profileID, phaseProgress, message);
                                 }
                             });
                         }
                         scheduledDiscoveryPlugin.UpdateImportStatuses(discoveryResultBase, action);
                     }
                     goto IL_CC;
                 }
             }
             if (DiscoveryNetObjectStatusManager.log.IsInfoEnabled)
             {
                 DiscoveryNetObjectStatusManager.log.InfoFormat("Skipping Discovered Net Object Status update for profile {0}", profileID);
             }
             IL_CC :;
         }
         catch (Exception ex)
         {
             DiscoveryNetObjectStatusManager.log.Error(string.Format("Update Discovered Net Object Statuses for profile {0} failed", profileID), ex);
         }
     }
 }
        // Token: 0x0600061D RID: 1565 RVA: 0x00024BA8 File Offset: 0x00022DA8
        public DiscoveryResultBase FilterIgnoredItems(DiscoveryResultBase discoveryResult)
        {
            DiscoveryResultBase    discoveryResultBase = this.FilterItems(discoveryResult, (IDiscoveryPlugin plugin, DiscoveryResultBase result) => plugin.FilterOutItemsFromIgnoreList(result));
            DiscoveryConfiguration config = DiscoveryDatabase.GetDiscoveryConfiguration(discoveryResult.GetPluginResultOfType <CoreDiscoveryPluginResult>().ProfileId ?? 0);

            if (config != null && config.IsAutoImport)
            {
                discoveryResultBase = this.FilterItems(discoveryResultBase, delegate(IDiscoveryPlugin plugin, DiscoveryResultBase result)
                {
                    if (!(plugin is ISupportAutoImport))
                    {
                        return(null);
                    }
                    return(((ISupportAutoImport)plugin).FilterAutoImportItems(result, config));
                });
            }
            return(discoveryResultBase);
        }
예제 #16
0
 internal static void UpdateRoutine(int profileID)
 {
     if (profileID <= 0)
     {
         throw new ArgumentException("Invalid ProfileID", nameof(profileID));
     }
     using (LocaleThreadState.EnsurePrimaryLocale())
     {
         try
         {
             IEnumerable <IScheduledDiscoveryPlugin> source = ((IEnumerable)DiscoveryHelper.GetOrderedDiscoveryPlugins()).OfType <IScheduledDiscoveryPlugin>();
             if (source.Count <IScheduledDiscoveryPlugin>() > 0)
             {
                 DiscoveryResultBase discoveryResult = DiscoveryResultManager.GetDiscoveryResult(profileID, (IList <IDiscoveryPlugin>)((IEnumerable)source).Cast <IDiscoveryPlugin>().ToList <IDiscoveryPlugin>());
                 using (IEnumerator <IScheduledDiscoveryPlugin> enumerator = source.GetEnumerator())
                 {
                     while (((IEnumerator)enumerator).MoveNext())
                     {
                         enumerator.Current.UpdateImportStatuses(discoveryResult, (Action <string, double>)((message, phaseProgress) =>
                         {
                             if (!DiscoveryNetObjectStatusManager.log.get_IsInfoEnabled())
                             {
                                 return;
                             }
                             DiscoveryNetObjectStatusManager.log.InfoFormat("Updating Discovered Net Object Statuses for profile {0}: {1} - {2}", (object)profileID, (object)phaseProgress, (object)message);
                         }));
                     }
                 }
             }
             else
             {
                 if (!DiscoveryNetObjectStatusManager.log.get_IsInfoEnabled())
                 {
                     return;
                 }
                 DiscoveryNetObjectStatusManager.log.InfoFormat("Skipping Discovered Net Object Status update for profile {0}", (object)profileID);
             }
         }
         catch (Exception ex)
         {
             DiscoveryNetObjectStatusManager.log.Error((object)string.Format("Update Discovered Net Object Statuses for profile {0} failed", (object)profileID), ex);
         }
     }
 }
 // Token: 0x060002AD RID: 685 RVA: 0x000107E4 File Offset: 0x0000E9E4
 internal static StartImportStatus StartImport(Guid importId, DiscoveryResultBase result, SortedDictionary <int, List <IDiscoveryPlugin> > importingPlugins, bool checkLicenseLimits, DiscoveryImportManager.CallbackDiscoveryImportFinished callbackAfterImport)
 {
     if (result == null)
     {
         throw new ArgumentNullException("result");
     }
     ThreadPool.QueueUserWorkItem(delegate(object state)
     {
         try
         {
             DiscoveryImportManager.StartImportInternal(importId, result, importingPlugins, checkLicenseLimits, callbackAfterImport);
         }
         catch (Exception ex)
         {
             DiscoveryImportManager.log.Error("Error in StartImport", ex);
         }
     });
     return(StartImportStatus.Started);
 }
 // Token: 0x0600061E RID: 1566 RVA: 0x00024C38 File Offset: 0x00022E38
 private DiscoveryResultBase FilterItems(DiscoveryResultBase discoveryResult, Func <IDiscoveryPlugin, DiscoveryResultBase, DiscoveryPluginResultBase> filterFunction)
 {
     foreach (IDiscoveryPlugin discoveryPlugin in DiscoveryHelper.GetOrderedDiscoveryPlugins())
     {
         DiscoveryPluginResultBase discoveryPluginResultBase = filterFunction(discoveryPlugin, discoveryResult);
         if (discoveryPluginResultBase != null)
         {
             discoveryPluginResultBase.PluginTypeName = discoveryPlugin.GetType().FullName;
             Type returnedType = discoveryPluginResultBase.GetType();
             List <DiscoveryPluginResultBase> list = (from item in discoveryResult.PluginResults
                                                      where item.GetType() != returnedType
                                                      select item).ToList <DiscoveryPluginResultBase>();
             discoveryResult.PluginResults.Clear();
             discoveryResult.PluginResults.Add(discoveryPluginResultBase);
             foreach (DiscoveryPluginResultBase discoveryPluginResultBase2 in list)
             {
                 discoveryResult.PluginResults.Add(discoveryPluginResultBase2);
             }
         }
     }
     return(discoveryResult);
 }
        public static void Show(DiscoveryResultBase result, StartImportStatus status)
        {
            DiscoveryAutoImportNotificationItemDAL notificationItemDal = DiscoveryAutoImportNotificationItemDAL.GetItem();
            string description = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "DiscoveryImportStatus:{0}", (object)status);
            string empty       = string.Empty;
            string title;

            switch (status - 4)
            {
            case 0:
                title = Resources2.get_Notification_DiscoveryAutoImport_Failed();
                break;

            case 1:
                title = Resources2.get_Notification_DiscoveryAutoImport_LicenseExceeded();
                break;

            case 2:
                title = Resources2.get_Notification_DiscoveryAutoImport_Succeeded();
                break;

            default:
                return;
            }
            if (notificationItemDal == null)
            {
                NotificationItemDAL.Insert(DiscoveryAutoImportNotificationItemDAL.DiscoveryAutoImportNotificationItemId, DiscoveryAutoImportNotificationItemDAL.DiscoveryAutoImportNotificationTypeGuid, title, description, false, DiscoveryAutoImportNotificationItemDAL.NetworkSonarDiscoveryURL, new DateTime?(), (string)null);
            }
            else
            {
                notificationItemDal.SetNotAcknowledged();
                notificationItemDal.Title       = title;
                notificationItemDal.Description = description;
                notificationItemDal.Update();
            }
        }
        private static DiscoveryResultBase FilterByPriority(
            DiscoveryResultBase result,
            TechnologyManager mgr,
            bool onlyMandatory)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }
            if (mgr == null)
            {
                throw new ArgumentNullException(nameof(mgr));
            }
            ILookup <string, ITechnologyPolling> lookup = mgr.TechnologyPollingFactory.Items().ToLookup <ITechnologyPolling, string>((Func <ITechnologyPolling, string>)(tp => tp.get_TechnologyPollingID()), (IEqualityComparer <string>)StringComparer.Ordinal);
            List <IDiscoveredObject>             idiscoveredObjectList = new List <IDiscoveredObject>();

            using (IEnumerator <DiscoveryPluginResultBase> enumerator = result.get_PluginResults().GetEnumerator())
            {
                while (((IEnumerator)enumerator).MoveNext())
                {
                    IEnumerable <IDiscoveredObject> discoveredObjects = enumerator.Current.GetDiscoveredObjects();
                    idiscoveredObjectList.AddRange(discoveredObjects);
                }
            }
            List <IDiscoveredObjectWithTechnology> list1 = ((IEnumerable)idiscoveredObjectList).OfType <IDiscoveredObjectWithTechnology>().ToList <IDiscoveredObjectWithTechnology>();

            using (IEnumerator <TechnologyDiscoveryGroup> enumerator1 = DiscoveryFilterResultByTechnology.GetDiscoveryGroupsInternal(mgr).GetEnumerator())
            {
                while (((IEnumerator)enumerator1).MoveNext())
                {
                    TechnologyDiscoveryGroup group = enumerator1.Current;
                    if (!onlyMandatory || group.get_SelectionDisabled())
                    {
                        IEnumerable <IDiscoveredObjectWithTechnology>  list2 = (IEnumerable <IDiscoveredObjectWithTechnology>)((IEnumerable <IDiscoveredObjectWithTechnology>)list1).Where <IDiscoveredObjectWithTechnology>((Func <IDiscoveredObjectWithTechnology, bool>)(n => group.IsMyGroupedObjectType((IDiscoveredObject)n))).ToList <IDiscoveredObjectWithTechnology>();
                        List <List <IDiscoveredObjectWithTechnology> > objectWithTechnologyListList = new List <List <IDiscoveredObjectWithTechnology> >();
                        using (List <IDiscoveredObject> .Enumerator enumerator2 = idiscoveredObjectList.GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                IDiscoveredObject current1 = enumerator2.Current;
                                if (((DiscoveredObjectBase)group).IsChildOf(current1))
                                {
                                    List <IDiscoveredObjectWithTechnology> objectWithTechnologyList = new List <IDiscoveredObjectWithTechnology>();
                                    using (IEnumerator <IDiscoveredObjectWithTechnology> enumerator3 = list2.GetEnumerator())
                                    {
                                        while (((IEnumerator)enumerator3).MoveNext())
                                        {
                                            IDiscoveredObjectWithTechnology current2 = enumerator3.Current;
                                            if (((IDiscoveredObject)current2).IsChildOf(current1))
                                            {
                                                objectWithTechnologyList.Add(current2);
                                            }
                                        }
                                    }
                                    objectWithTechnologyListList.Add(objectWithTechnologyList);
                                }
                            }
                        }
                        using (List <List <IDiscoveredObjectWithTechnology> > .Enumerator enumerator2 = objectWithTechnologyListList.GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                List <IDiscoveredObjectWithTechnology> current = enumerator2.Current;
                                if (onlyMandatory)
                                {
                                    if (((IEnumerable <IDiscoveredObjectWithTechnology>)current).Any <IDiscoveredObjectWithTechnology>((Func <IDiscoveredObjectWithTechnology, bool>)(to => ((IDiscoveredObject)to).get_IsSelected())))
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    current.ForEach((Action <IDiscoveredObjectWithTechnology>)(to => ((IDiscoveredObject)to).set_IsSelected(false)));
                                }
                                DiscoveryFilterResultByTechnology.SelectObjectWithHigherPriority((IEnumerable <IDiscoveredObjectWithTechnology>)current, lookup);
                            }
                        }
                    }
                }
            }
            return(result);
        }
 public static DiscoveryResultBase FilterMandatoryByPriority(
     DiscoveryResultBase result,
     TechnologyManager mgr)
 {
     return(DiscoveryFilterResultByTechnology.FilterByPriority(result, mgr, true));
 }
        // 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);
        }
예제 #23
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);
        }
예제 #24
0
        private static void StartImportInternal(
            Guid importId,
            DiscoveryResultBase result,
            SortedDictionary <int, List <IDiscoveryPlugin> > importingPlugins,
            bool checkLicenseLimits,
            DiscoveryImportManager.CallbackDiscoveryImportFinished callbackAfterImport)
        {
            Resources.get_WEBJS_PS0_17();
            StartImportStatus       status = (StartImportStatus)4;
            List <DiscoveryLogItem> items  = new List <DiscoveryLogItem>();

            try
            {
                DiscoveryDatabase.GetDiscoveryConfiguration(result.get_ProfileID())?.get_Name();
            }
            catch (Exception ex)
            {
                DiscoveryImportManager.log.Warn((object)"Unable to load profile name", ex);
            }
            using (LocaleThreadState.EnsurePrimaryLocale())
            {
                try
                {
                    DiscoveryNetObjectStatusManager.Instance.BeginOrionDatabaseChanges();
                    if (checkLicenseLimits && ((IEnumerable <ElementLicenseInfo>)DiscoveryImportManager.GetLicensedStatus(result)).Any <ElementLicenseInfo>((Func <ElementLicenseInfo, bool>)(n => (uint)n.get_ExceededBy() > 0U)))
                    {
                        DiscoveryImportManager.log.Debug((object)"Can't import discovery result, because license was exceeded");
                        status = (StartImportStatus)5;
                    }
                    else
                    {
                        double progress = 0.0;
                        double num      = (double)(100 / importingPlugins.Keys.Count);
                        using (SortedDictionary <int, List <IDiscoveryPlugin> > .KeyCollection.Enumerator enumerator1 = importingPlugins.Keys.GetEnumerator())
                        {
                            while (enumerator1.MoveNext())
                            {
                                int current = enumerator1.Current;
                                using (List <IDiscoveryPlugin> .Enumerator enumerator2 = importingPlugins[current].GetEnumerator())
                                {
                                    while (enumerator2.MoveNext())
                                    {
                                        IDiscoveryPlugin plugin = enumerator2.Current;
                                        if (plugin is ISupportImportLog isupportImportLog)
                                        {
                                            isupportImportLog.SetImportLogCallback(new Action <DiscoveryLogItem>(items.Add));
                                        }
                                        plugin.ImportResults(result, (Action <string, double>)((message, phaseProgress) => DiscoveryImportManager.UpdateProgress(importId, message, progress + phaseProgress / (double)importingPlugins.Keys.Count, phaseProgress, plugin.GetImportPhaseName(), false)));
                                    }
                                }
                                progress += num;
                            }
                        }
                        DiscoveryImportManager.UpdateProgress(importId, Resources.get_LIBCODE_VB0_28(), 100.0, 100.0, string.Empty, true);
                        status = (StartImportStatus)6;
                    }
                }
                catch (Exception ex)
                {
                    status = (StartImportStatus)4;
                    DiscoveryImportManager.log.Error((object)"Exception occurred during discovery import", ex);
                    DiscoveryImportManager.UpdateProgress(importId, Resources.get_LIBCODE_TM0_30(), 100.0, 100.0, string.Empty, true);
                }
                finally
                {
                    DiscoveryNetObjectStatusManager.Instance.EndOrionDatabaseChanges();
                    result.set_BatchID(Guid.NewGuid());
                    try
                    {
                        DiscoveryImportManager.InsertDiscoveryLogItems(items, result.get_BatchID());
                    }
                    catch (Exception ex)
                    {
                        DiscoveryImportManager.log.Error((object)"Unable to store discovery import items", ex);
                    }
                    if (callbackAfterImport != null)
                    {
                        try
                        {
                            callbackAfterImport(result, importId, status);
                        }
                        catch (Exception ex)
                        {
                            DiscoveryImportManager.log.Error((object)"Error while calling callback after import.", ex);
                        }
                    }
                    DiscoveryNetObjectStatusManager.Instance.RequestUpdateAsync((Action)null, BusinessLayerSettings.Instance.DiscoveryUpdateNetObjectStatusWaitForChangesDelay);
                }
            }
        }
예제 #25
0
        // Token: 0x060002A4 RID: 676 RVA: 0x0001028C File Offset: 0x0000E48C
        private static DiscoveryResultBase FilterByPriority(DiscoveryResultBase result, TechnologyManager mgr, bool onlyMandatory)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            if (mgr == null)
            {
                throw new ArgumentNullException("mgr");
            }
            ILookup <string, ITechnologyPolling> technologyPollingsById = mgr.TechnologyPollingFactory.Items().ToLookup((ITechnologyPolling tp) => tp.TechnologyPollingID, StringComparer.Ordinal);
            List <IDiscoveredObject>             list = new List <IDiscoveredObject>();

            foreach (DiscoveryPluginResultBase discoveryPluginResultBase in result.PluginResults)
            {
                IEnumerable <IDiscoveredObject> discoveredObjects = discoveryPluginResultBase.GetDiscoveredObjects();
                list.AddRange(discoveredObjects);
            }
            List <IDiscoveredObjectWithTechnology> source = list.OfType <IDiscoveredObjectWithTechnology>().ToList <IDiscoveredObjectWithTechnology>();

            foreach (TechnologyDiscoveryGroup group2 in DiscoveryFilterResultByTechnology.GetDiscoveryGroupsInternal(mgr))
            {
                TechnologyDiscoveryGroup group = group2;
                if (!onlyMandatory || group.SelectionDisabled)
                {
                    IEnumerable <IDiscoveredObjectWithTechnology> enumerable = (from n in source
                                                                                where @group.IsMyGroupedObjectType(n)
                                                                                select n).ToList <IDiscoveredObjectWithTechnology>();
                    List <List <IDiscoveredObjectWithTechnology> > list2 = new List <List <IDiscoveredObjectWithTechnology> >();
                    foreach (IDiscoveredObject discoveredObject in list)
                    {
                        if (group.IsChildOf(discoveredObject))
                        {
                            List <IDiscoveredObjectWithTechnology> list3 = new List <IDiscoveredObjectWithTechnology>();
                            foreach (IDiscoveredObjectWithTechnology discoveredObjectWithTechnology in enumerable)
                            {
                                if (discoveredObjectWithTechnology.IsChildOf(discoveredObject))
                                {
                                    list3.Add(discoveredObjectWithTechnology);
                                }
                            }
                            list2.Add(list3);
                        }
                    }
                    foreach (List <IDiscoveredObjectWithTechnology> list4 in list2)
                    {
                        if (onlyMandatory)
                        {
                            if (list4.Any((IDiscoveredObjectWithTechnology to) => to.IsSelected))
                            {
                                continue;
                            }
                        }
                        else
                        {
                            list4.ForEach(delegate(IDiscoveredObjectWithTechnology to)
                            {
                                to.IsSelected = false;
                            });
                        }
                        DiscoveryFilterResultByTechnology.SelectObjectWithHigherPriority(list4, technologyPollingsById);
                    }
                }
            }
            return(result);
        }
        // Token: 0x060002AE RID: 686 RVA: 0x00010840 File Offset: 0x0000EA40
        private static void StartImportInternal(Guid importId, DiscoveryResultBase result, SortedDictionary <int, List <IDiscoveryPlugin> > importingPlugins, bool checkLicenseLimits, DiscoveryImportManager.CallbackDiscoveryImportFinished callbackAfterImport)
        {
            string                  webjs_PS0_ = Resources.WEBJS_PS0_17;
            StartImportStatus       status     = StartImportStatus.Failed;
            List <DiscoveryLogItem> list       = new List <DiscoveryLogItem>();

            try
            {
                DiscoveryConfiguration discoveryConfiguration = DiscoveryDatabase.GetDiscoveryConfiguration(result.ProfileID);
                if (discoveryConfiguration != null)
                {
                    string name = discoveryConfiguration.Name;
                }
            }
            catch (Exception ex)
            {
                DiscoveryImportManager.log.Warn("Unable to load profile name", ex);
            }
            using (LocaleThreadState.EnsurePrimaryLocale())
            {
                try
                {
                    DiscoveryNetObjectStatusManager.Instance.BeginOrionDatabaseChanges();
                    if (checkLicenseLimits)
                    {
                        if (DiscoveryImportManager.GetLicensedStatus(result).Any((ElementLicenseInfo n) => n.ExceededBy != 0))
                        {
                            DiscoveryImportManager.log.Debug("Can't import discovery result, because license was exceeded");
                            status = StartImportStatus.LicenseExceeded;
                            return;
                        }
                    }
                    double progress = 0.0;
                    double num      = (double)(100 / importingPlugins.Keys.Count);
                    foreach (int key in importingPlugins.Keys)
                    {
                        using (List <IDiscoveryPlugin> .Enumerator enumerator2 = importingPlugins[key].GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                IDiscoveryPlugin  plugin           = enumerator2.Current;
                                ISupportImportLog supportImportLog = plugin as ISupportImportLog;
                                if (supportImportLog != null)
                                {
                                    supportImportLog.SetImportLogCallback(new Action <DiscoveryLogItem>(list.Add));
                                }
                                plugin.ImportResults(result, delegate(string message, double phaseProgress)
                                {
                                    DiscoveryImportManager.UpdateProgress(importId, message, progress + phaseProgress / (double)importingPlugins.Keys.Count, phaseProgress, plugin.GetImportPhaseName(), false);
                                });
                            }
                        }
                        progress += num;
                    }
                    DiscoveryImportManager.UpdateProgress(importId, Resources.LIBCODE_VB0_28, 100.0, 100.0, string.Empty, true);
                    status = StartImportStatus.Finished;
                }
                catch (Exception ex2)
                {
                    status = StartImportStatus.Failed;
                    DiscoveryImportManager.log.Error("Exception occurred during discovery import", ex2);
                    DiscoveryImportManager.UpdateProgress(importId, Resources.LIBCODE_TM0_30, 100.0, 100.0, string.Empty, true);
                }
                finally
                {
                    DiscoveryNetObjectStatusManager.Instance.EndOrionDatabaseChanges();
                    result.BatchID = Guid.NewGuid();
                    try
                    {
                        DiscoveryImportManager.InsertDiscoveryLogItems(list, result.BatchID);
                    }
                    catch (Exception ex3)
                    {
                        DiscoveryImportManager.log.Error("Unable to store discovery import items", ex3);
                    }
                    if (callbackAfterImport != null)
                    {
                        try
                        {
                            callbackAfterImport(result, importId, status);
                        }
                        catch (Exception ex4)
                        {
                            DiscoveryImportManager.log.Error("Error while calling callback after import.", ex4);
                        }
                    }
                    DiscoveryNetObjectStatusManager.Instance.RequestUpdateAsync(null, BusinessLayerSettings.Instance.DiscoveryUpdateNetObjectStatusWaitForChangesDelay);
                }
            }
        }
예제 #27
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);
            }
        }