コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Sitemap.Text2 = "实时监控";
            //Sitemap.Text3 = "地图定位监控";

            //LocatingServiceUtil.DemandLocatingService();
            if (!LocatingServiceUtil.IsAvailable())
            {
                ShowMessagePage("LocatingService未启动,无法获得即时状态。");
            }
            switch (Business.BusSystemConfig.GetVedioType())
            {
            case 1:
                vedioYangZhou.Visible = true;
                vedioDemo.Visible     = false;
                break;

            case 2:
                vedioYangZhou.Visible = false;
                vedioDemo.Visible     = true;
                break;

            default:
                divVedio.Visible = false;
                break;
            }
        }
コード例 #2
0
        protected void stopLocating_Click(object sender, EventArgs e)
        {
            if (!this.IsLocatingServiceAvailable)
            {
                feedbacks.Items.AddError("请求失败,请检查 LocatingService 是否可被连接。");
                LoadRepeater();
                return;
            }

            int[] tagIdArray = Strings.ParseToArray <int>(selectedTagIds.Value);
            if (tagIdArray.Length == 0)
            {
                feedbacks.Items.AddError("操作失败,没有选中任何记录行。");
                LoadRepeater();
                return;
            }

            TagLocateSetting.StopLocating(tagIdArray);

            // Send a command to LocatingService.
            LocatingServiceUtil.Instance <IServiceApi>().StartStopLocating();

            // Reload List
            LoadRepeater();
        }
コード例 #3
0
        private string GetList(int groupID)
        {
            if (groupID == 1 || groupID == 2)
            {
                if (LocatingServiceUtil.IsAvailable())
                {
                    IServiceApi     serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                    TagStatusView[] tagsView   = serviceApi.GetTagOnSentry();

                    if (tagsView == null)
                    {
                        return("");
                    }
                    var q = tagsView.Where(_d => _d != null && _d.HostTag.HostGroupId.Contains(groupID)).Select(_d => new { HostId = _d.HostTag.HostId, HostName = _d.HostTag.HostName, Mac = _d.Mac, HostPhotoPath = "../TagUsers/UserPhoto.ashx?id=" + _d.HostTag.HostId });

                    StringBuilder sb = new StringBuilder("");
                    foreach (var log in q)
                    {
                        sb.AppendFormat(@" 
                                    <td width=4></td>
                                    <td width=100 align=center valign=top><img src={0} width=100 height=120 /><br/><br/> 姓名:{1}<br/> 标签:{2}</td>
                                    ", log.HostPhotoPath, log.HostName, log.Mac);
                    }
                    if (sb.Length > 0)
                    {
                        sb.Insert(0, "<table border=0 cellspacing=0 cellpadding=0><tr>");
                        sb.Append("</tr></table>");
                    }
                    return(sb.ToString());
                }
            }
            return("");
        }
コード例 #4
0
        private int GetActiveAPTotalCount()
        {
            int totalCount = 0;

            if (LocatingServiceUtil.IsAvailable())
            {
                IServiceApi    serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                APStatusView[] apStatus   = serviceApi.SelectAPStatusList(
                    null,
                    null,
                    "",
                    SortDirection.Ascending,
                    9999,
                    0,
                    out totalCount
                    );
                totalCount = 0;
                if (apStatus != null && apStatus.Length > 0)
                {
                    for (int i = 0; i < apStatus.Length; i++)
                    {
                        if (apStatus[i].APLocatorStatus == (byte)APLocatorStatus.Success || apStatus[i].APLocatorStatus == (byte)APLocatorStatus.Running)
                        {
                            totalCount++;
                        }
                    }
                }
            }
            return(totalCount);
        }
コード例 #5
0
        public static string BindTag(int userId, int tagId)
        {
            //TagUser user = TagUser.SelectById(userId);
            string             newMac  = "FAIL";
            HostTagGroupStatus hostTag = HostTagGroupStatus.SelectByHostId(userId);

            if (hostTag != null)
            {
                //HostTag.ChangeHostTagBinding(userId, tagId);

                if (LocatingServiceUtil.IsAvailable())
                {
                    //LocatingServiceUtil.Instance<IServiceApi>().UpdateTagNameAndSerialNo(tagId, hostTag.HostName, hostTag.HostExternalId);
                    IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                    newMac = serviceApi.ExchangeTagMac(hostTag.HostId, 0, tagId);
                    SetStartLocating(tagId);

                    // Send a command to LocatingService.
                    LocatingServiceUtil.Instance <IServiceApi>().StartStopLocating();

                    string calling = GetGroupName(hostTag.HostGroupId);
                    //SecurityLog.Insert(tagId, userId, "为" + calling + hostTag.HostName + "绑定标签,标签MAC: " + newMac + "。", Priority.High);
                    Diary.Insert(ContextUser.Current.Id, tagId, hostTag.HostId, "为" + calling + hostTag.HostName + "绑定标签,标签MAC: " + newMac + "。");
                }
                //else
                //{
                //    SetStartLocating(tagId);
                //Tag.UpdateTagNameAndSerialNo(tagId, hostTag.HostName, hostTag.HostExternalId);
                //}
                //TagUser.BindTagToUser(userId, tagId);
            }
            return(newMac);
        }
コード例 #6
0
        private int GetActiveTagTotalCount(int groupId)
        {
            IList <TagStatusView> tagList = new List <TagStatusView>();
            string _keyword = "";

            int[] _hostGroupArray = new int[1];
            _hostGroupArray[0] = groupId;
            int totalCount = 0;

            if (LocatingServiceUtil.IsAvailable())
            {
                IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                if (serviceApi != null)
                {
                    TagStatusView tagStatusView = new TagStatusView();
                    tagList = serviceApi.SelectTagStatusList(
                        _keyword,
                        _hostGroupArray,
                        0,
                        true,
                        false, //SupportEvent.Absent),
                        false, //SupportEvent.BatteryInsufficient),
                        false, //SupportEvent.AreaEvent),
                        false, //SupportEvent.ButtonPressed),
                        false, //SupportEvent.WristletBroken),
                        "",
                        SortDirection.Ascending,
                        0,//only get total count
                        0,
                        out totalCount);
                }
            }
            return(totalCount);
        }
コード例 #7
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");
            }
        }
