Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            aaaaaaaaaa.Visible    = false;
            ProcessAlert1.Visible = false;


            Ajax.AjaxManager.RegisterClass(typeof(__AlertHostInfo));
            this.LoadTagStatus();

            NetRadio.Data.TagAlert a;

            NetRadio.Data.AppDataContext db = new AppDataContext();
            TagAlert ta = db.TagAlerts.Where(_d => _d.TagId == _tagId && _d.AlertStatus == 1).FirstOrDefault();

            if (ta != null)
            {
                aaaaaaaaaa.Visible    = true;
                ProcessAlert1.Visible = true;
                ProcessAlert1.AlertID = ta.AlertId;
                //_id = ta.AlertId;// Fetch.QueryUrlAsInteger("id");

                //LoadTagAlert();

                //if (!IsPostBack)
                //    LoadCopList();
            }



            AlertCoordinates.Value = "";
        }
Exemplo n.º 2
0
        public void UpdateAlert()
        {
            var tagAlert = new TagAlert
            {
                AlertAction = AlertAction.Kill,
                Tag         = new Tag {
                    Id = 0
                },
                IsEnabled   = true,
                MaxDuration = TimeSpan.FromHours(2),
                Range       = new RepeatingAlertRange
                {
                    DailyStartOffset = TimeSpan.FromMilliseconds(126),
                    DailyEndOffset   = TimeSpan.FromMilliseconds(12),
                    RepeatType       = RepeatType.Daily
                },
                ReminderOffset = TimeSpan.FromMinutes(5)
            };

            Repo.AddAlert(tagAlert);
            Assert.Equal(1, Repo.GetAlerts().Count().Wait());
            tagAlert.AlertAction    = AlertAction.Message;
            tagAlert.Tag.Id         = 2;
            tagAlert.IsEnabled      = false;
            tagAlert.MaxDuration    = TimeSpan.FromMilliseconds(200);
            tagAlert.ReminderOffset = TimeSpan.FromMilliseconds(10);
            tagAlert.Range          =
                new OnceAlertRange {
                StartTimestamp = DateTime.Now, EndTimestamp = DateTime.Now.AddHours(1)
            };
            Repo.UpdateAlert(tagAlert);
            var returnAppAlert = Repo.GetAlerts().SingleAsync().Wait();

            AssertEx.DeepEquals(tagAlert, returnAppAlert);
        }
        protected void handover_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(copDropDownList.SelectedItem.Value) == me.Id)
            {
                ShowMessagePage("不能将事件处理移交给自己。");
                return;
            }

            TagAlert.UpdateMasterByAlertId(_id, Convert.ToInt32(copDropDownList.SelectedItem.Value));
            AlertProcessLog.Insert(_id, me.Id, AlertStatusType.Processing, "将事件处理移交给:" + copDropDownList.SelectedItem.Text);
            LoadTagAlert();
        }
        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.º 5
0
        public static bool ProcessAlertFun(int alertID, int _value, int processID, string processName)
        {
            TagAlert.UpdateStatusByAlertId(alertID, AlertStatusType.Resolved);
            string reason = "";

            if (_value == 1)
            {
                reason = "确认报警,并 " + processName;
            }
            else if (_value == 0)
            {
                reason = "误报";
            }
            AlertProcessLog.Insert(alertID, ContextUser.Current.Id, AlertStatusType.Resolved, reason);
            return(true);
        }
        protected void alertProcess_Click(object sender, EventArgs e)
        {
            if (alertResultList.SelectedItem.Text == "其它" && otherReason.Text.Trim().Length == 0)
            {
                feedbacks.Items.AddError("报警原因选择其它时,需要输入具体信息。");
                return;
            }

            TagAlert.UpdateStatusByAlertId(_id, AlertStatusType.Resolved);

            string reason = me.Name + "将报警原因设置为:" + alertResultList.SelectedItem.Text;

            if (otherReason.Text != null && otherReason.Text.Trim().Length > 0)
            {
                reason += "," + otherReason.Text.Trim();
            }
            AlertProcessLog.Insert(_id, me.Id, AlertStatusType.Resolved, reason);
            LoadTagAlert();
        }
