コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Tag tag = Tag.Select(_tagId);

            if (tag == null)
            {
                ShowMessagePage("标签不存在。");
            }

            try
            {
                //using (AppDataContext db = new AppDataContext())
                //{
                //    var hostTagView = db.HostTagGroupStatus.Where(h => h.ParentGroupId == 0).Single(h => h.TagId == _tagId);
                HostTagGroupStatus hostTagView = HostTagGroupStatus.SelectByTagId(_tagId);
                if (hostTagView != null)
                {
                    Response.Redirect("../TagUsers/TagUser.aspx?type=" + hostTagView.HostGroupId + "&id=" + hostTagView.HostId, true);
                }
                //}
            }
            catch (Exception err)
            {
                Diary.Debug("Tag.aspx: " + err.ToString());
            }

            tagName.Text     = tag.TagName;
            macAddress.Text  = tag.TagMac;
            productType.Text = ((TagProductType)tag.ProductType).ToString();
        }
コード例 #2
0
        public static object[] SelectTags(string keyword, string groupIdSerial, int pageSize, int skipOffset)
        {
            using (AppDataContext db = new AppDataContext()) {
                //20091231: need to set filter
                if (Config.Settings.ModelHFilter != "")
                {
                    TagStatusView.aLicenseTagHFilter = Config.Settings.ModelHFilter.Split(';');
                }
                List <int> lHostTagIds = db.HostTags.Select(h => h.TagId).ToList();
                var        query       = Tag.AllValidTags
                                         //.Where(t => Config.Settings.ModelHFilter.Split(';').Contains(t.TagMac.Substring(0,5)))
                                         .Where(t => !lHostTagIds.Contains(t.Id))
                                         .Select(t => new {
                    Id      = t.Id,
                    TagName = t.TagMac.Substring(9, 8)
                });

                if (!string.IsNullOrEmpty(keyword))
                {
                    query = query.Where(t => t.TagName.Contains(keyword.Trim()));
                }
                if (!string.IsNullOrEmpty(groupIdSerial))
                {
                    var range1 = TagGroupCoverage.GetCoveredTagIdArray(Strings.ParseToArray <int>(groupIdSerial));
                    var range2 = HostTagGroupStatus.GetCoveredTagIdArray(Strings.ParseToArray <int>(groupIdSerial));
                    var range  = MergeTwoArrayWithoutDuplicates(range1, range2);
                    query = query.Where(t => range.Contains(t.Id));
                }

                query = query.OrderBy(t => t.TagName).Skip(skipOffset).Take(pageSize);

                return(query.ToArray());
            }
        }
コード例 #3
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);
        }
