Exemplo n.º 1
0
        /// <summary>
        /// Method to get trend alarms
        /// </summary>
        public List <TrendAlarmInfo> GetTrendAlarms()
        {
            var alarms  = new List <TrendAlarmInfo>();
            var sqlText = @"
            ;WITH Alarms AS
            (
                SELECT TT.*,TA.[DevID],L.[LscName],DT.[TypeID] AS DevTypeID,DT.[TypeName] AS DevTypeName
                FROM [dbo].[TA_TrendAlarm] TT
                INNER JOIN [dbo].[TM_AIC] TA ON TT.[LscID] = TA.[LscID] AND TT.[NodeID] = TA.[AicID]
                INNER JOIN [dbo].[TM_DEV] TD ON TA.[LscID] = TD.[LscID] AND TA.[DevID] = TD.[DevID]
                INNER JOIN [dbo].[TM_LSC] L ON TD.[LscID] = L.[LscID]
                LEFT OUTER JOIN [dbo].[TC_DeviceType] DT ON TD.[DevTypeID] = DT.[TypeID]
            )
            SELECT [LscID],[LscName],[Area1Name],[Area2Name],[Area3Name],[StaName],[DevID],[DevName],[NodeID],
            [NodeName],[DevTypeID],[DevTypeName],[AlarmType],[AlarmLevel],[StartValue],[AlarmValue],[DiffValue],
            [StartTime],[AlarmTime],[ConfirmName],[ConfirmTime],[EndName],[EndTime] FROM Alarms;";

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, sqlText, null)) {
                while (rdr.Read())
                {
                    var alarm = new TrendAlarmInfo();
                    alarm.LscID       = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                    alarm.LscName     = ComUtility.DBNullStringHandler(rdr["LscName"]);
                    alarm.Area1Name   = ComUtility.DBNullStringHandler(rdr["Area1Name"]);
                    alarm.Area2Name   = ComUtility.DBNullStringHandler(rdr["Area2Name"]);
                    alarm.Area3Name   = ComUtility.DBNullStringHandler(rdr["Area3Name"]);
                    alarm.StaName     = ComUtility.DBNullStringHandler(rdr["StaName"]);
                    alarm.DevID       = ComUtility.DBNullInt32Handler(rdr["DevID"]);
                    alarm.DevName     = ComUtility.DBNullStringHandler(rdr["DevName"]);
                    alarm.NodeID      = ComUtility.DBNullInt32Handler(rdr["NodeID"]);
                    alarm.NodeName    = ComUtility.DBNullStringHandler(rdr["NodeName"]);
                    alarm.DevTypeID   = ComUtility.DBNullInt32Handler(rdr["DevTypeID"]);
                    alarm.DevTypeName = ComUtility.DBNullStringHandler(rdr["DevTypeName"]);
                    alarm.AlarmType   = ComUtility.DBNullStringHandler(rdr["AlarmType"]);
                    alarm.AlarmLevel  = ComUtility.DBNullAlarmLevelHandler(rdr["AlarmLevel"]);
                    alarm.StartValue  = ComUtility.DBNullFloatHandler(rdr["StartValue"]);
                    alarm.AlarmValue  = ComUtility.DBNullFloatHandler(rdr["AlarmValue"]);
                    alarm.DiffValue   = ComUtility.DBNullFloatHandler(rdr["DiffValue"]);
                    alarm.StartTime   = ComUtility.DBNullDateTimeHandler(rdr["StartTime"]);
                    alarm.AlarmTime   = ComUtility.DBNullDateTimeHandler(rdr["AlarmTime"]);
                    alarm.ConfirmName = ComUtility.DBNullStringHandler(rdr["ConfirmName"]);
                    alarm.ConfirmTime = ComUtility.DBNullDateTimeHandler(rdr["ConfirmTime"]);
                    alarm.EndName     = ComUtility.DBNullStringHandler(rdr["EndName"]);
                    alarm.EndTime     = ComUtility.DBNullDateTimeHandler(rdr["EndTime"]);
                    alarms.Add(alarm);
                }
            }
            return(alarms);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method to get load alarms
        /// </summary>
        public List <LoadAlarmInfo> GetLoadAlarms()
        {
            var alarms  = new List <LoadAlarmInfo>();
            var sqlText = @"
            ;WITH Alarms AS
            (
                SELECT LA.*,L.[LscName],DT.[TypeName] AS [DevTypeName]
                FROM [dbo].[TA_LoadAlarm] LA
                INNER JOIN [dbo].[TM_DEV] TD ON LA.[LscID] = TD.[LscID] AND LA.[DevID] = TD.[DevID]
                INNER JOIN [dbo].[TM_LSC] L ON TD.[LscID] = L.[LscID]
                LEFT OUTER JOIN [dbo].[TC_DeviceType] DT ON TD.[DevTypeID] = DT.[TypeID]
            )
            SELECT [LscID],[LscName],[Area1Name],[Area2Name],[Area3Name],[StaName],[DevID],[DevName],
            [DevTypeID],[DevTypeName],[AlarmLevel],[RateValue],[LoadValue],[LoadPercent],[RightPercent],
            [StartTime],[ConfirmName],[ConfirmTime],[EndName],[EndTime] FROM Alarms;";

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, sqlText, null)) {
                while (rdr.Read())
                {
                    var alarm = new LoadAlarmInfo();
                    alarm.LscID        = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                    alarm.LscName      = ComUtility.DBNullStringHandler(rdr["LscName"]);
                    alarm.Area1Name    = ComUtility.DBNullStringHandler(rdr["Area1Name"]);
                    alarm.Area2Name    = ComUtility.DBNullStringHandler(rdr["Area2Name"]);
                    alarm.Area3Name    = ComUtility.DBNullStringHandler(rdr["Area3Name"]);
                    alarm.StaName      = ComUtility.DBNullStringHandler(rdr["StaName"]);
                    alarm.DevID        = ComUtility.DBNullInt32Handler(rdr["DevID"]);
                    alarm.DevName      = ComUtility.DBNullStringHandler(rdr["DevName"]);
                    alarm.DevTypeID    = ComUtility.DBNullInt32Handler(rdr["DevTypeID"]);
                    alarm.DevTypeName  = ComUtility.DBNullStringHandler(rdr["DevTypeName"]);
                    alarm.AlarmLevel   = ComUtility.DBNullAlarmLevelHandler(rdr["AlarmLevel"]);
                    alarm.RateValue    = ComUtility.DBNullFloatHandler(rdr["RateValue"]);
                    alarm.LoadValue    = ComUtility.DBNullFloatHandler(rdr["LoadValue"]);
                    alarm.LoadPercent  = ComUtility.DBNullFloatHandler(rdr["LoadPercent"]);
                    alarm.RightPercent = ComUtility.DBNullFloatHandler(rdr["RightPercent"]);
                    alarm.StartTime    = ComUtility.DBNullDateTimeHandler(rdr["StartTime"]);
                    alarm.ConfirmName  = ComUtility.DBNullStringHandler(rdr["ConfirmName"]);
                    alarm.ConfirmTime  = ComUtility.DBNullDateTimeHandler(rdr["ConfirmTime"]);
                    alarm.EndName      = ComUtility.DBNullStringHandler(rdr["EndName"]);
                    alarm.EndTime      = ComUtility.DBNullDateTimeHandler(rdr["EndTime"]);
                    alarms.Add(alarm);
                }
            }
            return(alarms);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Method to get trend count alarms
        /// </summary>
        public List <TrendAlarmInfo> GetTrendCountAlarms(int lscId, int nodeId, DateTime beginTime, DateTime endTime, float aiValue, int timeType, int valueType)
        {
            SqlParameter[] parms = { new SqlParameter("@LscID",     SqlDbType.Int),
                                     new SqlParameter("@AicID",     SqlDbType.Int),
                                     new SqlParameter("@BeginTime", SqlDbType.DateTime),
                                     new SqlParameter("@EndTime",   SqlDbType.DateTime),
                                     new SqlParameter("@AIValue",   SqlDbType.Real),
                                     new SqlParameter("@TimeType",  SqlDbType.Int),
                                     new SqlParameter("@ValueType", SqlDbType.Int) };

            parms[0].Value = lscId;
            if (nodeId == ComUtility.DefaultInt32)
            {
                parms[1].Value = DBNull.Value;
            }
            else
            {
                parms[1].Value = nodeId;
            }
            parms[2].Value = beginTime;
            parms[3].Value = endTime;
            parms[4].Value = aiValue;
            parms[5].Value = timeType;
            parms[6].Value = valueType;

            var alarms = new List <TrendAlarmInfo>();

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.HisConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_PREALARM_GETTRENDCOUNTALARMS, parms)) {
                while (rdr.Read())
                {
                    var alarm = new TrendAlarmInfo();
                    alarm.LscID      = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                    alarm.NodeID     = ComUtility.DBNullInt32Handler(rdr["AicID"]);
                    alarm.StartValue = ComUtility.DBNullFloatHandler(rdr["StartValue"]);
                    alarm.AlarmValue = ComUtility.DBNullFloatHandler(rdr["AlarmValue"]);
                    alarm.DiffValue  = ComUtility.DBNullFloatHandler(rdr["DiffValue"]);
                    alarm.StartTime  = ComUtility.DBNullDateTimeHandler(rdr["StartTime"]);
                    alarm.EndTime    = ComUtility.DBNullDateTimeHandler(rdr["EndTime"]);
                    alarms.Add(alarm);
                }
            }
            return(alarms);
        }
