Example #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();
        }
        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);
        }
Example #3
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运行。";
                }
            }
        }