public async Task CanCreateNewGroup()
        {
            var expectedGroup = new SurveyGroup
            {
                SurveyGroupId = 1,
                Name          = "Default",
                Description   = null,
                CreationDate  = new DateTime(1799, 11, 10)
            };

            _mockedHttpClient
            .Setup(client => client.PostAsJsonAsync(new Uri(ServiceAddress, "SurveyGroups"), It.IsAny <SurveyGroupValues>()))
            .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(expectedGroup))));

            var result = await _target.CreateAsync(new SurveyGroupValues
            {
                Name        = "Default",
                Description = null
            });

            Assert.NotNull(result);
            Assert.Equal("Default", result.Name);
            Assert.Equal(null, result.Description);
            Assert.Equal(new DateTime(1799, 11, 10), result.CreationDate);
            Assert.Equal(1, result.SurveyGroupId);
        }
예제 #2
0
        private void UpdateSurveyList(SurveyGroup SelectedSurveyGroup)
        {
            var index = SurveyGroupTest.IndexOf(SelectedSurveyGroup);

            SurveyGroupTest.Remove(SelectedSurveyGroup);
            SurveyGroupTest.Insert(index, SelectedSurveyGroup);
        }
        public async Task CanGetSpecificSurveyGroup()
        {
            var defaultSurveyGroup = new SurveyGroup
            {
                SurveyGroupId = 1,
                Name          = "Default",
                Description   = "Default Survey Group",
                CreationDate  = DateTime.UtcNow
            };

            var expectedSurveyGroup = new SurveyGroup
            {
                SurveyGroupId = 2,
                Name          = "SG",
                Description   = "Some description for a survey group",
                CreationDate  = DateTime.UtcNow
            };

            var surveyGroups = new[] { defaultSurveyGroup, expectedSurveyGroup };

            _mockedHttpClient
            .Setup(client => client.GetAsync(new Uri(ServiceAddress, $"SurveyGroups/{expectedSurveyGroup.SurveyGroupId}")))
            .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(expectedSurveyGroup))));

            var actualSurveyGroup = await _target.GetAsync(expectedSurveyGroup.SurveyGroupId);

            Assert.Equal(expectedSurveyGroup.SurveyGroupId, actualSurveyGroup.SurveyGroupId);
            Assert.Equal(expectedSurveyGroup.Name, actualSurveyGroup.Name);
            Assert.Equal(expectedSurveyGroup.Description, actualSurveyGroup.Description);
            Assert.Equal(expectedSurveyGroup.CreationDate, actualSurveyGroup.CreationDate);
        }
예제 #4
0
        public ActionResult DeleteConfirmed(long id)
        {
            SurveyGroup surveyGroup = db.TSurveyGroup.Find(id);

            db.TSurveyGroup.Remove(surveyGroup);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #5
0
 public ActionResult Edit([Bind(Include = "SurveyGroupId,SurveyGroupName")] SurveyGroup surveyGroup)
 {
     if (ModelState.IsValid)
     {
         db.Entry(surveyGroup).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(surveyGroup));
 }
        public async Task CanCreateModifyAndDeleteGroup()
        {
            var createdGroup = new SurveyGroup
            {
                SurveyGroupId = 2,
                Name          = "Default",
                Description   = null,
                CreationDate  = new DateTime(1799, 11, 10)
            };

            var updatedGroup = new SurveyGroup
            {
                SurveyGroupId = 2,
                Name          = "Default with a twist",
                Description   = "Modified description",
                CreationDate  = new DateTime(1799, 11, 10)
            };

            _mockedHttpClient
            .Setup(client => client.PostAsJsonAsync(new Uri(ServiceAddress, "SurveyGroups"), It.IsAny <SurveyGroupValues>()))
            .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(createdGroup))));
            _mockedHttpClient
            .Setup(client => client.PatchAsJsonAsync(new Uri(ServiceAddress, "SurveyGroups/2"), It.IsAny <SurveyGroupValues>()))
            .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(updatedGroup))));
            _mockedHttpClient
            .Setup(client => client.DeleteAsync(new Uri(ServiceAddress, "SurveyGroups/2")))
            .Returns(CreateTask(HttpStatusCode.OK));

            var result = await _target.CreateAsync(new SurveyGroupValues
            {
                Name        = "Default",
                Description = null
            });

            Assert.NotNull(result);
            Assert.Equal("Default", result.Name);
            Assert.Equal(null, result.Description);
            Assert.Equal(new DateTime(1799, 11, 10), result.CreationDate);
            Assert.Equal(2, result.SurveyGroupId);

            // modify survey group object we got back, then post it
            result.Name        = "Default with a twist";
            result.Description = "Modified description";

            result = await _target.UpdateAsync(result.SurveyGroupId, result);

            Assert.NotNull(result);
            Assert.Equal(updatedGroup.Name, result.Name);
            Assert.Equal(updatedGroup.Description, result.Description);
            Assert.Equal(updatedGroup.CreationDate, result.CreationDate);
            Assert.Equal(2, result.SurveyGroupId);

            await _target.DeleteAsync(result.SurveyGroupId);
        }