Exemplo n.º 7
0
        protected void setResolved_Click(object sender, EventArgs e)
        {
            IEnumerable <int> idList = Strings.ParseToArray <int>(Request.Form["selection"]);

            if (idList.Count() > 0)
            {
                using (AppDataContext db = new AppDataContext())
                {
                    var alerts = db.TagAlerts.Where(x => idList.Contains(x.AlertId)).ToList();
                    foreach (var item in alerts)
                    {
                        //TagStatusView.ChangeStatus(TagStatusView.SelectTagStatus(item.TagId).Mac, (SupportEvent)item.AlertType, EventStatus.Cleared);
                        //if need to notify server???
                        TagAlert.UpdateStatusByAlertId(item.AlertId, AlertStatusType.Processing);
                        AlertProcessLog.Insert(item.AlertId, me.Id, AlertStatusType.Processing, "处理中");
                    }
                }
            }
            me.TagEventApprizingTimePoint = DateTime.Now;
            Response.Redirect(Fetch.CurrentUrl);
        }
Exemplo n.º 8
0
        public void InsertTagAlertWithOnce()
        {
            var tagAlert = new TagAlert
            {
                AlertAction = AlertAction.Kill,
                Tag         = new Tag {
                    Id = 0
                },
                IsEnabled   = true,
                MaxDuration = TimeSpan.FromHours(2),
                Range       = new OnceAlertRange
                {
                    StartTimestamp = DateTime.Now,
                    EndTimestamp   = DateTime.Now.AddHours(1)
                },
                ReminderOffset = TimeSpan.FromMinutes(5)
            };

            Repo.AddAlert(tagAlert);
            var returnTagAlert = Repo.GetAlerts().SingleAsync().Wait();

            AssertEx.DeepEquals(tagAlert, returnTagAlert);
        }
Exemplo n.º 9
0
        public void RemoveTagAlert()
        {
            var tagAlert = new TagAlert
            {
                AlertAction = AlertAction.Kill,
                Tag         = new Tag {
                    Id = 0
                },
                IsEnabled   = true,
                MaxDuration = TimeSpan.FromHours(2),
                Range       = new RepeatingAlertRange
                {
                    DailyStartOffset = TimeSpan.FromMilliseconds(126),
                    DailyEndOffset   = TimeSpan.FromMilliseconds(12),
                    RepeatType       = RepeatType.Daily
                },
                ReminderOffset = TimeSpan.FromMinutes(5)
            };

            Repo.AddAlert(tagAlert);
            Assert.Equal(1, Repo.GetAlerts().Count().Wait());
            Repo.RemoveAlert(tagAlert);
            Assert.Equal(0, Repo.GetAlerts().Count().Wait());
        }
Exemplo n.º 10
0
        public void InsertTagAlertWithRepeat()
        {
            var tagAlert = new TagAlert
            {
                AlertAction = AlertAction.Kill,
                Tag         = new Tag {
                    Id = 0
                },
                IsEnabled   = true,
                MaxDuration = TimeSpan.FromHours(2),
                Range       = new RepeatingAlertRange
                {
                    DailyStartOffset = TimeSpan.FromMilliseconds(126),
                    DailyEndOffset   = TimeSpan.FromMilliseconds(12),
                    RepeatType       = RepeatType.Daily
                },
                ReminderOffset = TimeSpan.FromMinutes(5)
            };

            Repo.AddAlert(tagAlert);
            var returnTagAlert = Repo.GetAlerts().SingleAsync().Wait();

            AssertEx.DeepEquals(tagAlert, returnTagAlert);
        }
        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;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
        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("");
        }
Exemplo n.º 13
0
 public TagAlertViewModel(TagAlert alert) : base(alert)
 {
     Tag = new TagViewModel(alert.Tag);
 }
Exemplo n.º 14
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.º 15
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("删除成功。");
        }