Exemplo n.º 4
0
        public List <AlarmInfo> GetHisAlarms(Int32 lscId, String lscName, List <StandardProtocolInfo> protocols, List <GroupTreeInfo> groupNodes, HisAlarmConditionInfo condition)
        {
            SqlParameter[] parms = { new SqlParameter("@LscID",           SqlDbType.Int),
                                     new SqlParameter("@Area1Name",       SqlDbType.NVarChar,  40),
                                     new SqlParameter("@Area2Name",       SqlDbType.NVarChar,  40),
                                     new SqlParameter("@Area3Name",       SqlDbType.NVarChar,  40),
                                     new SqlParameter("@Area4Name",       SqlDbType.NVarChar,  40),
                                     new SqlParameter("@StaName",         SqlDbType.NVarChar,  40),
                                     new SqlParameter("@DevName",         SqlDbType.NVarChar,  40),
                                     new SqlParameter("@NodeName",        SqlDbType.NVarChar,  40),
                                     new SqlParameter("@AlarmDevName",    SqlDbType.NVarChar,  40),
                                     new SqlParameter("@AlarmLogicName",  SqlDbType.NVarChar,  40),
                                     new SqlParameter("@AlarmName",       SqlDbType.NVarChar,  40),
                                     new SqlParameter("@AlarmLevels",     SqlDbType.NVarChar,  50),
                                     new SqlParameter("@BeginFromTime",   SqlDbType.DateTime),
                                     new SqlParameter("@BeginToTime",     SqlDbType.DateTime),
                                     new SqlParameter("@EndFromTime",     SqlDbType.DateTime),
                                     new SqlParameter("@EndToTime",       SqlDbType.DateTime),
                                     new SqlParameter("@ConfirmName",     SqlDbType.NVarChar,  20),
                                     new SqlParameter("@ConfirmFromTime", SqlDbType.DateTime),
                                     new SqlParameter("@ConfirmToTime",   SqlDbType.DateTime),
                                     new SqlParameter("@MinDelay",        SqlDbType.Real),
                                     new SqlParameter("@MaxDelay",        SqlDbType.Real),
                                     new SqlParameter("@MHArea1",         SqlDbType.Bit),
                                     new SqlParameter("@MHArea2",         SqlDbType.Bit),
                                     new SqlParameter("@MHArea3",         SqlDbType.Bit),
                                     new SqlParameter("@MHArea4",         SqlDbType.Bit),
                                     new SqlParameter("@MHSta",           SqlDbType.Bit),
                                     new SqlParameter("@MHDev",           SqlDbType.Bit),
                                     new SqlParameter("@MHNode",          SqlDbType.Bit) };

            parms[0].Value = lscId;
            if (condition.Area1Item.Value == null || condition.Area1Item.Value.Equals(ComUtility.DefaultItemID))
            {
                parms[1].Value = DBNull.Value;
            }
            else
            {
                parms[1].Value = condition.Area1Item.Text;
            }

            if (condition.Area2Item.Value == null || condition.Area2Item.Value.Equals(ComUtility.DefaultItemID))
            {
                parms[2].Value = DBNull.Value;
            }
            else
            {
                parms[2].Value = condition.Area2Item.Text;
            }

            if (condition.Area3Item.Value == null || condition.Area3Item.Value.Equals(ComUtility.DefaultItemID))
            {
                parms[3].Value = DBNull.Value;
            }
            else
            {
                parms[3].Value = condition.Area3Item.Text;
            }

            if (condition.Area4Item.Value == null || condition.Area4Item.Value.Equals(ComUtility.DefaultItemID))
            {
                parms[4].Value = DBNull.Value;
            }
            else
            {
                parms[4].Value = condition.Area4Item.Text;
            }

            if (condition.StaItem.Value == null || condition.StaItem.Value.Equals(ComUtility.DefaultItemID))
            {
                parms[5].Value = DBNull.Value;
            }
            else
            {
                parms[5].Value = condition.StaItem.Text;
            }

            if (condition.DevItem.Value == null || condition.DevItem.Value.Equals(ComUtility.DefaultItemID))
            {
                parms[6].Value = DBNull.Value;
            }
            else
            {
                parms[6].Value = condition.DevItem.Text;
            }

            if (condition.NodeItem.Value == null || condition.NodeItem.Value.Equals(ComUtility.DefaultItemID))
            {
                parms[7].Value = DBNull.Value;
            }
            else
            {
                parms[7].Value = condition.NodeItem.Text;
            }

            if (condition.AlarmDevItem.Value.Equals(ComUtility.DefaultItemID))
            {
                parms[8].Value = DBNull.Value;
            }
            else
            {
                parms[8].Value = condition.AlarmDevItem.Text;
            }

            if (condition.AlarmLogicItem.Value.Equals(ComUtility.DefaultItemID))
            {
                parms[9].Value = DBNull.Value;
            }
            else
            {
                parms[9].Value = condition.AlarmLogicItem.Text;
            }

            if (condition.AlarmNameItem.Value.Equals(ComUtility.DefaultItemID))
            {
                parms[10].Value = DBNull.Value;
            }
            else
            {
                parms[10].Value = condition.AlarmNameItem.Text;
            }

            if (condition.AlarmLevelItems.Length <= 0)
            {
                parms[11].Value = DBNull.Value;
            }
            else
            {
                parms[11].Value = String.Join(",", condition.AlarmLevelItems);
            }

            if (String.IsNullOrEmpty(condition.BeginFromTimeText))
            {
                parms[12].Value = DBNull.Value;
            }
            else
            {
                parms[12].Value = condition.BeginFromTimeText;
            }

            if (String.IsNullOrEmpty(condition.BeginToTimeText))
            {
                parms[13].Value = DBNull.Value;
            }
            else
            {
                parms[13].Value = condition.BeginToTimeText;
            }

            if (String.IsNullOrEmpty(condition.EndFromTimeText))
            {
                parms[14].Value = DBNull.Value;
            }
            else
            {
                parms[14].Value = condition.EndFromTimeText;
            }

            if (String.IsNullOrEmpty(condition.EndToTimeText))
            {
                parms[15].Value = DBNull.Value;
            }
            else
            {
                parms[15].Value = condition.EndToTimeText;
            }

            if (String.IsNullOrEmpty(condition.ConfirmNameText))
            {
                parms[16].Value = DBNull.Value;
            }
            else
            {
                parms[16].Value = condition.ConfirmNameText;
            }

            if (String.IsNullOrEmpty(condition.ConfirmFromTimeText))
            {
                parms[17].Value = DBNull.Value;
            }
            else
            {
                parms[17].Value = condition.ConfirmFromTimeText;
            }

            if (String.IsNullOrEmpty(condition.ConfirmToTimeText))
            {
                parms[18].Value = DBNull.Value;
            }
            else
            {
                parms[18].Value = condition.ConfirmToTimeText;
            }

            if (condition.MinDelay == Double.MinValue)
            {
                parms[19].Value = DBNull.Value;
            }
            else
            {
                parms[19].Value = condition.MinDelay;
            }

            if (condition.MaxDelay == Double.MaxValue)
            {
                parms[20].Value = DBNull.Value;
            }
            else
            {
                parms[20].Value = condition.MaxDelay;
            }

            parms[21].Value = condition.Area1Item.SelectedIndex == -1;
            parms[22].Value = condition.Area2Item.SelectedIndex == -1;
            parms[23].Value = condition.Area3Item.SelectedIndex == -1;
            parms[24].Value = condition.Area4Item.SelectedIndex == -1;
            parms[25].Value = condition.StaItem.SelectedIndex == -1;
            parms[26].Value = condition.DevItem.SelectedIndex == -1;
            parms[27].Value = condition.NodeItem.SelectedIndex == -1;

            var alarms = new List <AlarmInfo>();

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.HisConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_ALARM_GETHISALARMS, parms)) {
                while (rdr.Read())
                {
                    var alarm = new AlarmInfo();
                    alarm.LscID          = lscId;
                    alarm.LscName        = lscName;
                    alarm.SerialNO       = ComUtility.DBNullInt32Handler(rdr["SerialNO"]);
                    alarm.Area1Name      = ComUtility.DBNullStringHandler(rdr["Area1Name"]);
                    alarm.Area2Name      = ComUtility.DBNullStringHandler(rdr["Area2Name"]);
                    alarm.Area3Name      = ComUtility.DBNullStringHandler(rdr["Area3Name"]);
                    alarm.Area4Name      = ComUtility.DBNullStringHandler(rdr["Area4Name"]);
                    alarm.StaName        = ComUtility.DBNullStringHandler(rdr["StaName"]);
                    alarm.DevName        = ComUtility.DBNullStringHandler(rdr["DevName"]);
                    alarm.DevDesc        = ComUtility.DefaultString;
                    alarm.NodeID         = ComUtility.DBNullInt32Handler(rdr["NodeID"]);
                    alarm.NodeType       = ComUtility.DBNullNodeTypeHandler(rdr["NodeType"]);
                    alarm.NodeName       = ComUtility.DBNullStringHandler(rdr["NodeName"]);
                    alarm.AlarmID        = ComUtility.DBNullInt32Handler(rdr["AlarmID"]);
                    alarm.AlarmValue     = ComUtility.DBNullFloatHandler(rdr["AlarmValue"]);
                    alarm.AlarmLevel     = ComUtility.DBNullAlarmLevelHandler(rdr["AlarmLevel"]);
                    alarm.AlarmStatus    = EnmAlarmStatus.Ended;
                    alarm.AlarmDesc      = ComUtility.DBNullStringHandler(rdr["AlarmDesc"]);
                    alarm.AuxAlarmDesc   = ComUtility.DBNullStringHandler(rdr["AuxAlarmDesc"]);
                    alarm.StartTime      = ComUtility.DBNullDateTimeHandler(rdr["StartTime"]);
                    alarm.EndTime        = ComUtility.DBNullDateTimeHandler(rdr["EndTime"]);
                    alarm.ConfirmName    = ComUtility.DBNullStringHandler(rdr["ConfirmName"]);
                    alarm.ConfirmMarking = ComUtility.DBNullConfirmMarkingHandler(rdr["ConfirmMarking"]);
                    alarm.ConfirmTime    = ComUtility.DBNullDateTimeHandler(rdr["ConfirmTime"]);
                    alarm.AuxSet         = ComUtility.DefaultString;
                    alarm.ProjName       = ComUtility.DBNullStringHandler(rdr["ProjName"]);
                    alarm.TurnCount      = 0;
                    alarm.UpdateTime     = ComUtility.DBNullDateTimeHandler(rdr["UpdateTime"]);
                    alarms.Add(alarm);
                }
            }

            if (alarms.Count > 0)
            {
                alarms = (from alarm in alarms
                          join node in groupNodes on ComUtility.GetDevID(alarm.NodeID) equals node.NodeID
                          join sp in protocols on alarm.AlarmID equals sp.AlarmID into tp
                          from dl in tp.DefaultIfEmpty()
                          select new AlarmInfo {
                    LscID = alarm.LscID,
                    LscName = alarm.LscName,
                    SerialNO = alarm.SerialNO,
                    Area1Name = alarm.Area1Name,
                    Area2Name = alarm.Area2Name,
                    Area3Name = alarm.Area3Name,
                    Area4Name = alarm.Area4Name,
                    StaName = alarm.StaName,
                    DevName = alarm.DevName,
                    DevDesc = alarm.DevDesc,
                    NodeID = alarm.NodeID,
                    NodeType = alarm.NodeType,
                    NodeName = alarm.NodeName,
                    AlarmID = alarm.AlarmID,
                    AlarmValue = alarm.AlarmValue,
                    AlarmLevel = alarm.AlarmLevel,
                    AlarmStatus = alarm.AlarmStatus,
                    AlarmDesc = alarm.AlarmDesc,
                    AuxAlarmDesc = alarm.AuxAlarmDesc,
                    StartTime = alarm.StartTime,
                    EndTime = alarm.EndTime,
                    ConfirmName = alarm.ConfirmName,
                    ConfirmMarking = alarm.ConfirmMarking,
                    ConfirmTime = alarm.ConfirmTime,
                    AuxSet = alarm.AuxSet,
                    ProjName = alarm.ProjName,
                    TurnCount = alarm.TurnCount,
                    UpdateTime = alarm.UpdateTime,
                    NMAlarmID = (dl == null ? ComUtility.DefaultString : dl.NMAlarmID),
                    AlarmName = (dl == null ? ComUtility.DefaultString : dl.AlarmName),
                    AlarmClass = (dl == null ? ComUtility.DefaultString : dl.AlarmClass),
                    AlarmDeviceTypeID = (dl == null ? ComUtility.DefaultInt32 : dl.AlarmDeviceTypeID),
                    AlarmDeviceType = (dl == null ? ComUtility.DefaultString : dl.AlarmDeviceType),
                    AlarmLogTypeID = (dl == null ? ComUtility.DefaultInt32 : dl.AlarmLogTypeID),
                    AlarmLogType = (dl == null ? ComUtility.DefaultString : dl.AlarmLogType)
                }).ToList();
            }
            return(alarms);
        }