コード例 #8
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);
        }
コード例 #9
0
        /// <summary>
        /// 取出需要删除掉的hostid
        /// </summary>
        /// <param name="delhostIds"></param>
        /// <param name="groupid"></param>
        /// <param name="MapId"></param>
        /// <param name="hostIds"></param>
        ///

        private void GetDelIDs(out int[] delhostIds, int groupid, int MapId, int[] hostIds)
        {
            LocatingServiceUtil.DemandLocatingService();
            IServiceApi serviceApi  = LocatingServiceUtil.Instance <IServiceApi>();
            List <int>  ihostid     = new List <int>();
            bool        bExist      = false;
            int         itotalcount = 0;
            int         imapid      = MapId;

            int[]           FindHostIDByGroup = new int[] { groupid };
            TagStatusView[] tgv = serviceApi.SelectTagStatusListByKeywords(
                "",
                FindHostIDByGroup,
                MapId,
                false,
                false,
                false,
                false,
                false,
                false,
                "TagName",
                SortDirection.Ascending,
                50,
                0,
                out itotalcount
                );
            for (int k = 0; k < tgv.Count(); k++)
            {
                for (int m = 0; m < hostIds.Count(); m++)
                {
                    if (tgv[k].HostTag.HostId == hostIds[m])
                    {
                        bExist = true;
                        break;
                    }
                }
                if (bExist)
                {
                    bExist = false;
                    continue;
                }
                else
                {
                    ihostid.Add(tgv[k].HostTag.HostId);
                }
            }
            if (ihostid.Count() > 0)
            {
                ihostid.Add(-1);
            }

            delhostIds = ihostid.ToArray();
        }
コード例 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Sitemap.Text2 = "实时监控";
            //Sitemap.Text3 = "地图定位监控";
            Ajax.AjaxManager.RegisterClass(typeof(__NewLocatingMap));
            //LocatingServiceUtil.DemandLocatingService();
            if (!LocatingServiceUtil.IsAvailable())
            {
                ShowMessagePage("LocatingService未启动,无法获得即时状态。");
            }

            video.Visible = true;
        }
コード例 #11
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), "");
                            }
                        }

                        //删除标签历史记录和相关信息
                        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);
        }
コード例 #12
0
        private void LoadRepeater()
        {
            //LocatingServiceUtil.DemandLocatingService();
            try
            {
                int            totalCount;
                IServiceApi    serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                APStatusView[] apStatus   = serviceApi.SelectAPStatusList(
                    null,
                    null,
                    _activatedSorter.SortKey,
                    _activatedSorter.SortDirection,
                    p.PageSize,
                    p.RecordOffset,
                    out totalCount
                    );

                if (_activatedSorter.SortDirection == SortDirection.Ascending)
                {
                    if (_activatedSorter.SortKey == "APName")
                    {
                        apStatus = apStatus.OrderBy(x => x.APName).ToArray();
                    }
                    else
                    {
                        apStatus = apStatus.OrderBy(x => x.UpdateTime).ToArray();
                    }
                }

                else
                {
                    if (_activatedSorter.SortKey == "APName")
                    {
                        apStatus = apStatus.OrderByDescending(x => x.APName).ToArray();
                    }
                    else
                    {
                        apStatus = apStatus.OrderByDescending(x => x.UpdateTime).ToArray();
                    }
                }
                apStatus          = apStatus.Where(a => !a.Mac.Substring(0, 11).Contains("00:55:52:48")).ToArray();
                p.RecordCount     = totalCount;//2010-11-17bydyp
                apList.DataSource = apStatus.ToList();
                apList.DataBind();
            }
            catch
            {
                //new PrettyTerminator().End("Locating Service 远程支持服务程序未启动,无法打开该页面。");
            }
        }
