// Token: 0x060004EB RID: 1259 RVA: 0x0001EBD8 File Offset: 0x0001CDD8
 private ThresholdIndicator.InstanceInformation GetInstanceInformation(string entityType, int instanceId)
 {
     if (string.IsNullOrEmpty(entityType) || instanceId == 0)
     {
         return(null);
     }
     ThresholdIndicator.InstanceInformation instanceInformation = new ThresholdIndicator.InstanceInformation();
     using (IInformationServiceProxy2 informationServiceProxy = this._swisFactory.CreateConnection())
     {
         DataTable dataTable = informationServiceProxy.Query("SELECT TOP 1 Prefix, KeyProperty, NameProperty FROM Orion.NetObjectTypes WHERE EntityType = @entityType", new Dictionary <string, object>
         {
             {
                 "entityType",
                 entityType
             }
         });
         if (dataTable != null && dataTable.Rows.Count == 1)
         {
             string arg  = dataTable.Rows[0]["Prefix"] as string;
             object obj  = dataTable.Rows[0]["KeyProperty"];
             object obj2 = dataTable.Rows[0]["NameProperty"];
             instanceInformation.NetObject = string.Format("{0}:{1}", arg, instanceId);
             if (obj != DBNull.Value && obj != DBNull.Value)
             {
                 DataTable dataTable2 = informationServiceProxy.Query(string.Format("SELECT {0} FROM {1} WHERE {2} = @InstanceId", obj2, entityType, obj), new Dictionary <string, object>
                 {
                     {
                         "InstanceId",
                         instanceId
                     }
                 });
                 if (dataTable2 != null && dataTable2.Rows.Count > 0)
                 {
                     instanceInformation.InstanceName = dataTable2.Rows[0][obj2.ToString()].ToString();
                 }
                 else
                 {
                     instanceInformation.InstanceName = instanceInformation.NetObject;
                 }
             }
             else
             {
                 instanceInformation.InstanceName = instanceInformation.NetObject;
             }
         }
     }
     return(instanceInformation);
 }
Esempio n. 2
0
        // Token: 0x06000318 RID: 792 RVA: 0x000139C8 File Offset: 0x00011BC8
        private static bool ShowUpdateProductNotification(string productTag)
        {
            ModuleInfo moduleInfo = ModulesCollector.GetModuleInfo(productTag);

            if (string.IsNullOrEmpty(moduleInfo.ValidateUpdateNotification))
            {
                return(true);
            }
            bool result;

            try
            {
                using (IInformationServiceProxy2 informationServiceProxy = SwisConnectionProxyPool.GetSystemCreator().Create())
                {
                    CoreHelper._log.DebugFormat("Calling SWQL query: {0}", moduleInfo.ValidateUpdateNotification);
                    DataTable dataTable = informationServiceProxy.Query(moduleInfo.ValidateUpdateNotification);
                    if (dataTable.Columns.Count != 1 && dataTable.Rows.Count != 1)
                    {
                        CoreHelper._log.WarnFormat("Invalid query: {0}", moduleInfo.ValidateUpdateNotification);
                        result = true;
                    }
                    else
                    {
                        result = (dataTable.Rows[0][0] == null || Convert.ToBoolean(dataTable.Rows[0][0]));
                    }
                }
            }
            catch (Exception ex)
            {
                CoreHelper._log.ErrorFormat("Execution of ValidateUpdateNotification '{0}' has failed. Exception: {1}", moduleInfo.ValidateUpdateNotification, ex);
                result = true;
            }
            return(result);
        }
        // Token: 0x060006EF RID: 1775 RVA: 0x0002C2A4 File Offset: 0x0002A4A4
        public static string GetNetObjectPrefix(IInformationServiceProxyFactory swisFactory, string entityType)
        {
            if (swisFactory == null)
            {
                throw new ArgumentNullException("swisFactory");
            }
            if (string.IsNullOrEmpty(entityType))
            {
                throw new ArgumentException("entityType");
            }
            string result;

            using (IInformationServiceProxy2 informationServiceProxy = swisFactory.CreateConnection())
            {
                DataTable dataTable = informationServiceProxy.Query("SELECT TOP 1 Prefix FROM Orion.NetObjectTypes WHERE EntityType = @entityType", new Dictionary <string, object>
                {
                    {
                        "entityType",
                        entityType
                    }
                });
                if (dataTable == null || dataTable.Rows.Count == 0)
                {
                    result = null;
                }
                else
                {
                    result = dataTable.Rows[0]["Prefix"].ToString();
                }
            }
            return(result);
        }
