Exemplo n.º 1
0
        private static string GetSyslogSwql(
            bool isNodeId,
            bool isDeviceType,
            bool isVendor,
            bool isIp_address,
            bool isHostname,
            bool isSiteId,
            bool isSeverityCode,
            bool isFacilityCode,
            bool isSearchString,
            bool showAck,
            int maxRowCount)
        {
            StringBuilder stringBuilder = new StringBuilder("SELECT TOP {1}\r\n\tTOSTRING(s.MessageID) AS MsgID,\r\n\ts.DateTime AS DateTime,\r\n\t'{0}' AS MessageType,\r\n\tTOSTRING(s.SysLogSeverity) AS Icon,\r\n\ts.Message AS Message,\r\n\t'N' AS ObjectType, \r\n\tTOSTRING(s.NodeID) AS ObjectID, \r\n\t'' AS ObjectID2,\r\n    '' AS NetObjectValue,\r\n\ts.IPAddress AS IPAddress,\r\n\ts.Hostname AS Caption,\r\n\ts.SysLogSeverity*1 AS BackColor,\r\n\ts.Acknowledged AS Acknowledged,\r\n\tTOSTRING(s.NodeID) AS ActiveNetObject,\r\n\t'N' AS NetObjectPrefix,\r\n    s.InstanceSiteId AS SiteId,\r\n    os.Name AS SiteName\r\nFROM Orion.Syslog (nolock=true) AS s\r\nLEFT JOIN Orion.Nodes (nolock=true) AS n ON s.NodeID = n.NodeID AND s.InstanceSiteId = n.InstanceSiteId\r\nLEFT JOIN Orion.Sites (nolock=true) AS os ON s.InstanceSiteId = os.SiteID\r\nWHERE s.DateTime >= @fromDate AND s.DateTime <= @toDate");

            if (isNodeId)
            {
                stringBuilder.Append(" AND s.NodeID=@nodeId ");
            }
            if (!showAck)
            {
                stringBuilder.Append(" AND s.Acknowledged=0 ");
            }
            if (isDeviceType)
            {
                stringBuilder.Append(" AND n.MachineType Like @deviceType ");
            }
            if (isVendor)
            {
                stringBuilder.Append(" AND n.Vendor = @vendor ");
            }
            if (isIp_address)
            {
                stringBuilder.Append(" AND s.IPAddress Like @ip_address ");
            }
            if (isHostname)
            {
                stringBuilder.Append(" AND (s.Hostname Like @hostname OR n.Caption Like @hostname) ");
            }
            if (isSeverityCode)
            {
                stringBuilder.Append(" AND s.SysLogSeverity = @syslog_severity ");
            }
            if (isFacilityCode)
            {
                stringBuilder.Append(" AND s.SysLogFacility = @syslog_facility ");
            }
            if (isSearchString)
            {
                stringBuilder.Append(" AND s.Message Like @search_str ");
            }
            if (isSiteId)
            {
                stringBuilder.Append(" AND s.InstanceSiteId = @siteId ");
            }
            stringBuilder.Append(" ORDER BY s.DateTime DESC");
            return(string.Format(stringBuilder.ToString(), (object)OrionMessagesHelper.GetMessageTypeString((OrionMessageType)3), (object)maxRowCount));
        }