コード例 #4
0
        protected void list_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            //AreaEventLogView log = e.Item.DataItem as AreaEventLogView;
            //---add by tan  2009-10-6---//
            DataRowView log = (DataRowView)e.Item.DataItem;

            if (log != null)
            {
                Anchor        tagName       = e.Item.FindControl("tagName") as Anchor;
                SmartLabel    facilityName  = e.Item.FindControl("facilityName") as SmartLabel;
                SmartLabel    areaName      = e.Item.FindControl("areaName") as SmartLabel;
                SmartLabel    areaEventType = e.Item.FindControl("areaEventType") as SmartLabel;
                DateTimeLabel writeTime     = e.Item.FindControl("writeTime") as DateTimeLabel;

                tagName.Text = LocatingMonitorUtils.GetHostName(log["TagName"].ToString(), log["TagMac"].ToString(), log["HostName"].ToString());
                HostTagGroupStatus hostTagGroupStatus = HostTagGroupStatus.SelectByHostId((int)log["HostId"]);
                if (hostTagGroupStatus != null)
                {
                    int groupId = hostTagGroupStatus.HostGroupId;

                    tagName.Href = PathUtil.ResolveUrl(string.Format("/TagUsers/TagUser.aspx?id={0}&type={1}", log["HostId"], groupId));
                }
                else
                {
                }

                facilityName.Text = Convert.ToString(log["FacilityName"]);
                areaName.Text     = Convert.ToString(log["AreaName"]);
                if (Convert.ToInt32(log["AreaEventType"]) == 0)
                {
                    areaEventType.Text = "进入区域";
                }
                else
                {
                    areaEventType.Text = "离开区域";
                }


                writeTime.DisplayValue = Convert.ToDateTime(log["WriteTime"]);
            }

            //----------------------------------//

            /*
             * Anchor tagName = e.Item.FindControl("tagName") as Anchor;
             * SmartLabel facilityName = e.Item.FindControl("facilityName") as SmartLabel;
             * SmartLabel areaName = e.Item.FindControl("areaName") as SmartLabel;
             * SmartLabel areaEventType = e.Item.FindControl("areaEventType") as SmartLabel;
             * DateTimeLabel writeTime = e.Item.FindControl("writeTime") as DateTimeLabel;
             *
             * tagName.Text = log.TagName;
             * tagName.Href = PathUtil.ResolveUrl("Objects/Tag.aspx?id=" + log.TagId);
             * facilityName.Text = log.FacilityName;
             * areaName.Text = log.AreaName;
             * areaEventType.Text = (AreaEventType)log.AreaEventType == AreaEventType.StayInside ? "进入区域" : "离开区域";
             * writeTime.DisplayValue = log.WriteTime;
             */
        }
コード例 #5
0
        protected void messageRepeater_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            DBViewTagAlert ev = e.Item.DataItem as DBViewTagAlert;

            if (ev != null)
            {
                SmartLabel isResolved = (SmartLabel)e.Item.FindControl("isResolved");
                if (ev.AlertStatus != (byte)AlertStatusType.New)
                {
                    isResolved.Text = "√";
                }
                else
                {
                    isResolved.Text = "<input type='checkbox' name='selection' value='" + ev.AlertId + "' />";
                }
                Img icon = e.Item.FindControl("icon") as Img;
                HostTagGroupStatus hostTagGroupStatus = HostTagGroupStatus.SelectByHostId((int)ev.HostId);
                int groupId = hostTagGroupStatus.HostGroupId;
                icon.Src = CommonExtension.IdentityIconByGroupId(groupId);

                Anchor tagName = (Anchor)e.Item.FindControl("tagName");
                tagName.Text = ev.HostName;
                tagName.Href = PathUtil.ResolveUrl(string.Format("/TagUsers/TagUser.aspx?id={0}&type={1}", ev.HostId, groupId));

                SmartLabel facilityName = (SmartLabel)e.Item.FindControl("facilityName");
                facilityName.Text = ev.FacilityName;

                SmartLabel coordinatesName = (SmartLabel)e.Item.FindControl("coordinatesName");
                coordinatesName.Text = ev.CoordinatesName;

                SmartLabel eventType = (SmartLabel)e.Item.FindControl("eventType");
                eventType.Text = CommonExtension.GetEventDescription((SupportEvent)ev.AlertType, ev.HostId.Value);

                SmartLabel alertStatus = (SmartLabel)e.Item.FindControl("alertStatus");
                alertStatus.Text = Misc.GetAlertStatus((AlertStatusType)ev.AlertStatus);

                DateTimeLabel lastHappenTime = (DateTimeLabel)e.Item.FindControl("lastHappenTime");
                lastHappenTime.DisplayValue = ev.WriteTime;

                Anchor alertDetail = (Anchor)e.Item.FindControl("alertDetail");
                alertDetail.Text = "详情";
                alertDetail.Href = PathUtil.ResolveUrl("/Monitor/TagAlertProcess.aspx?id=" + ev.AlertId);

                if (ev.AlertStatus == (byte)ResolveFlag.Processed)
                {
                    HtmlTableRow tr = (HtmlTableRow)e.Item.FindControl("tr");
                    tr.Attributes["class"] = "t3";
                    tagName.CssClass       = "t3";
                }
            }
        }