Exemplo n.º 5
0
        public List <AlarmInfo> GetHisAlarms(Int32 lscId, String lscName, List <StandardProtocolInfo> protocols, List <GroupTreeInfo> groupNodes, DateTime startTime, DateTime endTime, String[] nodeNames, Int32[] devTypes, Double?minInterval, Double?maxInterval)
        {
            SqlParameter[] parms = { new SqlParameter("@LscID",         SqlDbType.Int),
                                     new SqlParameter("@BeginFromTime", SqlDbType.DateTime),
                                     new SqlParameter("@BeginToTime",   SqlDbType.DateTime),
                                     new SqlParameter("@MinInterval",   SqlDbType.Float),
                                     new SqlParameter("@MaxInterval",   SqlDbType.Float),
                                     new SqlParameter("@NodeNames",     SqlDbType.NVarChar, 4000) };
            parms[0].Value = lscId;
            parms[1].Value = startTime;
            parms[2].Value = endTime;
            parms[3].Value = DBNull.Value;
            parms[4].Value = DBNull.Value;
            parms[5].Value = DBNull.Value;
            if (minInterval != null)
            {
                parms[3].Value = minInterval;
            }
            if (maxInterval != null)
            {
                parms[4].Value = maxInterval;
            }

            if (nodeNames != null && nodeNames.Length > 0)
            {
                for (var i = 0; i < nodeNames.Length; i++)
                {
                    nodeNames[i] = String.Format(@"SELECT '%{0}%' AS [NodeName]", nodeNames[i]);
                }
                parms[5].Value = String.Join(" UNION ", nodeNames);
            }

            var alarms = new List <AlarmInfo>();

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.HisConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_ALARM_GETHISALARMS2, parms)) {
                while (rdr.Read())
                {
                    var alarm = new AlarmInfo();
                    alarm.LscID          = lscId;
                    alarm.LscName        = lscName;
                    alarm.SerialNO       = ComUtility.DBNullInt32Handler(rdr["SerialNO"]);
                    alarm.Area1Name      = ComUtility.DBNullStringHandler(rdr["Area1Name"]);
                    alarm.Area2Name      = ComUtility.DBNullStringHandler(rdr["Area2Name"]);
                    alarm.Area3Name      = ComUtility.DBNullStringHandler(rdr["Area3Name"]);
                    alarm.Area4Name      = ComUtility.DBNullStringHandler(rdr["Area4Name"]);
                    alarm.StaName        = ComUtility.DBNullStringHandler(rdr["StaName"]);
                    alarm.DevName        = ComUtility.DBNullStringHandler(rdr["DevName"]);
                    alarm.DevDesc        = ComUtility.DefaultString;
                    alarm.NodeID         = ComUtility.DBNullInt32Handler(rdr["NodeID"]);
                    alarm.NodeType       = ComUtility.DBNullNodeTypeHandler(rdr["NodeType"]);
                    alarm.NodeName       = ComUtility.DBNullStringHandler(rdr["NodeName"]);
                    alarm.AlarmID        = ComUtility.DBNullInt32Handler(rdr["AlarmID"]);
                    alarm.AlarmValue     = ComUtility.DBNullFloatHandler(rdr["AlarmValue"]);
                    alarm.AlarmLevel     = ComUtility.DBNullAlarmLevelHandler(rdr["AlarmLevel"]);
                    alarm.AlarmStatus    = EnmAlarmStatus.Ended;
                    alarm.AlarmDesc      = ComUtility.DBNullStringHandler(rdr["AlarmDesc"]);
                    alarm.AuxAlarmDesc   = ComUtility.DBNullStringHandler(rdr["AuxAlarmDesc"]);
                    alarm.StartTime      = ComUtility.DBNullDateTimeHandler(rdr["StartTime"]);
                    alarm.EndTime        = ComUtility.DBNullDateTimeHandler(rdr["EndTime"]);
                    alarm.ConfirmName    = ComUtility.DBNullStringHandler(rdr["ConfirmName"]);
                    alarm.ConfirmMarking = ComUtility.DBNullConfirmMarkingHandler(rdr["ConfirmMarking"]);
                    alarm.ConfirmTime    = ComUtility.DBNullDateTimeHandler(rdr["ConfirmTime"]);
                    alarm.AuxSet         = ComUtility.DefaultString;
                    alarm.ProjName       = ComUtility.DBNullStringHandler(rdr["ProjName"]);
                    alarm.TurnCount      = 0;
                    alarm.UpdateTime     = ComUtility.DBNullDateTimeHandler(rdr["UpdateTime"]);
                    alarms.Add(alarm);
                }
            }

            if (alarms.Count > 0)
            {
                alarms = (from alarm in alarms
                          join node in groupNodes on ComUtility.GetDevID(alarm.NodeID) equals node.NodeID
                          join sp in protocols on alarm.AlarmID equals sp.AlarmID into tp
                          from dl in tp.DefaultIfEmpty()
                          select new AlarmInfo {
                    LscID = alarm.LscID,
                    LscName = alarm.LscName,
                    SerialNO = alarm.SerialNO,
                    Area1Name = alarm.Area1Name,
                    Area2Name = alarm.Area2Name,
                    Area3Name = alarm.Area3Name,
                    Area4Name = alarm.Area4Name,
                    StaName = alarm.StaName,
                    DevName = alarm.DevName,
                    DevDesc = alarm.DevDesc,
                    NodeID = alarm.NodeID,
                    NodeType = alarm.NodeType,
                    NodeName = alarm.NodeName,
                    AlarmID = alarm.AlarmID,
                    AlarmValue = alarm.AlarmValue,
                    AlarmLevel = alarm.AlarmLevel,
                    AlarmStatus = alarm.AlarmStatus,
                    AlarmDesc = alarm.AlarmDesc,
                    AuxAlarmDesc = alarm.AuxAlarmDesc,
                    StartTime = alarm.StartTime,
                    EndTime = alarm.EndTime,
                    ConfirmName = alarm.ConfirmName,
                    ConfirmMarking = alarm.ConfirmMarking,
                    ConfirmTime = alarm.ConfirmTime,
                    AuxSet = alarm.AuxSet,
                    ProjName = alarm.ProjName,
                    TurnCount = alarm.TurnCount,
                    UpdateTime = alarm.UpdateTime,
                    NMAlarmID = (dl == null ? ComUtility.DefaultString : dl.NMAlarmID),
                    AlarmName = (dl == null ? ComUtility.DefaultString : dl.AlarmName),
                    AlarmClass = (dl == null ? ComUtility.DefaultString : dl.AlarmClass),
                    AlarmDeviceTypeID = (dl == null ? ComUtility.DefaultInt32 : dl.AlarmDeviceTypeID),
                    AlarmDeviceType = (dl == null ? ComUtility.DefaultString : dl.AlarmDeviceType),
                    AlarmLogTypeID = (dl == null ? ComUtility.DefaultInt32 : dl.AlarmLogTypeID),
                    AlarmLogType = (dl == null ? ComUtility.DefaultString : dl.AlarmLogType)
                }).ToList();

                if (devTypes != null)
                {
                    alarms = alarms.FindAll(alarm => devTypes.Contains(alarm.AlarmDeviceTypeID));
                }
            }
            return(alarms);
        }
