// Token: 0x0600084F RID: 2127 RVA: 0x0003B338 File Offset: 0x00039538 public static DataTable GetOrionMessagesTable(OrionMessagesFilter filter) { if (!filter.IncludeAlerts && !filter.IncludeEvents && !filter.IncludeSyslogs && !filter.IncludeTraps && !filter.IncludeAudits) { return(null); } string arg = "SELECT MsgID, DateTime, MessageType, Icon, Message, ObjectType,\r\nObjectID, ObjectID2, NetObjectValue, IPAddress, Caption, BackColor, \r\nAcknowledged, ActiveNetObject, NetObjectPrefix, SiteId, SiteName FROM"; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("SELECT TOP {0}\r\nMsgID, DateTime, MessageType, Icon, Message, ObjectType,\r\nObjectID, ObjectID2, NetObjectValue, IPAddress, Caption, BackColor, \r\nAcknowledged, ActiveNetObject, NetObjectPrefix, SiteId, SiteName FROM (", filter.Count); string format = " {1} ( {0} )"; bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; bool flag5 = false; bool flag6 = false; int num = 0; if (!string.IsNullOrEmpty(filter.AlertType)) { string text = filter.AlertType; if (text.StartsWith("AA-")) { text = text.Substring("AA-".Length); } int num2; if (int.TryParse(text, out num2)) { num = num2; } } if (filter.NodeId != null) { flag = true; } else if (!string.IsNullOrEmpty(filter.DeviceType)) { flag2 = true; } else if (!string.IsNullOrEmpty(filter.Vendor)) { flag3 = true; } else if (!string.IsNullOrEmpty(filter.IpAddress)) { flag4 = true; } else if (!string.IsNullOrEmpty(filter.Hostname)) { flag5 = true; } if (filter.SiteID != null) { flag6 = true; } if (filter.IncludeAlerts) { stringBuilder.AppendFormat(format, OrionMessagesDAL.GetNewAlertsSwql(flag, flag2, flag3, flag4, flag5, flag6, num > 0, !string.IsNullOrEmpty(filter.SearchString), filter.ShowAcknowledged, filter.AlertCategoryLimitation, filter.Count), arg); format = " UNION ( {1} ( {0} ) ) "; } if (filter.IncludeAudits) { stringBuilder.AppendFormat(format, OrionMessagesDAL.GetAuditSwql(flag, flag2, flag3, flag4, flag5, flag6, filter), arg); format = " UNION ( {1} ( {0} ) ) "; } if (filter.IncludeEvents) { stringBuilder.AppendFormat(format, OrionMessagesDAL.GetEventsSwql(flag, flag2, flag3, flag4, flag5, flag6, !string.IsNullOrEmpty(filter.EventType), !string.IsNullOrEmpty(filter.SearchString), filter.ShowAcknowledged, filter.Count), arg); format = " UNION ( {1} ( {0} ) ) "; } if (filter.IncludeSyslogs) { stringBuilder.AppendFormat(format, OrionMessagesDAL.GetSyslogSwql(flag, flag2, flag3, flag4, flag5, flag6, filter.SyslogSeverity < byte.MaxValue, filter.SyslogFacility < byte.MaxValue, !string.IsNullOrEmpty(filter.SearchString), filter.ShowAcknowledged, filter.Count), arg); format = " UNION ( {1} ( {0} ) ) "; } if (filter.IncludeTraps) { stringBuilder.AppendFormat(format, OrionMessagesDAL.GetTrapsSwql(flag, flag2, flag3, flag4, flag5, flag6, !string.IsNullOrEmpty(filter.TrapType), !string.IsNullOrEmpty(filter.TrapCommunity), !string.IsNullOrEmpty(filter.SearchString), filter.ShowAcknowledged, filter.Count), arg); } stringBuilder.AppendLine(")a ORDER BY a.DateTime DESC"); DataTable result; using (IInformationServiceProxy2 informationServiceProxy = OrionMessagesDAL.creator.Create()) { Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary.Add("fromDate", filter.FromDate); dictionary.Add("toDate", filter.ToDate); if (flag) { dictionary.Add("nodeId", filter.NodeId); } if (flag2) { dictionary.Add("deviceType", filter.DeviceType); } if (flag3) { dictionary.Add("vendor", filter.Vendor); } if (flag4) { dictionary.Add("ip_address", string.Format("%{0}%", CommonHelper.FormatFilter(IPAddressHelper.ToStringIp(filter.IpAddress)))); } if (flag5) { dictionary.Add("hostname", string.Format("%{0}%", CommonHelper.FormatFilter(filter.Hostname))); } if (flag6) { dictionary.Add("siteId", filter.SiteID); } if (!string.IsNullOrEmpty(filter.EventType)) { dictionary.Add("event_type", filter.EventType); } if (filter.SyslogSeverity < 255) { dictionary.Add("syslog_severity", filter.SyslogSeverity); } if (filter.SyslogFacility < 255) { dictionary.Add("syslog_facility", filter.SyslogFacility); } if (!string.IsNullOrEmpty(filter.TrapType)) { dictionary.Add("trap_type", filter.TrapType); } if (!string.IsNullOrEmpty(filter.TrapCommunity)) { dictionary.Add("trap_community", filter.TrapCommunity); } if (filter.IncludeAlerts && num > 0) { dictionary.Add("newAlert_id", num); } if (filter.IncludeAlerts && !string.IsNullOrEmpty(filter.AlertCategoryLimitation)) { dictionary.Add("alertCategoryLimitation", filter.AlertCategoryLimitation); } if (!string.IsNullOrWhiteSpace(filter.AuditType)) { dictionary.Add("actionTypeId", int.Parse(filter.AuditType)); } if (!string.IsNullOrWhiteSpace(filter.Audituser)) { dictionary.Add("accountId", filter.Audituser); } if (!string.IsNullOrEmpty(filter.SearchString)) { dictionary.Add("search_str", string.Format("%{0}%", filter.SearchString)); } DataTable dataTable = informationServiceProxy.QueryWithAppendedErrors(stringBuilder.ToString(), dictionary, SwisFederationInfo.IsFederationEnabled); dataTable.TableName = "OrionMessages"; IEnumerableExtensions.Iterate <DataRow>(dataTable.Rows.OfType <DataRow>(), delegate(DataRow r) { r["DateTime"] = ((DateTime)r["DateTime"]).ToLocalTime(); }); result = dataTable; } return(result); }
public static DataTable GetOrionMessagesTable(OrionMessagesFilter filter) { if (!filter.get_IncludeAlerts() && !filter.get_IncludeEvents() && (!filter.get_IncludeSyslogs() && !filter.get_IncludeTraps()) && !filter.get_IncludeAudits()) { return((DataTable)null); } string str = "SELECT MsgID, DateTime, MessageType, Icon, Message, ObjectType,\r\nObjectID, ObjectID2, NetObjectValue, IPAddress, Caption, BackColor, \r\nAcknowledged, ActiveNetObject, NetObjectPrefix, SiteId, SiteName FROM"; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("SELECT TOP {0}\r\nMsgID, DateTime, MessageType, Icon, Message, ObjectType,\r\nObjectID, ObjectID2, NetObjectValue, IPAddress, Caption, BackColor, \r\nAcknowledged, ActiveNetObject, NetObjectPrefix, SiteId, SiteName FROM (", (object)filter.get_Count()); string format = " {1} ( {0} )"; bool isNodeId = false; bool isDeviceType = false; bool isVendor = false; bool isIp_address = false; bool isHostname = false; bool isSiteId = false; int num = 0; if (!string.IsNullOrEmpty(filter.get_AlertType())) { string s = filter.get_AlertType(); if (s.StartsWith("AA-")) { s = s.Substring("AA-".Length); } int result; if (int.TryParse(s, out result)) { num = result; } } if (filter.get_NodeId().HasValue) { isNodeId = true; } else if (!string.IsNullOrEmpty(filter.get_DeviceType())) { isDeviceType = true; } else if (!string.IsNullOrEmpty(filter.get_Vendor())) { isVendor = true; } else if (!string.IsNullOrEmpty(filter.get_IpAddress())) { isIp_address = true; } else if (!string.IsNullOrEmpty(filter.get_Hostname())) { isHostname = true; } if (filter.get_SiteID().HasValue) { isSiteId = true; } if (filter.get_IncludeAlerts()) { stringBuilder.AppendFormat(format, (object)OrionMessagesDAL.GetNewAlertsSwql(isNodeId, isDeviceType, isVendor, isIp_address, isHostname, isSiteId, num > 0, !string.IsNullOrEmpty(filter.get_SearchString()), filter.get_ShowAcknowledged(), filter.get_AlertCategoryLimitation(), filter.get_Count()), (object)str); format = " UNION ( {1} ( {0} ) ) "; } if (filter.get_IncludeAudits()) { stringBuilder.AppendFormat(format, (object)OrionMessagesDAL.GetAuditSwql(isNodeId, isDeviceType, isVendor, isIp_address, isHostname, isSiteId, filter), (object)str); format = " UNION ( {1} ( {0} ) ) "; } if (filter.get_IncludeEvents()) { stringBuilder.AppendFormat(format, (object)OrionMessagesDAL.GetEventsSwql(isNodeId, isDeviceType, isVendor, isIp_address, isHostname, isSiteId, !string.IsNullOrEmpty(filter.get_EventType()), !string.IsNullOrEmpty(filter.get_SearchString()), filter.get_ShowAcknowledged(), filter.get_Count()), (object)str); format = " UNION ( {1} ( {0} ) ) "; } if (filter.get_IncludeSyslogs()) { stringBuilder.AppendFormat(format, (object)OrionMessagesDAL.GetSyslogSwql(isNodeId, isDeviceType, isVendor, isIp_address, isHostname, isSiteId, filter.get_SyslogSeverity() < byte.MaxValue, filter.get_SyslogFacility() < byte.MaxValue, !string.IsNullOrEmpty(filter.get_SearchString()), filter.get_ShowAcknowledged(), filter.get_Count()), (object)str); format = " UNION ( {1} ( {0} ) ) "; } if (filter.get_IncludeTraps()) { stringBuilder.AppendFormat(format, (object)OrionMessagesDAL.GetTrapsSwql(isNodeId, isDeviceType, isVendor, isIp_address, isHostname, isSiteId, !string.IsNullOrEmpty(filter.get_TrapType()), !string.IsNullOrEmpty(filter.get_TrapCommunity()), !string.IsNullOrEmpty(filter.get_SearchString()), filter.get_ShowAcknowledged(), filter.get_Count()), (object)str); } stringBuilder.AppendLine(")a ORDER BY a.DateTime DESC"); using (IInformationServiceProxy2 iinformationServiceProxy2 = OrionMessagesDAL.creator.Create()) { Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary.Add("fromDate", (object)filter.get_FromDate()); dictionary.Add("toDate", (object)filter.get_ToDate()); if (isNodeId) { dictionary.Add("nodeId", (object)filter.get_NodeId()); } if (isDeviceType) { dictionary.Add("deviceType", (object)filter.get_DeviceType()); } if (isVendor) { dictionary.Add("vendor", (object)filter.get_Vendor()); } if (isIp_address) { dictionary.Add("ip_address", (object)string.Format("%{0}%", (object)CommonHelper.FormatFilter(IPAddressHelper.ToStringIp(filter.get_IpAddress())))); } if (isHostname) { dictionary.Add("hostname", (object)string.Format("%{0}%", (object)CommonHelper.FormatFilter(filter.get_Hostname()))); } if (isSiteId) { dictionary.Add("siteId", (object)filter.get_SiteID()); } if (!string.IsNullOrEmpty(filter.get_EventType())) { dictionary.Add("event_type", (object)filter.get_EventType()); } if (filter.get_SyslogSeverity() < byte.MaxValue) { dictionary.Add("syslog_severity", (object)filter.get_SyslogSeverity()); } if (filter.get_SyslogFacility() < byte.MaxValue) { dictionary.Add("syslog_facility", (object)filter.get_SyslogFacility()); } if (!string.IsNullOrEmpty(filter.get_TrapType())) { dictionary.Add("trap_type", (object)filter.get_TrapType()); } if (!string.IsNullOrEmpty(filter.get_TrapCommunity())) { dictionary.Add("trap_community", (object)filter.get_TrapCommunity()); } if (filter.get_IncludeAlerts() && num > 0) { dictionary.Add("newAlert_id", (object)num); } if (filter.get_IncludeAlerts() && !string.IsNullOrEmpty(filter.get_AlertCategoryLimitation())) { dictionary.Add("alertCategoryLimitation", (object)filter.get_AlertCategoryLimitation()); } if (!string.IsNullOrWhiteSpace(filter.get_AuditType())) { dictionary.Add("actionTypeId", (object)int.Parse(filter.get_AuditType())); } if (!string.IsNullOrWhiteSpace(filter.get_Audituser())) { dictionary.Add("accountId", (object)filter.get_Audituser()); } if (!string.IsNullOrEmpty(filter.get_SearchString())) { dictionary.Add("search_str", (object)string.Format("%{0}%", (object)filter.get_SearchString())); } DataTable dataTable = InformationServiceProxyExtensions.QueryWithAppendedErrors((IInformationServiceProxy)iinformationServiceProxy2, stringBuilder.ToString(), dictionary, SwisFederationInfo.get_IsFederationEnabled()); dataTable.TableName = "OrionMessages"; IEnumerableExtensions.Iterate <DataRow>((IEnumerable <M0>)dataTable.Rows.OfType <DataRow>(), (Action <M0>)(r => r["DateTime"] = (object)((DateTime)r["DateTime"]).ToLocalTime())); return(dataTable); } }