public static bool ClearAllEventStatus(string tagMac) { if (LocatingServiceUtil.IsAvailable()) { IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); bool boolean = serviceApi.ClearTagStatus(tagMac); //记录日志 using (AppDataContext db = new AppDataContext()) { Tag tag = db.Tags.SingleOrDefault(t => t.TagMac == tagMac); if (tag != null) { Diary.Insert(ContextUser.Current.Id, tag.Id, TagStatusView.SelectTagStatus(tag.Id).HostTag.HostId, "清除" + tag.TagName + "的所有报警状态。");//SecurityLog.Insert(tag.Id, TagUser.GetUserIdByTagId(tag.Id), "清除" + tag.TagName + "的所有报警状态。", Priority.High); } } return(boolean); } else { return(false); } }
protected void LoadTagAlert() { using (AppDataContext db = new AppDataContext()) { _tagAlert = db.TagAlerts.SingleOrDefault(t => t.AlertId == _id); if (_tagAlert == null) { ShowMessagePage("报警事件不存在。"); } else { HostTag thisHostTag = HostTag.GetById(_tagAlert.HostId); Tag thisTag = Tag.Select(thisHostTag.TagId); if (thisTag != null) { tagName.Text = thisHostTag.HostName; int coorid = _tagAlert.CoordinatesId; if (CommonExtension.IsIlltreatTag(_tagAlert.HostId) && Config.Settings.ProjectType != ProjectTypeEnum.NMPrison) { coorid = CommonExtension.GetCoordinatesId(thisHostTag.Description.Substring(0, thisHostTag.Description.Length - 2)); } if (Config.Settings.ProjectType == ProjectTypeEnum.NMPrison) { coordinatesName.Text = thisHostTag.HostName; } else { coordinatesName.Text = Coordinates.GetName(coorid); } if (LocatingServiceUtil.IsAvailable()) { IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); bool boolean = serviceApi.ClearTagStatus(thisTag.TagMac, (SupportEvent)_tagAlert.AlertType); } description.Text = CommonExtension.GetEventDescription((SupportEvent)_tagAlert.AlertType, _tagAlert.HostId); time.DisplayValue = _tagAlert.WriteTime; if (_tagAlert.MasterUserId > 0) { alertMaster.Text = Data.User.Select(_tagAlert.MasterUserId) == null ? "未知" : Data.User.Select(_tagAlert.MasterUserId).UserName; } alertStatus.Text = NetRadio.Common.LocatingMonitor.Misc.GetAlertStatus((AlertStatusType)_tagAlert.AlertStatus); list.DataSource = db.AlertProcessLogs.Where(t => t.AlertId == _id).OrderBy(t => t.UpdateTime).ToList(); list.ItemCreated += new RepeaterItemEventHandler(list_ItemCreated); list.DataBind(); if (!IsPostBack) { Dictionary <string, int> alertResults = new Dictionary <string, int>(); alertResults.Add(CommonExtension.GetEventDescription((SupportEvent)_tagAlert.AlertType, _tagAlert.HostId), 1); alertResults.Add("误报", 2); alertResults.Add("其它", 3); foreach (var item in alertResults) { ListItem listitem = new ListItem(item.Key, item.Value.ToString()); if (item.Value == 1) { listitem.Selected = true; } alertResultList.Items.Add(listitem); } } if (_tagAlert.AlertStatus == (byte)AlertStatusType.New || _tagAlert.AlertStatus == (byte)AlertStatusType.Processing) { alertResultList.Visible = true; alertResult.Visible = false; handover.Visible = true; alertProcess.Visible = true; otherReason.Visible = true; } else { alertResultList.Visible = false; alertResult.Visible = true; handover.Visible = false; alertProcess.Visible = false; otherReason.Visible = false; AlertProcessLog alertProcessLog = db.AlertProcessLogs.SingleOrDefault(t => t.AlertId == _id && t.AlertStatus == (byte)AlertStatusType.Resolved); if (alertProcessLog != null) { alertResult.Text = alertProcessLog.ChangeReason; } } } } } }
public static object GetData(int alertID) { string id_name = ""; string id_position = ""; string id_type = ""; string id_time = ""; string id_table = ""; NameID[] id_selectResult = null; using (AppDataContext db = new AppDataContext()) { TagAlert _tagAlert = db.TagAlerts.SingleOrDefault(t => t.AlertId == alertID); if (_tagAlert == null) { throw new Exception("报警事件不存在!"); } else { HostTag thisHostTag = HostTag.GetById(_tagAlert.HostId); Tag thisTag = Tag.Select(thisHostTag.TagId); if (thisTag != null) { if (CommonExtension.IsIlltreatTag(_tagAlert.HostId)) { if (Config.Settings.ProjectType == ProjectTypeEnum.NMPrison) { id_position = thisHostTag.HostName; } else { int coorid = CommonExtension.GetCoordinatesId(thisHostTag.Description.Substring(0, thisHostTag.Description.Length - 2)); id_position = Coordinates.GetName(coorid); } } else { id_position = Coordinates.GetName(_tagAlert.CoordinatesId); } //if (Config.Settings.ProjectType == ProjectTypeEnum.NMPrison) //{ // id_position = thisHostTag.HostName; //} //else //{ // int coorid = CommonExtension.GetCoordinatesId(thisHostTag.Description.Substring(0, thisHostTag.Description.Length - 2)); // id_position = Coordinates.GetName(coorid); //} if (LocatingServiceUtil.IsAvailable()) { IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); bool boolean = serviceApi.ClearTagStatus(thisTag.TagMac, (SupportEvent)_tagAlert.AlertType); } id_name = thisHostTag.HostName; //id_position = Coordinates.GetName(coorid); id_type = CommonExtension.GetEventDescription((SupportEvent)_tagAlert.AlertType, _tagAlert.HostId); id_time = _tagAlert.WriteTime.ToString("yyyy/MM/dd HH:mm:ss"); id_selectResult = db.ProcessResults.Select(_d => new NameID { ID = _d.ID, Name = _d.Text }).ToArray(); id_table = GetProcessTable(alertID); return(new { id_name, id_position, id_type, id_time, id_table, id_selectResult }); } } } return(""); }
public static bool ClearEventStatus(string tagMac, string eventKeyword) { SupportEvent clearEvent; string str; switch (eventKeyword) { case "absence": clearEvent = SupportEvent.Absent; str = "消失"; break; case "areaEvent": clearEvent = SupportEvent.AreaEvent; str = "进出区域"; break; case "batteryInsufficient": clearEvent = SupportEvent.BatteryInsufficient; str = "低电量"; break; case "batteryReset": clearEvent = SupportEvent.BatteryReset; str = "电池重置"; break; case "buttonPressed": clearEvent = SupportEvent.ButtonPressed; str = "按钮"; break; case "wristletBroken": clearEvent = SupportEvent.WristletBroken; str = "腕带"; break; default: return(false); } if (LocatingServiceUtil.IsAvailable()) { IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); bool boolean = serviceApi.ClearTagStatus(tagMac, 0); //记录日志 using (AppDataContext db = new AppDataContext()) { Tag tag = db.Tags.SingleOrDefault(t => t.TagMac == tagMac); if (tag != null) { Diary.Insert(ContextUser.Current.Id, tag.Id, TagStatusView.SelectTagStatus(tag.Id).HostTag.HostId, "清除" + tag.TagName + "的" + str + "报警状态。"); } } return(boolean); } else { return(false); } }