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); } }
public static DataTable GetAuditingTypesTable() { using (IInformationServiceProxy2 iinformationServiceProxy2 = AuditingDAL.creator.Create()) { DataTable dataTable = InformationServiceProxyExtensions.QueryWithAppendedErrors((IInformationServiceProxy)iinformationServiceProxy2, "SELECT DISTINCT ActionTypeID, ActionType, ActionTypeDisplayName FROM [Orion].[AuditingActionTypes] (nolock=true)", SwisFederationInfo.get_IsFederationEnabled()); dataTable.TableName = "AuditingTypesTable"; return(dataTable); } }