Esempio n. 4
0
        // Token: 0x0600058C RID: 1420 RVA: 0x00021BD0 File Offset: 0x0001FDD0
        internal string GetNetObjectPrefix(string entityName)
        {
            if (string.IsNullOrEmpty(entityName))
            {
                return(null);
            }
            string result;

            using (IInformationServiceProxy2 informationServiceProxy = this.swisProxy.Create())
            {
                DataTable dataTable = informationServiceProxy.Query("SELECT Prefix FROM Orion.NetObjectTypes WHERE EntityType = @entityName", new Dictionary <string, object>
                {
                    {
                        "entityName",
                        entityName
                    }
                });
                if (dataTable != null && dataTable.Rows != null && dataTable.Rows.Count == 1 && dataTable.Rows[0][0] != null)
                {
                    result = dataTable.Rows[0][0].ToString();
                }
                else
                {
                    result = null;
                }
            }
            return(result);
        }
        // Token: 0x0600060C RID: 1548 RVA: 0x00024550 File Offset: 0x00022750
        private ILookup <string, NetObjectTypeEx> LoadNetObjectTypesExtSwisInfo()
        {
            ILookup <string, NetObjectTypeEx> result;

            using (IInformationServiceProxy2 informationServiceProxy = this._swisServiceProxyCreator.Create())
            {
                result = (from DataRow row in informationServiceProxy.Query("SELECT EntityType, Name, Prefix, KeyProperty, NameProperty, KeyPropertyIndex, CanConvert FROM Orion.NetObjectTypesExt").Rows
                          select new NetObjectTypeEx(row.Field("EntityType"), row.Field("Name"), row.Field("Prefix"), row.Field("KeyProperty"), row.Field("NameProperty"), (int)row.Field("CanConvert"), row.Field("KeyPropertyIndex"))).ToLookup((NetObjectTypeEx k) => k.EntityType);
            }
            return(result);
        }
 // Token: 0x0600060D RID: 1549 RVA: 0x000245E4 File Offset: 0x000227E4
 private void DeleteOldSubscriptions()
 {
     using (IInformationServiceProxy2 informationServiceProxy = this._swisServiceProxyCreator.Create())
     {
         string text = "SELECT Uri FROM System.Subscription WHERE description = @description";
         foreach (DataRow dataRow in informationServiceProxy.Query(text, new Dictionary <string, object>
         {
             {
                 "description",
                 "NetObjectDowntimeIndication"
             }
         }).Rows.Cast <DataRow>())
         {
             informationServiceProxy.Delete(dataRow[0].ToString());
         }
     }
 }
 // Token: 0x06000371 RID: 881 RVA: 0x00015878 File Offset: 0x00013A78
 private static void DeleteOldSubscriptions()
 {
     using (IInformationServiceProxy2 informationServiceProxy = SwisConnectionProxyPool.GetSystemCreator().Create())
     {
         string text = "SELECT Uri FROM System.Subscription WHERE description = @description";
         foreach (DataRow dataRow in informationServiceProxy.Query(text, new Dictionary <string, object>
         {
             {
                 "description",
                 "OrionCoreIndications"
             }
         }).Rows.Cast <DataRow>())
         {
             informationServiceProxy.Delete(dataRow[0].ToString());
         }
     }
 }
 // Token: 0x060004EC RID: 1260 RVA: 0x0001ED58 File Offset: 0x0001CF58
 public void LoadPreviousThresholdData(int instanceId, string thresholdName)
 {
     using (IInformationServiceProxy2 informationServiceProxy = this._swisFactory.CreateConnection())
     {
         this._previousThresholdValues = informationServiceProxy.Query("SELECT OT.ThresholdOperator,\r\n                    OT.Level1Value,\r\n                    OT.Level1Formula,\r\n                    OT.Level2Value,\r\n                    OT.Level2Formula,\r\n                    OT.WarningPolls,\r\n                    OT.WarningPollsInterval,\r\n                    OT.CriticalPolls,\r\n                    OT.CriticalPollsInterval,\r\n                    OT.WarningEnabled,\r\n                    OT.CriticalEnabled\r\n                    FROM Orion.Thresholds OT\r\n                    WHERE OT.InstanceId = @InstanceId AND OT.Name = @Name", new Dictionary <string, object>
         {
             {
                 "InstanceId",
                 instanceId
             },
             {
                 "Name",
                 thresholdName
             }
         });
     }
 }
 // Token: 0x0600067D RID: 1661 RVA: 0x00026C6C File Offset: 0x00024E6C
 public MaintenancePlan Get(int planID)
 {
     using (IInformationServiceProxy2 informationServiceProxy = this.SwisFactory.Create())
     {
         DataTable dataTable = informationServiceProxy.Query("\r\n                SELECT TOP 1 ID, AccountID, Name, Reason, KeepPolling, Favorite, Enabled, UnmanageDate, RemanageDate\r\n                FROM Orion.MaintenancePlan\r\n                WHERE ID = @PlanID", new Dictionary <string, object>
         {
             {
                 "PlanID",
                 planID
             }
         });
         if (dataTable != null && dataTable.Rows.Count == 1)
         {
             return(MaintenanceModePlanDAL.DataRowToPlan(dataTable.Rows.Cast <DataRow>().FirstOrDefault <DataRow>()));
         }
     }
     return(null);
 }
 // Token: 0x060004ED RID: 1261 RVA: 0x0001EDC0 File Offset: 0x0001CFC0
 private string GetThresholdEntityType(string thresholdName)
 {
     using (IInformationServiceProxy2 informationServiceProxy = this._swisFactory.CreateConnection())
     {
         DataTable dataTable = informationServiceProxy.Query("SELECT EntityType FROM Orion.Thresholds WHERE Name = @Name", new Dictionary <string, object>
         {
             {
                 "Name",
                 thresholdName
             }
         });
         if (dataTable != null && dataTable.Rows.Count > 0)
         {
             return(dataTable.Rows[0]["EntityType"].ToString());
         }
     }
     return(null);
 }
        // Token: 0x06000604 RID: 1540 RVA: 0x00024018 File Offset: 0x00022218
        private void Initialize(object state)
        {
            List <NetObjectDowntime> list = new List <NetObjectDowntime>();

            try
            {
                using (IInformationServiceProxy2 informationServiceProxy = this._swisServiceProxyCreator.Create())
                {
                    DateTime utcNow = DateTime.UtcNow;
                    foreach (object obj in informationServiceProxy.Query("SELECT Uri, Status, InstanceType, AncestorDetailsUrls\r\n                                            FROM System.ManagedEntity\r\n                                            WHERE UnManaged = false").Rows)
                    {
                        DataRow dataRow = (DataRow)obj;
                        try
                        {
                            if (this.IsValid(dataRow))
                            {
                                list.Add(new NetObjectDowntime
                                {
                                    DateTimeFrom = utcNow,
                                    EntityID     = this._swisUriParser.GetEntityId(dataRow["Uri"].ToString()),
                                    NodeID       = this.ExtractStatusID(this.GetNodeIDFromUrl((string[])dataRow["AncestorDetailsUrls"])),
                                    EntityType   = dataRow["InstanceType"].ToString(),
                                    StatusID     = (int)dataRow["Status"]
                                });
                            }
                        }
                        catch (Exception arg)
                        {
                            DowntimeMonitoringNotificationSubscriber.log.Error(string.Format("Unable to create NetObjectDowntime instance from ManagedEntity with Uri '{0}', {1}", dataRow["Uri"], arg));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DowntimeMonitoringNotificationSubscriber.log.ErrorFormat("Exception while initializing NetObjectDowntime table with ManagedEntities. {0}", ex);
            }
            this._netObjectDowntimeDal.Insert(list);
            Scheduler.Instance.Remove("NetObjectDowntimeInitializator");
        }
        // Token: 0x06000945 RID: 2373 RVA: 0x000427C7 File Offset: 0x000409C7
        internal static IEnumerable <KeyValuePair <int, AgentStatus> > GetStatuses(ISwisConnectionProxyCreator swisProxyCreator, int masterEngineId)
        {
            using (IInformationServiceProxy2 proxy = swisProxyCreator.Create())
            {
                DataTable dataTable = proxy.Query("SELECT e.EngineID, a.AgentStatus FROM Orion.EngineProperties (nolock=true) p\r\nINNER JOIN Orion.AgentManagement.Agent (nolock=true) a\r\nON p.PropertyName='AgentId' AND a.AgentId=p.PropertyValue\r\nINNER JOIN Orion.Engines (nolock=true) e\r\nON e.EngineID=p.EngineID AND e.MasterEngineID=@MasterEngineId", new Dictionary <string, object>
                {
                    {
                        "MasterEngineId",
                        masterEngineId
                    }
                });
                foreach (object obj in dataTable.Rows)
                {
                    DataRow dataRow = (DataRow)obj;
                    yield return(new KeyValuePair <int, AgentStatus>((int)dataRow[0], (AgentStatus)dataRow[1]));
                }
                IEnumerator enumerator = null;
            }
            IInformationServiceProxy2 proxy = null;

            yield break;
            yield break;
        }
        // Token: 0x060006F0 RID: 1776 RVA: 0x0002C344 File Offset: 0x0002A544
        public static string GetEntityName(IInformationServiceProxyFactory swisFactory, string entityType)
        {
            if (swisFactory == null)
            {
                throw new ArgumentNullException("swisFactory");
            }
            if (string.IsNullOrEmpty(entityType))
            {
                throw new ArgumentException("entityType");
            }
            string result;

            using (IInformationServiceProxy2 informationServiceProxy = swisFactory.CreateConnection())
            {
                DataTable dataTable = informationServiceProxy.Query("SELECT DisplayName, Name FROM Metadata.Entity WHERE Type = @entityType", new Dictionary <string, object>
                {
                    {
                        "entityType",
                        entityType
                    }
                });
                if (dataTable == null || dataTable.Rows.Count == 0)
                {
                    result = null;
                }
                else
                {
                    string text = dataTable.Rows[0]["DisplayName"].ToString();
                    if (string.IsNullOrEmpty(text))
                    {
                        text = dataTable.Rows[0]["Name"].ToString();
                    }
                    result = text;
                }
            }
            return(result);
        }
Esempio n. 14
0
        // Token: 0x06000661 RID: 1633 RVA: 0x000263EC File Offset: 0x000245EC
        public static AlertIncidentCache Build(IInformationServiceProxy2 swisProxy, int?alertObjectId = null, bool detectIntegration = false)
        {
            if (swisProxy == null)
            {
                throw new ArgumentNullException("swisProxy");
            }
            AlertIncidentCache alertIncidentCache = new AlertIncidentCache();

            try
            {
                if (AlertIncidentCache.isIncidentIntegrationAvailable == null || detectIntegration)
                {
                    DataTable dataTable = swisProxy.Query("\r\nSELECT COUNT(EntityName) AS Cnt\r\nFROM Metadata.EntityMetadata\r\nWHERE EntityName = 'Orion.ESI.AlertIncident'");
                    if (dataTable == null || dataTable.Rows.Count == 0 || Convert.ToUInt32(dataTable.Rows[0][0]) == 0U)
                    {
                        AlertIncidentCache.log.Debug("Incident integration not found");
                        AlertIncidentCache.isIncidentIntegrationAvailable = new bool?(false);
                    }
                    else
                    {
                        AlertIncidentCache.log.Debug("Incident integration found");
                        AlertIncidentCache.isIncidentIntegrationAvailable = new bool?(true);
                    }
                }
                if (!AlertIncidentCache.isIncidentIntegrationAvailable.Value)
                {
                    return(alertIncidentCache);
                }
                DataTable dataTable2;
                if (alertObjectId != null)
                {
                    string text = string.Format("\r\nSELECT AlertObjectID, IncidentNumber, IncidentUrl, AssignedTo\r\nFROM Orion.ESI.AlertIncident\r\nWHERE AlertTriggerState > 0 {0}", "AND AlertObjectID = @aoId");
                    dataTable2 = swisProxy.Query(text, new Dictionary <string, object>
                    {
                        {
                            "aoId",
                            alertObjectId.Value
                        }
                    });
                }
                else
                {
                    string text2 = string.Format("\r\nSELECT AlertObjectID, IncidentNumber, IncidentUrl, AssignedTo\r\nFROM Orion.ESI.AlertIncident\r\nWHERE AlertTriggerState > 0 {0}", string.Empty);
                    dataTable2 = swisProxy.Query(text2);
                }
                foreach (object obj in dataTable2.Rows)
                {
                    DataRow dataRow = (DataRow)obj;
                    int     key     = (int)dataRow[0];
                    AlertIncidentCache.IncidentInfo item = new AlertIncidentCache.IncidentInfo
                    {
                        Number     = (AlertIncidentCache.Get <string>(dataRow, 1) ?? string.Empty),
                        Url        = (AlertIncidentCache.Get <string>(dataRow, 2) ?? string.Empty),
                        AssignedTo = (AlertIncidentCache.Get <string>(dataRow, 3) ?? string.Empty)
                    };
                    List <AlertIncidentCache.IncidentInfo> list;
                    if (!alertIncidentCache.incidentInfoByAlertObjectId.TryGetValue(key, out list))
                    {
                        list = (alertIncidentCache.incidentInfoByAlertObjectId[key] = new List <AlertIncidentCache.IncidentInfo>());
                    }
                    list.Add(item);
                }
            }
            catch (Exception ex)
            {
                AlertIncidentCache.log.Error(ex);
            }
            return(alertIncidentCache);
        }
        // Token: 0x060006EE RID: 1774 RVA: 0x0002C064 File Offset: 0x0002A264
        public static Dictionary <int, string> GetNetObjectsCaptions(IInformationServiceProxyFactory swisFactory, string entityType, int[] instanceIds)
        {
            if (swisFactory == null)
            {
                throw new ArgumentNullException("swisFactory");
            }
            if (string.IsNullOrEmpty(entityType))
            {
                throw new ArgumentException("entityType");
            }
            Dictionary <int, string> dictionary = new Dictionary <int, string>();
            string text = null;

            using (IInformationServiceProxy2 informationServiceProxy = swisFactory.CreateConnection())
            {
                DataTable dataTable = informationServiceProxy.Query("SELECT TOP 1 Prefix, KeyProperty, NameProperty FROM Orion.NetObjectTypes WHERE EntityType = @entityType", new Dictionary <string, object>
                {
                    {
                        "entityType",
                        entityType
                    }
                });
                if (dataTable != null && dataTable.Rows.Count > 0)
                {
                    text = dataTable.Rows[0]["Prefix"].ToString();
                    string text2 = dataTable.Rows[0]["KeyProperty"].ToString();
                    string text3 = dataTable.Rows[0]["NameProperty"].ToString();
                    if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text3))
                    {
                        DataTable dataTable2 = informationServiceProxy.Query(string.Format("SELECT {2},{0} FROM {1} WHERE {2} in ({3})", new object[]
                        {
                            text3,
                            entityType,
                            text2,
                            string.Join <int>(",", instanceIds)
                        }));
                        if (dataTable2 != null)
                        {
                            int ordinal  = dataTable2.Columns[text2].Ordinal;
                            int ordinal2 = dataTable2.Columns[text3].Ordinal;
                            foreach (DataRow dataRow in dataTable2.Rows.Cast <DataRow>())
                            {
                                string text4 = dataRow[ordinal].ToString();
                                int    key;
                                if (!string.IsNullOrEmpty(text4) && int.TryParse(text4, out key))
                                {
                                    dictionary[key] = dataRow[ordinal2].ToString();
                                }
                            }
                        }
                    }
                }
            }
            if (string.IsNullOrEmpty(text))
            {
                text = entityType;
            }
            for (int i = 0; i < instanceIds.Length; i++)
            {
                if (!dictionary.ContainsKey(instanceIds[i]))
                {
                    string value = string.Format("{0}:{1}", text, instanceIds[i]);
                    dictionary.Add(instanceIds[i], value);
                }
            }
            return(dictionary);
        }