public static string GetAllTagEventsDescription(TagStatusView status, int userType, int pid, string masterFile) { IList <string> arr = new List <string>(); if (status.AbsenceStatus == EventStatus.Occurring) { arr.Add(string.Format("<a href=\"" + Web.WebPath.GetFullPath("History/AbsenceLog.aspx?userType={0}&pid={1}&masterFile={2}") + "\">{3}</a>", userType, pid, masterFile, "消失")); } if (status.AreaEventStatus == EventStatus.Occurring) { arr.Add(string.Format("<a href=\"" + Web.WebPath.GetFullPath("History/AreaEventLog.aspx?userType={0}&pid={1}&masterFile={2}") + "\">{3}</a>", userType, pid, masterFile, "出入区域")); } if (status.BatteryInsufficientStatus == EventStatus.Occurring) { arr.Add(string.Format("<a href=\"" + Web.WebPath.GetFullPath("History/LowBatteryLog.aspx?userType={0}&pid={1}&masterFile={2}") + "\">{3}</a>", userType, pid, masterFile, "电量不足")); } if (status.BatteryResetStatus == EventStatus.Occurring) { arr.Add(string.Format("<a href=\"" + Web.WebPath.GetFullPath("History/BatteryResetLog.aspx?userType={0}&pid={1}&masterFile={2}") + "\">{3}</a>", userType, pid, masterFile, "换电池")); } if (status.ButtonPressedStatus == EventStatus.Occurring) { arr.Add(string.Format("<a href=\"" + Web.WebPath.GetFullPath("History/ButtonPressedLog.aspx?userType={0}&pid={1}&masterFile={2}") + "\">{3}</a>", userType, pid, masterFile, "触动按钮")); } if (status.WristletBrokenStatus == EventStatus.Occurring) { arr.Add(string.Format("<a href=\"" + Web.WebPath.GetFullPath("History/WristletBrokenLog.aspx?userType={0}&pid={1}&masterFile={2}") + "\">{3}</a>", userType, pid, masterFile, "断开腕带")); } return(string.Join("<span class='separator'> | </span>", arr.ToArray())); }
private int GetActiveTagTotalCount(int groupId) { IList <TagStatusView> tagList = new List <TagStatusView>(); string _keyword = ""; int[] _hostGroupArray = new int[1]; _hostGroupArray[0] = groupId; int totalCount = 0; if (LocatingServiceUtil.IsAvailable()) { IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); if (serviceApi != null) { TagStatusView tagStatusView = new TagStatusView(); tagList = serviceApi.SelectTagStatusList( _keyword, _hostGroupArray, 0, true, false, //SupportEvent.Absent), false, //SupportEvent.BatteryInsufficient), false, //SupportEvent.AreaEvent), false, //SupportEvent.ButtonPressed), false, //SupportEvent.WristletBroken), "", SortDirection.Ascending, 0,//only get total count 0, out totalCount); } } return(totalCount); }
public static string GetAllTagEventsDescription(TagStatusView status) { IList <string> arr = new List <string>(); if (status.AbsenceStatus == EventStatus.Occurring) { arr.Add("消失"); } if (status.AreaEventStatus == EventStatus.Occurring) { arr.Add("出入区域"); } if (status.BatteryInsufficientStatus == EventStatus.Occurring) { arr.Add("电量不足"); } if (status.BatteryResetStatus == EventStatus.Occurring) { arr.Add("换电池"); } if (status.ButtonPressedStatus == EventStatus.Occurring) { arr.Add("触动按钮"); } if (status.WristletBrokenStatus == EventStatus.Occurring) { arr.Add("断开腕带"); } return(string.Join("<span class='separator'> | </span>", arr.ToArray())); }
protected void deleteButton_Click(object sender, EventArgs e) { HostTag host = HostTag.GetById(_id); if (host != null) { bool serviceAvailable = LocatingServiceUtil.IsAvailable(); var tagId = host.TagId; if (tagId > 0) { using (AppDataContext db = new AppDataContext()) { //更新标签名称 Tag tag = Tag.Select(tagId); if (tag != null) { string mac = tag.TagMac; if (serviceAvailable) { LocatingServiceUtil.Instance <IServiceApi>().UpdateTagNameAndSerialNo(tagId, "NewTag_" + mac.Substring(12), ""); } else { Tag.UpdateTagNameAndSerialNo(tagId, "NewTag_" + mac.Substring(12), ""); } } //删除标签历史记录和相关信息 GenericEventLog.DeleteByTagId(tagId); TagEventStatus.DeleteMany(tagId); TagPositionStatus.DeleteMany(tagId); TagAlert.DeleteTagAlerts(tagId); } TagStatusView.SelectTagStatus(tagId).HostTag = null; } TagAlert.DeleteTagAlerts(_id); //删除host信息 HostTag.DeleteHostTag(_id); //记录日志 if (tagId > 0 && serviceAvailable) { LocatingServiceUtil.Instance <IServiceApi>().ReloadTagHost(tagId); } Diary.Insert(ContextUser.Current.Id, tagId, _id, "删除定点报警标签" + host.HostName + "的信息" + (host.TagId == 0 ? "" : "并解除标签绑定。") + "。"); } new SuccessTerminator().End("删除成功。", -1, Link.CloseWindow); }
private string CreateOutputContent() { StringBuilder sb = new StringBuilder(); sb.AppendLine("<?xml version=\"1.0\" standalone=\"yes\" ?>"); sb.AppendLine("<LatestEvents>"); using (AppDataContext db = new AppDataContext()) { //var list = db.LatestEvents // .Where(x => x.ResolveFlag != (byte)ResolveFlag.Processed) // .Where(x => HostTag.All.Where(u => u.TagId != 0).Select(u => u.TagId).ToArray().Contains(x.TagId)) // .OrderByDescending(x => x.LastHappenTime) // .ToList(); var list = db.TagAlerts.Where(l => l.AlertStatus == (byte)AlertStatusType.New) .Where(l => l.HostId > 0) .OrderByDescending(l => l.WriteTime) .ThenByDescending(l => l.AlertLevel) //.OrderByDescending(l => l.AlertLevel) .ToList(); //lyz 获取用户的类型 System.Collections.Generic.IEnumerable <int> hostidds = list.Select(u => u.HostId); System.Collections.Generic.IEnumerable <Data.HostGroup> hgs = db.HostGroups.Where(_d => hostidds.Contains(_d.HostId) && (_d.HostGroupId == 1 || _d.HostGroupId == 2)).AsEnumerable(); var str = " <item id='{0}' tagId='{1}' tagMac='{2}' tagName='{3}' coordinatesId='{4}' coodinatesName='{5}' eventType='{6}' eventDescription='{7}' lastHappenTime='{8}' hostGroupID='{9}' />\r\n"; foreach (var i in list) { //lyz 获取用户的类型 Data.HostGroup hg = hgs.Where(_d => _d.HostId == i.HostId).FirstOrDefault(); //20100106: select by host //TagStatusView tagStatusView = TagStatusView.SelectTagStatus(i.TagId); TagStatusView tagStatusView = TagStatusView.SelectTagStatusByHostId(i.HostId); if (hg != null && tagStatusView != null)//判断对象是否存在 lyz { sb.AppendFormat(str, i.HostId, i.TagId, tagStatusView.Mac, tagStatusView.HostTag.HostName, i.CoordinatesId, Coordinates.GetName(i.CoordinatesId), i.AlertType, CommonExtension.GetEventDescription((SupportEvent)i.AlertType, i.HostId), i.WriteTime, hg.HostGroupId); } } } sb.AppendLine("</LatestEvents>"); return(sb.ToString()); }
protected void list_ItemCreated(object sender, RepeaterItemEventArgs e) { Facility f = (Facility)e.Item.DataItem; SmartLabel facilityName = e.Item.FindControl("facilityName") as SmartLabel; SmartLabel headCount = e.Item.FindControl("headCount") as SmartLabel; facilityName.Text = f.FacilityName; IList <TagStatusView> tagList = new List <TagStatusView>(); string _keyword = ""; //GTang 20101122 修改为统计hostGroupid=1,2 //int[] _hostGroupArray = new int[1] { 1 }; int[] _hostGroupArray = new int[2] { 1, 2 }; int totalCount = 0; IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); if (serviceApi != null && LocatingServiceUtil.IsAvailable()) { TagStatusView tagStatusView = new TagStatusView(); tagList = serviceApi.SelectTagStatusList( _keyword, _hostGroupArray, f.MapId, true, false, //SupportEvent.Absent), false, //SupportEvent.BatteryInsufficient), false, //SupportEvent.AreaEvent), false, //SupportEvent.ButtonPressed), false, //SupportEvent.WristletBroken), "", SortDirection.Ascending, 0,//only get total count 0, out totalCount); headCount.Text = totalCount.ToString(); _totalCount += totalCount; } }
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 list_ItemCreated(object sender, RepeaterItemEventArgs e) { MapArea area = e.Item.DataItem as MapArea; if (area != null) { SmartLabel areaName = (SmartLabel)e.Item.FindControl("areaName"); areaName.Text = area.AreaName; NumericLabel quota = (NumericLabel)e.Item.FindControl("quota"); quota.Value = CulpritRoomReference.All.Count(x => x.JailRoomId == area.Id); NumericLabel bindingCount = (NumericLabel)e.Item.FindControl("bindingCount"); NumericLabel currentCount = (NumericLabel)e.Item.FindControl("currentCount"); SmartLabel expectedNames = (SmartLabel)e.Item.FindControl("expectedNames"); SmartLabel illedNames = (SmartLabel)e.Item.FindControl("illedNames"); var coordinates = MapAreaCoverage.All.Where(x => x.AreaId == area.Id).Select(x => x.CoordinatesId).ToArray(); IList <TagStatusView> nowUsers = new List <TagStatusView>(); foreach (var item in FullTagStatusView) { if (coordinates.Contains(item.CoordinatesId) && HostTag.GetHostGroup(item.HostTag.HostId).Contains((int)TagUserType.Culprit) && item.AbsenceStatus != EventStatus.Occurring) { currentCount.Value++; nowUsers.Add(item); } } if (currentCount.Value != quota.Value) { currentCount.CssClass = "t2"; } IList <HostTag> shouldUsers = HostTag.AllActive .Where(x => CulpritRoomReference.All.Where(r => r.JailRoomId == area.Id).Select(r => r.CulpritId).Contains(x.HostId)) .ToList(); bindingCount.Value = shouldUsers.Count; IList <string> arr1 = new List <string>(); //foreach (var item in nowUsers) //{ // if (shouldUsers.Any(x => x.TagId == item.TagId) == false) // { // arr1.Add("<a href='../Objects/Tag.aspx?id=" + item.TagId + "' target='_blank'>" + item.TagName + "</a>"); // } //} //extraNames.Text = string.Join(", ", arr1.ToArray()); IList <string> arr2 = new List <string>(); foreach (var item in shouldUsers) { TagStatusView tagStatusView = LocatingServiceUtil.Instance <IServiceApi>().SelectTagStatus(item.TagId); if (nowUsers.Any(x => x.TagId == item.TagId) == false) { int hostType = HostTagView.GetHostView(item.TagId).HostGroupId.Contains(1) ? 1 : 2; arr2.Add("<a href='../TagUsers/TagUser.aspx?type=" + hostType + "&id=" + item.HostId + "' target='_blank'>" + item.HostName + "</a> : " + tagStatusView.CoordinatesName); } if (tagStatusView.HostTag.HostGroupId.Contains((int)TagUserType.IlledPrisoner)) { arr1.Add("<a href='../TagUsers/TagUser.aspx?type=" + (int)TagUserType.Culprit + "&id=" + item.HostId + "' target='_blank'>" + item.HostName + "</a>"); } } expectedNames.Text = string.Join("<br>", arr2.ToArray()); illedNames.Text = string.Join(", ", arr1.ToArray()); } }
private string CreateOutputContent() { StringBuilder sb = new StringBuilder(); sb.AppendLine("<?xml version=\"1.0\" standalone=\"yes\" ?>"); sb.AppendLine("<tagCoordinates>"); if (!LocatingServiceUtil.IsAvailable()) { sb.AppendLine("</tagCoordinates>"); return(sb.ToString()); } IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); TagStatusView tagStatusView = new TagStatusView(); if (_tagId > 0) { tagStatusView = serviceApi.SelectTagStatus(_tagId); if (tagStatusView != null && _mapId > 0 && tagStatusView.TagId > 0) { _mapId = tagStatusView.MapId; } if (tagStatusView.WorkingStatus != TagWorkingStatus.Locating) { _tagId = 0; _mapId = Fetch.QueryUrlAsIntegerOrDefault("mapId", -1); } } int totalCount = 0; IList <TagStatusView> tagList = new List <TagStatusView>(); if (_hostGroupArray == null || _hostGroupArray.Length == 0) { _hostGroupArray = new int[] { 1, 2 }; } if (_keyword.Length > 0 && !_keyword.Contains(',')) { _mapId = 0; tagList = serviceApi.SelectTagStatusListByKeywords( _keyword, _hostGroupArray, _mapId, true, _eventTypes.Contains((int)SupportEvent.Absent), _eventTypes.Contains((int)SupportEvent.BatteryInsufficient), _eventTypes.Contains((int)SupportEvent.AreaEvent), _eventTypes.Contains((int)SupportEvent.ButtonPressed), _eventTypes.Contains((int)SupportEvent.WristletBroken), "Position", SortDirection.Ascending, _pageSize, _pageSize * (_currentPage - 1), out totalCount ).ToList(); tagList = tagList.Where(x => x.X > 0 && !x.HostTag.HostGroupId.Contains((int)TagUserType.Position)).OrderBy(x => x.X).ToList(); //totalCount = tagList.Count; } else { tagList = serviceApi.SelectTagStatusList( _keyword, _hostGroupArray, _mapId, true, _eventTypes.Contains((int)SupportEvent.Absent), _eventTypes.Contains((int)SupportEvent.BatteryInsufficient), _eventTypes.Contains((int)SupportEvent.AreaEvent), _eventTypes.Contains((int)SupportEvent.ButtonPressed), _eventTypes.Contains((int)SupportEvent.WristletBroken), "Position", SortDirection.Ascending, _pageSize, _pageSize * (_currentPage - 1), out totalCount ).ToList(); tagList = tagList.Where(x => x.X > 0).OrderBy(x => x.X).ToList(); //totalCount = tagList.Count; } int tracingItemIndex = -1; if (tagStatusView != null && _tagId > 0) { for (int i = 0; i < tagList.Count(); i++) { if (tagList[i].Mac == tagStatusView.Mac) { tracingItemIndex = i; } } } //IList<TagStatusView> tagStatusList = tagList.ToList(); if (tracingItemIndex != 0 && _tagId > 0) { if (tracingItemIndex > 0) { tagList.RemoveAt(tracingItemIndex); } tagList.Insert(0, tagStatusView); } sb.AppendLine("<pagination>"); sb.AppendFormat("<recordCount>{0}</recordCount>\r\n", totalCount); sb.AppendFormat("<pageSize>{0}</pageSize>\r\n", _pageSize); sb.AppendFormat("<currentPage>{0}</currentPage>\r\n", _currentPage); sb.AppendLine("</pagination>"); var coordinatesFormat = "<coordinates id=\"{0}\" mapId=\"{1}\" mapName=\"{2}\" coordinatesName=\"{3}\" x=\"{4}\" y=\"{5}\">"; var tagFormat = "<tag id=\"{0}\" tagName=\"{1}\" warningTypes=\"{2}\" warningLevel=\"{3}\" moveSpeed=\"{4}\" icon=\"{5}\" updateTime=\"{6}\" groupIds=\"{7}\" />"; foreach (var item in tagList) { if (_coordinatesId != item.CoordinatesId) { if (_coordinatesId >= 0) { sb.AppendLine("</coordinates>"); } sb.AppendFormat(coordinatesFormat, item.CoordinatesId, item.MapId, Facility.GetNameByMapId(item.MapId), item.CoordinatesName, item.X, item.Y); _coordinatesId = item.CoordinatesId; } List <string> warningTypes = new List <string>(); if (item.AreaEventStatus == EventStatus.Occurring) { warningTypes.Add(((int)SupportEvent.AreaEvent).ToString()); } if (item.AbsenceStatus == EventStatus.Occurring) { warningTypes.Add(((int)SupportEvent.Absent).ToString()); } if (item.BatteryInsufficientStatus == EventStatus.Occurring) { warningTypes.Add(((int)SupportEvent.BatteryInsufficient).ToString()); } if (item.BatteryResetStatus == EventStatus.Occurring) { warningTypes.Add(((int)SupportEvent.BatteryReset).ToString()); } if (item.ButtonPressedStatus == EventStatus.Occurring) { warningTypes.Add(((int)SupportEvent.ButtonPressed).ToString()); } if (item.WristletBrokenStatus == EventStatus.Occurring) { warningTypes.Add(((int)SupportEvent.WristletBroken).ToString()); } string hostGroupIds = ""; if (item.HostTag.HostGroupId.Length > 0) { foreach (int gId in item.HostTag.HostGroupId) { if (gId > 0) { if (hostGroupIds == "") { hostGroupIds += gId.ToString(); } else { hostGroupIds += "," + gId.ToString(); } } } } string hostName = item.HostTag.HostName; if (hostName == "") { hostName = item.TagName; } sb.AppendFormat(tagFormat, item.TagId, hostName, string.Join(",", warningTypes.ToArray()), warningTypes.ToArray().Length > 0 ? "3" : "1", "2", CommonExtension.IdentityIconByGroupId(item.HostTag.HostGroupId), item.PositionUpdateTime.ToString("yyyy/M/d H:mm:ss").Replace('-', '/'), hostGroupIds /*item.HostTag.HostGroupId.Contains(1) ? 1 : 2*/); } if (_coordinatesId >= 0) { sb.AppendLine("</coordinates>"); } sb.AppendLine("</tagCoordinates>"); return(sb.ToString()); }
private void AddHostTagGroup(int[] TagIdArray, int groupId) { int MapId = 0; List <int> lHostIds = new List <int>(); for (int i = 0; i < TagIdArray.Length; i++) { HostTag host = HostTag.GetById(TagIdArray[i]); if (host != null && host.HostId > 0) { HostTag.SetHostGroup(host.HostId, groupId); } else { host = new HostTag(); Tag tag = Tag.Select(TagIdArray[i]); if (tag != null) { host.HostExternalId = tag.SerialNo; //TagHost tagHost = Tag.SelectTagHost(TagIdArray[i]); host.HostName = groupName.Text.Trim() + "_" + ((tag.TagMac.Length > 9) ? tag.TagMac.Substring(9) : tag.TagMac); host.Description = tag.TagName; host.ImagePath = ""; host.HostType = 0; host.TagId = TagIdArray[i]; host.HostId = HostTag.AddOrUpdateHostTag(0, host.TagId, host.HostExternalId, host.HostName, host.HostType, host.Description, host.ImagePath); HostTag.SetHostGroup(host.HostId, groupId); if (i == 0) { TagStatusView tagView1 = TagStatusView.SelectTagStatusByHostId(host.HostId); MapId = tagView1.MapId; } } } lHostIds.Add(host.HostId); } int[] hostIds = lHostIds.ToArray(); if (LocatingServiceUtil.IsAvailable()) { //内蒙不需要这样删除 try { int[] delhostIds; GetDelIDs(out delhostIds, groupId, MapId, hostIds); if (delhostIds.Count() > 1) { //合并两个数组,传值,以-1为分界值 int[] myhostIds = new int[delhostIds.Length + hostIds.Length]; delhostIds.CopyTo(myhostIds, 0); hostIds.CopyTo(myhostIds, delhostIds.Length); LocatingServiceUtil.Instance <IServiceApi>().UpdateHostGroup(myhostIds, groupId); } else { LocatingServiceUtil.Instance <IServiceApi>().UpdateHostGroup(hostIds, groupId); } } catch (Exception err) { } } }
private string CreateOutputContent() { StringBuilder sb = new StringBuilder(); sb.AppendLine("<?xml version=\"1.0\" standalone=\"yes\" ?>"); sb.AppendLine("<areaList>"); if (_mapId > 0) { var list = this.SelectItemList(); var format = " <area id=\"{0}\" name=\"{1}\" coordinatesArray=\"{2}\" quota=\"{3}\" currentCount=\"{4}\" mapId=\"{5}\" />"; foreach (var a in list) { try { if (a.LinkedMapId > 0) { IList <TagStatusView> tagList = new List <TagStatusView>(); string _keyword = ""; int[] _hostGroupArray = new int[2] { 1, 2 }; //2010-11-bydyp int totalCount = 0; IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); if (serviceApi != null) { TagStatusView tagStatusView = new TagStatusView(); tagList = serviceApi.SelectTagStatusList( _keyword, _hostGroupArray, a.LinkedMapId, true, false, //SupportEvent.Absent), false, //SupportEvent.BatteryInsufficient), false, //SupportEvent.AreaEvent), false, //SupportEvent.ButtonPressed), false, //SupportEvent.WristletBroken), "", SortDirection.Ascending, 0,//only get total count 0, out totalCount); sb.AppendFormat(format, a.Id, a.AreaName, a.CoordinatesArray, 0, totalCount, a.LinkedMapId); sb.AppendLine(); } } else { int quota = 0; try { quota = CulpritRoomReference.All.Count(x => x.JailRoomId == a.Id); } catch { } int currentCount = 0; var coordinates = MapAreaCoverage.All.Where(x => x.AreaId == a.Id).Select(x => x.CoordinatesId).ToArray(); foreach (var item in FullTagStatusView) { if (coordinates.Contains(item.CoordinatesId) && item.AbsenceStatus != EventStatus.Occurring && item.X > 0) { currentCount++; } } sb.AppendFormat(format, a.Id, a.AreaName, a.CoordinatesArray, quota, currentCount, -1); sb.AppendLine(); } } catch { } } } sb.AppendLine("</areaList>"); return(sb.ToString()); }
protected void deleteButton_Click(object sender, EventArgs e) { //TagUser user = TagUser.SelectById(_id); HostTag host = HostTag.GetById(_id); if (host != null) { bool serviceAvailable = LocatingServiceUtil.IsAvailable(); var tagId = host.TagId; if (tagId > 0) { using (AppDataContext db = new AppDataContext()) { //更新标签名称 Tag tag = Tag.Select(tagId); if (tag != null) { string mac = tag.TagMac; if (serviceAvailable) { LocatingServiceUtil.Instance <IServiceApi>().UpdateTagNameAndSerialNo(tagId, "NewTag_" + mac.Substring(12), ""); } else { Tag.UpdateTagNameAndSerialNo(tagId, "NewTag_" + mac.Substring(12), ""); } } //删除标签历史记录和相关信息 AreaEventLog.DeleteByTagId(tagId); GenericEventLog.DeleteByTagId(tagId); TagPositionLog.DeleteByTagId(tagId); //LocationChangeLog.DeleteMany(tagId); //LatestEvent.DeleteByTagId(tagId); TagEventStatus.DeleteMany(tagId); TagPositionStatus.DeleteMany(tagId); AreaWarningRuleCoverage.DeleteMany(tagId); TagAlert.DeleteTagAlerts(tagId); //保留低电记录 //db.ExecuteCommand("delete from history_BatteryResetLog where TagId=", tagId); } TagLocateSetting.StopLocating(tagId); if (serviceAvailable) { LocatingServiceUtil.Instance <IServiceApi>().StartStopLocating(); } //TagUser.DeleteById(_id); TagStatusView.SelectTagStatus(tagId).HostTag = null; } TagAlert.DeleteTagAlerts(_id); //删除人员信息 HostTag.DeleteHostTag(_id); //记录日志 if (tagId > 0 && serviceAvailable) { LocatingServiceUtil.Instance <IServiceApi>().ReloadTagHost(tagId); } Diary.Insert(ContextUser.Current.Id, tagId, _id, "删除使用者" + host.HostName + "的信息" + (host.TagId == 0 ? "" : "并解除标签绑定。") + "。"); } ShowMessagePage("删除成功。"); }
protected void Page_Load(object sender, EventArgs e) { NetRadio.Data.User oUser = NetRadio.Data.User.SelectByUserName(me.Name); if (oUser.Role >= (int)UserRole.Admin) { isAdmin = true; } if (!Page.IsPostBack) { AjaxUtil.RegisterClientScript(typeof(__TagUser), this.Page); int _tagId; string _tagMac = null; using (AppDataContext db = new AppDataContext()) { var position = db.HostTagGroupStatus.SingleOrDefault(h => h.HostId == _id && h.HostGroupId == (int)TagUserType.Position); if (position == null) { Terminator.End("记录不存在。"); } _tagId = position.TagId; var tag = Tag.Select(_tagId); if (tag != null) { _tagMac = tag.TagMac; } currentTagId.Value = _tagId.ToString(); tagMac.Text = _tagMac; userId.Value = position.HostId.ToString(); name.Text = newName.Text = position.HostName; memo.Text = newMemo.Text = Strings.TextEncode(position.Description); if (!isAdmin) { changeMemo.Visible = false; deleteButton.Visible = false; } } if (!LocatingServiceUtil.IsAvailable() || !isAdmin) { //changeTag.Visible = false; clearAllEvents.Visible = false; locatingServiceDownMarker.Visible = true; } else { try { if (!string.IsNullOrEmpty(_tagMac)) { TagStatusView tagStatus = LocatingServiceUtil.Instance <IServiceApi>().SelectTagStatus(_tagMac); if (tagStatus != null) { batteryInsufficient.Text = Misc.GetEventStatusDescription(tagStatus.BatteryInsufficientStatus); batteryReset.Text = Misc.GetEventStatusDescription(tagStatus.BatteryResetStatus); buttonPressed.Text = Misc.GetEventStatusDescription(tagStatus.ButtonPressedStatus); eventUpdateTime.Value = tagStatus.EventUpdateTime; clearBatteryInsufficient.Visible = tagStatus.BatteryInsufficientStatus != (byte)EventStatus.Cleared; clearBatteryReset.Visible = tagStatus.BatteryResetStatus != (byte)EventStatus.Cleared; clearButtonPressed.Visible = tagStatus.ButtonPressedStatus != (byte)EventStatus.Cleared; } } } catch { } } } }
public static bool SetCulpritstatus(string tagMac, bool isIll, bool isSerious, bool isArraignment) { if (LocatingServiceUtil.IsAvailable()) { TagStatusView tagView = TagStatusView.SelectTagStatus(tagMac); if (isIll) { tagView.HostTag.AddHostGroup(4); Diary.Insert(ContextUser.Current.Id, tagView.TagId, tagView.HostTag.HostId, "将犯人" + tagView.HostTag.HostName + "设置为病犯。"); } else { if (tagView.HostTag.HostGroupId.Contains(4)) { tagView.HostTag.RemoveHostGroup(4); Diary.Insert(ContextUser.Current.Id, tagView.TagId, tagView.HostTag.HostId, "取消犯人" + tagView.HostTag.HostName + "的病犯设置。"); } } if (isSerious) { tagView.HostTag.AddHostGroup(3); Diary.Insert(ContextUser.Current.Id, tagView.TagId, tagView.HostTag.HostId, "将犯人" + tagView.HostTag.HostName + "设置为重刑犯。"); } else { if (tagView.HostTag.HostGroupId.Contains(3)) { tagView.HostTag.RemoveHostGroup(3); Diary.Insert(ContextUser.Current.Id, tagView.TagId, tagView.HostTag.HostId, "取消犯人" + tagView.HostTag.HostName + "的病犯设置。"); } } try { if (isArraignment) { if (tagView.HostTag.HostStatusId == (int)HostTagStatusType.Normal) { tagView.HostTag.HostStatusId = (int)HostTagStatusType.Interrogation; HostTag.SetHostStatus(tagView.HostTag.HostId, (int)HostTagStatusType.Interrogation); using (AppExtensionDataContext dbExtension = new AppExtensionDataContext()) { InterrogationLog interrogationLog = new InterrogationLog(); interrogationLog.PoliceId = ContextUser.Current.Id; interrogationLog.CulpritId = tagView.HostTag.HostId; interrogationLog.StartTime = DateTime.Now; dbExtension.InterrogationLogs.InsertOnSubmit(interrogationLog); dbExtension.SubmitChanges(); } Diary.Insert(ContextUser.Current.Id, tagView.TagId, tagView.HostTag.HostId, "提审犯人" + tagView.HostTag.HostName + "。"); } } else { if (tagView.HostTag.HostStatusId == (int)HostTagStatusType.Interrogation) { tagView.HostTag.HostStatusId = (int)HostTagStatusType.Normal; HostTag.SetHostStatus(tagView.HostTag.HostId, (int)HostTagStatusType.Normal); using (AppExtensionDataContext dbExtension = new AppExtensionDataContext()) { InterrogationLog interrogationLog = dbExtension.InterrogationLogs.SingleOrDefault(t => t.PoliceId == ContextUser.Current.Id && t.CulpritId == tagView.HostTag.HostId && t.EndTime == null); if (interrogationLog != null) { interrogationLog.EndTime = DateTime.Now; dbExtension.SubmitChanges(); } } Diary.Insert(ContextUser.Current.Id, tagView.TagId, tagView.HostTag.HostId, "犯人" + tagView.HostTag.HostName + "结束提审。"); } } } catch (Exception exp) { string err = exp.Source + ":" + exp.Message; } LocatingServiceUtil.Instance <IServiceApi>().ReloadTagHost(tagView.TagId); return(true); } else { return(false); } }
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); } }
protected void Page_Load(object sender, EventArgs e) { NetRadio.Data.User oUser = NetRadio.Data.User.SelectByUserName(me.Name); if (oUser.Role >= (int)UserRole.Admin) { isAdmin = true; } if (BusSystemConfig.IsAutoSelectStrongestRssiTag() == false) { tagSelector.Visible = true; selectStrongestRssiTag.Visible = false; changeTag.Href = "javascript:tt();"; } else { tagSelector.Visible = false; selectStrongestRssiTag.Visible = true; changeTag.Href = "javascript:tt2();"; } if (!Page.IsPostBack) { Ajax.AjaxManager.RegisterClass(typeof(__TagUser)); AjaxUtil.RegisterClientScript(typeof(__TagUser), this.Page); int _tagId; string _tagMac = null; using (AppDataContext db = new AppDataContext()) { var cop = db.HostTagGroupStatus.SingleOrDefault(h => h.HostId == _id && h.HostGroupId == (int)TagUserType.Cop); if (cop == null) { ShowMessagePage("记录不存在。"); } _tagId = cop.TagId; var tag = Tag.Select(_tagId); if (tag != null) { _tagMac = tag.TagMac; } currentTagId.Value = _tagId.ToString(); tagMac.Text = _tagMac; userId.Value = cop.HostId.ToString(); name.Text = newName.Text = cop.HostName; number.Text = newNumber.Text = cop.HostExternalId; string[] aGroupIds = HostTagGroupStatus.GetBelongsGroupNameArrayByHostId(_id); if (aGroupIds != null && aGroupIds.Length > 0) { LabelGroup.Text = String.Join(", ", aGroupIds); } memo.Text = newMemo.Text = Strings.TextEncode(cop.Description); groups.Text = string.Join(",", HostTagGroupStatus.GetBelongsGroupNameArrayByHostId(_id)); tagBound.Text = cop.TagId == 0 ? "未携带标签" : "已领用标签"; photo.Src = "UserPhoto.ashx?id=" + _id; if (!isAdmin) { changeName.Visible = false; changeNumber.Visible = false; changeMemo.Visible = false; deleteButton.Visible = false; uploadButton.Visible = false; } } if (Config.Settings.ProjectType == ProjectTypeEnum.YZPrison) { absencediv.Visible = false; } else { absencediv.Visible = true; } locatingServiceDownMarker.Visible = !LocatingServiceUtil.IsAvailable(); if (!LocatingServiceUtil.IsAvailable() || !isAdmin) { changeTag.Visible = false; clearAllEvents.Visible = false; //locatingServiceDownMarker.Visible = true; } else { try { if (!string.IsNullOrEmpty(_tagMac)) { TagStatusView tagStatus = LocatingServiceUtil.Instance <IServiceApi>().SelectTagStatus(_tagMac); if (tagStatus != null) { coordinatesName.Text = Coordinates.GetName(tagStatus.CoordinatesId); positionUpdateTime.Value = tagStatus.PositionUpdateTime; absence.Text = Misc.GetEventStatusDescription(tagStatus.AbsenceStatus); areaEvent.Text = Misc.GetEventStatusDescription(tagStatus.AreaEventStatus); batteryInsufficient.Text = Misc.GetEventStatusDescription(tagStatus.BatteryInsufficientStatus); batteryReset.Text = Misc.GetEventStatusDescription(tagStatus.BatteryResetStatus); buttonPressed.Text = Misc.GetEventStatusDescription(tagStatus.ButtonPressedStatus); //wristletBroken.Text = Misc.GetEventStatusDescription(tagStatus.WristletBrokenStatus); eventUpdateTime.Value = tagStatus.EventUpdateTime; clearAbsence.Visible = tagStatus.AbsenceStatus != (byte)EventStatus.Cleared; clearAreaEvent.Visible = tagStatus.AreaEventStatus != (byte)EventStatus.Cleared; clearBatteryInsufficient.Visible = tagStatus.BatteryInsufficientStatus != (byte)EventStatus.Cleared; clearBatteryReset.Visible = tagStatus.BatteryResetStatus != (byte)EventStatus.Cleared; clearButtonPressed.Visible = tagStatus.ButtonPressedStatus != (byte)EventStatus.Cleared; //clearWristletBroken.Visible = tagStatus.WristletBrokenStatus != (byte)EventStatus.Cleared; } } } catch { } } } }
protected void saveButton_Click(object sender, EventArgs e) { if (name.Text.Trim().Length == 0) { feedbacks.Items.AddError("没有填写" + nameCalling.Text + "。"); } //if (_userType == TagUserType.Cop && number.Text.Trim().Length != 6) //{ // feedbacks.Items.AddError(numberCalling.Text + "必须是6位数字。"); //} //if (_userType == TagUserType.Culprit && number.Text.Trim().Length != 5) //{ // feedbacks.Items.AddError(numberCalling.Text + "必须是5位数字。"); //} if (_userType != TagUserType.Position && number.Text.Trim().Length == 0) { feedbacks.Items.AddError("请输入编号"); } if (_userType == TagUserType.Culprit && culpritRoom.Items.Count > 0 && culpritRoom.SelectedIndex < 1) { feedbacks.Items.AddError("没有选择该犯人所在的监舍。"); } if (feedbacks.HasItems) { return; } //yyang 090916 //if (TagUser.All.Any(x => string.Compare(x.Number, number.Text.Trim(), true) == 0)) //{ // feedbacks.Items.AddError(numberCalling.Text + " " + number.Text.Trim() + " 已经存在在系统中, 请勿重复。"); // return; //} if (_userType != TagUserType.Position && HostTag.All.Any(x => string.Compare(x.HostExternalId, number.Text.Trim(), true) == 0)) { feedbacks.Items.AddError(numberCalling.Text + " " + number.Text.Trim() + " 已经存在在系统中, 请勿重复。"); return; } if (BusSystemConfig.IsAutoSelectStrongestRssiTag() == false) { if (tagSelector.SelectedTagIdArray.Length > 0) { if (HostTag.All.Any(x => x.TagId == tagSelector.SelectedTagIdArray[0])) { feedbacks.Items.AddError("您选择的标签已经被别人领用,请核实。"); return; } } } string photoPath = ""; if (uploadPhoto.HasFile) { photoPath = CreatePhotoUploadPath() + "/" + Misc.CreateUniqueFileName() + Path.GetExtension(uploadPhoto.FileName); try { using (System.Drawing.Image image = System.Drawing.Image.FromStream(uploadPhoto.FileContent)) { if (image != null) { using (Bitmap bitmap = new Bitmap(image, 100, 120)) { bitmap.Save(Fetch.MapPath(PathUtil.ResolveUrl(photoPath)), ImageFormat.Jpeg); } } } } catch (Exception) { feedbacks.Items.AddError("上传照片出错,可能是图片体积过大,或者不是图片格式文件。"); return; } } HostTag hostTag = new HostTag(); //TagUser user = new TagUser(); hostTag.HostName = name.Text.Trim(); hostTag.HostExternalId = number.Text.Trim(); hostTag.ImagePath = photoPath; hostTag.HostType = 1; hostTag.Description = Strings.Left(memo.Text, 500); if (BusSystemConfig.IsAutoSelectStrongestRssiTag()) { hostTag.TagId = tagSelectorAuto.GetStrongestRssiTagID(); } else { if (tagSelector.SelectedTagIdArray.Length > 0) { hostTag.TagId = tagSelector.SelectedTagIdArray[0]; } } //TagUser.Insert(user); //yzhu 090913 HostTagView oHostTag = new HostTagView(); try { int hostId = HostTag.AddOrUpdateHostTag(0, hostTag.TagId, hostTag.HostExternalId, hostTag.HostName, (int)HostTypeType.Unknown, hostTag.Description, hostTag.ImagePath); hostTag.HostId = hostId; //lyz 设置用户绑定的标签的名称 device_Tag tag = new device_Tag(); tag.Id = hostTag.TagId; if (tag.Select()) { tag.TagName = hostTag.HostName; tag.Save(); } HostTag.SetHostGroup(hostId, (int)_userType); if (grouplist.SelectedIndex > 0) { HostTag.SetHostGroup(hostId, int.Parse(grouplist.SelectedItem.Value)); } HostTag.SetHostStatus(hostId, (int)HostTagStatusType.Normal); Caching.Remove(AppKeys.Cache_TagStatusDictionary); } catch { } //记录日志 Diary.Insert(ContextUser.Current.Id, hostTag.TagId, oHostTag.HostId, "新增标签使用者, " + nameCalling.Text + ": " + hostTag.HostName + (hostTag.TagId == 0 ? "。" : ",并已为其绑定标签。")); //清除缓存 //TagUser.ClearCache(); bool isServiceAvailable = LocatingServiceUtil.IsAvailable(); //更新标签信息 if (hostTag.TagId != 0) { //Tag.UpdateTagNameAndSerialNo(hostTag.TagId, hostTag.HostName, hostTag.HostExternalId); //LocatingServiceUtil.Instance<IServiceApi>().UpdateTagNameAndSerialNo(hostTag.TagId, hostTag.HostName, hostTag.HostExternalId); if (Config.Settings.ProjectType != ProjectTypeEnum.WXFactory)//无锡项目需要给标签设定参数,所以需要手动启动定位 { //自定将标签启动定位 XDocument xDoc = XDocument.Load(Server.MapPath(PathUtil.ResolveUrl("Settings/LocateParameters.xml"))); XElement root = xDoc.Element("Parameters"); int surveyGroupId = int.Parse(root.Element("SurveyGroup").Value); using (AppDataContext db = new AppDataContext()) { SurveyGroup surveryGroupValue = db.SurveyGroups.FirstOrDefault(); if (surveryGroupValue != null) { surveyGroupId = surveryGroupValue.Id; } } TagLocateSetting useSettingModel = new TagLocateSetting { LocatingMode = byte.Parse(root.Element("LocatingMode").Value), RssiBackCount = int.Parse(root.Element("RssiBackCount").Value), ScanInterval = int.Parse(root.Element("ScanInterval").Value), ScanMode = byte.Parse(root.Element("ScanMode").Value), ScanSsid = root.Element("ScanSsid").Value, ScanChannels = root.Element("ScanChannels").Value, ScanTarget = byte.Parse(root.Element("ScanTarget").Value), SurveyGroupId = surveyGroupId, UpdateTime = DateTime.Now, CommandState = (byte)LocatingCommandState.WaitToStart }; if (Config.Settings.ProjectType == ProjectTypeEnum.WXFactory) { useSettingModel.ScanMode = 1; } TagLocateSetting.StartLocating(new int[] { hostTag.TagId }, useSettingModel); if (isServiceAvailable) { // Send a command to LocatingService. LocatingServiceUtil.Instance <IServiceApi>().StartStopLocating(); LocatingServiceUtil.Instance <IServiceApi>().ReloadTagHost(hostTag.TagId); } TagStatusView tagView = TagStatusView.SelectTagStatus(hostTag.TagId); tagView.HostTag = HostTagView.GetHostView(hostTag.TagId); } } int groupId = 1; //设置犯人所在监舍 if (_userType == TagUserType.Culprit) { groupId = 2; int areaId = int.Parse(culpritRoom.SelectedValue); CulpritRoomReference.ArrangeNewReference(hostTag.HostId, areaId); //查询警告条件 int ruleId = AreaWarningRule.SelectRuleByAreaId(areaId).Select(x => x.Id).FirstOrDefault(); //如果警告条件不存在,则自动建立一条 if (ruleId == 0) { var rule = new AreaWarningRule { AreaEventType = (byte)AreaEventType.StayOutside, AreaId = areaId, EnableToAllTags = false, IsDisabled = false }; if (isServiceAvailable) { ruleId = LocatingServiceUtil.Instance <IServiceApi>().InsertWarningRule(rule).Id; } else { ruleId = AreaWarningRule.InsertAndReturnId(rule); } } //为警告条件设置关联标签 var culpritIdArray = CulpritRoomReference.All.Where(x => x.JailRoomId == areaId).Select(x => x.CulpritId).ToArray(); var tagIdArray = HostTag.All.Where(x => culpritIdArray.Contains(x.HostId) && x.TagId > 0).Select(x => x.TagId).ToArray(); if (isServiceAvailable) { LocatingServiceUtil.Instance <IServiceApi>().SetWarningRuleCoverage(ruleId, tagIdArray); } else { AreaWarningRuleCoverage.SetCoverage(ruleId, tagIdArray); } } else if (_userType == TagUserType.Cop) { groupId = 1; } /*if (hostTag.TagId != 0) * { * TagGroup oGroup = TagGroup.Select(groupId); * if (oGroup == null) * { * * } * else * { * int[] tagIdArray = new int[1]; * int[] selectedTagIdArray = TagGroupCoverage.GetCoveredTagIdArray(groupId); * bool bIncluded = false; * if (selectedTagIdArray != null && selectedTagIdArray.Length > 0) * { * for (int i = 0; i < selectedTagIdArray.Length; i++) * { * if (selectedTagIdArray[i] == hostTag.TagId) * { * bIncluded = true; * break; * } * } * if (!bIncluded) * { * tagIdArray = new int[selectedTagIdArray.Length + 1]; * tagIdArray[selectedTagIdArray.Length] = hostTag.TagId; * } * } * else * { * * tagIdArray[0] = hostTag.TagId; * } * if (!bIncluded) * TagGroup.UpdateById(groupId, oGroup.GroupName, oGroup.GroupDescription, tagIdArray); * } * }*/ //结束 ShowMessagePage(string.Format( "{0}: <span class='bold'>{1}</span>, {2}: <span class='bold'>{3}</span> 的信息已成功添加到系统中。", nameCalling.Text, name.Text.Trim(), numberCalling.Text, number.Text.Trim() ), new Link("继续"// + Wrap.Title , Fetch.CurrentUrl), Config.Settings.ProjectType == ProjectTypeEnum.NMPrison?new Link():new Link("返回信息列表", WebPath.GetFullPath("TagUsers/TagUserList.aspx?type=" + (byte)_userType)) ); }
protected void deleteButton_Click(object sender, EventArgs e) { HostTag host = HostTag.GetById(_id); if (host != null) { bool serviceAvailable = LocatingServiceUtil.IsAvailable(); var tagId = host.TagId; if (tagId > 0) { using (AppDataContext db = new AppDataContext()) { //更新标签名称 Tag tag = Tag.Select(tagId); if (tag != null) { string mac = tag.TagMac; if (serviceAvailable) { LocatingServiceUtil.Instance <IServiceApi>().UpdateTagNameAndSerialNo(tagId, "NewTag_" + mac.Substring(12), ""); } else { Tag.UpdateTagNameAndSerialNo(tagId, "NewTag_" + mac.Substring(12), ""); } } //删除标签历史记录和相关信息 AreaEventLog.DeleteByTagId(tagId); GenericEventLog.DeleteByTagId(tagId); TagPositionLog.DeleteByTagId(tagId); //LocationChangeLog.DeleteMany(tagId); //LatestEvent.DeleteByTagId(tagId); TagEventStatus.DeleteMany(tagId); TagPositionStatus.DeleteMany(tagId); AreaWarningRuleCoverage.DeleteMany(tagId); InterrogationLog.DeleteMany(host.HostId); TagAlert.DeleteTagAlerts(tagId); //删除低电记录: 不执行删除 //db.ExecuteCommand("delete from history_BatteryResetLog where TagId=", tagId); } TagLocateSetting.StopLocating(tagId); if (serviceAvailable) { var s = LocatingServiceUtil.Instance <IServiceApi>(); s.StartStopLocating(); } int areaId = CulpritRoomReference.GetRoomIdByCulpritId(host.HostId); if (areaId != 0) { //查询警告条件 var ruleId = AreaWarningRule.SelectRuleByAreaId(areaId).Select(x => x.Id).FirstOrDefault(); //如果警告条件不存在,则自动建立一条 if (ruleId != 0) { //为警告条件设置关联标签 var culpritIdArray = CulpritRoomReference.All.Where(x => x.JailRoomId == areaId).Select(x => x.CulpritId).ToArray(); var tagIdArray = HostTag.All.Where(x => culpritIdArray.Contains(x.HostId) && x.TagId > 0 && x.TagId != tagId).Select(x => x.TagId).ToArray(); if (serviceAvailable) { LocatingServiceUtil.Instance <IServiceApi>().SetWarningRuleCoverage(ruleId, tagIdArray); } else { AreaWarningRuleCoverage.SetCoverage(ruleId, tagIdArray); } } } } //删除使用者信息 CulpritRoomReference.DeleteByCulpritId(_id); //TagUser.DeleteById(_id); HostTag.DeleteHostTag(_id); TagStatusView.SelectTagStatus(tagId).HostTag = null; if (tagId > 0 && serviceAvailable) { LocatingServiceUtil.Instance <IServiceApi>().ReloadTagHost(tagId); } //记录日志 Diary.Insert(ContextUser.Current.Id, tagId, _id, "删除犯人" + host.HostName + "的信息" + (host.TagId == 0 ? "" : "并解除标签绑定。") + "。"); } ShowMessagePage("删除成功。"); }
protected void Page_Load(object sender, EventArgs e) { NetRadio.Data.User oUser = NetRadio.Data.User.SelectByUserName(me.Name); if (oUser.Role >= (int)UserRole.Admin) { isAdmin = true; } if (BusSystemConfig.IsAutoSelectStrongestRssiTag() == false) { tagSelector.Visible = true; selectStrongestRssiTag.Visible = false; changeTag.Href = "javascript:tt();"; } else { tagSelector.Visible = false; selectStrongestRssiTag.Visible = true; changeTag.Href = "javascript:tt2();"; } Ajax.AjaxManager.RegisterClass(typeof(__TagUser)); AjaxUtil.RegisterClientScript(typeof(__TagUser), this.Page); if (!Page.IsPostBack) { LoadJailRoomList(); } int _tagId; string _tagMac = null; userId.Value = _id.ToString(); using (AppDataContext db = new AppDataContext()) { var culprit = db.HostTagGroupStatus.SingleOrDefault(u => u.HostGroupId == (int)TagUserType.Culprit && u.HostId == _id); if (culprit == null) { ShowMessagePage("记录不存在。"); } _tagId = culprit.TagId; var tag = Tag.Select(_tagId); if (tag != null) { _tagMac = tag.TagMac; } currentTagId.Value = _tagId.ToString(); tagMac.Text = _tagMac; userId.Value = culprit.HostId.ToString(); name.Text = newName.Text = culprit.HostName; number.Text = newNumber.Text = culprit.HostExternalId; memo.Text = newMemo.Text = Strings.TextEncode(culprit.Description); if (Config.Settings.IsLoadHostInfo) { CulMoreInfo.Visible = true; string strConnect = System.Configuration.ConfigurationSettings.AppSettings["FXConnectionString"].ToString(); SqlConnection conn = new SqlConnection(strConnect); string strSQL = "SELECT top 1 RYBH, ZJHM, JYAQ,V_SSJD.HZ as SSJDHZ, V_AJLB.HZ as AJLBHZ from V_RYXXALL join V_AJLB on V_RYXXALL.AJLB=V_AJLB.DM join V_SSJD on V_SSJD.DM=V_RYXXALL.SSJD where RYBH='" + culprit.HostExternalId + "'"; DataSet ds = new DataSet(); // 创建一个 DataSet conn.Open(); SqlDataAdapter command = new SqlDataAdapter(strSQL, conn); // 用 SqlDataAdapter 得到一个数据集 command.Fill(ds, "CulInfo"); //把Dataset绑定到数据表 DataTable dt = ds.Tables["CulInfo"]; if (dt.Rows.Count > 0) { IDNO.Text = dt.Rows[0]["ZJHM"].ToString(); CulKind.Text = dt.Rows[0]["AJLBHZ"].ToString(); CulState.Text = dt.Rows[0]["SSJDHZ"].ToString(); CulDes.Text = dt.Rows[0]["JYAQ"].ToString(); } } else { CulMoreInfo.Visible = false; } tagBound.Text = culprit.TagId == 0 ? "未携带标签" : "已领用标签"; photo.Src = "UserPhoto.ashx?id=" + _id; jailRoom.Text = MapArea.All.Where(a => a.Id == CulpritRoomReference.All.Where(r => r.CulpritId == _id).Select(r => r.JailRoomId).SingleOrDefault()).Select(a => a.AreaName).SingleOrDefault(); if (!isAdmin) { changeName.Visible = false; changeNumber.Visible = false; changeMemo.Visible = false; deleteButton.Visible = false; uploadButton.Visible = false; } } if (!LocatingServiceUtil.IsAvailable() || !isAdmin) { changeTag.Visible = false; changeJailRoom.Visible = false; clearAllEvents.Visible = false; locatingServiceDownMarker.Visible = true; setStatus.Visible = false; locatingServiceDownMarker1.Visible = true; } else { try { if (!string.IsNullOrEmpty(_tagMac)) { TagStatusView tagStatus = LocatingServiceUtil.Instance <IServiceApi>().SelectTagStatus(_tagMac); if (tagStatus != null) { coordinatesName.Text = Coordinates.GetName(tagStatus.CoordinatesId); positionUpdateTime.Value = tagStatus.PositionUpdateTime; if (tagStatus.HostTag.HostGroupId.Contains(4)) { illness.Checked = true; } if (tagStatus.HostTag.HostGroupId.Contains(3)) { serious.Checked = true; } if (tagStatus.HostTag.HostStatusId == (int)HostTagStatusType.Interrogation) { arraignment.Checked = true; using (AppExtensionDataContext dbExtension = new AppExtensionDataContext()) { InterrogationLog interrogationLog = dbExtension.InterrogationLogs.SingleOrDefault(t => t.CulpritId == tagStatus.HostTag.HostId && t.StartTime == null); if (interrogationLog != null) { if (interrogationLog.PoliceId == me.Id) { arraignment.Enabled = true; } else { arraignment.Enabled = false; } } else { //状态与数据库不一致,需要同步 } } } absence.Text = Misc.GetEventStatusDescription(tagStatus.AbsenceStatus); areaEvent.Text = Misc.GetEventStatusDescription(tagStatus.AreaEventStatus); batteryInsufficient.Text = Misc.GetEventStatusDescription(tagStatus.BatteryInsufficientStatus); batteryReset.Text = Misc.GetEventStatusDescription(tagStatus.BatteryResetStatus); buttonPressed.Text = Misc.GetEventStatusDescription(tagStatus.ButtonPressedStatus); wristletBroken.Text = Misc.GetEventStatusDescription(tagStatus.WristletBrokenStatus); eventUpdateTime.Value = tagStatus.EventUpdateTime; clearAbsence.Visible = tagStatus.AbsenceStatus != (byte)EventStatus.Cleared; clearAreaEvent.Visible = tagStatus.AreaEventStatus != (byte)EventStatus.Cleared; clearBatteryInsufficient.Visible = tagStatus.BatteryInsufficientStatus != (byte)EventStatus.Cleared; clearBatteryReset.Visible = tagStatus.BatteryResetStatus != (byte)EventStatus.Cleared; clearButtonPressed.Visible = tagStatus.ButtonPressedStatus != (byte)EventStatus.Cleared; clearWristletBroken.Visible = tagStatus.WristletBrokenStatus != (byte)EventStatus.Cleared; } } } catch { } } using (AppDataContext db = new AppDataContext()) { list.DataSource = db.DBViewTagAlerts.Where(x => x.TagId == _tagId).OrderByDescending(x => x.WriteTime).Take(10).ToList(); list.ItemCreated += new RepeaterItemEventHandler(list_ItemCreated); list.DataBind(); if (latestWarnings.Visible = list.Items.Count > 0) { moreWarninngs.Href = "../History/MarshalEventLog.aspx?tagNameKeyword=" + Server.UrlEncode(name.Text); } } }
public object GetAnchorCameraAndTagInfo(int tagID) { if (!LocatingServiceUtil.IsAvailable()) { return(null); } IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); TagStatusView tagStatusView = serviceApi.SelectTagStatus(tagID); int coordinatesID = 0; string hostName = ""; string coordinates = ""; string tagStatus = ""; bool SystemHasVedio = BusSystemConfig.GetVedioType() == 2; bool CoordinatesHasVedio = false; string url = ""; int iChannel = 0; string urlref = ""; int iChannelref = 0; AnchorCamera[] coordinate = null; if (tagStatusView != null) { hostName = string.Format("<a href=\"{0}\">{1}</a>", Web.WebPath.GetFullPath("TagUsers/TagUser.aspx?id=" + tagStatusView.HostTag.HostId), tagStatusView.HostTag.HostName); coordinates = tagStatusView.CoordinatesName; coordinatesID = tagStatusView.CoordinatesId; //tagStatus.Text = LocatingMonitorUtils.GetAllTagEventsDescription(tagStatusView); tagStatus = LocatingMonitorUtils.GetAllTagEventsDescription(tagStatusView, tagStatusView.HostTag.HostGroupId.Min(), 10, "Master/WebItem.Master"); if (tagStatus.Length == 0) { tagStatus = "正常"; } if (SystemHasVedio) { using (AppDataContext db = new AppDataContext()) { coordinate = db.AnchorCameras.Where(c => c.CoordinateID == coordinatesID).ToArray(); if (coordinate != null && coordinate.Length > 0) { CoordinatesHasVedio = true; //coordinate = null; //url = coordinate.CameraIP; //iChannel = coordinate.iChannel; //urlref = coordinate.CameraIPlref; //iChannelref = coordinate.iChannelref; } else { CoordinatesHasVedio = false; coordinate = null; } } } return(new { //------位置、状态----- hostName, coordinates, tagStatus, coordinatesID, //------是否有视频----- SystemHasVedio, CoordinatesHasVedio, //------摄像头信息----- coordinate, VedioType = NetRadio.Business.BusSystemConfig.GetVedioType() //url, //iChannel, //urlref, //iChannelref }); } else { return(null); } }
public object GetResult() { StringBuilder sb = new StringBuilder(); TagAlert[] tas = null; using (AppDataContext db = new AppDataContext()) { tas = db.TagAlerts.Where(t => t.AlertStatus == (byte)AlertStatusType.New) .Where(t => t.HostId > 0) .OrderByDescending(x => x.WriteTime).ToArray(); } string div = ""; string tagName = ""; string tagNameHref = ""; string coordinatesName = ""; string coordinatesNameHref = ""; string description = ""; string time = ""; string tagIcon = ""; int firstCoordinateID = 0; foreach (TagAlert ev in tas) { if (firstCoordinateID == 0) { firstCoordinateID = ev.CoordinatesId; } if (ev != null) { div = "id_" + ev.AlertId; HostTagGroupStatus hostTag = HostTagGroupStatus.SelectByHostId(ev.HostId); tagName = hostTag.HostName; tagIcon = CommonExtension.IdentityIconByGroupId(hostTag.HostGroupId); //need to open video based on the _alertId if (CommonExtension.IsIlltreatTag(ev.HostId)) { if (Config.Settings.ProjectType == ProjectTypeEnum.NMPrison) { coordinatesName = hostTag.HostName; } else { int coorid = CommonExtension.GetCoordinatesId(hostTag.Description.Substring(0, hostTag.Description.Length - 2)); coordinatesName = Coordinates.GetName(coorid); switch (VedioType) { case 1: coordinatesNameHref = "javascript:AlertView(" + ev.CoordinatesId + ");"; break; case 2: coordinatesNameHref = "javascript:AlertView2(" + ev.CoordinatesId + ");"; break; case 3: coordinatesNameHref = "javascript:AlertView3(" + ev.CoordinatesId + ");"; break; default: break; } } } else { int hosttype = TagStatusView.SelectTagStatus(ev.TagId).HostTag.HostGroupId.Contains(1) ? 1 : 2; tagNameHref = "../TagUsers/TagUser.aspx?id=" + ev.HostId + "&type=" + hosttype; coordinatesName = Coordinates.GetName(ev.CoordinatesId); switch (VedioType) { case 1: coordinatesNameHref = "javascript:AlertView(" + ev.CoordinatesId + ");"; break; case 2: coordinatesNameHref = "javascript:AlertView2(" + ev.CoordinatesId + ");"; //coordinatesName.Attributes["onclick"] = "AlertView2(" + ev.CoordinatesId + ")"; break; case 3: coordinatesNameHref = "javascript:AlertView3(" + ev.CoordinatesId + ");"; break; default: break; } } description = CommonExtension.GetEventDescription((SupportEvent)ev.AlertType, ev.HostId); time = ev.WriteTime.ToString(); /**********************/ sb.AppendFormat(@" <tr> <td> <img src='{0}' Width='13' Height='13'/> <a href='{1}' style='font-weight: bold;' target='_blank'>{2}</a> </td> <td> {3} </td> <td> <span>{4}</span> </td> <td> <span>{5}</span> </td> <td> <div id='{6}'> <a onclick='javascript:setResolved(this);' href='#' style='width:35px; height:19px;' title='点此按钮后该事件将标记为已确认,页面将跳转到事件处理页面'>[确认]</a> </div> </td> </tr> ", tagIcon, tagNameHref, tagName, coordinatesNameHref.Length > 0 ? "<a href='" + coordinatesNameHref + "' style='font-weight: bold;'>" + coordinatesName + "</a>" : coordinatesName, description, time, div); /**********************/ } }//foreach if (sb.Length > 0) { sb.Insert(0, "<table cellpadding=0 cellspacing=0 border=0>"); sb.Append("</table>"); } else { sb.Append("<br/>暂时没有发现报警。。。 【<span onclick=\" window.opener=null;window.open('','_self');window.close();\" style=\"cursor:pointer;\">关闭窗口</span>】<br/><br/>"); } switch (VedioType) { case 1: return(new { html = sb.ToString(), callBackFunction = "loadfirst(" + firstCoordinateID + ")" }); case 2: return(new { html = sb.ToString(), callBackFunction = "loadfirst2(" + firstCoordinateID + ")" }); default: return(new { html = sb.ToString(), callBackFunction = "" }); } }