Esempio n. 1
0
 public void OnJobFinished(FinishedJobInfo[] jobFinishedInfo)
 {
     using (LocaleThreadState.EnsurePrimaryLocale())
     {
         if (this.parent.IsServiceDown)
         {
             JobSchedulerEventsService.log.InfoFormat("Core Service Engine is in an invalid state.  Job results will be discarded.", Array.Empty <object>());
         }
         else
         {
             this.resultsManager.AddJobResults(jobFinishedInfo);
             for (FinishedJobInfo jobResult = this.resultsManager.GetJobResult(); jobResult != null; jobResult = this.resultsManager.GetJobResult())
             {
                 try
                 {
                     this.ProcessJobResult(jobResult);
                 }
                 catch (Exception ex)
                 {
                     JobSchedulerEventsService.log.Error((object)"Error processing job", ex);
                 }
                 finally
                 {
                     this.resultsManager.FinishProcessingJobResult(jobResult);
                 }
             }
         }
     }
 }
        // Token: 0x060007B3 RID: 1971 RVA: 0x0003728C File Offset: 0x0003548C
        public Dictionary <string, string> GetNetworkDeviceTypes(List <int> limitationIDs)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            using (SqlCommand textCommand = SqlHelper.GetTextCommand(Limitation.LimitSQL(" SELECT Vendor + '%' AS Value, '' AS Name \r\n FROM Nodes \r\n WHERE (Vendor <> '')  \r\n GROUP BY Vendor HAVING (Count(Vendor) > 1) \r\n UNION\r\n SELECT MachineType AS Value, MachineType AS Name \r\n FROM Nodes\r\n WHERE MachineType <> '' \r\n GROUP BY MachineType ", limitationIDs)))
            {
                using (IDataReader dataReader = SqlHelper.ExecuteReader(textCommand))
                {
                    int    ordinal  = dataReader.GetOrdinal("Value");
                    int    ordinal2 = dataReader.GetOrdinal("Name");
                    string libcode_VB0_;
                    using (LocaleThreadState.EnsurePrimaryLocale())
                    {
                        libcode_VB0_ = Resources.LIBCODE_VB0_61;
                        goto IL_97;
                    }
IL_53:
                    string text = dataReader.GetString(ordinal2);
                    string @string = dataReader.GetString(ordinal);
                    text = ((!string.IsNullOrEmpty(text)) ? text : string.Format(libcode_VB0_, @string.Substring(0, @string.Length - 1)));
                    dictionary.Add(@string, text);
IL_97:
                    if (dataReader.Read())
                    {
                        goto IL_53;
                    }
                }
            }
            return(dictionary);
        }
Esempio n. 3
0
 // Token: 0x0600043A RID: 1082 RVA: 0x0001CD5C File Offset: 0x0001AF5C
 private object ThreadPoolRoutine(object state)
 {
     UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTask scheduledTask = state as UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTask;
     if (scheduledTask == null)
     {
         throw new ArgumentException("Unexpected state object or null", "state");
     }
     try
     {
         bool      taskExecuted = false;
         Exception ex           = null;
         using (LocaleThreadState.EnsurePrimaryLocale())
         {
             if (!SmartThreadPool.IsWorkItemCanceled)
             {
                 try
                 {
                     taskExecuted = true;
                     this.taskRoutine(scheduledTask.TaskKey);
                 }
                 catch (Exception ex2)
                 {
                     ex = ex2;
                     this.log.Error(string.Format("Task {0} cought unhandled exception from task routine", scheduledTask), ex2);
                 }
             }
             if (scheduledTask.Callbacks != null)
             {
                 foreach (UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTaskCallback scheduledTaskCallback in scheduledTask.Callbacks)
                 {
                     try
                     {
                         scheduledTaskCallback.Callback(new UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTaskCallbackEventArgs(scheduledTask.TaskKey, scheduledTaskCallback.State, ex, taskExecuted));
                     }
                     catch (Exception ex3)
                     {
                         this.log.Error(string.Format("Task {0} callback failed", scheduledTask), ex3);
                     }
                 }
             }
         }
     }
     catch (Exception ex4)
     {
         this.log.Error(string.Format("Task {0} cought unhandled exception during task processing", scheduledTask), ex4);
     }
     finally
     {
         object obj = this.syncLock;
         lock (obj)
         {
             this.ongoingTasks.Remove(scheduledTask);
         }
     }
     return(null);
 }