コード例 #6
0
 private static void UpdateHostTag(HostTagGroupStatus userHost)
 {
     if (userHost != null)
     {
         HostTag hostTag = new HostTag();
         hostTag.HostId         = userHost.HostId;
         hostTag.TagId          = userHost.TagId;
         hostTag.HostExternalId = userHost.HostExternalId;
         hostTag.HostName       = userHost.HostName;
         hostTag.Description    = userHost.Description;
         hostTag.HostType       = userHost.HostType;
         hostTag.ImagePath      = userHost.ImagePath;
         HostTag.UpdateHostTag(hostTag);
     }
 }
コード例 #7
0
        protected void list_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            DataRowView log = (DataRowView)e.Item.DataItem;

            if (log != null)
            {
                Anchor tagName = e.Item.FindControl("tagName") as Anchor;
                //tagName.Text = LocatingMonitorUtils.GetHostName(log["TagName"].ToString(), log["TagMac"].ToString(), log["HostName"].ToString());
                tagName.Text = Convert.ToString(log["HostName"]);
                HostTagGroupStatus hostTagGroupStatus = HostTagGroupStatus.SelectByHostId((int)log["HostId"]);
                if (hostTagGroupStatus != null)
                {
                    int groupId = hostTagGroupStatus.HostGroupId;

                    tagName.Href = PathUtil.ResolveUrl(string.Format("/TagUsers/TagUser.aspx?id={0}&type={1}", log["HostId"], groupId));
                }
                else
                {
                }

                DateTimeLabel writeTime = e.Item.FindControl("writeTime") as DateTimeLabel;
                writeTime.DisplayValue = Convert.ToDateTime(log["WriteTime"]);
                SmartLabel facilityName    = e.Item.FindControl("facilityName") as SmartLabel;
                SmartLabel coordinatesName = e.Item.FindControl("coordinatesName") as SmartLabel;
                facilityName.Text    = Convert.ToString(log["FacilityName"]);
                coordinatesName.Text = Convert.ToString(log["CoordinatesName"]);
            }

            ///////////////////////////////////////////////////////////////////////

            /*
             *          GenericEventLogView log = e.Item.DataItem as GenericEventLogView;
             *          if (log != null) {
             *                  Anchor tagName = e.Item.FindControl("tagName") as Anchor;
             *  tagName.Text = LocatingMonitorUtils.GetHostName(log.TagName, log.HostName);
             *                  tagName.Href = PathUtil.ResolveUrl("Objects/Tag.aspx?id=" + log.TagId);
             *
             *                  DateTimeLabel writeTime = e.Item.FindControl("writeTime") as DateTimeLabel;
             *                  writeTime.DisplayValue = log.WriteTime;
             *
             *                  SmartLabel facilityName = e.Item.FindControl("facilityName") as SmartLabel;
             *                  facilityName.Text = log.FacilityName;
             *
             *                  SmartLabel coordinatesName = e.Item.FindControl("coordinatesName") as SmartLabel;
             *                  coordinatesName.Text = log.CoordinatesName;
             *          }
             */
        }
