public void DoInventory(SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.InventoryTask task)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();
            Node      node      = this.GetNode(task.NodeID);

            if (node == null || node.get_PolledStatus() != 1)
            {
                SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.InfoFormat("Skipping inventorying of Node {0}, status is not UP.", (object)task.NodeID);
            }
            else
            {
                Credential         credentialsForNode = this.GetCredentialsForNode(node);
                GlobalSettingsBase globals            = (GlobalSettingsBase)this.snmpGlobals;
                if (node.get_NodeSubType() == 3)
                {
                    globals = (GlobalSettingsBase)this.wmiGlobals;
                }
                if (SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.get_IsInfoEnabled())
                {
                    SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.InfoFormat("Starting inventorying of Node {0}, NeedsInventory = '{1}'", (object)task.NodeID, (object)task.Settings);
                }
                string[]      strArray       = task.Settings.Split(':');
                List <string> failedTasks    = new List <string>();
                List <string> completedTasks = new List <string>();
                foreach (string key in strArray)
                {
                    SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.InfoFormat("Attempting to inventory with plugin '{0}' on Node {1}", (object)key, (object)task.NodeID);
                    if (!this.inventories.ContainsKey(key))
                    {
                        failedTasks.Add(key);
                        if (SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.get_IsErrorEnabled())
                        {
                            SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.ErrorFormat("Unable to inventory '{0}' on Node {1}", (object)key, (object)task.NodeID);
                        }
                    }
                    else
                    {
                        if (this.IsScheduledTaskCanceled())
                        {
                            if (SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.get_IsInfoEnabled())
                            {
                                SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.InfoFormat("Inventorying of Node {0} was canceled. ElapsedTime = {1}", (object)task.NodeID, (object)stopwatch.ElapsedMilliseconds);
                            }
                            stopwatch.Stop();
                            return;
                        }
                        if (!this.IsValidPlugin(this.inventories[key]))
                        {
                            failedTasks.Add(key);
                            if (SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.get_IsErrorEnabled())
                            {
                                SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.ErrorFormat("No plugins are available to execute Inventory '{0}' on Node {1} returned null result", (object)key, (object)task.NodeID);
                            }
                        }
                        else
                        {
                            InventoryResultBase result = this.DoInventory(this.inventories[key], task, globals, credentialsForNode, node);
                            if (result == null)
                            {
                                failedTasks.Add(key);
                                if (SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.get_IsErrorEnabled())
                                {
                                    SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.ErrorFormat("Inventory '{0}' on Node {1} returned null result", (object)key, (object)task.NodeID);
                                }
                            }
                            else
                            {
                                if (result.get_Outcome() == 1)
                                {
                                    bool flag = false;
                                    try
                                    {
                                        flag = this.ProcessResults(this.inventories[key], task, result, node);
                                    }
                                    catch (Exception ex)
                                    {
                                        SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.Error((object)string.Format("Inventory '{0}' failed to import results for {1}", (object)task, (object)key), ex);
                                    }
                                    if (flag)
                                    {
                                        completedTasks.Add(key);
                                    }
                                    else
                                    {
                                        failedTasks.Add(key);
                                    }
                                }
                                else
                                {
                                    failedTasks.Add(key);
                                    if (result.get_Error() != null)
                                    {
                                        if (SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.get_IsWarnEnabled())
                                        {
                                            SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.WarnFormat("Inventory '{0}' on Node {1} failed with code {2}", (object)key, (object)task, (object)result.get_Error().get_ErrorCode());
                                        }
                                        if (result.get_Error().get_ErrorCode() != 31002U)
                                        {
                                            List <string> list = ((IEnumerable <string>)strArray).Where <string>((Func <string, bool>)(n => !completedTasks.Contains(n) && !failedTasks.Contains(n))).ToList <string>();
                                            if (list.Count > 0)
                                            {
                                                failedTasks.AddRange((IEnumerable <string>)list);
                                                if (SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.get_IsWarnEnabled())
                                                {
                                                    SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.WarnFormat("Skipping inventory for '{0}' on Node {1}", (object)string.Join(":", list.ToArray()), (object)task.NodeID);
                                                    break;
                                                }
                                                break;
                                            }
                                        }
                                    }
                                    else if (SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.get_IsWarnEnabled())
                                    {
                                        SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.WarnFormat("Inventory '{0}' on Node {1} failed on unknown error", (object)key, (object)task.NodeID);
                                    }
                                }
                                SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.InfoFormat("Inventory with plugin '{0}' on Node {1} is completed", (object)key, (object)task.NodeID);
                            }
                        }
                    }
                }
                string settingsForTask = this.GetSettingsForTask(task);
                if ((string.IsNullOrEmpty(settingsForTask) || !settingsForTask.Equals(task.Settings, StringComparison.OrdinalIgnoreCase)) && SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.get_IsInfoEnabled())
                {
                    SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.InfoFormat("Skipping inventory result processing for {0}, NeedsInventory flag changed. OldValue = '{1}', NewValue = '{2}'.", (object)task, (object)task.Settings, (object)settingsForTask);
                }
                else
                {
                    if (failedTasks.Count == 0)
                    {
                        if (task.InventoryInput == SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.InventoryTask.InventoryInputSource.NodeSettings)
                        {
                            NodeSettingsDAL.DeleteSpecificSettings(task.ObjectSettingID, task.InventorySettingName);
                        }
                        else
                        {
                            InventorySettingsDAL.DeleteSpecificSettings(task.ObjectSettingID, task.InventorySettingName);
                        }
                        if (SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.get_IsInfoEnabled())
                        {
                            SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.InfoFormat("Inventorying of {0} completed in {1}ms.", (object)task, (object)stopwatch.ElapsedMilliseconds);
                        }
                    }
                    else if (failedTasks.Count < strArray.Length)
                    {
                        string str = string.Join(":", failedTasks.ToArray());
                        if (task.InventoryInput == SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.InventoryTask.InventoryInputSource.NodeSettings)
                        {
                            NodeSettingsDAL.UpdateSettingValue(task.ObjectSettingID, task.InventorySettingName, (object)str);
                        }
                        else
                        {
                            InventorySettingsDAL.UpdateSettingValue(task.ObjectSettingID, task.InventorySettingName, (object)str);
                        }
                        if (SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.get_IsInfoEnabled())
                        {
                            SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.InfoFormat("Inventorying of {0} partially completed in {1}ms. NeedsInventory updated to '{2}'", (object)task, (object)stopwatch.ElapsedMilliseconds, (object)str);
                        }
                    }
                    else if (SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.get_IsInfoEnabled())
                    {
                        SolarWinds.Orion.Core.BusinessLayer.BackgroundInventory.BackgroundInventory.log.InfoFormat("Inventorying of {0} failed. Elapsed time {1}ms.", (object)task, (object)stopwatch.ElapsedMilliseconds);
                    }
                    stopwatch.Stop();
                }
            }
        }
        // Token: 0x060008E0 RID: 2272 RVA: 0x0003F9F4 File Offset: 0x0003DBF4
        public void DoInventory(BackgroundInventory.InventoryTask task)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();
            Node      node      = this.GetNode(task.NodeID);

            if (node == null || node.PolledStatus != 1)
            {
                BackgroundInventory.log.InfoFormat("Skipping inventorying of Node {0}, status is not UP.", task.NodeID);
                return;
            }
            Credential         credentialsForNode = this.GetCredentialsForNode(node);
            GlobalSettingsBase globals            = this.snmpGlobals;

            if (node.NodeSubType == NodeSubType.WMI)
            {
                globals = this.wmiGlobals;
            }
            if (BackgroundInventory.log.IsInfoEnabled)
            {
                BackgroundInventory.log.InfoFormat("Starting inventorying of Node {0}, NeedsInventory = '{1}'", task.NodeID, task.Settings);
            }
            string[] array = task.Settings.Split(new char[]
            {
                ':'
            });
            List <string> failedTasks    = new List <string>();
            List <string> completedTasks = new List <string>();

            Func <string, bool> < > 9__0;
            foreach (string text in array)
            {
                BackgroundInventory.log.InfoFormat("Attempting to inventory with plugin '{0}' on Node {1}", text, task.NodeID);
                if (!this.inventories.ContainsKey(text))
                {
                    failedTasks.Add(text);
                    if (BackgroundInventory.log.IsErrorEnabled)
                    {
                        BackgroundInventory.log.ErrorFormat("Unable to inventory '{0}' on Node {1}", text, task.NodeID);
                    }
                }
                else
                {
                    if (this.IsScheduledTaskCanceled())
                    {
                        if (BackgroundInventory.log.IsInfoEnabled)
                        {
                            BackgroundInventory.log.InfoFormat("Inventorying of Node {0} was canceled. ElapsedTime = {1}", task.NodeID, stopwatch.ElapsedMilliseconds);
                        }
                        stopwatch.Stop();
                        return;
                    }
                    if (!this.IsValidPlugin(this.inventories[text]))
                    {
                        failedTasks.Add(text);
                        if (BackgroundInventory.log.IsErrorEnabled)
                        {
                            BackgroundInventory.log.ErrorFormat("No plugins are available to execute Inventory '{0}' on Node {1} returned null result", text, task.NodeID);
                        }
                    }
                    else
                    {
                        InventoryResultBase inventoryResultBase = this.DoInventory(this.inventories[text], task, globals, credentialsForNode, node);
                        if (inventoryResultBase == null)
                        {
                            failedTasks.Add(text);
                            if (BackgroundInventory.log.IsErrorEnabled)
                            {
                                BackgroundInventory.log.ErrorFormat("Inventory '{0}' on Node {1} returned null result", text, task.NodeID);
                            }
                        }
                        else
                        {
                            if (inventoryResultBase.Outcome == 1)
                            {
                                bool flag = false;
                                try
                                {
                                    flag = this.ProcessResults(this.inventories[text], task, inventoryResultBase, node);
                                }
                                catch (Exception ex)
                                {
                                    BackgroundInventory.log.Error(string.Format("Inventory '{0}' failed to import results for {1}", task, text), ex);
                                }
                                if (flag)
                                {
                                    completedTasks.Add(text);
                                }
                                else
                                {
                                    failedTasks.Add(text);
                                }
                            }
                            else
                            {
                                failedTasks.Add(text);
                                if (inventoryResultBase.Error != null)
                                {
                                    if (BackgroundInventory.log.IsWarnEnabled)
                                    {
                                        BackgroundInventory.log.WarnFormat("Inventory '{0}' on Node {1} failed with code {2}", text, task, inventoryResultBase.Error.ErrorCode);
                                    }
                                    if (inventoryResultBase.Error.ErrorCode != 31002U)
                                    {
                                        IEnumerable <string> source = array;
                                        Func <string, bool>  predicate;
                                        if ((predicate = < > 9__0) == null)
                                        {
                                            predicate = (< > 9__0 = ((string n) => !completedTasks.Contains(n) && !failedTasks.Contains(n)));
                                        }
                                        List <string> list = source.Where(predicate).ToList <string>();
                                        if (list.Count > 0)
                                        {
                                            failedTasks.AddRange(list);
                                            if (BackgroundInventory.log.IsWarnEnabled)
                                            {
                                                BackgroundInventory.log.WarnFormat("Skipping inventory for '{0}' on Node {1}", string.Join(":", list.ToArray()), task.NodeID);
                                                break;
                                            }
                                            break;
                                        }
                                    }
                                }
                                else if (BackgroundInventory.log.IsWarnEnabled)
                                {
                                    BackgroundInventory.log.WarnFormat("Inventory '{0}' on Node {1} failed on unknown error", text, task.NodeID);
                                }
                            }
                            BackgroundInventory.log.InfoFormat("Inventory with plugin '{0}' on Node {1} is completed", text, task.NodeID);
                        }
                    }
                }
            }
            string settingsForTask = this.GetSettingsForTask(task);

            if ((string.IsNullOrEmpty(settingsForTask) || !settingsForTask.Equals(task.Settings, StringComparison.OrdinalIgnoreCase)) && BackgroundInventory.log.IsInfoEnabled)
            {
                BackgroundInventory.log.InfoFormat("Skipping inventory result processing for {0}, NeedsInventory flag changed. OldValue = '{1}', NewValue = '{2}'.", task, task.Settings, settingsForTask);
                return;
            }
            if (failedTasks.Count == 0)
            {
                if (task.InventoryInput == BackgroundInventory.InventoryTask.InventoryInputSource.NodeSettings)
                {
                    NodeSettingsDAL.DeleteSpecificSettings(task.ObjectSettingID, task.InventorySettingName);
                }
                else
                {
                    InventorySettingsDAL.DeleteSpecificSettings(task.ObjectSettingID, task.InventorySettingName);
                }
                if (BackgroundInventory.log.IsInfoEnabled)
                {
                    BackgroundInventory.log.InfoFormat("Inventorying of {0} completed in {1}ms.", task, stopwatch.ElapsedMilliseconds);
                }
            }
            else if (failedTasks.Count < array.Length)
            {
                string text2 = string.Join(":", failedTasks.ToArray());
                if (task.InventoryInput == BackgroundInventory.InventoryTask.InventoryInputSource.NodeSettings)
                {
                    NodeSettingsDAL.UpdateSettingValue(task.ObjectSettingID, task.InventorySettingName, text2);
                }
                else
                {
                    InventorySettingsDAL.UpdateSettingValue(task.ObjectSettingID, task.InventorySettingName, text2);
                }
                if (BackgroundInventory.log.IsInfoEnabled)
                {
                    BackgroundInventory.log.InfoFormat("Inventorying of {0} partially completed in {1}ms. NeedsInventory updated to '{2}'", task, stopwatch.ElapsedMilliseconds, text2);
                }
            }
            else if (BackgroundInventory.log.IsInfoEnabled)
            {
                BackgroundInventory.log.InfoFormat("Inventorying of {0} failed. Elapsed time {1}ms.", task, stopwatch.ElapsedMilliseconds);
            }
            stopwatch.Stop();
        }