예제 #1
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);
        }
        public static AlertIncidentCache Build(
            IInformationServiceProxy2 swisProxy,
            int?alertObjectId      = null,
            bool detectIntegration = false)
        {
            if (swisProxy == null)
            {
                throw new ArgumentNullException(nameof(swisProxy));
            }
            AlertIncidentCache alertIncidentCache = new AlertIncidentCache();

            try
            {
                if (!AlertIncidentCache.isIncidentIntegrationAvailable.HasValue | detectIntegration)
                {
                    DataTable dataTable = ((IInformationServiceProxy)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((object)"Incident integration not found");
                        AlertIncidentCache.isIncidentIntegrationAvailable = new bool?(false);
                    }
                    else
                    {
                        AlertIncidentCache.log.Debug((object)"Incident integration found");
                        AlertIncidentCache.isIncidentIntegrationAvailable = new bool?(true);
                    }
                }
                if (!AlertIncidentCache.isIncidentIntegrationAvailable.Value)
                {
                    return(alertIncidentCache);
                }
                DataTable dataTable1;
                if (alertObjectId.HasValue)
                {
                    string str = string.Format("\r\nSELECT AlertObjectID, IncidentNumber, IncidentUrl, AssignedTo\r\nFROM Orion.ESI.AlertIncident\r\nWHERE AlertTriggerState > 0 {0}", (object)"AND AlertObjectID = @aoId");
                    dataTable1 = ((IInformationServiceProxy)swisProxy).Query(str, (IDictionary <string, object>) new Dictionary <string, object>()
                    {
                        {
                            "aoId",
                            (object)alertObjectId.Value
                        }
                    });
                }
                else
                {
                    string str = string.Format("\r\nSELECT AlertObjectID, IncidentNumber, IncidentUrl, AssignedTo\r\nFROM Orion.ESI.AlertIncident\r\nWHERE AlertTriggerState > 0 {0}", (object)string.Empty);
                    dataTable1 = ((IInformationServiceProxy)swisProxy).Query(str);
                }
                foreach (DataRow row in (InternalDataCollectionBase)dataTable1.Rows)
                {
                    int key = (int)row[0];
                    AlertIncidentCache.IncidentInfo incidentInfo = new AlertIncidentCache.IncidentInfo()
                    {
                        Number     = AlertIncidentCache.Get <string>(row, 1) ?? string.Empty,
                        Url        = AlertIncidentCache.Get <string>(row, 2) ?? string.Empty,
                        AssignedTo = AlertIncidentCache.Get <string>(row, 3) ?? string.Empty
                    };
                    List <AlertIncidentCache.IncidentInfo> incidentInfoList;
                    if (!alertIncidentCache.incidentInfoByAlertObjectId.TryGetValue(key, out incidentInfoList))
                    {
                        alertIncidentCache.incidentInfoByAlertObjectId[key] = incidentInfoList = new List <AlertIncidentCache.IncidentInfo>();
                    }
                    incidentInfoList.Add(incidentInfo);
                }
            }
            catch (Exception ex)
            {
                AlertIncidentCache.log.Error((object)ex);
            }
            return(alertIncidentCache);
        }