コード例 #8
0
        private void LoadRepeater()
        {
            using (AppDataContext db = new AppDataContext())
            {
                var query = db.DBViewTagSettings
                            .Where(x => HostTag.All
                                   .Where(u => u.TagId != 0)
                                   .Select(u => u.TagId).ToArray()
                                   .Contains((int)x.Id));//x.TagId));
                switch (stateFilter.SelectedIndex)
                {
                default:
                case 0:
                    break;

                case 1:
                    query = query.Where(x => x.WorkingStatus == (byte)TagWorkingStatus.Locating);
                    break;

                case 2:
                    query = query.Where(x => x.WorkingStatus != (byte)TagWorkingStatus.Locating);
                    break;

                case 3:
                    query = query.Where(x => x.CommandState == null);
                    break;
                }

                string keyword = tagNameKeyword.Text == "关键字" ? string.Empty : tagNameKeyword.Text.Trim();
                if (keyword.Length != 0)
                {
                    query = query.Where(x => x.HostName.Contains(keyword));
                }

                if (groupSelector.SelectedGroupIdArray != null && groupSelector.SelectedGroupIdArray.Length > 0)
                {
                    var range = HostTagGroupStatus.GetCoveredTagIdArray(groupSelector.SelectedGroupIdArray);
                    query = query.Where(x => range.Contains((int)x.Id));//x.TagId));
                }

                p.RecordCount          = query.Count();
                settingList.DataSource = query.OrderByDescending(x => x.HostName).Skip(p.RecordOffset).Take(p.PageSize).ToList();
                settingList.DataBind();
                //settingList.DataSource = query.Skip(p.RecordOffset).Take(p.PageSize).OrderBy(x => x.TagName).ToList();
            }
        }
コード例 #9
0
        protected void list_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            HostTagGroupStatus user = e.Item.DataItem as HostTagGroupStatus;

            if (user != null)
            {
                Anchor name = (Anchor)e.Item.FindControl("name");
                name.Text    = user.HostName;
                name.ToolTip = user.HostName;

                name.Href = "TagUser.aspx?type=" + user.HostGroupId + "&id=" + user.HostId;

                if (user.TagId != 0)
                {
                    Tag        tag  = Tag.Select(user.TagId);
                    SmartLabel smac = (SmartLabel)e.Item.FindControl("mac");
                    smac.Text = tag.TagMac.Substring(9);
                }
            }
        }
コード例 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = Fetch.QueryUrlAsInteger("id");

            int n = Fetch.QueryUrlAsIntegerOrDefault("type", -1);

            if (n <= 0)
            {
                try
                {
                    HostTagGroupStatus host = HostTagGroupStatus.SelectByHostId(id);
                    if (host != null)
                    {
                        n = host.HostGroupId;
                    }
                }
                catch (Exception err)
                {
                    Diary.Debug("TagUser.aspx: " + err.ToString());
                }
            }

            switch (n)
            {
            case 1:
                Response.Redirect("Police.aspx?id=" + id);
                break;

            case 2:
                Response.Redirect("Culprit.aspx?id=" + id);
                break;

            case 3:
                Response.Redirect("Position.aspx?id=" + id);
                break;

            default:
                ShowMessagePage("访问无效。");
                break;
            }
        }
