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); }