예제 #7
0
        public ActionResult Create([Bind(Include = "SurveyGroupId,SurveyGroupName")] SurveyGroup surveyGroup)
        {
            if (ModelState.IsValid)
            {
                db.TSurveyGroup.Add(surveyGroup);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(surveyGroup));
        }
예제 #8
0
        // GET: SurveyGroups/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SurveyGroup surveyGroup = db.TSurveyGroup.Find(id);

            if (surveyGroup == null)
            {
                return(HttpNotFound());
            }
            return(View(surveyGroup));
        }
예제 #9
0
        public async Task <ActionResult> CreateSurveyGroup([FromBody] SurveyGroup surveyGroup)
        {
            try
            {
                _db.SurveyGroups.Add(surveyGroup);
                await _db.SaveChangesAsync();

                return(Ok(surveyGroup));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
예제 #10
0
        public JsonResult SaveGroup(string groupName, List <Survey> surveys)
        {
            var surveyGroup = new SurveyGroup()
            {
                SurveyGroupName = groupName
            };

            db.TSurveyGroup.Add(surveyGroup);
            db.SaveChanges();

            foreach (var item in surveys)
            {
                db.TSurveyGroupMap.Add(new SurveyGroupMap()
                {
                    SurveyId      = item.SurveyId,
                    SurveyGroupId = surveyGroup.SurveyGroupId
                });
                db.SaveChanges();
            }

            return(Json("Saved", JsonRequestBehavior.AllowGet));
        }
        private static void SetStartLocating(int tagId)
        {
            //自定将标签启动定位
            XDocument xDoc = XDocument.Load(HttpContext.Current.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[] { tagId }, useSettingModel);
        }
예제 #12
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))
                            );
        }
