/// <summary> /// Get Device Type /// </summary> public Dictionary <String, Int32> GetDevType(int lscId, int nodeId) { SqlParameter[] parms = { new SqlParameter("@LscID", SqlDbType.Int), new SqlParameter("@DevID", SqlDbType.Int) }; parms[0].Value = lscId; if (nodeId == ComUtility.DefaultInt32) { parms[1].Value = DBNull.Value; } else { parms[1].Value = ComUtility.GetDevID(nodeId); } var dict = new Dictionary <String, Int32>(); using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_PREALARM_GETDEVTYPE, parms)) { while (rdr.Read()) { var key = String.Format("{0}-{1}", ComUtility.DBNullInt32Handler(rdr["LscID"]), ComUtility.DBNullInt32Handler(rdr["DevID"])); var value = ComUtility.DBNullInt32Handler(rdr["DevTypeID"]); dict.Add(key, value); } } return(dict); }
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); }
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); }
/// <summary> /// Method to get history frequency alarms /// </summary> public List <FrequencyAlarmInfo> GetHisFrequencyAlarms(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 <FrequencyAlarmInfo>(); using (var rdr = SqlHelper.ExecuteReader(SqlHelper.HisConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_PREALARM_GETFREHISALARMS, parms)) { if (rdr.HasRows) { dict = GetDevType(lscId, nodeId); } while (rdr.Read()) { var alarm = new FrequencyAlarmInfo(); 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.NodeType = ComUtility.DBNullNodeTypeHandler(rdr["NodeType"]); alarm.NodeName = ComUtility.DBNullStringHandler(rdr["NodeName"]); alarm.AlarmLevel = ComUtility.DBNullAlarmLevelHandler(rdr["AlarmLevel"]); alarm.FreAlarmValue = ComUtility.DBNullInt32Handler(rdr["FreAlarmValue"]); alarm.FreRightValue = ComUtility.DBNullInt32Handler(rdr["FreRightValue"]); 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); }