// Token: 0x060007B3 RID: 1971 RVA: 0x0003728C File Offset: 0x0003548C
        public Dictionary <string, string> GetNetworkDeviceTypes(List <int> limitationIDs)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            using (SqlCommand textCommand = SqlHelper.GetTextCommand(Limitation.LimitSQL(" SELECT Vendor + '%' AS Value, '' AS Name \r\n FROM Nodes \r\n WHERE (Vendor <> '')  \r\n GROUP BY Vendor HAVING (Count(Vendor) > 1) \r\n UNION\r\n SELECT MachineType AS Value, MachineType AS Name \r\n FROM Nodes\r\n WHERE MachineType <> '' \r\n GROUP BY MachineType ", limitationIDs)))
            {
                using (IDataReader dataReader = SqlHelper.ExecuteReader(textCommand))
                {
                    int    ordinal  = dataReader.GetOrdinal("Value");
                    int    ordinal2 = dataReader.GetOrdinal("Name");
                    string libcode_VB0_;
                    using (LocaleThreadState.EnsurePrimaryLocale())
                    {
                        libcode_VB0_ = Resources.LIBCODE_VB0_61;
                        goto IL_97;
                    }
IL_53:
                    string text = dataReader.GetString(ordinal2);
                    string @string = dataReader.GetString(ordinal);
                    text = ((!string.IsNullOrEmpty(text)) ? text : string.Format(libcode_VB0_, @string.Substring(0, @string.Length - 1)));
                    dictionary.Add(@string, text);
IL_97:
                    if (dataReader.Read())
                    {
                        goto IL_53;
                    }
                }
            }
            return(dictionary);
        }
        public static DataTable GetEventTypesTable()
        {
            DataTable dataTable = (DataTable)null;

            using (SqlCommand textCommand = SqlHelper.GetTextCommand(Limitation.LimitSQL("SELECT DISTINCT Name, EventType FROM EventTypes ORDER BY Name", Array.Empty <Limitation>())))
                dataTable = SqlHelper.ExecuteDataTable(textCommand);
            dataTable.TableName = "EventTypesTable";
            return(dataTable);
        }
        public List <string> GetAllVendors(List <int> limitationIDs)
        {
            List <string> stringList = new List <string>();

            using (SqlCommand textCommand = SqlHelper.GetTextCommand(Limitation.LimitSQL("SELECT DISTINCT Vendor \r\n From Nodes WHERE (Vendor <> '')", (IEnumerable <int>)limitationIDs)))
            {
                using (IDataReader dataReader = SqlHelper.ExecuteReader(textCommand))
                {
                    while (dataReader.Read())
                    {
                        stringList.Add(DatabaseFunctions.GetString(dataReader, "Vendor"));
                    }
                }
            }
            return(stringList);
        }
        public static DataTable GetEventSummaryTable(
            int netObjectID,
            string netObjectType,
            DateTime fromDate,
            DateTime toDate,
            List <int> limitationIDs)
        {
            DataTable dataTable = (DataTable)null;

            using (SqlCommand textCommand = SqlHelper.GetTextCommand(string.Empty))
            {
                StringBuilder stringBuilder = new StringBuilder("SELECT Events.EventType as EventType, EventTypes.Name as Name, EventTypes.BackColor as BackColor, Count(Events.EventType) as Total  \r\n                                                        FROM EventTypes \r\n                                                        INNER JOIN Events WITH(NOLOCK) ON EventTypes.EventType = Events.EventType\r\n                                                        LEFT JOIN NodesData WITH(NOLOCK) ON Events.NetworkNode = NodesData.NodeID \r\n                                                        LEFT JOIN NodesCustomProperties WITH(NOLOCK) ON Events.NetworkNode = NodesCustomProperties.NodeID \r\n                                                        WHERE Events.Acknowledged='false' \r\n                                                        AND Events.EventTime >= @fromDate AND Events.EventTime <= @toDate ");
                textCommand.Parameters.Add(new SqlParameter("@fromDate", (object)fromDate));
                textCommand.Parameters.Add(new SqlParameter("@toDate", (object)toDate));
                if (netObjectID >= 0 && !string.IsNullOrEmpty(netObjectType) && netObjectType.Equals("N", StringComparison.OrdinalIgnoreCase))
                {
                    stringBuilder.Append(" AND ((Events.NetObjectID=@netObjectID AND Events.NetObjectType LIKE @netObjectType) OR Events.NetworkNode=@netObjectID)");
                    textCommand.Parameters.Add(new SqlParameter("@netObjectID", (object)netObjectID));
                    textCommand.Parameters.Add(new SqlParameter("@netObjectType", (object)netObjectType));
                }
                else
                {
                    if (netObjectID >= 0)
                    {
                        stringBuilder.Append(" AND Events.NetObjectID=@netObjectID");
                        textCommand.Parameters.Add(new SqlParameter("@netObjectID", (object)netObjectID));
                    }
                    if (!string.IsNullOrEmpty(netObjectType))
                    {
                        stringBuilder.Append(" AND Events.NetObjectType LIKE @netObjectType");
                        SqlParameterCollection parameters   = textCommand.Parameters;
                        SqlParameter           sqlParameter = new SqlParameter("@netObjectType", SqlDbType.VarChar, 10);
                        sqlParameter.Value = (object)netObjectType;
                        parameters.Add(sqlParameter);
                    }
                }
                stringBuilder.Append(" GROUP BY Events.EventType, EventTypes.Name, EventTypes.BackColor ORDER BY Events.EventType");
                textCommand.CommandText = Limitation.LimitSQL(stringBuilder.ToString(), (IEnumerable <int>)limitationIDs);
                dataTable = SqlHelper.ExecuteDataTable(textCommand);
            }
            dataTable.TableName = "EventSummaryTable";
            return(dataTable);
        }
        public Dictionary <string, string> GetNetworkDeviceTypes(List <int> limitationIDs)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            using (SqlCommand textCommand = SqlHelper.GetTextCommand(Limitation.LimitSQL(" SELECT Vendor + '%' AS Value, '' AS Name \r\n FROM Nodes \r\n WHERE (Vendor <> '')  \r\n GROUP BY Vendor HAVING (Count(Vendor) > 1) \r\n UNION\r\n SELECT MachineType AS Value, MachineType AS Name \r\n FROM Nodes\r\n WHERE MachineType <> '' \r\n GROUP BY MachineType ", (IEnumerable <int>)limitationIDs)))
            {
                using (IDataReader dataReader = SqlHelper.ExecuteReader(textCommand))
                {
                    int    ordinal1 = dataReader.GetOrdinal("Value");
                    int    ordinal2 = dataReader.GetOrdinal("Name");
                    string libcodeVb061;
                    using (LocaleThreadState.EnsurePrimaryLocale())
                        libcodeVb061 = Resources.get_LIBCODE_VB0_61();
                    while (dataReader.Read())
                    {
                        string str1 = dataReader.GetString(ordinal2);
                        string key  = dataReader.GetString(ordinal1);
                        string str2 = !string.IsNullOrEmpty(str1) ? str1 : string.Format(libcodeVb061, (object)key.Substring(0, key.Length - 1));
                        dictionary.Add(key, str2);
                    }
                }
            }
            return(dictionary);
        }
        public static DataTable GetEvents(GetEventsParameter param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            DataTable     dataTable     = (DataTable)null;
            StringBuilder stringBuilder = new StringBuilder();

            using (SqlCommand textCommand = SqlHelper.GetTextCommand(string.Empty))
            {
                stringBuilder.Append("SELECT TOP (@maxRecords) NetObjectType, NetObjectID, NetObjectID2, NetObjectValue, EventID, Acknowledged, EventTime, \r\n                             Events.EventType as EventType, Message, ISNULL(EventTypes.BackColor, 0) as BackColor, NodesData.NodeID as LinkNodeID\r\n                             FROM Events WITH(NOLOCK)\r\n                             LEFT JOIN NodesData WITH(NOLOCK) ON Events.NetworkNode = NodesData.NodeID\r\n                             LEFT JOIN NodesCustomProperties WITH(NOLOCK) ON Events.NetworkNode = NodesCustomProperties.NodeID\r\n                             LEFT JOIN EventTypes ON Events.EventType = EventTypes.EventType");
                textCommand.Parameters.Add(new SqlParameter("@maxRecords", (object)param.get_MaxRecords()));
                List <string> stringList = new List <string>();
                if (!param.get_IncludeAcknowledged())
                {
                    stringList.Add("Acknowledged='false'");
                }
                if (param.get_NodeId() >= 0)
                {
                    stringList.Add(" Events.NetworkNode=@nodeID");
                    textCommand.Parameters.Add(new SqlParameter("@nodeID", (object)param.get_NodeId()));
                }
                if (param.get_NetObjectId() >= 0)
                {
                    stringList.Add(" Events.NetObjectID=@netObjectID");
                    textCommand.Parameters.Add(new SqlParameter("@netObjectID", (object)param.get_NetObjectId()));
                }
                if (!string.IsNullOrEmpty(param.get_NetObjectType()))
                {
                    stringList.Add(" Events.NetObjectType Like @netObjectType");
                    SqlParameterCollection parameters   = textCommand.Parameters;
                    SqlParameter           sqlParameter = new SqlParameter("@netObjectType", SqlDbType.VarChar, 10);
                    sqlParameter.Value = (object)param.get_NetObjectType();
                    parameters.Add(sqlParameter);
                }
                if (!string.IsNullOrEmpty(param.get_DeviceType()))
                {
                    stringList.Add(" (NodesData.MachineType Like @deviceType)");
                    textCommand.Parameters.Add(new SqlParameter("@deviceType", (object)param.get_DeviceType()));
                }
                if (param.get_EventType() > 0)
                {
                    stringList.Add(" Events.EventType=@eventType");
                    textCommand.Parameters.Add(new SqlParameter("@eventType", (object)param.get_EventType().ToString()));
                }
                if (param.get_FromDate().HasValue&& param.get_ToDate().HasValue)
                {
                    stringList.Add(" EventTime >= @fromDate AND EventTime <= @toDate");
                    textCommand.Parameters.Add(new SqlParameter("@fromDate", (object)param.get_FromDate()));
                    textCommand.Parameters.Add(new SqlParameter("@toDate", (object)param.get_ToDate()));
                }
                if (stringList.Count > 0)
                {
                    stringBuilder.Append(" WHERE");
                    if (stringList.Count == 1)
                    {
                        stringBuilder.AppendFormat(" {0}", (object)stringList[0]);
                    }
                    else
                    {
                        stringBuilder.AppendFormat(" {0}", (object)stringList[0]);
                        for (int index = 1; index < stringList.Count; ++index)
                        {
                            stringBuilder.AppendFormat(" AND {0}", (object)stringList[index]);
                        }
                    }
                }
                stringBuilder.Append(" ORDER BY EventID DESC");
                textCommand.CommandText = Limitation.LimitSQL(stringBuilder.ToString(), (IEnumerable <int>)param.get_LimitationIDs());
                dataTable = SqlHelper.ExecuteDataTable(textCommand);
            }
            dataTable.TableName = "EventsTable";
            return(dataTable);
        }