コード例 #13
0
        public object GetStrongestRssiTag()
        {
            string Mes    = "";
            int    TagID  = 0;
            string TagMAC = "";

            int Error = 0;// 标签可用 = 0 ; 标签已经被绑定 =1 ; LocatingService不可用时 = 2  ; 没有扫描到可用的标签 = 3


            if (LocatingServiceUtil.IsAvailable())
            {
                IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                string      mac        = serviceApi.GetTagOnReception();
                if (mac == null)
                {
                    mac = "";
                }
                AppDataContext   db   = new AppDataContext();
                IQueryable <Tag> tags = db.Tags.Where(_d => _d.TagMac.ToLower().Trim() == mac.ToLower().Trim());
                if (tags.Count() == 1)
                {
                    Tag tag = tags.First();
                    IQueryable <HostTag> hostTags = db.HostTags.Where(_d => _d.TagId == tag.Id);
                    if (hostTags.Count() > 0)
                    {
                        Mes   = string.Format("×当前信号最强的标签MAC地址是{0},但已经被绑定,标签不可用。", tag.TagMac);
                        Error = 1;
                    }
                    else
                    {
                        Mes    = string.Format("√当前信号最强的标签MAC地址是{0},标签可用。", tag.TagMac);
                        TagID  = tag.Id;
                        TagMAC = tag.TagMac;
                        Error  = 0;
                    }
                }
                else
                {
                    Mes   = "暂时没有扫描到可用的标签!";
                    Error = 3;
                }
            }
            else
            {
                Mes   = "LocatingService不可用";
                Error = 2;
            }
            return(new { Mes, TagID, TagMAC, Error });
        }
コード例 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!LocatingServiceUtil.IsAvailable())
            {
                ShowMessagePage("服务器程序未启动,无法获得实时监房统计。");
            }

            LocatingServiceUtil.DemandLocatingService();
            string areaname = Request.QueryString["areaname"].Trim();

            if (!string.IsNullOrEmpty(areaname))
            {
                list.DataSource = MapArea.All.Where(_d => _d.AreaName.Trim().Substring(0, 1) == areaname);
                list.DataBind();
            }
        }
コード例 #15
0
        public bool ImportUsers()
        {
            int totalCount = 0;

            if (LocatingServiceUtil.IsAvailable())
            {
                IServiceApi   serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                GeneralResult gr         = serviceApi.LoadHostInfo();
                CulpritRoomReference.RemoveCaching();
                if (!gr.Suceess)
                {
                    throw new Exception(gr.ErrText);
                }
            }
            return(true);
        }
コード例 #16
0
        protected void list_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            Facility   f            = (Facility)e.Item.DataItem;
            SmartLabel facilityName = e.Item.FindControl("facilityName") as SmartLabel;
            SmartLabel headCount    = e.Item.FindControl("headCount") as SmartLabel;

            facilityName.Text = f.FacilityName;

            IList <TagStatusView> tagList = new List <TagStatusView>();
            string _keyword = "";

            //GTang 20101122 修改为统计hostGroupid=1,2
            //int[] _hostGroupArray = new int[1] { 1 };
            int[] _hostGroupArray = new int[2] {
                1, 2
            };
            int totalCount = 0;

            IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();

            if (serviceApi != null && LocatingServiceUtil.IsAvailable())
            {
                TagStatusView tagStatusView = new TagStatusView();
                tagList = serviceApi.SelectTagStatusList(
                    _keyword,
                    _hostGroupArray,
                    f.MapId,
                    true,
                    false, //SupportEvent.Absent),
                    false, //SupportEvent.BatteryInsufficient),
                    false, //SupportEvent.AreaEvent),
                    false, //SupportEvent.ButtonPressed),
                    false, //SupportEvent.WristletBroken),
                    "",
                    SortDirection.Ascending,
                    0,//only get total count
                    0,
                    out totalCount);

                headCount.Text = totalCount.ToString();
                _totalCount   += totalCount;
            }
        }
コード例 #17
0
        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);
            }
        }
コード例 #18
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))
                            );
        }
コード例 #19
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("");
        }
