Пример #1
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: 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);
 }
Пример #3
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);
                }
            }
        }
Пример #4
0
 public static void UpdateProgress(Guid importId, string text, string phaseName, bool finished)
 {
     DiscoveryImportManager.UpdateProgress(importId, text, 0.0, 0.0, phaseName, finished);
 }
        // 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);
                }
            }
        }