Example #7
0
        // Token: 0x0600078B RID: 1931 RVA: 0x00033FF4 File Offset: 0x000321F4
        public static DataTable GetEvents(GetEventsParameter param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            DataTable     dataTable     = null;
            StringBuilder stringBuilder = new StringBuilder();

            using (SqlCommand textCommand = SqlHelper.GetTextCommand(string.Empty))
            {
                stringBuilder.Append("SELECT TOP (@maxRecords) NetObjectType, NetObjectID, NetObjectID2, NetObjectValue, EventID, Acknowledged, EventTime, \r\n                             Events.EventType as EventType, Message, ISNULL(EventTypes.BackColor, 0) as BackColor, NodesData.NodeID as LinkNodeID\r\n                             FROM Events WITH(NOLOCK)\r\n                             LEFT JOIN NodesData WITH(NOLOCK) ON Events.NetworkNode = NodesData.NodeID\r\n                             LEFT JOIN NodesCustomProperties WITH(NOLOCK) ON Events.NetworkNode = NodesCustomProperties.NodeID\r\n                             LEFT JOIN EventTypes ON Events.EventType = EventTypes.EventType");
                textCommand.Parameters.Add(new SqlParameter("@maxRecords", param.MaxRecords));
                List <string> list = new List <string>();
                if (!param.IncludeAcknowledged)
                {
                    list.Add("Acknowledged='false'");
                }
                if (param.NodeId >= 0)
                {
                    list.Add(" Events.NetworkNode=@nodeID");
                    textCommand.Parameters.Add(new SqlParameter("@nodeID", param.NodeId));
                }
                if (param.NetObjectId >= 0)
                {
                    list.Add(" Events.NetObjectID=@netObjectID");
                    textCommand.Parameters.Add(new SqlParameter("@netObjectID", param.NetObjectId));
                }
                if (!string.IsNullOrEmpty(param.NetObjectType))
                {
                    list.Add(" Events.NetObjectType Like @netObjectType");
                    textCommand.Parameters.Add(new SqlParameter("@netObjectType", SqlDbType.VarChar, 10)
                    {
                        Value = param.NetObjectType
                    });
                }
                if (!string.IsNullOrEmpty(param.DeviceType))
                {
                    list.Add(" (NodesData.MachineType Like @deviceType)");
                    textCommand.Parameters.Add(new SqlParameter("@deviceType", param.DeviceType));
                }
                if (param.EventType > 0)
                {
                    list.Add(" Events.EventType=@eventType");
                    textCommand.Parameters.Add(new SqlParameter("@eventType", param.EventType.ToString()));
                }
                if (param.FromDate != null && param.ToDate != null)
                {
                    list.Add(" EventTime >= @fromDate AND EventTime <= @toDate");
                    textCommand.Parameters.Add(new SqlParameter("@fromDate", param.FromDate));
                    textCommand.Parameters.Add(new SqlParameter("@toDate", param.ToDate));
                }
                if (list.Count > 0)
                {
                    stringBuilder.Append(" WHERE");
                    if (list.Count == 1)
                    {
                        stringBuilder.AppendFormat(" {0}", list[0]);
                    }
                    else
                    {
                        stringBuilder.AppendFormat(" {0}", list[0]);
                        for (int i = 1; i < list.Count; i++)
                        {
                            stringBuilder.AppendFormat(" AND {0}", list[i]);
                        }
                    }
                }
                stringBuilder.Append(" ORDER BY EventID DESC");
                textCommand.CommandText = Limitation.LimitSQL(stringBuilder.ToString(), param.LimitationIDs);
                dataTable = SqlHelper.ExecuteDataTable(textCommand);
            }
            dataTable.TableName = "EventsTable";
            return(dataTable);
        }