コード例 #20
0
        protected void list_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            MapArea area = e.Item.DataItem as MapArea;

            if (area != null)
            {
                SmartLabel areaName = (SmartLabel)e.Item.FindControl("areaName");
                areaName.Text = area.AreaName;

                NumericLabel quota = (NumericLabel)e.Item.FindControl("quota");
                quota.Value = CulpritRoomReference.All.Count(x => x.JailRoomId == area.Id);

                NumericLabel bindingCount = (NumericLabel)e.Item.FindControl("bindingCount");

                NumericLabel currentCount  = (NumericLabel)e.Item.FindControl("currentCount");
                SmartLabel   expectedNames = (SmartLabel)e.Item.FindControl("expectedNames");
                SmartLabel   illedNames    = (SmartLabel)e.Item.FindControl("illedNames");

                var coordinates = MapAreaCoverage.All.Where(x => x.AreaId == area.Id).Select(x => x.CoordinatesId).ToArray();
                IList <TagStatusView> nowUsers = new List <TagStatusView>();
                foreach (var item in FullTagStatusView)
                {
                    if (coordinates.Contains(item.CoordinatesId) && HostTag.GetHostGroup(item.HostTag.HostId).Contains((int)TagUserType.Culprit) && item.AbsenceStatus != EventStatus.Occurring)
                    {
                        currentCount.Value++;
                        nowUsers.Add(item);
                    }
                }
                if (currentCount.Value != quota.Value)
                {
                    currentCount.CssClass = "t2";
                }
                IList <HostTag> shouldUsers = HostTag.AllActive
                                              .Where(x => CulpritRoomReference.All.Where(r => r.JailRoomId == area.Id).Select(r => r.CulpritId).Contains(x.HostId))
                                              .ToList();

                bindingCount.Value = shouldUsers.Count;

                IList <string> arr1 = new List <string>();
                //foreach (var item in nowUsers)
                //{
                //    if (shouldUsers.Any(x => x.TagId == item.TagId) == false)
                //    {
                //        arr1.Add("<a href='../Objects/Tag.aspx?id=" + item.TagId + "' target='_blank'>" + item.TagName + "</a>");
                //    }
                //}
                //extraNames.Text = string.Join(", ", arr1.ToArray());

                IList <string> arr2 = new List <string>();
                foreach (var item in shouldUsers)
                {
                    TagStatusView tagStatusView = LocatingServiceUtil.Instance <IServiceApi>().SelectTagStatus(item.TagId);

                    if (nowUsers.Any(x => x.TagId == item.TagId) == false)
                    {
                        int hostType = HostTagView.GetHostView(item.TagId).HostGroupId.Contains(1) ? 1 : 2;
                        arr2.Add("<a href='../TagUsers/TagUser.aspx?type=" + hostType + "&id=" + item.HostId + "' target='_blank'>" + item.HostName + "</a> : " + tagStatusView.CoordinatesName);
                    }

                    if (tagStatusView.HostTag.HostGroupId.Contains((int)TagUserType.IlledPrisoner))
                    {
                        arr1.Add("<a href='../TagUsers/TagUser.aspx?type=" + (int)TagUserType.Culprit + "&id=" + item.HostId + "' target='_blank'>" + item.HostName + "</a>");
                    }
                }
                expectedNames.Text = string.Join("<br>", arr2.ToArray());
                illedNames.Text    = string.Join(", ", arr1.ToArray());
            }
        }
