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);
        }
Beispiel #2
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("删除成功。");
        }
Beispiel #3
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("删除成功。");
        }