Exemplo n.º 6
0
        public List <AlarmInfo> GetAlarms()
        {
            var alarms  = new List <AlarmInfo>();
            var sqlText = @"
            ;WITH Alarms AS
            (
                SELECT L.[LscID],L.[LscName],TA.[SerialNO],TA.[Area1Name],TA.[Area2Name],TA.[Area3Name],TA.[Area4Name],
                TA.[StaName],TA.[DevName],TA.[DevDesc],TA.[NodeID],TA.[NodeType],TA.[NodeName],TA.[AlarmID],TA.[AlarmValue],
                TA.[AlarmLevel],TA.[AlarmStatus],TA.[AlarmDesc],TA.[AuxAlarmDesc],TA.[StartTime],TA.[EndTime],TA.[ConfirmName],
                TA.[ConfirmMarking],TA.[ConfirmTime],TA.[AuxSet],TA.[ProjName],TA.[TurnCount],TA.[UpdateTime] 
                FROM [dbo].[TA_Alarm] TA INNER JOIN [dbo].[TM_LSC] L ON TA.[LscID] = L.[LscID]
            ),
            AlarmDetails AS
            (
                SELECT AN.[ID] AS AlarmID,AN.[AlarmName],AN.[AlarmInterpret],AN.[AlarmVer],AN.[AlarmLevel], 
                AN.[DevEffect],AN.[OperEffect],AN.[SubAlarmLogTypeID],SALT.[TypeDesc] AS SubAlarmLogType, 
                SALT.[AlarmLogTypeID],ALT.[TypeDesc] AS AlarmLogType,ALT.[AlarmDeviceTypeID], 
                ADT.[TypeDesc] AS AlarmDeviceType,AN.[NMAlarmID], AN.[AlarmClass] FROM [dbo].[TC_AlarmName] AN 
                LEFT OUTER JOIN [dbo].[TC_SubAlarmLogType] SALT ON AN.[SubAlarmLogTypeID] = SALT.[TypeID]
                LEFT OUTER JOIN [dbo].[TC_AlarmLogType] ALT ON SALT.[AlarmLogTypeID] = ALT.[TypeID]
                LEFT OUTER JOIN [dbo].[TC_AlarmDeviceType] ADT ON ALT.[AlarmDeviceTypeID] = ADT.[TypeID]
            )
            SELECT A.[LscID],A.[LscName],A.[SerialNO],A.[Area1Name],A.[Area2Name],A.[Area3Name],A.[Area4Name],
            A.[StaName],A.[DevName],A.[DevDesc],A.[NodeID],A.[NodeType],A.[NodeName],A.[AlarmID],A.[AlarmValue],
            A.[AlarmLevel],A.[AlarmStatus],A.[AlarmDesc],A.[AuxAlarmDesc],A.[StartTime],A.[EndTime],A.[ConfirmName],
            A.[ConfirmMarking],A.[ConfirmTime],A.[AuxSet],A.[ProjName],A.[TurnCount],A.[UpdateTime],AD.[NMAlarmID],
            AD.[AlarmName],AD.[AlarmClass],AD.[AlarmDeviceTypeID],AD.[AlarmDeviceType],AD.[AlarmLogTypeID],AD.[AlarmLogType] 
            FROM Alarms A LEFT OUTER JOIN AlarmDetails AD ON A.AlarmID = AD.AlarmID;";

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, sqlText, null)) {
                while (rdr.Read())
                {
                    var alarm = new AlarmInfo();
                    alarm.LscID             = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                    alarm.LscName           = ComUtility.DBNullStringHandler(rdr["LscName"]);
                    alarm.SerialNO          = ComUtility.DBNullInt32Handler(rdr["SerialNO"]);
                    alarm.Area1Name         = ComUtility.DBNullStringHandler(rdr["Area1Name"]);
                    alarm.Area2Name         = ComUtility.DBNullStringHandler(rdr["Area2Name"]);
                    alarm.Area3Name         = ComUtility.DBNullStringHandler(rdr["Area3Name"]);
                    alarm.Area4Name         = ComUtility.DBNullStringHandler(rdr["Area4Name"]);
                    alarm.StaName           = ComUtility.DBNullStringHandler(rdr["StaName"]);
                    alarm.DevName           = ComUtility.DBNullStringHandler(rdr["DevName"]);
                    alarm.DevDesc           = ComUtility.DBNullStringHandler(rdr["DevDesc"]);
                    alarm.NodeID            = ComUtility.DBNullInt32Handler(rdr["NodeID"]);
                    alarm.NodeType          = ComUtility.DBNullNodeTypeHandler(rdr["NodeType"]);
                    alarm.NodeName          = ComUtility.DBNullStringHandler(rdr["NodeName"]);
                    alarm.AlarmID           = ComUtility.DBNullInt32Handler(rdr["AlarmID"]);
                    alarm.AlarmValue        = ComUtility.DBNullFloatHandler(rdr["AlarmValue"]);
                    alarm.AlarmLevel        = ComUtility.DBNullAlarmLevelHandler(rdr["AlarmLevel"]);
                    alarm.AlarmStatus       = ComUtility.DBNullAlarmStatusHandler(rdr["AlarmStatus"]);
                    alarm.AlarmDesc         = ComUtility.DBNullStringHandler(rdr["AlarmDesc"]);
                    alarm.AuxAlarmDesc      = ComUtility.DBNullStringHandler(rdr["AuxAlarmDesc"]);
                    alarm.StartTime         = ComUtility.DBNullDateTimeHandler(rdr["StartTime"]);
                    alarm.EndTime           = ComUtility.DBNullDateTimeHandler(rdr["EndTime"]);
                    alarm.ConfirmName       = ComUtility.DBNullStringHandler(rdr["ConfirmName"]);
                    alarm.ConfirmMarking    = ComUtility.DBNullConfirmMarkingHandler(rdr["ConfirmMarking"]);
                    alarm.ConfirmTime       = ComUtility.DBNullDateTimeHandler(rdr["ConfirmTime"]);
                    alarm.AuxSet            = ComUtility.DBNullStringHandler(rdr["AuxSet"]);
                    alarm.ProjName          = ComUtility.DBNullStringHandler(rdr["ProjName"]);
                    alarm.TurnCount         = ComUtility.DBNullInt32Handler(rdr["TurnCount"]);
                    alarm.UpdateTime        = ComUtility.DBNullDateTimeHandler(rdr["UpdateTime"]);
                    alarm.NMAlarmID         = ComUtility.DBNullStringHandler(rdr["NMAlarmID"]);
                    alarm.AlarmName         = ComUtility.DBNullStringHandler(rdr["AlarmName"]);
                    alarm.AlarmClass        = ComUtility.DBNullStringHandler(rdr["AlarmClass"]);
                    alarm.AlarmDeviceTypeID = ComUtility.DBNullInt32Handler(rdr["AlarmDeviceTypeID"]);
                    alarm.AlarmDeviceType   = ComUtility.DBNullStringHandler(rdr["AlarmDeviceType"]);
                    alarm.AlarmLogTypeID    = ComUtility.DBNullInt32Handler(rdr["AlarmLogTypeID"]);
                    alarm.AlarmLogType      = ComUtility.DBNullStringHandler(rdr["AlarmLogType"]);
                    alarms.Add(alarm);
                }
            }
            return(alarms);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Method to get history load alarms
        /// </summary>
        public List <LoadAlarmInfo> GetHisLoadAlarms(int lscId, string lscName, string area1Name, string area2Name, string area3Name, string staName, int devId, DateTime beginTime, DateTime endTime, DateTime confirmBeginTime, DateTime confirmEndTime, string confirmName, DateTime endBeginTime, DateTime endEndTime, string endName)
        {
            SqlParameter[] parms = { new SqlParameter("@LscID",            SqlDbType.Int),
                                     new SqlParameter("@Area1Name",        SqlDbType.NVarChar,  40),
                                     new SqlParameter("@Area2Name",        SqlDbType.NVarChar,  40),
                                     new SqlParameter("@Area3Name",        SqlDbType.NVarChar,  40),
                                     new SqlParameter("@StaName",          SqlDbType.NVarChar,  40),
                                     new SqlParameter("@DevID",            SqlDbType.Int),
                                     new SqlParameter("@BeginTime",        SqlDbType.DateTime),
                                     new SqlParameter("@EndTime",          SqlDbType.DateTime),
                                     new SqlParameter("@ConfirmBeginTime", SqlDbType.DateTime),
                                     new SqlParameter("@ConfirmEndTime",   SqlDbType.DateTime),
                                     new SqlParameter("@ConfirmName",      SqlDbType.NVarChar,  20),
                                     new SqlParameter("@EndBeginTime",     SqlDbType.DateTime),
                                     new SqlParameter("@EndEndTime",       SqlDbType.DateTime),
                                     new SqlParameter("@EndName",          SqlDbType.NVarChar, 20) };

            parms[0].Value = lscId;
            if (area1Name == ComUtility.DefaultString)
            {
                parms[1].Value = DBNull.Value;
            }
            else
            {
                parms[1].Value = area1Name;
            }
            if (area2Name == ComUtility.DefaultString)
            {
                parms[2].Value = DBNull.Value;
            }
            else
            {
                parms[2].Value = area2Name;
            }
            if (area3Name == ComUtility.DefaultString)
            {
                parms[3].Value = DBNull.Value;
            }
            else
            {
                parms[3].Value = area3Name;
            }
            if (staName == ComUtility.DefaultString)
            {
                parms[4].Value = DBNull.Value;
            }
            else
            {
                parms[4].Value = staName;
            }
            if (devId == ComUtility.DefaultInt32)
            {
                parms[5].Value = DBNull.Value;
            }
            else
            {
                parms[5].Value = devId;
            }
            if (beginTime == ComUtility.DefaultDateTime)
            {
                parms[6].Value = DBNull.Value;
            }
            else
            {
                parms[6].Value = beginTime;
            }
            if (endTime == ComUtility.DefaultDateTime)
            {
                parms[7].Value = DBNull.Value;
            }
            else
            {
                parms[7].Value = endTime;
            }
            if (confirmBeginTime == ComUtility.DefaultDateTime)
            {
                parms[8].Value = DBNull.Value;
            }
            else
            {
                parms[8].Value = confirmBeginTime;
            }
            if (confirmEndTime == ComUtility.DefaultDateTime)
            {
                parms[9].Value = DBNull.Value;
            }
            else
            {
                parms[9].Value = confirmEndTime;
            }
            if (confirmName == ComUtility.DefaultString)
            {
                parms[10].Value = DBNull.Value;
            }
            else
            {
                parms[10].Value = confirmName;
            }
            if (endBeginTime == ComUtility.DefaultDateTime)
            {
                parms[11].Value = DBNull.Value;
            }
            else
            {
                parms[11].Value = endBeginTime;
            }
            if (endEndTime == ComUtility.DefaultDateTime)
            {
                parms[12].Value = DBNull.Value;
            }
            else
            {
                parms[12].Value = endEndTime;
            }
            if (endName == ComUtility.DefaultString)
            {
                parms[13].Value = DBNull.Value;
            }
            else
            {
                parms[13].Value = endName;
            }

            var alarms = new List <LoadAlarmInfo>();

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.HisConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_PREALARM_GETHISLOADALARMS, parms)) {
                while (rdr.Read())
                {
                    var alarm = new LoadAlarmInfo();
                    alarm.LscID        = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                    alarm.LscName      = lscName;
                    alarm.Area1Name    = ComUtility.DBNullStringHandler(rdr["Area1Name"]);
                    alarm.Area2Name    = ComUtility.DBNullStringHandler(rdr["Area2Name"]);
                    alarm.Area3Name    = ComUtility.DBNullStringHandler(rdr["Area3Name"]);
                    alarm.StaName      = ComUtility.DBNullStringHandler(rdr["StaName"]);
                    alarm.DevID        = ComUtility.DBNullInt32Handler(rdr["DevID"]);
                    alarm.DevName      = ComUtility.DBNullStringHandler(rdr["DevName"]);
                    alarm.DevTypeID    = ComUtility.DBNullInt32Handler(rdr["DevTypeID"]);
                    alarm.AlarmLevel   = ComUtility.DBNullAlarmLevelHandler(rdr["AlarmLevel"]);
                    alarm.RateValue    = ComUtility.DBNullFloatHandler(rdr["RateValue"]);
                    alarm.LoadValue    = ComUtility.DBNullFloatHandler(rdr["LoadValue"]);
                    alarm.LoadPercent  = ComUtility.DBNullFloatHandler(rdr["LoadPercent"]);
                    alarm.RightPercent = ComUtility.DBNullFloatHandler(rdr["RightPercent"]);
                    alarm.StartTime    = ComUtility.DBNullDateTimeHandler(rdr["StartTime"]);
                    alarm.ConfirmName  = ComUtility.DBNullStringHandler(rdr["ConfirmName"]);
                    alarm.ConfirmTime  = ComUtility.DBNullDateTimeHandler(rdr["ConfirmTime"]);
                    alarm.EndName      = ComUtility.DBNullStringHandler(rdr["EndName"]);
                    alarm.EndTime      = ComUtility.DBNullDateTimeHandler(rdr["EndTime"]);
                    alarms.Add(alarm);
                }
            }
            return(alarms);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Method to get history trend alarms
        /// </summary>
        public List <TrendAlarmInfo> GetHisTrendAlarms(int lscId, string lscName, string area1Name, string area2Name, string area3Name, string staName, string devName, int nodeId, DateTime beginTime, DateTime endTime, DateTime confirmBeginTime, DateTime confirmEndTime, string confirmName, DateTime endBeginTime, DateTime endEndTime, string endName)
        {
            SqlParameter[] parms = { new SqlParameter("@LscID",            SqlDbType.Int),
                                     new SqlParameter("@Area1Name",        SqlDbType.NVarChar,  40),
                                     new SqlParameter("@Area2Name",        SqlDbType.NVarChar,  40),
                                     new SqlParameter("@Area3Name",        SqlDbType.NVarChar,  40),
                                     new SqlParameter("@StaName",          SqlDbType.NVarChar,  40),
                                     new SqlParameter("@DevName",          SqlDbType.NVarChar,  40),
                                     new SqlParameter("@NodeID",           SqlDbType.Int),
                                     new SqlParameter("@BeginTime",        SqlDbType.DateTime),
                                     new SqlParameter("@EndTime",          SqlDbType.DateTime),
                                     new SqlParameter("@ConfirmBeginTime", SqlDbType.DateTime),
                                     new SqlParameter("@ConfirmEndTime",   SqlDbType.DateTime),
                                     new SqlParameter("@ConfirmName",      SqlDbType.NVarChar,  20),
                                     new SqlParameter("@EndBeginTime",     SqlDbType.DateTime),
                                     new SqlParameter("@EndEndTime",       SqlDbType.DateTime),
                                     new SqlParameter("@EndName",          SqlDbType.NVarChar, 20) };

            parms[0].Value = lscId;
            if (area1Name == ComUtility.DefaultString)
            {
                parms[1].Value = DBNull.Value;
            }
            else
            {
                parms[1].Value = area1Name;
            }
            if (area2Name == ComUtility.DefaultString)
            {
                parms[2].Value = DBNull.Value;
            }
            else
            {
                parms[2].Value = area2Name;
            }
            if (area3Name == ComUtility.DefaultString)
            {
                parms[3].Value = DBNull.Value;
            }
            else
            {
                parms[3].Value = area3Name;
            }
            if (staName == ComUtility.DefaultString)
            {
                parms[4].Value = DBNull.Value;
            }
            else
            {
                parms[4].Value = staName;
            }
            if (devName == ComUtility.DefaultString)
            {
                parms[5].Value = DBNull.Value;
            }
            else
            {
                parms[5].Value = devName;
            }
            if (nodeId == ComUtility.DefaultInt32)
            {
                parms[6].Value = DBNull.Value;
            }
            else
            {
                parms[6].Value = nodeId;
            }
            if (beginTime == ComUtility.DefaultDateTime)
            {
                parms[7].Value = DBNull.Value;
            }
            else
            {
                parms[7].Value = beginTime;
            }
            if (endTime == ComUtility.DefaultDateTime)
            {
                parms[8].Value = DBNull.Value;
            }
            else
            {
                parms[8].Value = endTime;
            }
            if (confirmBeginTime == ComUtility.DefaultDateTime)
            {
                parms[9].Value = DBNull.Value;
            }
            else
            {
                parms[9].Value = confirmBeginTime;
            }
            if (confirmEndTime == ComUtility.DefaultDateTime)
            {
                parms[10].Value = DBNull.Value;
            }
            else
            {
                parms[10].Value = confirmEndTime;
            }
            if (confirmName == ComUtility.DefaultString)
            {
                parms[11].Value = DBNull.Value;
            }
            else
            {
                parms[11].Value = confirmName;
            }
            if (endBeginTime == ComUtility.DefaultDateTime)
            {
                parms[12].Value = DBNull.Value;
            }
            else
            {
                parms[12].Value = endBeginTime;
            }
            if (endEndTime == ComUtility.DefaultDateTime)
            {
                parms[13].Value = DBNull.Value;
            }
            else
            {
                parms[13].Value = endEndTime;
            }
            if (endName == ComUtility.DefaultString)
            {
                parms[14].Value = DBNull.Value;
            }
            else
            {
                parms[14].Value = endName;
            }

            var dict   = new Dictionary <String, Int32>();
            var alarms = new List <TrendAlarmInfo>();

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.HisConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_PREALARM_GETHISTREND, parms)) {
                if (rdr.HasRows)
                {
                    dict = GetDevType(lscId, nodeId);
                }
                while (rdr.Read())
                {
                    var alarm = new TrendAlarmInfo();
                    alarm.LscID       = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                    alarm.LscName     = lscName;
                    alarm.Area1Name   = ComUtility.DBNullStringHandler(rdr["Area1Name"]);
                    alarm.Area2Name   = ComUtility.DBNullStringHandler(rdr["Area2Name"]);
                    alarm.Area3Name   = ComUtility.DBNullStringHandler(rdr["Area3Name"]);
                    alarm.StaName     = ComUtility.DBNullStringHandler(rdr["StaName"]);
                    alarm.DevName     = ComUtility.DBNullStringHandler(rdr["DevName"]);
                    alarm.NodeID      = ComUtility.DBNullInt32Handler(rdr["NodeID"]);
                    alarm.NodeName    = ComUtility.DBNullStringHandler(rdr["NodeName"]);
                    alarm.AlarmType   = ComUtility.DBNullStringHandler(rdr["AlarmType"]);
                    alarm.AlarmLevel  = ComUtility.DBNullAlarmLevelHandler(rdr["AlarmLevel"]);
                    alarm.StartValue  = ComUtility.DBNullFloatHandler(rdr["StartValue"]);
                    alarm.AlarmValue  = ComUtility.DBNullFloatHandler(rdr["AlarmValue"]);
                    alarm.DiffValue   = ComUtility.DBNullFloatHandler(rdr["DiffValue"]);
                    alarm.StartTime   = ComUtility.DBNullDateTimeHandler(rdr["StartTime"]);
                    alarm.AlarmTime   = ComUtility.DBNullDateTimeHandler(rdr["AlarmTime"]);
                    alarm.ConfirmName = ComUtility.DBNullStringHandler(rdr["ConfirmName"]);
                    alarm.ConfirmTime = ComUtility.DBNullDateTimeHandler(rdr["ConfirmTime"]);
                    alarm.EndName     = ComUtility.DBNullStringHandler(rdr["EndName"]);
                    alarm.EndTime     = ComUtility.DBNullDateTimeHandler(rdr["EndTime"]);

                    var key = String.Format("{0}-{1}", alarm.LscID, ComUtility.GetDevID(alarm.NodeID));
                    alarm.DevTypeID = dict.ContainsKey(key) ? dict[key] : ComUtility.DefaultInt32;
                    alarms.Add(alarm);
                }
            }
            return(alarms);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Method to get virtual trend alarms
        /// </summary>
        public List <TrendAlarmInfo> GetVirtualTrendAlarms(int lscId, int area1Id, int area2Id, int area3Id, int staId, int devId, int nodeId)
        {
            var sqlText = new StringBuilder();
            var alarms  = new List <TrendAlarmInfo>();

            sqlText.AppendFormat(@"
            SELECT TL.[LscID],TL.[LscName],TAAA.[AreaName] AS [Area1Name],TAA.[AreaName] AS [Area2Name],TA.[AreaName] AS [Area3Name],TS.[StaName],
            TD.[DevName],AI.[AicID] AS [NodeID],AI.[AicName] AS [NodeName],DT.[TypeID] AS [DevTypeID],DT.[TypeName] AS [DevTypeName],
            N'统计对比' AS [AlarmType],AI.[AlarmLevel],0 AS [StartValue],0 AS [AlarmValue],0 AS [DiffValue],NULL AS [StartTime],NULL AS [AlarmTime],
            NULL AS [ConfirmName],NULL AS [ConfirmTime],NULL AS [EndName],NULL AS [EndTime] FROM [dbo].[TM_AIC] AI
            INNER JOIN [dbo].[TM_DEV] TD ON AI.[LscID] = TD.[LscID] AND AI.[DevID] = TD.[DevID]
            INNER JOIN [dbo].[TM_STA] TS ON TD.[LscID] = TS.[LscID] AND TD.[StaID] = TS.[StaID]
            INNER JOIN [dbo].[TM_AREA] TA ON TS.[LscID] = TA.[LscID] AND TS.[AreaID] = TA.[AreaID]
            INNER JOIN [dbo].[TM_LSC] TL ON TA.[LscID] = TL.[LscID]
            LEFT OUTER JOIN [dbo].[TC_DeviceType] DT ON TD.[DevTypeID] = DT.[TypeID]
            LEFT OUTER JOIN [dbo].[TM_AREA] TAA ON TA.[LscID] = TAA.[LscID] AND TA.[LastAreaID] = TAA.[AreaID] AND TAA.[NodeLevel] = 2
            LEFT OUTER JOIN [dbo].[TM_AREA] TAAA ON TAA.[LscID] = TAAA.[LscID] AND TAA.[LastAreaID] = TAAA.[AreaID] AND TAAA.[NodeLevel] = 1
            WHERE TL.[LscID] = @LscID");

            if (area1Id != ComUtility.DefaultInt32)
            {
                sqlText.AppendFormat(@" AND TAAA.[AreaID] = {0}", area1Id);
            }

            if (area2Id != ComUtility.DefaultInt32)
            {
                sqlText.AppendFormat(@" AND TAA.[AreaID] = {0}", area2Id);
            }

            if (area3Id != ComUtility.DefaultInt32)
            {
                sqlText.AppendFormat(@" AND TA.[AreaID] = {0}", area3Id);
            }

            if (staId != ComUtility.DefaultInt32)
            {
                sqlText.AppendFormat(@" AND TS.[StaID] = {0}", staId);
            }

            if (devId != ComUtility.DefaultInt32)
            {
                sqlText.AppendFormat(@" AND TD.[DevID] = {0}", devId);
            }

            if (nodeId != ComUtility.DefaultInt32)
            {
                sqlText.AppendFormat(@" AND AI.[AicID] = {0}", nodeId);
            }

            SqlParameter[] parms = { new SqlParameter("@LscID", SqlDbType.Int) };
            parms[0].Value = lscId;

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, sqlText.ToString(), parms)) {
                while (rdr.Read())
                {
                    var alarm = new TrendAlarmInfo();
                    alarm.LscID       = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                    alarm.LscName     = ComUtility.DBNullStringHandler(rdr["LscName"]);
                    alarm.Area1Name   = ComUtility.DBNullStringHandler(rdr["Area1Name"]);
                    alarm.Area2Name   = ComUtility.DBNullStringHandler(rdr["Area2Name"]);
                    alarm.Area3Name   = ComUtility.DBNullStringHandler(rdr["Area3Name"]);
                    alarm.StaName     = ComUtility.DBNullStringHandler(rdr["StaName"]);
                    alarm.DevName     = ComUtility.DBNullStringHandler(rdr["DevName"]);
                    alarm.NodeID      = ComUtility.DBNullInt32Handler(rdr["NodeID"]);
                    alarm.NodeName    = ComUtility.DBNullStringHandler(rdr["NodeName"]);
                    alarm.DevTypeID   = ComUtility.DBNullInt32Handler(rdr["DevTypeID"]);
                    alarm.DevTypeName = ComUtility.DBNullStringHandler(rdr["DevTypeName"]);
                    alarm.AlarmType   = ComUtility.DBNullStringHandler(rdr["AlarmType"]);
                    alarm.AlarmLevel  = ComUtility.DBNullAlarmLevelHandler(rdr["AlarmLevel"]);
                    alarm.StartValue  = ComUtility.DBNullFloatHandler(rdr["StartValue"]);
                    alarm.AlarmValue  = ComUtility.DBNullFloatHandler(rdr["AlarmValue"]);
                    alarm.DiffValue   = ComUtility.DBNullFloatHandler(rdr["DiffValue"]);
                    alarm.StartTime   = ComUtility.DBNullDateTimeHandler(rdr["StartTime"]);
                    alarm.AlarmTime   = ComUtility.DBNullDateTimeHandler(rdr["AlarmTime"]);
                    alarm.ConfirmName = ComUtility.DBNullStringHandler(rdr["ConfirmName"]);
                    alarm.ConfirmTime = ComUtility.DBNullDateTimeHandler(rdr["ConfirmTime"]);
                    alarm.EndName     = ComUtility.DBNullStringHandler(rdr["EndName"]);
                    alarm.EndTime     = ComUtility.DBNullDateTimeHandler(rdr["EndTime"]);
                    alarms.Add(alarm);
                }
            }
            return(alarms);
        }