コード例 #21
0
        private string CreateOutputContent()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<?xml version=\"1.0\" standalone=\"yes\" ?>");
            sb.AppendLine("<tagCoordinates>");

            if (!LocatingServiceUtil.IsAvailable())
            {
                sb.AppendLine("</tagCoordinates>");
                return(sb.ToString());
            }

            IServiceApi   serviceApi    = LocatingServiceUtil.Instance <IServiceApi>();
            TagStatusView tagStatusView = new TagStatusView();

            if (_tagId > 0)
            {
                tagStatusView = serviceApi.SelectTagStatus(_tagId);

                if (tagStatusView != null && _mapId > 0 && tagStatusView.TagId > 0)
                {
                    _mapId = tagStatusView.MapId;
                }

                if (tagStatusView.WorkingStatus != TagWorkingStatus.Locating)
                {
                    _tagId = 0;
                    _mapId = Fetch.QueryUrlAsIntegerOrDefault("mapId", -1);
                }
            }
            int totalCount = 0;
            IList <TagStatusView> tagList = new List <TagStatusView>();

            if (_hostGroupArray == null || _hostGroupArray.Length == 0)
            {
                _hostGroupArray = new int[] { 1, 2 };
            }

            if (_keyword.Length > 0 && !_keyword.Contains(','))
            {
                _mapId  = 0;
                tagList = serviceApi.SelectTagStatusListByKeywords(
                    _keyword,
                    _hostGroupArray,
                    _mapId,
                    true,
                    _eventTypes.Contains((int)SupportEvent.Absent),
                    _eventTypes.Contains((int)SupportEvent.BatteryInsufficient),
                    _eventTypes.Contains((int)SupportEvent.AreaEvent),
                    _eventTypes.Contains((int)SupportEvent.ButtonPressed),
                    _eventTypes.Contains((int)SupportEvent.WristletBroken),
                    "Position",
                    SortDirection.Ascending,
                    _pageSize,
                    _pageSize * (_currentPage - 1),
                    out totalCount
                    ).ToList();
                tagList = tagList.Where(x => x.X > 0 && !x.HostTag.HostGroupId.Contains((int)TagUserType.Position)).OrderBy(x => x.X).ToList();
                //totalCount = tagList.Count;
            }
            else
            {
                tagList = serviceApi.SelectTagStatusList(
                    _keyword,
                    _hostGroupArray,
                    _mapId,
                    true,
                    _eventTypes.Contains((int)SupportEvent.Absent),
                    _eventTypes.Contains((int)SupportEvent.BatteryInsufficient),
                    _eventTypes.Contains((int)SupportEvent.AreaEvent),
                    _eventTypes.Contains((int)SupportEvent.ButtonPressed),
                    _eventTypes.Contains((int)SupportEvent.WristletBroken),
                    "Position",
                    SortDirection.Ascending,
                    _pageSize,
                    _pageSize * (_currentPage - 1),
                    out totalCount
                    ).ToList();
                tagList = tagList.Where(x => x.X > 0).OrderBy(x => x.X).ToList();
                //totalCount = tagList.Count;
            }

            int tracingItemIndex = -1;

            if (tagStatusView != null && _tagId > 0)
            {
                for (int i = 0; i < tagList.Count(); i++)
                {
                    if (tagList[i].Mac == tagStatusView.Mac)
                    {
                        tracingItemIndex = i;
                    }
                }
            }

            //IList<TagStatusView> tagStatusList = tagList.ToList();
            if (tracingItemIndex != 0 && _tagId > 0)
            {
                if (tracingItemIndex > 0)
                {
                    tagList.RemoveAt(tracingItemIndex);
                }
                tagList.Insert(0, tagStatusView);
            }

            sb.AppendLine("<pagination>");
            sb.AppendFormat("<recordCount>{0}</recordCount>\r\n", totalCount);
            sb.AppendFormat("<pageSize>{0}</pageSize>\r\n", _pageSize);
            sb.AppendFormat("<currentPage>{0}</currentPage>\r\n", _currentPage);
            sb.AppendLine("</pagination>");

            var coordinatesFormat = "<coordinates id=\"{0}\" mapId=\"{1}\" mapName=\"{2}\" coordinatesName=\"{3}\" x=\"{4}\" y=\"{5}\">";
            var tagFormat         = "<tag id=\"{0}\" tagName=\"{1}\" warningTypes=\"{2}\" warningLevel=\"{3}\" moveSpeed=\"{4}\" icon=\"{5}\" updateTime=\"{6}\"  groupIds=\"{7}\" />";

            foreach (var item in tagList)
            {
                if (_coordinatesId != item.CoordinatesId)
                {
                    if (_coordinatesId >= 0)
                    {
                        sb.AppendLine("</coordinates>");
                    }
                    sb.AppendFormat(coordinatesFormat, item.CoordinatesId, item.MapId, Facility.GetNameByMapId(item.MapId), item.CoordinatesName, item.X, item.Y);
                    _coordinatesId = item.CoordinatesId;
                }

                List <string> warningTypes = new List <string>();
                if (item.AreaEventStatus == EventStatus.Occurring)
                {
                    warningTypes.Add(((int)SupportEvent.AreaEvent).ToString());
                }
                if (item.AbsenceStatus == EventStatus.Occurring)
                {
                    warningTypes.Add(((int)SupportEvent.Absent).ToString());
                }
                if (item.BatteryInsufficientStatus == EventStatus.Occurring)
                {
                    warningTypes.Add(((int)SupportEvent.BatteryInsufficient).ToString());
                }
                if (item.BatteryResetStatus == EventStatus.Occurring)
                {
                    warningTypes.Add(((int)SupportEvent.BatteryReset).ToString());
                }
                if (item.ButtonPressedStatus == EventStatus.Occurring)
                {
                    warningTypes.Add(((int)SupportEvent.ButtonPressed).ToString());
                }
                if (item.WristletBrokenStatus == EventStatus.Occurring)
                {
                    warningTypes.Add(((int)SupportEvent.WristletBroken).ToString());
                }

                string hostGroupIds = "";
                if (item.HostTag.HostGroupId.Length > 0)
                {
                    foreach (int gId in item.HostTag.HostGroupId)
                    {
                        if (gId > 0)
                        {
                            if (hostGroupIds == "")
                            {
                                hostGroupIds += gId.ToString();
                            }
                            else
                            {
                                hostGroupIds += "," + gId.ToString();
                            }
                        }
                    }
                }
                string hostName = item.HostTag.HostName;
                if (hostName == "")
                {
                    hostName = item.TagName;
                }
                sb.AppendFormat(tagFormat, item.TagId, hostName, string.Join(",", warningTypes.ToArray()), warningTypes.ToArray().Length > 0 ? "3" : "1", "2", CommonExtension.IdentityIconByGroupId(item.HostTag.HostGroupId), item.PositionUpdateTime.ToString("yyyy/M/d H:mm:ss").Replace('-', '/'),
                                hostGroupIds /*item.HostTag.HostGroupId.Contains(1) ? 1 : 2*/);
            }

            if (_coordinatesId >= 0)
            {
                sb.AppendLine("</coordinates>");
            }

            sb.AppendLine("</tagCoordinates>");
            return(sb.ToString());
        }
