示例#1
0
        protected void ruleList_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            AreaWarningRule rule = e.Item.DataItem as AreaWarningRule;

            if (rule != null)
            {
                SmartLabel ruleDescription = (SmartLabel)e.Item.FindControl("ruleDescription");
                var        str             = string.Empty;
                if (rule.EnableToAllTags)
                {
                    str = "所有标签";
                }
                else
                {
                    str = "指定的标签";
                }

                if (rule.AreaEventType == (byte)AreaEventType.StayInside)
                {
                    str += "进入停留在区域内时";
                }
                else
                {
                    str += "离开区域或停留在区域外时";
                }
                ruleDescription.Text = str + "触发告警";

                Anchor deleteRule = (Anchor)e.Item.FindControl("deleteRule");
                deleteRule.Href = "?areaid=" + _id + "&deleteRuleId=" + rule.Id;
            }
        }
示例#2
0
        void ruleList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Label _labPeople = e.Item.FindControl("labPeople") as Label;

            if (_labPeople != null)
            {
                AreaWarningRule     _awr = e.Item.DataItem as AreaWarningRule;
                IEnumerable <_temp> awrs = _list.Where(_d => _d.RuleId == _awr.Id);
                _labPeople.Text = "";
                for (int i = 0; i < awrs.Count(); i++)
                {
                    if (i == 0)
                    {
                        _labPeople.Text += awrs.ElementAt(i).HostName;
                    }
                    else
                    {
                        _labPeople.Text += "," + awrs.ElementAt(i).HostName;
                    }
                }
                if (_labPeople.Text.Length != 0)
                {
                    _labPeople.Text = "{&nbsp;" + _labPeople.Text + "&nbsp;}";
                }
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                tagSelector.SetDataSourceLeft(NetRadio.LocatingMonitor.Controls.__SelectTagUser.SelectTagUsers2);
            }
            ruleList.ItemDataBound += new RepeaterItemEventHandler(ruleList_ItemDataBound);
            //var list=(select new { a=1,b=2}).
            /////////////////////tagSelector.SelectedGroupId = -1;

            int deleteRuleId = Fetch.QueryUrlAsIntegerOrDefault("deleteRuleId", -1);

            if (deleteRuleId != -1)
            {
                if (!LocatingServiceUtil.IsAvailable())
                {
                    AreaWarningRule.Delete(deleteRuleId);
                    AreaWarningRuleCoverage.DeleteByRuleId(deleteRuleId);
                }
                else
                {
                    IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                    serviceApi.DeleteWarningRule(deleteRuleId);
                    serviceApi.DeleteWarningRuleCoverage(deleteRuleId);
                }
                Terminator.Redirect(Fetch.Referrer);
            }

            MapArea area = MapArea.Select(_id);

            areaName.Text     = area.AreaName;
            facilityName.Text = Facility.GetNameByMapId(area.MapId);

            IList <AreaWarningRule>         _p = AreaWarningRule.SelectRuleByAreaId(area.Id);
            IList <AreaWarningRuleCoverage> _c = AreaWarningRuleCoverage.GetAreaWarningRuleCoverages();

            _list = (from _p1 in _p
                     join _c1 in _c
                     on _p1.Id equals _c1.RuleId
                     join _h1 in HostTag.All
                     on _c1.TagId equals _h1.TagId
                     select new _temp
            {
                RuleId = _c1.RuleId,
                TagId = _c1.TagId,
                HostName = _h1.HostName
            }).ToList();

            ruleList.DataSource = _p;
            ruleList.DataBind();
            ruleCount.Value = ruleList.Items.Count;

            if (forAllTags.SelectedValue == "1")
            {
                tagSelectorContainer.Style.Add("display", "none");
            }
        }
示例#4
0
        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);
        }