예제 #13
0
        public async Task <ActionResult> Update([FromBody] SurveyGroup surveyGroup)
        {
            try
            {
                var username = string.Empty;

                if (HttpContext.User.Identity is ClaimsIdentity identity)
                {
                    username = identity.FindFirst(ClaimTypes.Name).Value;
                }

                var existingGroup = await _db.SurveyGroups.Include(group => group.ApplicationUsers).Where(group => group.Id == surveyGroup.Id).FirstOrDefaultAsync();

                existingGroup.GroupName = surveyGroup.GroupName;

                // update associated users
                var users = _db.Users.Where(user => surveyGroup.ApplicationUserIds.Contains(user.Id)).ToList();

                // remove users which have been removed from the group
                List <ApplicationUser> usersToRemove = new List <ApplicationUser>();

                foreach (var user in existingGroup.ApplicationUsers)
                {
                    if (!surveyGroup.ApplicationUserIds.Contains(user.Id))
                    {
                        usersToRemove.Add(user);
                    }
                }

                usersToRemove.ForEach(user => existingGroup.ApplicationUsers.Remove(user));

                foreach (var user in usersToRemove)
                {
                    if (!string.IsNullOrEmpty(user.RegistrationId))
                    {
                        var registrationDescription = await _hub.GetRegistrationAsync <RegistrationDescription>(user.RegistrationId);

                        if (registrationDescription.Tags.Contains($"group:{existingGroup.GroupName.Replace(' ', '-')}"))
                        {
                            registrationDescription.Tags.Remove($"group:{existingGroup.GroupName.Replace(' ', '-')}");
                            await _hub.CreateOrUpdateRegistrationAsync(registrationDescription);
                        }
                    }
                }

                // users to add
                foreach (var user in users)
                {
                    if (existingGroup.ApplicationUsers.Where(usr => usr.Id == user.Id).Count() == 0)
                    {
                        existingGroup.ApplicationUsers.Add(user);
                    }
                }

                foreach (var user in existingGroup.ApplicationUsers)
                {
                    if (!string.IsNullOrEmpty(user.RegistrationId))
                    {
                        var registrationDescription = await _hub.GetRegistrationAsync <RegistrationDescription>(user.RegistrationId);

                        if (!registrationDescription.Tags.Contains($"group:{existingGroup.GroupName.Replace(' ','-')}"))
                        {
                            registrationDescription.Tags.Add($"group:{existingGroup.GroupName.Replace(' ', '-')}");
                            await _hub.CreateOrUpdateRegistrationAsync(registrationDescription);
                        }
                    }
                }

                _db.Entry(existingGroup).State = EntityState.Modified;
                await _db.SaveChangesAsync();

                return(Ok(existingGroup));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
예제 #14
0
        protected void startLocating_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;
            }


            IList <string> selectedChannels = new List <string>();

            foreach (ListItem item in scanChannels.Items)
            {
                if (item.Selected)
                {
                    selectedChannels.Add(item.Value);
                }
            }

            //自定将标签启动定位,从配置文件中加载数据
            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
            };


            //TagLocateSetting useSettingModel = new TagLocateSetting {
            //    LocatingMode = byte.Parse(locatingMode.SelectedValue),
            //    RssiBackCount = int.Parse(rssiBackCount.SelectedValue),
            //    ScanInterval = int.Parse(scanInterval.SelectedValue),
            //    ScanMode = 2,
            //    ScanSsid = scanSsid.Text.Trim(),
            //    ScanChannels = string.Join(",", selectedChannels.ToArray()),
            //    ScanTarget = byte.Parse(scanTarget.SelectedValue),
            //    SurveyGroupId = int.Parse(surveyGroup.SelectedValue),
            //    UpdateTime = DateTime.Now,
            //    CommandState = (byte)LocatingCommandState.WaitToStart
            //};
            if (Config.Settings.ProjectType == ProjectTypeEnum.WXFactory)
            {
                useSettingModel.ScanMode = 1;


                TagSetting useSetting = new TagSetting
                {
                    ScanMarkEnable           = true,
                    ScanMarkDetectInterval   = Convert.ToInt32(this.detectInterval.Text.Trim()),
                    ScanMarkScanTime         = Convert.ToInt32(this.scanTime.Text.Trim()),
                    ScanMarkScanInterval     = Convert.ToInt32(this.wscanInterval.Text.Trim()),
                    ScanMarkScanCount        = Convert.ToInt32(this.scanCount.Text.Trim()),
                    ScanMarkGoodSignal       = Convert.ToInt32(this.goodSignal.Text.Trim()),
                    ScanMarkLocatingInterval = Convert.ToInt32(this.locatingInterval.Text.Trim())
                };
                foreach (var id in tagIdArray)
                {
                    if (id > 0)
                    {
                        using (AppDataContext db = new AppDataContext())
                        {
                            var dbTagSet = db.TagSettings.SingleOrDefault(t => t.TagId == id);
                            if (dbTagSet != null)
                            {
                                dbTagSet.ScanMarkEnable           = true;
                                dbTagSet.ScanMarkDetectInterval   = useSetting.ScanMarkDetectInterval;
                                dbTagSet.ScanMarkScanTime         = useSetting.ScanMarkScanTime;
                                dbTagSet.ScanMarkScanInterval     = useSetting.ScanMarkScanInterval;
                                dbTagSet.ScanMarkScanCount        = useSetting.ScanMarkScanCount;
                                dbTagSet.ScanMarkGoodSignal       = useSetting.ScanMarkGoodSignal;
                                dbTagSet.ScanMarkLocatingInterval = useSetting.ScanMarkLocatingInterval;
                                db.SubmitChanges();
                            }
                            //else if (dbTagSet.ScanMarkDetectInterval != 0 && dbTagSet.ScanMarkGoodSignal != 0)
                            //{
                            //    this.detectInterval.Text = dbTagSet.ScanMarkDetectInterval.ToString();
                            //    this.scanTime.Text = dbTagSet.ScanMarkScanTime.ToString();
                            //    this.wscanInterval.Text = dbTagSet.ScanMarkScanInterval.ToString();
                            //    this.scanCount.Text = dbTagSet.ScanMarkScanCount.ToString();
                            //    this.goodSignal.Text = dbTagSet.ScanMarkGoodSignal.ToString();
                            //    this.locatingInterval.Text = dbTagSet.ScanMarkLocatingInterval.ToString();

                            //}
                        }
                    }
                }
            }
            TagLocateSetting.StartLocating(tagIdArray, useSettingModel);

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

            // Reload List
            LoadRepeater();
        }