コード例 #22
0
        private void AddHostTagGroup(int[] TagIdArray, int groupId)
        {
            int        MapId    = 0;
            List <int> lHostIds = new List <int>();

            for (int i = 0; i < TagIdArray.Length; i++)
            {
                HostTag host = HostTag.GetById(TagIdArray[i]);

                if (host != null && host.HostId > 0)
                {
                    HostTag.SetHostGroup(host.HostId, groupId);
                }
                else
                {
                    host = new HostTag();
                    Tag tag = Tag.Select(TagIdArray[i]);
                    if (tag != null)
                    {
                        host.HostExternalId = tag.SerialNo;
                        //TagHost tagHost = Tag.SelectTagHost(TagIdArray[i]);
                        host.HostName    = groupName.Text.Trim() + "_" + ((tag.TagMac.Length > 9) ? tag.TagMac.Substring(9) : tag.TagMac);
                        host.Description = tag.TagName;
                        host.ImagePath   = "";
                        host.HostType    = 0;
                        host.TagId       = TagIdArray[i];
                        host.HostId      = HostTag.AddOrUpdateHostTag(0, host.TagId, host.HostExternalId, host.HostName, host.HostType, host.Description, host.ImagePath);
                        HostTag.SetHostGroup(host.HostId, groupId);
                        if (i == 0)
                        {
                            TagStatusView tagView1 = TagStatusView.SelectTagStatusByHostId(host.HostId);
                            MapId = tagView1.MapId;
                        }
                    }
                }
                lHostIds.Add(host.HostId);
            }
            int[] hostIds = lHostIds.ToArray();
            if (LocatingServiceUtil.IsAvailable())
            {
                //内蒙不需要这样删除
                try
                {
                    int[] delhostIds;
                    GetDelIDs(out delhostIds, groupId, MapId, hostIds);
                    if (delhostIds.Count() > 1)
                    {
                        //合并两个数组,传值,以-1为分界值
                        int[] myhostIds = new int[delhostIds.Length + hostIds.Length];
                        delhostIds.CopyTo(myhostIds, 0);
                        hostIds.CopyTo(myhostIds, delhostIds.Length);
                        LocatingServiceUtil.Instance <IServiceApi>().UpdateHostGroup(myhostIds, groupId);
                    }
                    else
                    {
                        LocatingServiceUtil.Instance <IServiceApi>().UpdateHostGroup(hostIds, groupId);
                    }
                }
                catch (Exception err)
                {
                }
            }
        }
コード例 #23
0
        public static bool ChangeName(int userId, string newName, string newNumber)
        {
            //var user = TagUser.All.SingleOrDefault(u => u.Id == userId);
            var userHost = HostTagGroupStatus.All.SingleOrDefault(h => h.HostId == userId && h.ParentGroupId == 0);

            if (userHost != null)
            {
                string oldName   = userHost.HostName;
                string oldNumber = userHost.HostExternalId;

                userHost.HostName       = newName;
                userHost.HostExternalId = newNumber;
                if (HostTag.All.Where(_d => _d.HostId != userId && _d.HostExternalId.Trim() == newNumber.Trim()).Count() > 0)
                {
                    throw new Exception("编号已经被使用!");
                }
                else
                {
                    UpdateHostTag(userHost);
                }
                if (userHost.TagId != 0)
                {
                    if (LocatingServiceUtil.IsAvailable())
                    {
                        IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                        serviceApi.UpdateTagNameAndSerialNo(userHost.TagId, newName, newNumber);
                    }
                    else
                    {
                        Tag.UpdateTagNameAndSerialNo(userHost.TagId, newName, newNumber);
                    }
                }

                //包含更新缓存
                //TagUser.UpdateNameAndNumber(userHost.Id, newName, newNumber);

                //var host = HostTag.AllActive.SingleOrDefault(h => h.HostId == userId);
                //host.HostName = newName;
                //host.HostExternalId = newNumber;
                if (Config.Settings.ProjectType == ProjectTypeEnum.WXFactory)
                {
                }


                //记录日志
                string str = "";
                if (oldName != newName)
                {
                    str += "名称由" + oldName + "改为" + newName + " ";
                }
                if (oldNumber != newNumber)
                {
                    str += "号码由" + oldNumber + "改为" + newNumber;
                }
                if (str != "")
                {
                    string calling = GetGroupName(userHost.HostGroupId);
                    Diary.Insert(ContextUser.Current.Id, 0, userHost.HostId, "修改" + calling + "信息: " + str);
                }

                return(true);
            }
            return(false);
        }
コード例 #24
0
        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);
            }
        }
