private void LoadRepeater()
        {
            if (Session["TagLogFilter"] != null)
            {
                tagLogFilter = (NetRadio.LocatingMonitor.Controls.__TagLogFilter)Session["TagLogFilter"];
                string tagFilterCondition = tagLogFilter.ConditionDescription;
            }

            //过滤条件
            //tagLogFilter.SelectedGroupIdArray = new int[1] { (int)_userType };  //20091228 add
            string strWhere   = LocatingMonitorUtils.ConstructSQLWhere(tagLogFilter);
            string zCondition = "GenericEventType= " + (int)SupportEvent.BatteryInsufficient;

            strWhere += (strWhere.Trim() == "") ? zCondition : " AND " + zCondition;
            strWhere += " AND hostgroupid= " + ((int)_userType).ToString();

            string zSortDir = "desc";

            if (_sortDir == SortDirection.Ascending)
            {
                zSortDir = "";
            }

            int     totalCount = 0;
            DataSet ds         = GenericEventLog.GetGenericEventLog(strWhere, _zSortKey, zSortDir, p.PageSize, p.PageIndex, out totalCount);

            p.RecordCount = totalCount;
            if (ds.Tables.Count != 0)
            {
                list.DataSource = ds.Tables[0].DefaultView;
                list.DataBind();
            }
        }
        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);
        }
Exemplo n.º 3
0
        private void LoadRepeater()
        {
            using (AppDataContext db = new AppDataContext())
            {
                if (Session["TagLogFilter"] != null)
                {
                    tagLogFilter = (NetRadio.LocatingMonitor.Controls.__TagLogFilter)Session["TagLogFilter"];
                    string tagFilterCondition = tagLogFilter.ConditionDescription;
                }

                //过滤条件
                //tagLogFilter.SelectedGroupIdArray = new int[1] { (int)_userType };  //20091228 add
                string strWhere   = LocatingMonitorUtils.ConstructSQLWhere(tagLogFilter);
                string zCondition = "GenericEventType= " + (int)SupportEvent.ButtonPressed;
                strWhere += (strWhere.Trim() == "") ? zCondition : " AND " + zCondition;
                strWhere += " AND hostgroupid= " + ((int)_userType).ToString();

                string zSortDir = "desc";
                if (_sortDir == SortDirection.Ascending)
                {
                    zSortDir = "";
                }

                int     totalCount = 0;
                DataSet ds         = GenericEventLog.GetGenericEventLog(strWhere, _zSortKey, zSortDir, p.PageSize, p.PageIndex, out totalCount);
                p.RecordCount = totalCount;
                if (ds.Tables.Count != 0)
                {
                    list.DataSource = ds.Tables[0].DefaultView;
                    list.DataBind();
                }
            }
            ////////////////////////////////////////////////////////////////////////////////

            /*using (AppDataContext db = new AppDataContext()) {
             *  var query = db.GenericEventLogViews
             *      .Where(x => x.GenericEventType == (int)SupportEvent.ButtonPressed)
             *      .OrderByDescending(x => x.Id)
             *      .Select(x => new GenericEventLogView {
             *          TagId = x.TagId,
             *          TagName = x.TagName,
             *          MapId = x.MapId,
             *          CoordinatesName = x.CoordinatesName,
             *          FacilityName = x.FacilityName,
             *          WriteTime = x.WriteTime
             *      });
             *  if (Session["TagLogFilter"] != null)
             *  {
             *      tagLogFilter = (NetRadio.LocatingMonitor.Controls.__TagLogFilter)Session["TagLogFilter"];
             *      string tagFilterCondition = tagLogFilter.ConditionDescription;
             *  }
             *
             *  query = query.Where(x => x.WriteTime > tagLogFilter.FromTime);
             *  query = query.Where(x => x.WriteTime < tagLogFilter.ToTime);
             *
             *  if (tagLogFilter.TagNameKeyword.Length > 0) {
             *      query = query.Where(x => x.TagName.Contains(tagLogFilter.TagNameKeyword));
             *  }
             *
             *  if (tagLogFilter.SelectedGroupIdArray != null)
             *  {
             *      //int[] coveredTagIdArray = TagGroupCoverage.GetCoveredTagIdArray(tagLogFilter.SelectedGroupIdArray);
             *      int[] coveredTagIdArray = HostTagGroupStatus.GetCoveredTagIdArray(tagLogFilter.SelectedGroupIdArray);
             *      query = query.Where(x => coveredTagIdArray.Contains(x.TagId));
             *  }
             *
             *  if (tagLogFilter.FacilityFilterRowVisible && tagLogFilter.MapId > 0) {
             *      query = query.Where(x => x.MapId == tagLogFilter.MapId);
             *  }
             *
             *  p.RecordCount = query.Count();
             *  query = query.Skip(p.RecordOffset).Take(p.PageSize);
             *
             *  list.DataSource = query.ToList();
             *  list.DataBind();
             * }
             */
        }
Exemplo n.º 4
0
        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("删除成功。");
        }
Exemplo n.º 5
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("删除成功。");
        }