Exemplo n.º 2
0
        private static string GetTrapsSwql(
            bool isNodeId,
            bool isDeviceType,
            bool isVendor,
            bool isIp_address,
            bool isHostname,
            bool isSiteId,
            bool isTrapType,
            bool isCommunity,
            bool isSearchString,
            bool showAck,
            int maxRowCount)
        {
            StringBuilder stringBuilder = new StringBuilder("Select TOP {1}\r\n\tTOSTRING(t.TrapID) AS MsgID,\r\n\tt.DateTime AS DateTime,\r\n\t'{0}' AS MessageType,\r\n\t'' AS Icon,\r\n\tt.Message AS Message,\r\n\t'N' AS ObjectType, \r\n\tTOSTRING(t.NodeID) AS ObjectID, \r\n\t'' AS ObjectID2,\r\n    '' AS NetObjectValue,\r\n\tt.IPAddress AS IPAddress,\r\n\tt.Hostname AS Caption,\r\n\tt.ColorCode AS BackColor,\r\n\tt.Acknowledged AS Acknowledged,\r\n\tTOSTRING(t.NodeID) AS ActiveNetObject,\r\n\t'N' AS NetObjectPrefix,\r\n    t.InstanceSiteId AS SiteId,\r\n    s.Name AS SiteName\r\nFROM Orion.Traps (nolock=true) AS t\r\nLEFT JOIN Orion.Nodes (nolock=true) AS n ON t.NodeID = n.NodeID AND t.InstanceSiteId = n.InstanceSiteId\r\nLEFT JOIN Orion.Sites (nolock=true) AS s ON t.InstanceSiteId = s.SiteID\r\nWHERE t.DateTime >= @fromDate AND t.DateTime <= @toDate");

            if (isNodeId)
            {
                stringBuilder.Append(" AND t.NodeID=@nodeId ");
            }
            if (!showAck)
            {
                stringBuilder.Append(" AND t.Acknowledged=0 ");
            }
            if (isDeviceType)
            {
                stringBuilder.Append(" AND n.MachineType Like @deviceType ");
            }
            if (isVendor)
            {
                stringBuilder.Append(" AND n.Vendor = @vendor ");
            }
            if (isIp_address)
            {
                stringBuilder.Append(" AND t.IPAddress Like @ip_address ");
            }
            if (isTrapType)
            {
                stringBuilder.Append(" AND t.TrapType Like @trap_type ");
            }
            if (isHostname)
            {
                stringBuilder.Append(" AND (t.Hostname Like @hostname OR n.Caption Like @hostname) ");
            }
            if (isCommunity)
            {
                stringBuilder.Append(" AND t.Community Like @trap_community ");
            }
            if (isSearchString)
            {
                stringBuilder.Append(" AND t.Message Like @search_str ");
            }
            if (isSiteId)
            {
                stringBuilder.Append(" AND t.InstanceSiteId = @siteId ");
            }
            stringBuilder.Append(" ORDER BY t.DateTime DESC");
            return(string.Format(stringBuilder.ToString(), (object)OrionMessagesHelper.GetMessageTypeString((OrionMessageType)4), (object)maxRowCount));
        }
Exemplo n.º 3
0
        private static string GetAuditSwql(
            bool isNodeId,
            bool isDeviceType,
            bool isVendor,
            bool isIp_address,
            bool isHostname,
            bool isSiteId,
            OrionMessagesFilter filter)
        {
            StringBuilder stringBuilder1 = new StringBuilder("\r\nSELECT TOP {1}\r\n    TOSTRING(a.AuditEventID) AS MsgID,\r\n    a.TimeLoggedUtc AS DateTime,\r\n    '{0}' AS MessageType,\r\n    '' AS Icon, \r\n    a.AuditEventMessage AS Message, \r\n\ta.NetObjectType AS ObjectType, \r\n\tTOSTRING(a.NetObjectID) AS ObjectID, \r\n    '' AS ObjectID2, \r\n    '' AS NetObjectValue,\r\n    '' AS IPAddress, \r\n    '' AS Caption,\r\n    0 AS BackColor,\r\n    0 AS Acknowledged,\r\n\tTOSTRING(a.NetObjectID) AS ActiveNetObject,\r\n\ta.NetObjectType AS NetObjectPrefix,\r\n    a.InstanceSiteId AS SiteId,\r\n    s.Name AS SiteName\r\nFROM Orion.AuditingEvents (nolock=true) AS a\r\n{3}\r\nLEFT JOIN Orion.Sites (nolock=true) AS s ON a.InstanceSiteId = s.SiteID\r\nWHERE \r\n    a.TimeLoggedUtc >= @fromDate AND a.TimeLoggedUtc <= @toDate\r\n    {2} \r\n ORDER BY a.TimeLoggedUtc DESC");
            bool          flag           = false;
            StringBuilder stringBuilder2 = new StringBuilder();

            if (isNodeId)
            {
                stringBuilder2.Append(" AND a.NetworkNode = @nodeId ");
            }
            if (isDeviceType)
            {
                stringBuilder2.Append(" AND n.MachineType Like @deviceType ");
                flag = true;
            }
            if (isVendor)
            {
                stringBuilder2.Append(" AND n.Vendor = @vendor ");
                flag = true;
            }
            if (isIp_address)
            {
                stringBuilder2.Append(" AND n.IP_Address Like @ip_address ");
                flag = true;
            }
            if (isHostname)
            {
                stringBuilder2.Append(" AND (n.SysName Like @hostname OR n.Caption Like @hostname) ");
                flag = true;
            }
            if (!string.IsNullOrWhiteSpace(filter.get_AuditType()))
            {
                stringBuilder2.Append(" AND a.ActionTypeID = @actionTypeId ");
            }
            if (!string.IsNullOrWhiteSpace(filter.get_Audituser()))
            {
                stringBuilder2.Append(" AND a.AccountID LIKE @accountId ");
            }
            if (!string.IsNullOrWhiteSpace(filter.get_SearchString()))
            {
                stringBuilder2.Append(" AND a.AuditEventMessage LIKE @search_str ");
            }
            if (isSiteId)
            {
                stringBuilder2.Append(" AND a.InstanceSiteId = @siteId");
            }
            return(string.Format(stringBuilder1.ToString(), (object)OrionMessagesHelper.GetMessageTypeString((OrionMessageType)5), (object)filter.get_Count(), (object)stringBuilder2, flag ? (object)" LEFT JOIN Orion.Nodes (nolock=true) AS n ON a.NetworkNode = n.NodeID AND a.InstanceSiteId = n.InstanceSiteId " : (object)string.Empty));
        }