コード例 #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            NetRadio.Data.User oUser = NetRadio.Data.User.SelectByUserName(me.Name);
            if (oUser.Role >= (int)UserRole.Admin)
            {
                isAdmin = true;
            }

            if (!Page.IsPostBack)
            {
                AjaxUtil.RegisterClientScript(typeof(__TagUser), this.Page);

                int    _tagId;
                string _tagMac = null;

                using (AppDataContext db = new AppDataContext())
                {
                    var position = db.HostTagGroupStatus.SingleOrDefault(h => h.HostId == _id && h.HostGroupId == (int)TagUserType.Position);
                    if (position == null)
                    {
                        Terminator.End("记录不存在。");
                    }

                    _tagId = position.TagId;
                    var tag = Tag.Select(_tagId);
                    if (tag != null)
                    {
                        _tagMac = tag.TagMac;
                    }

                    currentTagId.Value = _tagId.ToString();
                    tagMac.Text        = _tagMac;
                    userId.Value       = position.HostId.ToString();

                    name.Text = newName.Text = position.HostName;

                    memo.Text = newMemo.Text = Strings.TextEncode(position.Description);



                    if (!isAdmin)
                    {
                        changeMemo.Visible   = false;
                        deleteButton.Visible = false;
                    }
                }


                if (!LocatingServiceUtil.IsAvailable() || !isAdmin)
                {
                    //changeTag.Visible = false;
                    clearAllEvents.Visible            = false;
                    locatingServiceDownMarker.Visible = true;
                }
                else
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(_tagMac))
                        {
                            TagStatusView tagStatus = LocatingServiceUtil.Instance <IServiceApi>().SelectTagStatus(_tagMac);
                            if (tagStatus != null)
                            {
                                batteryInsufficient.Text = Misc.GetEventStatusDescription(tagStatus.BatteryInsufficientStatus);
                                batteryReset.Text        = Misc.GetEventStatusDescription(tagStatus.BatteryResetStatus);
                                buttonPressed.Text       = Misc.GetEventStatusDescription(tagStatus.ButtonPressedStatus);
                                eventUpdateTime.Value    = tagStatus.EventUpdateTime;

                                clearBatteryInsufficient.Visible = tagStatus.BatteryInsufficientStatus != (byte)EventStatus.Cleared;
                                clearBatteryReset.Visible        = tagStatus.BatteryResetStatus != (byte)EventStatus.Cleared;
                                clearButtonPressed.Visible       = tagStatus.ButtonPressedStatus != (byte)EventStatus.Cleared;
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
コード例 #26
0
 public static bool DetectLocatingService()
 {
     return(LocatingServiceUtil.IsAvailable());
 }
コード例 #27
0
        public object GetAnchorCameraAndTagInfo(int tagID)
        {
            if (!LocatingServiceUtil.IsAvailable())
            {
                return(null);
            }

            IServiceApi   serviceApi    = LocatingServiceUtil.Instance <IServiceApi>();
            TagStatusView tagStatusView = serviceApi.SelectTagStatus(tagID);

            int    coordinatesID       = 0;
            string hostName            = "";
            string coordinates         = "";
            string tagStatus           = "";
            bool   SystemHasVedio      = BusSystemConfig.GetVedioType() == 2;
            bool   CoordinatesHasVedio = false;
            string url         = "";
            int    iChannel    = 0;
            string urlref      = "";
            int    iChannelref = 0;

            AnchorCamera[] coordinate = null;

            if (tagStatusView != null)
            {
                hostName      = string.Format("<a href=\"{0}\">{1}</a>", Web.WebPath.GetFullPath("TagUsers/TagUser.aspx?id=" + tagStatusView.HostTag.HostId), tagStatusView.HostTag.HostName);
                coordinates   = tagStatusView.CoordinatesName;
                coordinatesID = tagStatusView.CoordinatesId;
                //tagStatus.Text = LocatingMonitorUtils.GetAllTagEventsDescription(tagStatusView);
                tagStatus = LocatingMonitorUtils.GetAllTagEventsDescription(tagStatusView, tagStatusView.HostTag.HostGroupId.Min(), 10, "Master/WebItem.Master");

                if (tagStatus.Length == 0)
                {
                    tagStatus = "正常";
                }


                if (SystemHasVedio)
                {
                    using (AppDataContext db = new AppDataContext())
                    {
                        coordinate = db.AnchorCameras.Where(c => c.CoordinateID == coordinatesID).ToArray();
                        if (coordinate != null && coordinate.Length > 0)
                        {
                            CoordinatesHasVedio = true;
                            //coordinate = null;
                            //url = coordinate.CameraIP;
                            //iChannel = coordinate.iChannel;
                            //urlref = coordinate.CameraIPlref;
                            //iChannelref = coordinate.iChannelref;
                        }
                        else
                        {
                            CoordinatesHasVedio = false;
                            coordinate          = null;
                        }
                    }
                }
                return(new
                {
                    //------位置、状态-----
                    hostName,
                    coordinates,
                    tagStatus,
                    coordinatesID,
                    //------是否有视频-----
                    SystemHasVedio,
                    CoordinatesHasVedio,
                    //------摄像头信息-----
                    coordinate,
                    VedioType = NetRadio.Business.BusSystemConfig.GetVedioType()
                                //url,
                                //iChannel,
                                //urlref,
                                //iChannelref
                });
            }
            else
            {
                return(null);
            }
        }
コード例 #28
0
        private string CreateOutputContent()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<?xml version=\"1.0\" standalone=\"yes\" ?>");
            sb.AppendLine("<areaList>");

            if (_mapId > 0)
            {
                var list   = this.SelectItemList();
                var format = "	<area id=\"{0}\" name=\"{1}\" coordinatesArray=\"{2}\" quota=\"{3}\" currentCount=\"{4}\" mapId=\"{5}\" />";
                foreach (var a in list)
                {
                    try
                    {
                        if (a.LinkedMapId > 0)
                        {
                            IList <TagStatusView> tagList = new List <TagStatusView>();
                            string _keyword        = "";
                            int[]  _hostGroupArray = new int[2] {
                                1, 2
                            };                                          //2010-11-bydyp
                            int totalCount = 0;

                            IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                            if (serviceApi != null)
                            {
                                TagStatusView tagStatusView = new TagStatusView();
                                tagList = serviceApi.SelectTagStatusList(
                                    _keyword,
                                    _hostGroupArray,
                                    a.LinkedMapId,
                                    true,
                                    false, //SupportEvent.Absent),
                                    false, //SupportEvent.BatteryInsufficient),
                                    false, //SupportEvent.AreaEvent),
                                    false, //SupportEvent.ButtonPressed),
                                    false, //SupportEvent.WristletBroken),
                                    "",
                                    SortDirection.Ascending,
                                    0,//only get total count
                                    0,
                                    out totalCount);

                                sb.AppendFormat(format, a.Id, a.AreaName, a.CoordinatesArray, 0, totalCount, a.LinkedMapId);
                                sb.AppendLine();
                            }
                        }
                        else
                        {
                            int quota = 0;

                            try
                            {
                                quota = CulpritRoomReference.All.Count(x => x.JailRoomId == a.Id);
                            }
                            catch { }

                            int currentCount = 0;
                            var coordinates  = MapAreaCoverage.All.Where(x => x.AreaId == a.Id).Select(x => x.CoordinatesId).ToArray();

                            foreach (var item in FullTagStatusView)
                            {
                                if (coordinates.Contains(item.CoordinatesId) &&

                                    item.AbsenceStatus != EventStatus.Occurring &&
                                    item.X > 0)
                                {
                                    currentCount++;
                                }
                            }

                            sb.AppendFormat(format, a.Id, a.AreaName, a.CoordinatesArray, quota, currentCount, -1);
                            sb.AppendLine();
                        }
                    }
                    catch
                    {
                    }
                }
            }

            sb.AppendLine("</areaList>");
            return(sb.ToString());
        }