コード例 #11
0
        private void LoadRepeater()
        {
            //CommonExtension.ClearPoliceInvalidAlert();
            using (AppDataContext db = new AppDataContext())
            {
                if (Session["TagLogFilter"] != null)
                {
                    tagLogFilter = (NetRadio.LocatingMonitor.Controls.__TagLogFilter)Session["TagLogFilter"];
                    string tagFilterCondition = tagLogFilter.ConditionDescription;
                }

                /*
                 * IList<DBViewTagAlert> lAlerts = db.DBViewTagAlerts.Where(t => t.HostId > 0)
                 *      //.Where(t => t.AlertStatus == (int)AlertStatusType.Closed || t.AlertStatus==(int)AlertStatusType.Resolved)
                 *      .Where(t => t.AlertStatus != (int)AlertStatusType.New)
                 *      .OrderByDescending(t => t.WriteTime)
                 *      //.OrderBy(t => t.AlertStatus)
                 *      //.ThenByDescending(t => t.WriteTime)
                 *      .ToList();
                 * if (tagLogFilter.TagNameKeyword != null && tagLogFilter.TagNameKeyword.Trim().Length > 0)
                 * {
                 *  lAlerts = lAlerts.Where(t => t.HostName.Contains(tagLogFilter.TagNameKeyword.Trim())).ToList();
                 * }
                 *
                 * if (tagLogFilter.FromTime.ToString().Trim() != "")
                 * {
                 *  lAlerts = lAlerts.Where(t => t.WriteTime >= tagLogFilter.FromTime).ToList();
                 * }
                 *
                 * if (tagLogFilter.ToTime.ToString().Trim() != "")
                 * {
                 *  lAlerts = lAlerts.Where(t => t.WriteTime <= tagLogFilter.ToTime).ToList();
                 * }
                 * int[] groupIds = new int[1] { (int)_userType };
                 * var range = HostTagGroupStatus.GetCoveredHostIdArray(groupIds);
                 * var query = lAlerts.Where(x => range.Contains((int)x.HostId)).ToList();
                 *
                 * p.RecordCount = query.Count();
                 * messageRepeater.DataSource = query.Skip(p.RecordOffset).Take(p.PageSize).ToList();
                 * messageRepeater.DataBind();*/

                IList <DBViewTagAlert> lAlerts = db.DBViewTagAlerts.Where(t => (t.AlertStatus == (int)AlertStatusType.Ignored || t.AlertStatus == (int)AlertStatusType.Resolved || t.AlertStatus == (int)AlertStatusType.Closed))
                                                 .Where(t => t.HostId > 0).ToList();
                if (tagLogFilter.TagNameKeyword != null && tagLogFilter.TagNameKeyword.Trim().Length > 0)
                {
                    lAlerts = lAlerts.Where(t => t.HostName.Contains(tagLogFilter.TagNameKeyword.Trim())).ToList();
                }

                if (tagLogFilter.FromTime.ToString().Trim() != "")
                {
                    lAlerts = lAlerts.Where(t => t.WriteTime >= tagLogFilter.FromTime).ToList();
                }

                if (tagLogFilter.ToTime.ToString().Trim() != "")
                {
                    lAlerts = lAlerts.Where(t => t.WriteTime <= tagLogFilter.ToTime).ToList();
                }
                int[] groupIds = new int[1] {
                    (int)_userType
                };
                var range = HostTagGroupStatus.GetCoveredHostIdArray(groupIds);
                var query = lAlerts.Where(x => range.Contains((int)x.HostId)).ToList();

                if (_zSortKey == "HostName")
                {
                    if (_sortDir == SortDirection.Ascending)
                    {
                        query = query.OrderBy(t => t.HostName).ThenByDescending(t => t.WriteTime).ToList();
                    }
                    else
                    {
                        query = query.OrderByDescending(t => t.HostName).ThenByDescending(t => t.WriteTime).ToList();
                    }
                }
                else if (_zSortKey == "WriteTime")
                {
                    if (_sortDir == SortDirection.Ascending)
                    {
                        query = query.OrderBy(t => t.WriteTime).ToList();
                    }
                    else
                    {
                        query = query.OrderByDescending(t => t.WriteTime).ToList();
                    }
                }
                else
                {
                    query = query.OrderByDescending(t => t.WriteTime).ToList();
                }

                if (query != null)
                {
                    p.RecordCount = query.Count();

                    messageRepeater.DataSource = query.Skip(p.RecordOffset).Take(p.PageSize).ToList();
                    messageRepeater.DataBind();
                }
            }
        }
