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);
        }
        public static bool ClearAllEventStatus(string tagMac)
        {
            if (LocatingServiceUtil.IsAvailable())
            {
                IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                bool        boolean    = serviceApi.ClearTagStatus(tagMac);

                //记录日志
                using (AppDataContext db = new AppDataContext())
                {
                    Tag tag = db.Tags.SingleOrDefault(t => t.TagMac == tagMac);
                    if (tag != null)
                    {
                        Diary.Insert(ContextUser.Current.Id, tag.Id, TagStatusView.SelectTagStatus(tag.Id).HostTag.HostId, "清除" + tag.TagName + "的所有报警状态。");//SecurityLog.Insert(tag.Id, TagUser.GetUserIdByTagId(tag.Id), "清除" + tag.TagName + "的所有报警状态。", Priority.High);
                    }
                }
                return(boolean);
            }
            else
            {
                return(false);
            }
        }
예제 #3
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 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);
            }
        }
        public static bool ClearEventStatus(string tagMac, string eventKeyword)
        {
            SupportEvent clearEvent;
            string       str;

            switch (eventKeyword)
            {
            case "absence":
                clearEvent = SupportEvent.Absent;
                str        = "消失";
                break;

            case "areaEvent":
                clearEvent = SupportEvent.AreaEvent;
                str        = "进出区域";
                break;

            case "batteryInsufficient":
                clearEvent = SupportEvent.BatteryInsufficient;
                str        = "低电量";
                break;

            case "batteryReset":
                clearEvent = SupportEvent.BatteryReset;
                str        = "电池重置";
                break;

            case "buttonPressed":
                clearEvent = SupportEvent.ButtonPressed;
                str        = "按钮";
                break;

            case "wristletBroken":
                clearEvent = SupportEvent.WristletBroken;
                str        = "腕带";
                break;

            default:
                return(false);
            }

            if (LocatingServiceUtil.IsAvailable())
            {
                IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                bool        boolean    = serviceApi.ClearTagStatus(tagMac, 0);

                //记录日志
                using (AppDataContext db = new AppDataContext())
                {
                    Tag tag = db.Tags.SingleOrDefault(t => t.TagMac == tagMac);
                    if (tag != null)
                    {
                        Diary.Insert(ContextUser.Current.Id, tag.Id, TagStatusView.SelectTagStatus(tag.Id).HostTag.HostId, "清除" + tag.TagName + "的" + str + "报警状态。");
                    }
                }

                return(boolean);
            }
            else
            {
                return(false);
            }
        }
예제 #6
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("删除成功。");
        }
예제 #7
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("删除成功。");
        }
예제 #8
0
        public object GetResult()
        {
            StringBuilder sb = new StringBuilder();

            TagAlert[] tas = null;
            using (AppDataContext db = new AppDataContext())
            {
                tas = db.TagAlerts.Where(t => t.AlertStatus == (byte)AlertStatusType.New)
                      .Where(t => t.HostId > 0)
                      .OrderByDescending(x => x.WriteTime).ToArray();
            }
            string div                 = "";
            string tagName             = "";
            string tagNameHref         = "";
            string coordinatesName     = "";
            string coordinatesNameHref = "";
            string description         = "";
            string time                = "";
            string tagIcon             = "";
            int    firstCoordinateID   = 0;

            foreach (TagAlert ev in tas)
            {
                if (firstCoordinateID == 0)
                {
                    firstCoordinateID = ev.CoordinatesId;
                }

                if (ev != null)
                {
                    div = "id_" + ev.AlertId;

                    HostTagGroupStatus hostTag = HostTagGroupStatus.SelectByHostId(ev.HostId);
                    tagName = hostTag.HostName;
                    tagIcon = CommonExtension.IdentityIconByGroupId(hostTag.HostGroupId);



                    //need to open video based on the _alertId
                    if (CommonExtension.IsIlltreatTag(ev.HostId))
                    {
                        if (Config.Settings.ProjectType == ProjectTypeEnum.NMPrison)
                        {
                            coordinatesName = hostTag.HostName;
                        }
                        else
                        {
                            int coorid = CommonExtension.GetCoordinatesId(hostTag.Description.Substring(0, hostTag.Description.Length - 2));
                            coordinatesName = Coordinates.GetName(coorid);

                            switch (VedioType)
                            {
                            case 1:
                                coordinatesNameHref = "javascript:AlertView(" + ev.CoordinatesId + ");";
                                break;

                            case 2:
                                coordinatesNameHref = "javascript:AlertView2(" + ev.CoordinatesId + ");";
                                break;

                            case 3:
                                coordinatesNameHref = "javascript:AlertView3(" + ev.CoordinatesId + ");";
                                break;

                            default: break;
                            }
                        }
                    }
                    else
                    {
                        int hosttype = TagStatusView.SelectTagStatus(ev.TagId).HostTag.HostGroupId.Contains(1) ? 1 : 2;
                        tagNameHref = "../TagUsers/TagUser.aspx?id=" + ev.HostId + "&type=" + hosttype;

                        coordinatesName = Coordinates.GetName(ev.CoordinatesId);
                        switch (VedioType)
                        {
                        case 1:
                            coordinatesNameHref = "javascript:AlertView(" + ev.CoordinatesId + ");";
                            break;

                        case 2:
                            coordinatesNameHref = "javascript:AlertView2(" + ev.CoordinatesId + ");";
                            //coordinatesName.Attributes["onclick"] = "AlertView2(" + ev.CoordinatesId + ")";
                            break;

                        case 3:
                            coordinatesNameHref = "javascript:AlertView3(" + ev.CoordinatesId + ");";
                            break;

                        default: break;
                        }
                    }

                    description = CommonExtension.GetEventDescription((SupportEvent)ev.AlertType, ev.HostId);

                    time = ev.WriteTime.ToString();


                    /**********************/
                    sb.AppendFormat(@"
        <tr>
            <td>
                <img src='{0}' Width='13' Height='13'/>
                <a href='{1}' style='font-weight: bold;' target='_blank'>{2}</a> 
            </td>
            <td>
                {3}
            </td>
            <td>
                <span>{4}</span>
            </td>
            <td>
                <span>{5}</span>
            </td>
            <td>  
                <div id='{6}'>                          
		    <a onclick='javascript:setResolved(this);' href='#' style='width:35px; height:19px;' title='点此按钮后该事件将标记为已确认,页面将跳转到事件处理页面'>[确认]</a>
                </div>
            </td>
        </tr>
               ", tagIcon, tagNameHref, tagName, coordinatesNameHref.Length > 0 ? "<a href='" + coordinatesNameHref + "' style='font-weight: bold;'>" + coordinatesName + "</a>" : coordinatesName, description, time, div);
                    /**********************/
                }
            }//foreach


            if (sb.Length > 0)
            {
                sb.Insert(0, "<table cellpadding=0 cellspacing=0 border=0>");
                sb.Append("</table>");
            }
            else
            {
                sb.Append("<br/>暂时没有发现报警。。。&nbsp;&nbsp;【<span onclick=\" window.opener=null;window.open('','_self');window.close();\" style=\"cursor:pointer;\">关闭窗口</span>】<br/><br/>");
            }

            switch (VedioType)
            {
            case 1:
                return(new { html = sb.ToString(), callBackFunction = "loadfirst(" + firstCoordinateID + ")" });

            case 2:
                return(new { html = sb.ToString(), callBackFunction = "loadfirst2(" + firstCoordinateID + ")" });

            default:
                return(new { html = sb.ToString(), callBackFunction = "" });
            }
        }