Esempio n. 4
0
 public void OnJobProgress(JobProgress[] jobProgressInfo)
 {
     using (LocaleThreadState.EnsurePrimaryLocale())
     {
         foreach (JobProgress jobProgress in jobProgressInfo)
         {
             this.ProcessJobProgress(jobProgress);
         }
     }
 }
Esempio n. 5
0
 private object ThreadPoolRoutine(object state)
 {
     if (!(state is UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTask scheduledTask))
     {
         throw new ArgumentException("Unexpected state object or null", nameof(state));
     }
     try
     {
         bool      taskExecuted = false;
         Exception ex1          = (Exception)null;
         using (LocaleThreadState.EnsurePrimaryLocale())
         {
             if (!SmartThreadPool.get_IsWorkItemCanceled())
             {
                 try
                 {
                     taskExecuted = true;
                     this.taskRoutine(scheduledTask.TaskKey);
                 }
                 catch (Exception ex2)
                 {
                     ex1 = ex2;
                     this.log.Error((object)string.Format("Task {0} cought unhandled exception from task routine", (object)scheduledTask), ex2);
                 }
             }
             if (scheduledTask.Callbacks != null)
             {
                 foreach (UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTaskCallback callback in scheduledTask.Callbacks)
                 {
                     try
                     {
                         callback.Callback(new UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTaskCallbackEventArgs(scheduledTask.TaskKey, callback.State, ex1, taskExecuted));
                     }
                     catch (Exception ex2)
                     {
                         this.log.Error((object)string.Format("Task {0} callback failed", (object)scheduledTask), ex2);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         this.log.Error((object)string.Format("Task {0} cought unhandled exception during task processing", (object)scheduledTask), ex);
     }
     finally
     {
         lock (this.syncLock)
             this.ongoingTasks.Remove(scheduledTask);
     }
     return((object)null);
 }
 // 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);
         }
     }
 }
Esempio n. 7
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);
         }
     }
 }
Esempio n. 8
0
 private object ThreadPoolCallBack(object state)
 {
     if (state is TTask task)
     {
         try
         {
             if (!SmartThreadPool.get_IsWorkItemCanceled())
             {
                 using (LocaleThreadState.EnsurePrimaryLocale())
                     this.processingRoutine(task);
             }
         }
         catch (Exception ex)
         {
             QueuedTaskScheduler <TTask> .log.Error((object)"Unhandled exception in queued task processing:", ex);
         }
     }
     return((object)null);
 }
        // Token: 0x060003C3 RID: 963 RVA: 0x00018AB8 File Offset: 0x00016CB8
        private object ThreadPoolCallBack(object state)
        {
            TTask ttask = state as TTask;

            if (ttask != null)
            {
                try
                {
                    if (!SmartThreadPool.IsWorkItemCanceled)
                    {
                        using (LocaleThreadState.EnsurePrimaryLocale())
                        {
                            this.processingRoutine(ttask);
                        }
                    }
                }
                catch (Exception ex)
                {
                    QueuedTaskScheduler <TTask> .log.Error("Unhandled exception in queued task processing:", ex);
                }
            }
            return(null);
        }
        public Dictionary <string, string> GetNetworkDeviceTypes(List <int> limitationIDs)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            using (SqlCommand textCommand = SqlHelper.GetTextCommand(Limitation.LimitSQL(" SELECT Vendor + '%' AS Value, '' AS Name \r\n FROM Nodes \r\n WHERE (Vendor <> '')  \r\n GROUP BY Vendor HAVING (Count(Vendor) > 1) \r\n UNION\r\n SELECT MachineType AS Value, MachineType AS Name \r\n FROM Nodes\r\n WHERE MachineType <> '' \r\n GROUP BY MachineType ", (IEnumerable <int>)limitationIDs)))
            {
                using (IDataReader dataReader = SqlHelper.ExecuteReader(textCommand))
                {
                    int    ordinal1 = dataReader.GetOrdinal("Value");
                    int    ordinal2 = dataReader.GetOrdinal("Name");
                    string libcodeVb061;
                    using (LocaleThreadState.EnsurePrimaryLocale())
                        libcodeVb061 = Resources.get_LIBCODE_VB0_61();
                    while (dataReader.Read())
                    {
                        string str1 = dataReader.GetString(ordinal2);
                        string key  = dataReader.GetString(ordinal1);
                        string str2 = !string.IsNullOrEmpty(str1) ? str1 : string.Format(libcodeVb061, (object)key.Substring(0, key.Length - 1));
                        dictionary.Add(key, str2);
                    }
                }
            }
            return(dictionary);
        }
Esempio n. 11
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);
                }
            }
        }
        // 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);
                }
            }
        }