コード例 #12
0
        private void LoadDefaultView()
        {
            //tagSelector.SelectedGroupId = -1;

            string zSortDir = "desc";

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

            if (tagSelector.SelectedUserIds != null && tagSelector.SelectedUserIds.Length > 0)
            {
                string     hostIds   = "(";
                List <int> lGroupIds = new List <int>();
                for (int i = 0; i < tagSelector.SelectedUserIds.Length; i++)
                {
                    hostIds += tagSelector.SelectedUserIds[i].ToString();
                    HostTagGroupStatus hostGroup = HostTagGroupStatus.SelectByHostId(tagSelector.SelectedUserIds[i]);
                    if (hostGroup != null && !lGroupIds.Contains(hostGroup.HostGroupId))
                    {
                        lGroupIds.Add(hostGroup.HostGroupId);
                    }
                    if (i != (tagSelector.SelectedUserIds.Length - 1))
                    {
                        hostIds += ", ";
                    }
                }
                hostIds += ")";
                strWhere = "A.HostId in " + hostIds;

                if (lGroupIds.Count > 0)
                {
                    string zGroupIds = "(";
                    int    j         = 0;
                    foreach (int groupId in lGroupIds)
                    {
                        if (j == 0)
                        {
                            zGroupIds += groupId.ToString();
                        }
                        else
                        {
                            zGroupIds += ", " + groupId.ToString();
                        }
                        j++;
                    }
                    zGroupIds += ")";
                    strWhere  += " AND HostGroupId in " + zGroupIds;
                }
                DateTime dtFrom = DateTime.Parse(fromDate.Text);
                dtFrom    = new DateTime(dtFrom.Year, dtFrom.Month, dtFrom.Day, fromHour.SelectedIndex, fromMinute.SelectedIndex, 0);
                strWhere += " AND WriteTime >= '" + dtFrom.ToString("M/d/yyyy H:m:s") + "'";

                DateTime dtTo = DateTime.Parse(toDate.Text);
                dtTo      = new DateTime(dtTo.Year, dtTo.Month, dtTo.Day, toHour.SelectedIndex, toMinute.SelectedIndex, 59);
                strWhere += " AND WriteTime <= '" + dtTo.ToString("M/d/yyyy H:m:s") + "'";

                int     totalCount = 0;
                DataSet ds         = DBPositionLog.GetPositionLog(strWhere, _zSortKey, zSortDir, p.PageSize, p.PageIndex, out totalCount);
                p.RecordCount = totalCount;
                if (ds.Tables.Count != 0)
                {
                    list.DataSource = ds.Tables[0].DefaultView;
                    list.DataBind();
                }
            }
        }
コード例 #13
0
        public static string ChangeTag(int oldTagId, int newTagId)
        {
            string newMac = "FAIL";

            if (oldTagId == newTagId)
            {
                return("");
            }
            HostTagGroupStatus hostTag = HostTagGroupStatus.SelectByTagId(oldTagId);

            if (LocatingServiceUtil.IsAvailable())
            {
                //TagUser user = TagUser.SelectByTagId(oldTagId);
                IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                newMac = serviceApi.ExchangeTagMac(hostTag.HostId, oldTagId, newTagId);
                //无锡换地标
                if (Config.Settings.ProjectType == ProjectTypeEnum.WXFactory)
                {
                    Tag oldTag = Tag.Select(oldTagId);
                    Tag newTag = Tag.Select(newTagId);

                    //更新缓存

                    IDictionary <string, APStatusView> dicAPStatus = APStatusView.SelectFullAPStatusView();
                    IServiceApi serApi = LocatingServiceUtil.Instance <IServiceApi>();
                    serApi.ExchangePositionTag(oldTag.TagMac, newTag.TagMac);
                    //更新数据库
                    AP.ChangeMac(oldTag.TagMac, newTag.TagMac);
                }


                //自定将标签启动和停止定位
                TagLocateSetting.StopLocating(new int[] { oldTagId });
                if (Config.Settings.ProjectType != ProjectTypeEnum.WXFactory)
                {
                    if (newTagId > 0)
                    {
                        SetStartLocating(newTagId);
                    }
                    else
                    {
                        newMac = "未携带标签";
                    }
                    // Send a command to LocatingService.
                    LocatingServiceUtil.Instance <IServiceApi>().StartStopLocating();
                }
                //记录日志
                string calling = GetGroupName(hostTag.HostGroupId);
                if (newTagId > 0)
                {
                    Diary.Insert(ContextUser.Current.Id, newTagId, hostTag.HostId, "为" + calling + hostTag.HostName + "调换标签,新标签MAC: " + newMac + "。");
                }
                else
                {
                    Diary.Insert(ContextUser.Current.Id, newTagId, hostTag.HostId, "为" + calling + hostTag.HostName + "解除绑定标签,原标签MAC: " + hostTag.TagMac + "。");
                }
                //SecurityLog.Insert(newTagId, hostTag.HostId, "为" + calling + hostTag.HostName + "调换标签,新标签MAC: " + newMac + "。", Priority.High);
            }

            /*else
             * {
             *  HostTag.ChangeHostTagBinding(hostTag.HostId, newTagId);
             *  Tag oTag = Tag.Select(newTagId);
             *  newMac = oTag.TagMac;
             *  //自定将标签启动和停止定位
             *  TagLocateSetting.StopLocating(new int[] { oldTagId });
             *  SetStartLocating(newTagId);
             *
             *  //记录日志
             *  string calling = GetGroupName(hostTag.HostGroupId);
             *  SecurityLog.Insert(hostTag.TagId, hostTag.HostId, "为" + calling + hostTag.HostName + "调换标签,新标签MAC: " + newMac + "。", Priority.High);
             * }*/

            //AlertProcessLog.DeleteAlertProcessLog(hostTag.HostId);
            //TagAlert.DeleteTagAlerts(hostTag.HostId);

            return(newMac);
        }