Exemplo n.º 4
0
        private static string GetEventsSwql(
            bool isNodeId,
            bool isDeviceType,
            bool isVendor,
            bool isIp_address,
            bool isHostname,
            bool isSiteId,
            bool isEventType,
            bool isSearchString,
            bool showAck,
            int maxRowCount)
        {
            StringBuilder stringBuilder = new StringBuilder("SELECT TOP {1}\r\n\tTOSTRING(e.EventID) AS MsgID,\r\n\te.EventTime AS DateTime, \r\n\t'{0}' AS MessageType,\r\n\tTOSTRING(e.EventType) AS Icon,\r\n\te.Message AS Message,\r\n\te.NetObjectType AS ObjectType, \r\n\tTOSTRING(e.NetObjectID) AS ObjectID, \r\n\t'' AS ObjectID2,\r\n    e.NetObjectValue AS NetObjectValue,\r\n\tn.IP_Address AS IPAddress,\r\n\t'' AS Caption,\r\n\tISNULL(et.BackColor, 0) AS BackColor,\r\n\te.Acknowledged AS Acknowledged,\r\n\tTOSTRING(e.NetObjectID) AS ActiveNetObject,\r\n\te.NetObjectType AS NetObjectPrefix,\r\n    e.InstanceSiteId AS SiteId,\r\n    s.Name AS SiteName\r\nFROM Orion.Events (nolock=true) AS e\r\nLEFT JOIN Orion.Nodes (nolock=true) AS n ON e.NetworkNode = n.NodeID AND e.InstanceSiteId = n.InstanceSiteId\r\nLEFT JOIN Orion.EventTypes (nolock=true) AS et ON e.EventType = et.EventType AND e.InstanceSiteId = et.InstanceSiteId\r\nLEFT JOIN Orion.Sites (nolock=true) AS s ON s.SiteID = e.InstanceSiteId\r\nWHERE e.EventTime >= @fromDate AND e.EventTime <= @toDate ");

            if (isNodeId)
            {
                stringBuilder.Append(" AND e.NetworkNode=@nodeId ");
            }
            if (!showAck)
            {
                stringBuilder.Append(" AND e.Acknowledged=0 ");
            }
            if (isDeviceType)
            {
                stringBuilder.Append(" AND n.MachineType Like @deviceType ");
            }
            if (isVendor)
            {
                stringBuilder.Append(" AND n.Vendor = @vendor ");
            }
            if (isIp_address)
            {
                stringBuilder.Append(" AND n.IP_Address Like @ip_address ");
            }
            if (isHostname)
            {
                stringBuilder.Append(" AND (n.SysName Like @hostname OR n.Caption Like @hostname) ");
            }
            if (isEventType)
            {
                stringBuilder.Append(" AND e.EventType = @event_type ");
            }
            if (isSearchString)
            {
                stringBuilder.Append(" AND e.Message Like @search_str ");
            }
            if (isSiteId)
            {
                stringBuilder.Append(" AND e.InstanceSiteId = @siteId ");
            }
            stringBuilder.Append(" ORDER BY e.EventTime DESC");
            return(string.Format(stringBuilder.ToString(), (object)OrionMessagesHelper.GetMessageTypeString((OrionMessageType)2), (object)maxRowCount));
        }