コード例 #29
0
        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;
                            }
                        }
                    }
                }
            }
        }
コード例 #30
0
        private void LoadRepeater(string p_keyword, string p_extandId, int p_jailRoomSelectedIndex, string p_jailRoomSelectedValue, string tagBindingSelectedValue, string tagOnlineSelectedValue)
        {
            // var query = HostTagGroupStatus.All().Where(u => u.HostGroupId == (byte)_userType);

            using (AppDataContext db = new AppDataContext())
            {
                var query = db.HostPositionStatusViews.ToList().Where(u => u.HostGroupId == (byte)_userType);

                if (!string.IsNullOrEmpty(p_keyword.Trim()))
                {
                    query = query.Where(u => u.HostName.ToUpper().Contains(p_keyword.Trim().ToUpper()));
                }

                if (!string.IsNullOrEmpty(p_extandId.Trim()))
                {
                    query = query.Where(u => u.HostExternalId.ToUpper().Contains(p_extandId.Trim().ToUpper()));
                }

                if (tagBindingSelectedValue == "1")
                {
                    query = query.Where(u => u.TagId != 0);
                }
                if (tagBindingSelectedValue == "2")
                {
                    query = query.Where(u => u.TagId == 0);
                }

                if (tagOnlineSelectedValue == "1")
                {
                    IList <TagStatusView> tagList = new List <TagStatusView>();
                    string _keyword        = "";
                    int[]  _hostGroupArray = null;
                    int    totalCount      = 0;
                    if (LocatingServiceUtil.IsAvailable())
                    {
                        IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                        if (serviceApi != null)
                        {
                            tagList = serviceApi.SelectTagStatusList(
                                _keyword,
                                _hostGroupArray,
                                0,
                                true,
                                false, //SupportEvent.Absent),
                                false, //SupportEvent.BatteryInsufficient),
                                false, //SupportEvent.AreaEvent),
                                false, //SupportEvent.ButtonPressed),
                                false, //SupportEvent.WristletBroken),
                                "",
                                SortDirection.Ascending,
                                9999,
                                0,
                                out totalCount);
                        }
                    }

                    query = query.Where(u => tagList.Where(t => t.X > 0).Select(t => t.TagId).ToList().Contains(u.TagId));
                }

                if (tagOnlineSelectedValue == "2")
                {
                    IList <TagStatusView> tagList = new List <TagStatusView>();
                    string _keyword        = "";
                    int[]  _hostGroupArray = null;
                    int    totalCount      = 0;
                    if (LocatingServiceUtil.IsAvailable())
                    {
                        IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                        if (serviceApi != null)
                        {
                            tagList = serviceApi.SelectTagStatusList(
                                _keyword,
                                _hostGroupArray,
                                0,
                                true,
                                false, //SupportEvent.Absent),
                                false, //SupportEvent.BatteryInsufficient),
                                false, //SupportEvent.AreaEvent),
                                false, //SupportEvent.ButtonPressed),
                                false, //SupportEvent.WristletBroken),
                                "",
                                SortDirection.Ascending,
                                9999,
                                0,
                                out totalCount);
                        }
                    }

                    query = query.Where(u => !tagList.Where(t => t.X > 0).Select(t => t.TagId).ToList().Contains(u.TagId));
                }

                if (_userType == TagUserType.Culprit && p_jailRoomSelectedIndex > 0)
                {
                    int[] range = CulpritRoomReference.GetCulpritIdByRoomId(int.Parse(p_jailRoomSelectedValue));
                    query = query.Where(u => range.Contains(u.HostId));
                }

                p.RecordCount = query.Count();

                //if (_sortDir == SortDirection.Ascending)
                //{
                //    query = query.OrderBy(u => u.HostName);
                //}
                //else
                //{
                //    query = query.OrderByDescending(u => u.HostName);
                //}
                list.DataSource = query.Skip(p.RecordOffset).Take(p.PageSize).ToList();
                list.DataBind();
            }
        }