protected void repeater_ItemCreated(object sender, RepeaterItemEventArgs e) { InterrogationLog log = e.Item.DataItem as InterrogationLog; SmartLabel policeName = e.Item.FindControl("policeName") as SmartLabel; SmartLabel culpritName = e.Item.FindControl("culpritName") as SmartLabel; SmartLabel status = e.Item.FindControl("status") as SmartLabel; DateTimeLabel StartTime = e.Item.FindControl("StartTime") as DateTimeLabel; DateTimeLabel EndTime = e.Item.FindControl("EndTime") as DateTimeLabel; User user = Data.User.Select(log.PoliceId); if (user != null) { policeName.Text = Data.User.Select(log.PoliceId).UserName; } culpritName.Text = HostTag.GetById(log.CulpritId).HostName; StartTime.DisplayValue = log.StartTime; if (log.EndTime != null) { EndTime.DisplayValue = log.EndTime.Value; status.Text = "提审完成"; } else { status.Text = "提审中"; } }
private static void UpdateHostTag(HostTag userHost) { if (userHost != null) { HostTag.UpdateHostTag(userHost); //HostTag.AddOrUpdateHostTag(userHost.HostId, userHost.TagId, userHost.HostExternalId, userHost.HostName, (int)userHost.HostType, userHost.Description, userHost.ImagePath); } }
protected void saveNewRule_Click(object sender, EventArgs e) { AreaWarningRule rule = new AreaWarningRule(); rule.EnableToAllTags = forAllTags.SelectedValue == "1"; rule.AreaEventType = byte.Parse(areaEventType.SelectedValue); rule.AreaId = _id; rule.IsDisabled = false; int[] tagidarray = new int[tagSelector.SelectedUserIds.Count()]; ArrayList alHostId = new ArrayList(); int[] hostIdArray = null; sTagID = ""; for (int i = 0; i < tagSelector.SelectedUserIds.Count(); i++) { //根据hostid取得tagid HostTag ht = new HostTag(); ht = HostTag.GetById(tagSelector.SelectedUserIds[i]); if (ht != null) { alHostId.Add(ht.HostId); sTagID += ht.TagId + ","; tagidarray[i] = ht.TagId; } } hostIdArray = (int[])alHostId.ToArray(typeof(int)); AreaWarningRule.sTagID = sTagID; if (!LocatingServiceUtil.IsAvailable()) { AreaWarningRule.InsertAndReturnId(rule); if (rule.EnableToAllTags == false) { //AreaWarningRuleCoverage.SetCoverage(rule.Id, hostIdArray); AreaWarningRuleCoverage.SetCoverage(rule.Id, tagidarray); //AreaWarningRuleCoverage.SetCoverage(rule.Id, tagSelector.SelectedTagIdArray); } } else { IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); EditResult result = serviceApi.InsertWarningRule(rule); rule.Id = result.Id; if (rule.EnableToAllTags == false) { serviceApi.SetWarningRuleCoverage(rule.Id, tagidarray); //serviceApi.SetWarningRuleCoverage(rule.Id, tagSelector.SelectedTagIdArray); } } Terminator.Redirect(Fetch.CurrentUrl); }
protected void submit_Click(object sender, EventArgs e) { try { int hostId = HostTag.AddOrUpdateHostTag(0, tagSelector.SelectedTagIdArray[0], "", tagName.Text.Trim(), (int)HostTypeType.Other, newJailRoom.SelectedItem.Text + "监房", ""); HostTag.SetHostGroup(hostId, (int)TagUserType.Position); } catch { } Response.Redirect("/Objects/AlertTag.aspx"); }
void SaveHostTag(Host host, int hostId = -1) { List <HostTag> HostTagList = new List <HostTag>(); foreach (Tag tag in host.Tags) { HostTag ht = new HostTag(); ht.HostId = hostId == -1? host.Id:hostId; ht.TagId = tag.Id; HostTagList.Add(ht); } m_HostTagRepo.Save(HostTagList); }
protected void setDelete_Click(object sender, EventArgs e) { IEnumerable <int> idList = Strings.ParseToArray <int>(Request.Form["selection"]); if (idList.Count() > 0) { foreach (int hostId in idList) { HostTag.DeleteHostTag(hostId); HostTag.RemoveHostGroupByHostId(hostId); } } Response.Redirect(Fetch.CurrentUrl); }
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); }
protected void uploadButton_Click(object sender, EventArgs e) { 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) { Terminator.End("上传照片出错,可能是图片体积过大,或者不是图片格式文件。"); return; } } HostTag hostTag = HostTag.GetById(_id); //删除旧文件 try { string oldPath = hostTag.ImagePath; if (oldPath != null) { File.Delete(Fetch.MapPath(PathUtil.ResolveUrl(hostTag.ImagePath))); } } catch (Exception) { } hostTag.ImagePath = photoPath; //更新数据库 HostTag.UpdateHostTag(hostTag); //TagUser.UpdatePhotoUrl(_id, photoPath); Terminator.Redirect(Fetch.CurrentUrl); }
private static void UpdateHostTag(HostTagGroupStatus userHost) { if (userHost != null) { HostTag hostTag = new HostTag(); hostTag.HostId = userHost.HostId; hostTag.TagId = userHost.TagId; hostTag.HostExternalId = userHost.HostExternalId; hostTag.HostName = userHost.HostName; hostTag.Description = userHost.Description; hostTag.HostType = userHost.HostType; hostTag.ImagePath = userHost.ImagePath; HostTag.UpdateHostTag(hostTag); } }
protected void list_ItemDataBound(object sender, RepeaterItemEventArgs e) { HostTag ev = e.Item.DataItem as HostTag; if (ev != null) { SmartLabel isChecked = (SmartLabel)e.Item.FindControl("isChecked"); SmartLabel jailRoom = e.Item.FindControl("jailRoom") as SmartLabel; SmartLabel tagHostName = e.Item.FindControl("tagHostName") as SmartLabel; SmartLabel tagMac = e.Item.FindControl("tagMac") as SmartLabel; DateTimeLabel writeTime = e.Item.FindControl("writeTime") as DateTimeLabel; isChecked.Text = "<input type='checkbox' name='selection' value='" + ev.HostId + "' />"; jailRoom.Text = ev.Description; tagHostName.Text = ev.HostName; tagMac.Text = Tag.Select(ev.TagId).TagMac; writeTime.DisplayValue = ev.WriteTime; } }
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(""); }
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) { //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 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 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) { } } }
protected void save_click(object sender, EventArgs e) { if (groupName.Text.Trim().Length == 0) { feedbacks.Items.AddError("请输入对象组名称。"); } //if (_editMode == EditMode.AddNew && TagGroup.All.Any(g => g.GroupName == groupName.Text.Trim())) { //if (HostGroupInfo.All.Any(g => g.HostGroupName.Trim() == groupName.Text.Trim() && g.HostGroupId != tagSelector.SelectedGroupId)) if (HostGroupInfo.All.Any(g => g.HostGroupName.Trim() == groupName.Text.Trim() && g.HostGroupId != (_id == -1 ? 0 : _id))) { feedbacks.Items.AddError("对象组名称“" + groupName.Text.Trim() + "”已存在。"); } if (feedbacks.Items.Count > 0) { return; } if (_editMode == EditMode.AddNew) { //_id = TagGroup.Insert(groupName.Text.Trim(), Strings.Left(groupDescription.Text.Trim(), 200), tagSelector.SelectedTagIdArray); //yzhu 20091002, add parent Group _id = HostGroupInfo.AddHostGroupInfo(0, groupName.Text.Trim(), Strings.Left(groupDescription.Text.Trim(), 200), Convert.ToInt32(this.grouplist.SelectedValue)); HostTag.RemoveHostGroupByGroupId(_id); //如果是根组,把tagid=0的用户都插入该组,下面的插入数据代码后期需要写在数据层HostGroup里 /*if (Convert.ToInt32(this.grouplist.SelectedValue) == 0) * { * var query = HostTag.All.Where(t =>t.TagId == 0).Select(x => x.HostId).ToList(); * * using (AppDataContext db = new AppDataContext()) * { * for (int i = 0; i < query.Count; i++) * { * HostGroup hg = new HostGroup(); * hg.HostId = Convert.ToInt32(query[i].ToString()); * hg.HostGroupId = _id; * db.HostGroups.InsertOnSubmit(hg); * db.SubmitChanges(); * } * } * } */ if (tagSelector.SelectedUserIds != null) { AddHostTagGroup(tagSelector.SelectedUserIds, _id); } Terminator.Redirect("TagGroupList.aspx"); } else { //TagGroup.UpdateById(_id, groupName.Text.Trim(), Strings.Left(groupDescription.Text.Trim(), 200), tagSelector.SelectedTagIdArray); HostGroupInfo.UpdateHostGroupInfo(_id, groupName.Text.Trim(), Strings.Left(groupDescription.Text.Trim(), 200), Convert.ToInt32(this.grouplist.SelectedValue)); HostTag.RemoveHostGroupByGroupId(_id); if (tagSelector.SelectedUserIds != null) { AddHostTagGroup(tagSelector.SelectedUserIds, _id); } //add 2009-10-21 //////////////////tagSelector.SelectedTagIdArray = HostTagGroupStatus.GetCoveredHostIdArray(_id); feedbacks.Items.AddPrompt("保存成功。"); } }
private void LoadRepeater(List <int> listAreaCoordinates, int[] TagIdArray, DateTime dtFrom, DateTime dtTo, string SearchType) { try { IList <AreaInOutTime> lTime = new List <AreaInOutTime>(); int totalCount = 0; using (AppDataContext db = new AppDataContext()) { for (int i = 0; i < TagIdArray.Length; i++) { long totalTicks = 0; int entryCount = 0; DateTime firstInTime = DateTime.MinValue; DateTime lastOutTime = DateTime.MinValue; DateTime endTime = DateTime.Now; if (dtTo < endTime) { endTime = dtTo; } int hostId = TagIdArray[i]; HostTag oHost = HostTag.GetById(hostId); if (oHost == null) { lblMessage.Text += String.Format("ID={0}不存在", hostId); continue; } int tagId = oHost.TagId; string hostName = oHost.HostName; IList <TagPositionLog> lLog = db.TagPositionLogs .Where(x => x.HostId == hostId && x.WriteTime >= dtFrom && x.WriteTime <= endTime) .OrderBy(x => x.WriteTime).ToList(); var firstQuery = db.TagPositionLogs.Where(x => x.WriteTime < dtFrom && x.HostId == hostId) .OrderByDescending(x => x.WriteTime).Take(1); TagPositionLog prevLog = null; try { if (firstQuery != null) { prevLog = firstQuery.First(); } } catch { } AreaInOutTime areaTime = new AreaInOutTime(); areaTime.hostName = hostName; areaTime.hostId = hostId; //previous log if (prevLog != null) { if (prevLog.X > 0) { if (listAreaCoordinates.Contains(prevLog.CoordinatesId)) { areaTime.inTime = dtFrom; firstInTime = areaTime.inTime; } } } bool bFirst = true; if (lLog != null && lLog.Count > 0) { foreach (TagPositionLog log in lLog) { DateTime dtWriteTime = new DateTime(log.WriteTime.Year, log.WriteTime.Month, log.WriteTime.Day, log.WriteTime.Hour, log.WriteTime.Minute, log.WriteTime.Second); if (bFirst) { bFirst = false; //first log if (log.X > 0 && listAreaCoordinates.Contains(log.CoordinatesId)) { if (areaTime.inTime == DateTime.MinValue) { areaTime.inTime = dtWriteTime; firstInTime = areaTime.inTime; } } else { areaTime.outTime = dtWriteTime; if (areaTime.inTime < dtWriteTime) { lastOutTime = areaTime.outTime; } } } else { if (log.X > 0 && listAreaCoordinates.Contains(log.CoordinatesId)) { if (areaTime.inTime == DateTime.MinValue) { areaTime.inTime = dtWriteTime; firstInTime = areaTime.inTime; if (areaTime.outTime != DateTime.MinValue) { areaTime.outTime = DateTime.MinValue; } } else { if (areaTime.outTime == DateTime.MinValue) { } else { double disappearedTime = (dtWriteTime - areaTime.outTime).Duration().TotalSeconds; if (disappearedTime > 60) { areaTime.stayTime = (areaTime.outTime - areaTime.inTime).Duration(); totalTicks += areaTime.stayTime.Ticks; if (SearchType == "2") { lTime.Add(areaTime); } entryCount++; areaTime = new AreaInOutTime(); areaTime.inTime = dtWriteTime; } else { areaTime.outTime = DateTime.MinValue; } } } } else { if (areaTime.outTime == DateTime.MinValue) { areaTime.outTime = dtWriteTime; lastOutTime = areaTime.outTime; } } } } } if (areaTime.inTime != DateTime.MinValue) { if (areaTime.outTime != DateTime.MinValue) { double disappearedTime = (endTime - areaTime.outTime).Duration().TotalSeconds; if (disappearedTime > 60) { areaTime.stayTime = (areaTime.outTime - areaTime.inTime).Duration(); totalTicks += areaTime.stayTime.Ticks; if (SearchType == "2") { lTime.Add(areaTime); } entryCount++; } else { areaTime.stayTime = (endTime - areaTime.inTime).Duration(); totalTicks += areaTime.stayTime.Ticks; if (SearchType == "2") { lTime.Add(areaTime); } entryCount++; } lastOutTime = areaTime.outTime; } else { areaTime.stayTime = (endTime - areaTime.inTime).Duration(); totalTicks += areaTime.stayTime.Ticks; if (SearchType == "2") { lTime.Add(areaTime); } entryCount++; } } if (totalTicks > 0) { lastOutTime = areaTime.outTime; //record the last out time areaTime = new AreaInOutTime(); areaTime.hostId = -1; if (SearchType == "1") { areaTime.hostName = hostName; areaTime.inTime = firstInTime; areaTime.outTime = lastOutTime; //assign last out time //if (areaTime.inTime < lastOutTime) // areaTime.outTime = lastOutTime; } else if (SearchType == "2") { areaTime.hostName = "--- ---"; areaTime.inTime = DateTime.MinValue; areaTime.outTime = DateTime.MinValue; } areaTime.stayTime = new TimeSpan(totalTicks); lTime.Add(areaTime); totalCount++; } else { areaTime = new AreaInOutTime(); areaTime.hostName = hostName; areaTime.inTime = DateTime.MinValue; areaTime.outTime = DateTime.MinValue; areaTime.stayTime = new TimeSpan(0); lTime.Add(areaTime); totalCount++; } } } DataTable dt = new DataTable(); dt.Columns.Add("hostName", typeof(string)); dt.Columns.Add("inTime", typeof(string)); dt.Columns.Add("outTime", typeof(string)); dt.Columns.Add("stayTime", typeof(string)); for (int i = 0; i < lTime.Count(); i++) { string inTimeValue = (lTime.ElementAt(i).inTime == DateTime.MinValue) ? "" : lTime.ElementAt(i).inTime.ToString(); string outTimeValue = (lTime.ElementAt(i).outTime == DateTime.MinValue) ? "" : lTime.ElementAt(i).outTime.ToString(); dt.Rows.Add( lTime.ElementAt(i).hostName, inTimeValue, outTimeValue, lTime.ElementAt(i).stayTime.ToString() ); } ViewState["dt"] = dt; list.DataSource = lTime; list.DataBind(); } catch (Exception err) { lblMessage.Text += err.ToString(); } lbltime.Text = " 从[" + dtFrom.ToString("yyyy年MM月dd日HH时mm分", DateTimeFormatInfo.InvariantInfo) + "] 到 [" + dtTo.ToString("yyyy年MM月dd日HH时mm分", DateTimeFormatInfo.InvariantInfo) + "]"; }
public static string ChangeJailRoom(int culpritId, int newJailRoomId) { //get Host HostTag hostTag = HostTag.GetById(culpritId); if (hostTag == null || hostTag.HostName == "") { return(""); } //记录旧ID var oldJailRoomId = CulpritRoomReference.GetRoomIdByCulpritId(culpritId); //取得新监舍名称 string newName = MapArea.All.Where(x => x.Id == newJailRoomId).Select(x => x.AreaName).SingleOrDefault(); //判断是否相同 if (oldJailRoomId == newJailRoomId) { return(newName); } //执行更换 CulpritRoomReference.ChangeRoom(culpritId, newJailRoomId); //警告条件绑定 var isServiceAvailable = LocatingServiceUtil.IsAvailable(); int ruleId = 0; int[] culpritIdArray = null; int[] tagIdArray = null; //旧监舍 ------------------------------------- if (oldJailRoomId != 0) { //查询警告条件 ruleId = AreaWarningRule.SelectRuleByAreaId(oldJailRoomId).Select(x => x.Id).FirstOrDefault(); //如果警告条件不存在,则自动建立一条 if (ruleId == 0) { var rule = new AreaWarningRule { AreaEventType = (byte)AreaEventType.StayOutside, AreaId = oldJailRoomId, EnableToAllTags = false, IsDisabled = false }; if (isServiceAvailable) { ruleId = LocatingServiceUtil.Instance <IServiceApi>().InsertWarningRule(rule).Id; } else { ruleId = AreaWarningRule.InsertAndReturnId(rule); } } //为警告条件设置关联标签 culpritIdArray = CulpritRoomReference.All.Where(x => x.JailRoomId == oldJailRoomId).Select(x => x.CulpritId).ToArray(); 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); } } //新监舍 ------------------------------------- //查询警告条件 ruleId = AreaWarningRule.SelectRuleByAreaId(newJailRoomId).Select(x => x.Id).FirstOrDefault(); //如果警告条件不存在,则自动建立一条 if (ruleId == 0) { var rule = new AreaWarningRule { AreaEventType = (byte)AreaEventType.StayOutside, AreaId = newJailRoomId, EnableToAllTags = false, IsDisabled = false }; if (isServiceAvailable) { ruleId = LocatingServiceUtil.Instance <IServiceApi>().InsertWarningRule(rule).Id; } else { ruleId = AreaWarningRule.InsertAndReturnId(rule); } } //为警告条件设置关联标签 culpritIdArray = CulpritRoomReference.All.Where(x => x.JailRoomId == newJailRoomId).Select(x => x.CulpritId).ToArray(); 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); } //记录日志,返回 Diary.Insert(ContextUser.Current.Id, 0, culpritId, "将犯人" + hostTag.HostName + "更换监舍到" + newName); return(newName); }
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); } }
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; } } } } } }
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("删除成功。"); }