示例#5
0
        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))
                            );
        }
        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 string GetHTML(int mapID)
        {
            AppDataContext db = new AppDataContext();

            MapArea[]         mas = mapID == 0 ? db.MapAreas.ToArray() : db.MapAreas.Where(_d => _d.MapId == mapID).ToArray();
            AreaWarningRule[] aws = db.AreaWarningRules.Where(_d => mas.Select(_e => _e.Id).Contains(_d.AreaId)).ToArray();
            IEnumerable <AreaWarningRuleCoverage> awrcs = db.AreaWarningRuleCoverages.Where(_d => aws.Select(_e => _e.Id).Contains(_d.RuleId));

            var q = (from _d1 in db.HostTags
                     join _d2 in awrcs
                     on _d1.TagId equals _d2.TagId
                     select new
            {
                ruleId = _d2.RuleId,
                hostName = _d1.HostName,
                tagId = _d1.TagId
            }
                     ).ToArray();

            StringBuilder sb = new StringBuilder();

            sb.Append(@"
            <table cellpadding=""0"" cellspacing=""0"" class=""grid alternate fixed"">
                <thead class=""category"">
                     <th width=""200"" style=""text-align: center"">
                       区域名称
                    </th>
                         <th width=""200"" style=""text-align: center"">
                       进入区域告警
                    </th>
                       <th style=""text-align: center"">
                       离开区域告警
                    </th>
                </thead>
            ");
            int i = 0;

            foreach (MapArea ma in mas)
            {
                i++;
                //进
                AreaWarningRule idAWRsIN = aws.Where(_d => _d.AreaId == ma.Id && _d.AreaEventType == 0).FirstOrDefault();
                //出
                AreaWarningRule idAWRsOUT = aws.Where(_d => _d.AreaId == ma.Id && _d.AreaEventType == 1).FirstOrDefault();

                string inContext  = "";
                string outContext = "";
                int    idRuleIN   = 0;
                int    idRuleOUT  = 0;
                string inTagIds   = "";
                string outTagIds  = "";
                int    flag       = 0;
                //进
                if (idAWRsIN != null)
                {
                    idRuleIN = idAWRsIN.Id;
                    if (idAWRsIN.EnableToAllTags)
                    {
                        inContext = "全部";
                        inTagIds  = "";
                    }
                    else
                    {
                        flag = 0;
                        foreach (var order in q.Where(_d => _d.ruleId == idAWRsIN.Id))
                        {
                            inContext += order.hostName + ";";
                            if (flag == 0)
                            {
                                inTagIds += order.tagId;
                            }
                            else
                            {
                                inTagIds += "," + order.tagId;
                            }
                            flag++;
                        }
                    }
                }

                //出
                if (idAWRsOUT != null)
                {
                    idRuleOUT = idAWRsOUT.Id;
                    if (idAWRsOUT.EnableToAllTags)
                    {
                        outContext = "全部";
                        outTagIds  = "";
                    }
                    else
                    {
                        flag = 0;
                        foreach (var order in q.Where(_d => _d.ruleId == idAWRsOUT.Id))
                        {
                            outContext += order.hostName + ";";
                            if (flag == 0)
                            {
                                outTagIds += order.tagId;
                            }
                            else
                            {
                                outTagIds += "," + order.tagId;
                            }
                            flag++;
                        }
                    }
                }

                inTagIds  = "'" + inTagIds + "'";
                outTagIds = "'" + outTagIds + "'";
                // areaid, ruleid ,inOut, tagids
                sb.AppendFormat(@"
                <tr>
                    <td width=""200""  style=""text-align: center"">
                         {0} 
                    </td>
                    <td width=""200""  style=""text-align: center"">  
                            <table width=200 align=center class=inTable>
                            <tr>
                            <td valign=top width=150>{1}</td>
                            <td valign=top width=50> <input  type=button value=""设置"" onclick=""return btnSet_onclick({3},{4},0,{6})"" /></td>
                            </tr>
                            </table>
                    </td>
                    <td style=""text-align: center"">                
                            <table width=200 align=center class=inTable>
                            <tr>
                            <td valign=top width=150>{2}</td>
                            <td valign=top width=50><input  type=button value=""设置"" onclick=""return btnSet_onclick({3},{5},1,{7})"" /></td>
                            </tr>
                            </table>
                    </td>
                </tr>
            ", ma.AreaName, inContext, outContext, ma.Id, idRuleIN, idRuleOUT, inTagIds, outTagIds);
            }


            if (i == 0)
            {
                sb.AppendFormat(@"
                <tr>
                    <td colspan=""3"">                
                       无数据记录
                    </td>
                </tr>");
            }
            sb.Append(@"</table>");
            return(sb.ToString());
        }
示例#8
0
        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("删除成功。");
        }