コード例 #14
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 (BusSystemConfig.IsAutoSelectStrongestRssiTag() == false)
            {
                tagSelector.Visible            = true;
                selectStrongestRssiTag.Visible = false;
                changeTag.Href = "javascript:tt();";
            }
            else
            {
                tagSelector.Visible            = false;
                selectStrongestRssiTag.Visible = true;
                changeTag.Href = "javascript:tt2();";
            }

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

                int    _tagId;
                string _tagMac = null;

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

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

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

                    name.Text   = newName.Text = cop.HostName;
                    number.Text = newNumber.Text = cop.HostExternalId;
                    string[] aGroupIds = HostTagGroupStatus.GetBelongsGroupNameArrayByHostId(_id);
                    if (aGroupIds != null && aGroupIds.Length > 0)
                    {
                        LabelGroup.Text = String.Join(", ", aGroupIds);
                    }
                    memo.Text = newMemo.Text = Strings.TextEncode(cop.Description);

                    groups.Text = string.Join(",", HostTagGroupStatus.GetBelongsGroupNameArrayByHostId(_id));

                    tagBound.Text = cop.TagId == 0 ? "未携带标签" : "已领用标签";
                    photo.Src     = "UserPhoto.ashx?id=" + _id;

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

                if (Config.Settings.ProjectType == ProjectTypeEnum.YZPrison)
                {
                    absencediv.Visible = false;
                }
                else
                {
                    absencediv.Visible = true;
                }

                locatingServiceDownMarker.Visible = !LocatingServiceUtil.IsAvailable();

                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)
                            {
                                coordinatesName.Text     = Coordinates.GetName(tagStatus.CoordinatesId);
                                positionUpdateTime.Value = tagStatus.PositionUpdateTime;

                                absence.Text             = Misc.GetEventStatusDescription(tagStatus.AbsenceStatus);
                                areaEvent.Text           = Misc.GetEventStatusDescription(tagStatus.AreaEventStatus);
                                batteryInsufficient.Text = Misc.GetEventStatusDescription(tagStatus.BatteryInsufficientStatus);
                                batteryReset.Text        = Misc.GetEventStatusDescription(tagStatus.BatteryResetStatus);
                                buttonPressed.Text       = Misc.GetEventStatusDescription(tagStatus.ButtonPressedStatus);
                                //wristletBroken.Text = Misc.GetEventStatusDescription(tagStatus.WristletBrokenStatus);
                                eventUpdateTime.Value = tagStatus.EventUpdateTime;

                                clearAbsence.Visible             = tagStatus.AbsenceStatus != (byte)EventStatus.Cleared;
                                clearAreaEvent.Visible           = tagStatus.AreaEventStatus != (byte)EventStatus.Cleared;
                                clearBatteryInsufficient.Visible = tagStatus.BatteryInsufficientStatus != (byte)EventStatus.Cleared;
                                clearBatteryReset.Visible        = tagStatus.BatteryResetStatus != (byte)EventStatus.Cleared;
                                clearButtonPressed.Visible       = tagStatus.ButtonPressedStatus != (byte)EventStatus.Cleared;
                                //clearWristletBroken.Visible = tagStatus.WristletBrokenStatus != (byte)EventStatus.Cleared;
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
コード例 #15
0
        protected void settingList_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            DBViewTagSetting setting = e.Item.DataItem as DBViewTagSetting;

            if (setting != null)
            {
                Img icon = e.Item.FindControl("icon") as Img;
                icon.Src = CommonExtension.IdentityIcon((int)setting.Id);//TagId);


                Anchor     tagName  = (Anchor)e.Item.FindControl("tagName");
                SmartLabel userType = (SmartLabel)e.Item.FindControl("userType");
                SmartLabel userMemo = (SmartLabel)e.Item.FindControl("memo");
                tagName.Text = setting.HostName;

                HostTagGroupStatus tagUser = HostTagGroupStatus.SelectByTagId((int)setting.Id);//.TagId);
                int groupId = 0;
                if (tagUser != null)
                {
                    groupId       = tagUser.HostGroupId;
                    userType.Text = BusTagUserType.GetTagUserTypeName(tagUser.HostGroupId);
                    userMemo.Text = tagUser.Description;
                }
                tagName.Href = PathUtil.ResolveUrl(string.Format("/TagUsers/TagUser.aspx?id={0}&type={1}",
                                                                 setting.HostId, groupId));

                SmartLabel idSelection  = (SmartLabel)e.Item.FindControl("idSelection");
                string     disableOrNot = this.IsLocatingServiceAvailable ? "" : " disabled=\"disabled\"";
                idSelection.Text = "<input type=\"checkbox\" name=\"selection\"" + disableOrNot + " onclick=\"javascript:Locating.selectTag(this);\" value=\"" + setting.Id + "\" />";//setting.TagId + "\" />";


                if (setting.CommandState == null)
                {
                    return;     // <-----------------If never been configured ----------------------------------------------
                }

                SmartLabel    commandState = (SmartLabel)e.Item.FindControl("commandState");
                DateTimeLabel startTime    = (DateTimeLabel)e.Item.FindControl("startTime");
                Anchor        operate      = (Anchor)e.Item.FindControl("operate");

                switch ((LocatingCommandState)setting.CommandState)
                {
                case LocatingCommandState.WaitToStart:
                    operate.Text      = "N/A";
                    operate.CssClass  = "t3";
                    commandState.Text = "请求开始中";
                    commandState.Style.Add("color", "Green");
                    break;

                case LocatingCommandState.WaitToStop:
                    operate.Text      = "N/A";
                    operate.CssClass  = "t3";
                    commandState.Text = "请求停止中";
                    commandState.Style.Add("color", "Red");
                    break;

                default:
                case LocatingCommandState.Executed:
                    if (setting.WorkingStatus == (byte)TagWorkingStatus.Locating)
                    {
                        operate.Text           = "停止";
                        operate.Href           = "javascript:Locating.quickStop(" + setting.Id + ");"; //setting.TagId + ");";
                        startTime.DisplayValue = (DateTime)setting.UpdateTime;
                    }
                    else
                    {
                        operate.Text    = "快速启动";
                        operate.ToolTip = "按照已设定参数快速启动";
                        operate.Href    = "javascript:Locating.quickStart(" + setting.Id + ");"; //setting.TagId + ");";
                    }
                    operate.Attributes["id"] = "op_" + setting.Id;                               //setting.TagId;
                    break;
                }

                if (!this.IsLocatingServiceAvailable)
                {
                    operate.Text     = "N/A";
                    operate.Href     = null;
                    operate.CssClass = "t3";
                    operate.ToolTip  = "系统未检测到LocatingServer运行。";
                }
            }
        }
コード例 #16
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 = "" });
            }
        }