public string GetMarkers(double minLng, double maxLng, double minLat, double maxLat) { try { var markers = new StringBuilder(); var userData = UserData; var alarms = WebUtility.AlarmSAlmFilter(WebUtility.GetUserAlarms(userData)); var AL1Cnt = alarms.Count(alarm => alarm.AlarmLevel == EnmAlarmLevel.Critical); var AL2Cnt = alarms.Count(alarm => alarm.AlarmLevel == EnmAlarmLevel.Major); var AL3Cnt = alarms.Count(alarm => alarm.AlarmLevel == EnmAlarmLevel.Minor); var AL4Cnt = alarms.Count(alarm => alarm.AlarmLevel == EnmAlarmLevel.Hint); var gm = from alarm in alarms group alarm by new { alarm.LscID, alarm.StaName } into g select new { LscID = g.Key.LscID, StaName = g.Key.StaName, MaxAL = g.Min(a => a.AlarmLevel) }; markers.AppendFormat("{{AL1:{0},AL2:{1},AL3:{2},AL4:{3},Stations:{{", AL1Cnt, AL2Cnt, AL3Cnt, AL4Cnt); var cnt = 0; foreach (var s in gm) { if (cnt++ > 0) { markers.Append(","); } markers.AppendFormat("\"{0}\":{1}", Uri.EscapeDataString(String.Format("m_{0}_{1}", s.LscID, s.StaName)), (int)s.MaxAL); } markers.Append("}}"); return(markers.ToString()); } catch { return(String.Empty); } }
public string GetStationDetail(int lscId, int staId) { try { var otherEntity = new BOther(); var station = otherEntity.GetStation(lscId, staId); if (station != null) { int AL1Cnt = 0, AL2Cnt = 0, AL3Cnt = 0, AL4Cnt = 0; var userData = UserData; var alarms = WebUtility.AlarmSAlmFilter(WebUtility.GetUserAlarms(userData)); if (alarms != null && alarms.Count > 0) { AL1Cnt = alarms.Count(alarm => { return(alarm.StaName.Equals(station.StaName) && alarm.AlarmLevel == EnmAlarmLevel.Critical); }); AL2Cnt = alarms.Count(alarm => { return(alarm.StaName.Equals(station.StaName) && alarm.AlarmLevel == EnmAlarmLevel.Major); }); AL3Cnt = alarms.Count(alarm => { return(alarm.StaName.Equals(station.StaName) && alarm.AlarmLevel == EnmAlarmLevel.Minor); }); AL4Cnt = alarms.Count(alarm => { return(alarm.StaName.Equals(station.StaName) && alarm.AlarmLevel == EnmAlarmLevel.Hint); }); } return(String.Format("{{lscId:{0},lscName:\"{1}\",staId:{2},staName:\"{3}\",staTypeName:\"{4}\",staFeatureName:\"{5}\",address:\"{6}\",AL1:{7},AL2:{8},AL3:{9},AL4:{10}}}", station.LscID, station.LscName, station.StaID, station.StaName, station.StaTypeName, station.StaFeatureName, station.MapDesc, AL1Cnt, AL2Cnt, AL3Cnt, AL4Cnt)); } } catch { } return(String.Empty); }
/// <summary> /// History Alarms Refresh /// </summary> protected void OnHisAlarmsRefresh(object sender, StoreRefreshDataEventArgs e) { try { var start = Int32.Parse(e.Parameters["start"]); var limit = Int32.Parse(e.Parameters["limit"]); var end = start + limit; var data = new List <object>(limit); var cacheKey = WebUtility.GetCacheKeyName(UserData, "his-alarms"); var alarms = HttpRuntime.Cache[cacheKey] as List <AlarmInfo>; if (alarms == null) { alarms = AddDataToCache(); } if (alarms != null && alarms.Count > 0) { alarms = WebUtility.AlarmSAlmFilter(alarms); if (end > alarms.Count) { end = alarms.Count; } for (int i = start; i < end; i++) { data.Add(new { ID = i + 1, LscID = alarms[i].LscID, LscName = alarms[i].LscName, SerialNO = alarms[i].SerialNO, Area1Name = alarms[i].Area1Name, Area2Name = alarms[i].Area2Name, Area3Name = alarms[i].Area3Name, Area4Name = alarms[i].Area4Name, StaName = alarms[i].StaName, DevName = alarms[i].DevName, DevDesc = alarms[i].DevDesc, NodeID = alarms[i].NodeID, NodeType = (int)alarms[i].NodeType, NodeName = alarms[i].NodeName, AlarmID = alarms[i].AlarmID, AlarmDesc = alarms[i].AlarmDesc, AlarmDevice = alarms[i].AlarmDeviceType, AlarmLogic = alarms[i].AlarmLogType, AlarmName = alarms[i].AlarmName, AlarmClass = alarms[i].AlarmClass, AlarmLevel = (int)alarms[i].AlarmLevel, AlarmLevelName = WebUtility.GetAlarmLevelName(alarms[i].AlarmLevel), NMAlarmID = alarms[i].NMAlarmID, StartTime = WebUtility.GetDateString(alarms[i].StartTime), EndTime = WebUtility.GetDateString(alarms[i].EndTime), ConfirmMarking = (int)alarms[i].ConfirmMarking, ConfirmMarkingName = WebUtility.GetConfirmMarkingName(alarms[i].ConfirmMarking), ConfirmTime = WebUtility.GetDateString(alarms[i].ConfirmTime), ConfirmName = alarms[i].ConfirmName, TimeInterval = WebUtility.GetDateTimeInterval(alarms[i].StartTime, alarms[i].EndTime), ProjName = alarms[i].ProjName, MAlm = alarms[i].AuxAlarmDesc, Conn = alarms[i].AuxAlarmDesc, TurnCount = alarms[i].TurnCount }); } } e.Total = (alarms != null ? alarms.Count : 0); HisAlarmsStore.DataSource = data; HisAlarmsStore.DataBind(); } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
/// <summary> /// Save Button Click /// </summary> protected void SaveBtn_Click(object sender, DirectEventArgs e) { try { var cacheKey = WebUtility.GetCacheKeyName(UserData, "his-alarms"); var alarms = HttpRuntime.Cache[cacheKey] as List <AlarmInfo>; if (alarms == null) { alarms = AddDataToCache(); } if (alarms == null) { WebUtility.ShowMessage(EnmErrType.Warning, "获取数据时发生错误,导出失败!"); return; } var datas = new DataTable(); datas.Columns.Add(new DataColumn("Lsc名称", typeof(String))); datas.Columns.Add(new DataColumn("地区名称", typeof(String))); datas.Columns.Add(new DataColumn("县市名称", typeof(String))); datas.Columns.Add(new DataColumn("局站名称", typeof(String))); datas.Columns.Add(new DataColumn("设备名称", typeof(String))); datas.Columns.Add(new DataColumn("设备描述", typeof(String))); datas.Columns.Add(new DataColumn("测点名称", typeof(String))); datas.Columns.Add(new DataColumn("告警描述", typeof(String))); datas.Columns.Add(new DataColumn("告警设备类型", typeof(String))); datas.Columns.Add(new DataColumn("告警逻辑分类", typeof(String))); datas.Columns.Add(new DataColumn("告警标准名称", typeof(String))); datas.Columns.Add(new DataColumn("告警类别", typeof(String))); datas.Columns.Add(new DataColumn("告警级别", typeof(String))); datas.Columns.Add(new DataColumn("告警时间", typeof(DateTime))); datas.Columns.Add(new DataColumn("结束时间", typeof(DateTime))); datas.Columns.Add(new DataColumn("处理标识", typeof(String))); datas.Columns.Add(new DataColumn("处理时间", typeof(DateTime))); datas.Columns.Add(new DataColumn("处理人员", typeof(String))); datas.Columns.Add(new DataColumn("告警历时", typeof(String))); datas.Columns.Add(new DataColumn("动环监控告警ID", typeof(String))); datas.Columns.Add(new DataColumn("工程预约", typeof(String))); datas.Columns.Add(new DataColumn("主告警", typeof(String))); datas.Columns.Add(new DataColumn("关联告警", typeof(String))); datas.Columns.Add(new DataColumn("翻转次数", typeof(Int32))); datas.Columns.Add(new DataColumn("ColorColumn", typeof(Excel.Color))); alarms = WebUtility.AlarmSAlmFilter(alarms); DataRow row; for (int i = 0; i < alarms.Count; i++) { row = datas.NewRow(); row["Lsc名称"] = alarms[i].LscName; row["地区名称"] = alarms[i].Area2Name; row["县市名称"] = alarms[i].Area3Name; row["局站名称"] = alarms[i].StaName; row["设备名称"] = alarms[i].DevName; row["设备描述"] = alarms[i].DevDesc; row["测点名称"] = alarms[i].NodeName; row["告警描述"] = alarms[i].AlarmDesc; row["告警设备类型"] = alarms[i].AlarmDeviceType; row["告警逻辑分类"] = alarms[i].AlarmLogType; row["告警标准名称"] = alarms[i].AlarmName; row["告警类别"] = alarms[i].AlarmClass; row["告警级别"] = WebUtility.GetAlarmLevelName(alarms[i].AlarmLevel); row["告警时间"] = WebUtility.DBNullDateTimeChecker(alarms[i].StartTime); row["结束时间"] = WebUtility.DBNullDateTimeChecker(alarms[i].EndTime); row["处理标识"] = WebUtility.GetConfirmMarkingName(alarms[i].ConfirmMarking); row["处理时间"] = WebUtility.DBNullDateTimeChecker(alarms[i].ConfirmTime); row["处理人员"] = alarms[i].ConfirmName; row["告警历时"] = WebUtility.GetDateTimeInterval(alarms[i].StartTime, alarms[i].EndTime); row["动环监控告警ID"] = alarms[i].NMAlarmID; row["工程预约"] = WebUtility.GetBooleanName(!String.IsNullOrEmpty(alarms[i].ProjName)); row["主告警"] = WebUtility.GetBooleanName(alarms[i].AuxAlarmDesc.Equals("MAlm")); row["关联告警"] = WebUtility.GetBooleanName(alarms[i].AuxAlarmDesc.Equals("Conn")); row["翻转次数"] = alarms[i].TurnCount; row["ColorColumn"] = WebUtility.GetExcelAlarmColor(alarms[i].AlarmLevel); datas.Rows.Add(row); } var fileName = "HisAlarms.xls"; var sheetName = "历史告警"; var title = "动力环境监控中心系统 历史告警报表"; var subTitle = String.Format("值班员:{0} 日期:{1}", Page.User.Identity.Name, WebUtility.GetDateString(DateTime.Now)); var xls = WebUtility.ExportDataToExcel(fileName, sheetName, title, subTitle, datas); if (xls != null) { xls.Send(); } } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
public string PlayHandler() { try { List <LscInfo> lscs = null; List <AlarmInfo> alarms = null; var audios = new List <string>(); var userData = UserData; foreach (var lscUser in userData.LscUsers) { if (lscUser.AlarmSoundFiterItem == null) { continue; } if (lscUser.AlarmSoundFiterItem.SpDisconnect) { if (lscs == null) { var lscEntity = new BLsc(); lscs = lscEntity.GetLscs(); } var lsc = lscs.Find(l => { return(l.LscID == lscUser.LscID); }); if (lsc != null && !lsc.Connected) { audios.Add(String.Format("\"请注意,{0}服务器通信中断!\"", lsc.LscName)); } } bool isAdd = true; if (lscUser.AlarmSoundFiterItem.AL1Enabled && isAdd) { if (alarms == null) { alarms = WebUtility.AlarmSAlmFilter(WebUtility.GetUserAlarms(userData)); } if (alarms != null && alarms.Count > 0) { var agi = alarms.Find(a => { return(a.LscID == lscUser.LscID && a.AlarmLevel == EnmAlarmLevel.Critical); }); if (agi != null) { audios.Add(String.Format("\"请注意,{0}发生{1}!\"", agi.LscName, WebUtility.GetAlarmLevelName(agi.AlarmLevel))); isAdd = false; } } } if (lscUser.AlarmSoundFiterItem.AL2Enabled && isAdd) { if (alarms == null) { alarms = WebUtility.AlarmSAlmFilter(WebUtility.GetUserAlarms(userData)); } if (alarms != null && alarms.Count > 0) { var agi = alarms.Find(a => { return(a.LscID == lscUser.LscID && a.AlarmLevel == EnmAlarmLevel.Major); }); if (agi != null) { audios.Add(String.Format("\"请注意,{0}发生{1}!\"", agi.LscName, WebUtility.GetAlarmLevelName(agi.AlarmLevel))); isAdd = false; } } } if (lscUser.AlarmSoundFiterItem.AL3Enabled && isAdd) { if (alarms == null) { alarms = WebUtility.AlarmSAlmFilter(WebUtility.GetUserAlarms(userData)); } if (alarms != null && alarms.Count > 0) { var agi = alarms.Find(a => { return(a.LscID == lscUser.LscID && a.AlarmLevel == EnmAlarmLevel.Minor); }); if (agi != null) { audios.Add(String.Format("\"请注意,{0}发生{1}!\"", agi.LscName, WebUtility.GetAlarmLevelName(agi.AlarmLevel))); isAdd = false; } } } if (lscUser.AlarmSoundFiterItem.AL4Enabled && isAdd) { if (alarms == null) { alarms = WebUtility.AlarmSAlmFilter(WebUtility.GetUserAlarms(userData)); } if (alarms != null && alarms.Count > 0) { var agi = alarms.Find(a => { return(a.LscID == lscUser.LscID && a.AlarmLevel == EnmAlarmLevel.Hint); }); if (agi != null) { audios.Add(String.Format("\"请注意,{0}发生{1}!\"", agi.LscName, WebUtility.GetAlarmLevelName(agi.AlarmLevel))); isAdd = false; } } } if (!String.IsNullOrEmpty(lscUser.AlarmSoundFiterItem.SpDevFilter) || !String.IsNullOrEmpty(lscUser.AlarmSoundFiterItem.SpNodeFilter)) { if (alarms == null) { alarms = WebUtility.AlarmSAlmFilter(WebUtility.GetUserAlarms(userData)); } if (alarms != null && alarms.Count > 0) { DateTime curScan, scanTime; curScan = scanTime = alarms.Max(a => a.UpdateTime); if (Request.Cookies["ScanTime"] != null) { scanTime = ConvertStringToDateTime(Request.Cookies["ScanTime"].Value); } if (Request.Cookies["ScanTime"] == null || !lscUser.AlarmSoundFiterItem.SpLoop) { var cookie = new HttpCookie("ScanTime", curScan.Ticks.ToString()); Response.Cookies.Add(cookie); } var agis = alarms.FindAll(a => { return(a.LscID == lscUser.LscID && a.UpdateTime > scanTime && (WebUtility.StringSplit(lscUser.AlarmSoundFiterItem.SpDevFilter).Contains(a.DevName) || WebUtility.StringSplit(lscUser.AlarmSoundFiterItem.SpNodeFilter).Contains(a.NodeName))); }); if (agis != null) { foreach (var agi in agis) { audios.Add(String.Format("\"{0}{1}{2}{3}{4}{5}发生{6}!\"", agi.LscName, lscUser.AlarmSoundFiterItem.SpArea2 ? agi.Area2Name : String.Empty, lscUser.AlarmSoundFiterItem.SpArea3 ? agi.Area3Name : String.Empty, lscUser.AlarmSoundFiterItem.SpStation ? agi.StaName : String.Empty, lscUser.AlarmSoundFiterItem.SpDevice ? agi.DevName : String.Empty, lscUser.AlarmSoundFiterItem.SpNode ? agi.NodeName : String.Empty, lscUser.AlarmSoundFiterItem.SpALDesc ? WebUtility.GetAlarmLevelName(agi.AlarmLevel) : "告警")); } } } } } return(String.Format("[{0}]", String.Join(",", audios.ToArray()))); } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); } return(String.Empty); }