__NSCFNumber isEqualToString:的问题.--[__NSCFNumber isEqualToString:]: unrecognized selector sent to in

本文介绍了一个在iOS开发中使用AFNetworking进行网络请求时遇到的问题:比较服务器返回的状态码出现错误。通过正确转换和比较状态码,解决了匹配结果与预期不符的问题。

-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x7c2680b0

解析服务器返回的状态码,如果直接跟字符串对比的话,会出现这个错误。网上说将isEqualToString改成isEqual,果然不报错了,但是匹配返回的布尔值跟预期的不一样。

果断将得到数据,再次用nsstring包装下,然后还是用isEqualToString来进行匹配,答案是正确的。


[AFNetworkingTool postWithUrl:urlString

                           params:params

                          success:^(id response) {

                              NSLog(@"会议签到数据 responseObject = %@",response);

                              NSString *code = [response objectForKey:@"status"];

                              NSString *codeStr = [NSString stringWithFormat:@"%@",code];

                              BOOL ok = [codeStr isEqualToString:@"200"];

                              if (ok) {

  NSMutableArray *array = [response objectForKey:@"datas"];

                                  complation(array);

                              }else{

                                  NSMutableArray *array = [[NSMutableArray alloc]init];

                                  [array addObject:@"error"];

                                  complation(array);

                              }

                              

                              

                              

                          } fail:^(NSError *error) {

                              

                              NSLog(@"会议签到 error = %@",error);

                              

                          }];


分析代码,帮我寻找退出逻辑 // // SDNChangeSiteCustomerViewController.m // Omada // // Created by ZJT on 2025/4/8. // Copyright © 2025 TP-Link. All rights reserved. // #import "Omada-Swift.h" #import "SDNChangeSiteCustomerViewController.h" #import "SDNSitePageLoadViewModel.h" #import "SDNControllerCentralPlatformSiteCell.h" #import "TPTitleSubTitleCounterArrowCell.h" #import "ALSDNMSPDashBoard.h" #import "VMSDNGlobalSiteInfo.h" #import "VMSDNGlobalCustomerInfo.h" #import "VMSDNGlobalPermissionInfo.h" #import "TPSDNControllerTransport.h" #import "DeleteSiteBaffleView.h" #import "SDNMoreAddOrEditSiteVC.h" #import "NewUserGuideTool.h" #import "TPDataStorage.h" #import "SDNControllerCoordinator.h" #import "UIViewController+ControllerCoordinator.h" #import "ALSDNMspGlobal.h" @interface SDNChangeSiteCustomerViewController ()<SDNSitePageLoadViewModelDelegate,SDNCommonPageLoadViewModelDelegate, ControllerCoordinatorLoginFlowDelegate> @property (nonatomic, strong) SDNSitePageLoadViewModel *viewModel; @property (nonatomic, strong) SDNCentralPlatformSiteListPageLoadViewModel *centralViewModel; @property (nonatomic, strong) VMSDNGlobalPermissionInfo *vmPermissionInfo; //@property (nonatomic, strong) TPBSegmentedControl *siteCustomerControl; @property (nonatomic, strong) TPBSearchBar *searchBar; @property (nonatomic, strong) TPBButton *manageButton; @property (nonatomic, strong) UIView *headerView; @property (nonatomic, copy) NSArray<DMSDNGlobalSiteSummary *> *siteSearchResultList; @property (nonatomic, copy) NSArray<DMSDNCustomerStatInfo *> *customerSearchResultList; @property (nonatomic, copy) NSArray<DMSDNCustomerStatInfo *> *allCustomerList; @property (nonatomic, copy) NSString *selectedCustomerID; @property (nonatomic, copy) NSString *selectedCustomerName; @property (nonatomic, assign) BOOL isInAnimation; @property (nonatomic, assign) CGRect currentBounds; @property (nonatomic, assign, readwrite) BOOL isUserGuideShowing; @end @implementation SDNChangeSiteCustomerViewController - (instancetype)init { self = [super init]; if (self) { } return self; } - (void)viewDidLoad { [super viewDidLoad]; [self controllerCoordinator_bindDelegate]; } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self tpbMakeConstraint]; } - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; if (self.isUserGuideShowing) { [self showUserGuideWithBounds:self.currentBounds]; } } - (void)coordinatorLoginFlow_loadViewWithCachedData{ self.searchBar.userInteractionEnabled = NO; // self.siteSearchResultList = self.controllerCoordinator.cacheModel.siteList; if ([TPSDNControllerClient currentInstance].ecDevice.isInCentralPlatform){ self.siteSearchResultList = [TPSDNControllerClient currentInstance].currentCentral.centralPlatformComponent.allSiteList; }else if (TPSDNControllerClient.currentInstance.userComponent.curUserInfo.userLevel == DMSDNUserLevelMSP && [TPSDNControllerClient currentInstance].mspSitesComponent.isSupported){ self.siteSearchResultList = [TPSDNControllerClient currentInstance].mspSitesComponent.currentPageMSPSiteList; }else if([TPSDNControllerClient currentInstance].siteListComponent.isSupported){ self.siteSearchResultList = [TPSDNControllerClient currentInstance].siteListComponent.allSiteList; }else{ self.siteSearchResultList = [TPSDNControllerClient currentInstance].mspGlobalComponent.allPageSiteList; } self.manageButton.hidden = YES; [self reloadView]; } - (void)coordinatorLoginFlow_refreshViewWhenLaunchSuccess{ if (self.siteSearchResultList.count == 0) { [self omd_changePageStatusConfig:[OmadaPageStatusConfig loadingConfigWithContent:nil]]; } [self updateInitData]; self.searchBar.userInteractionEnabled = YES; self.emptyView.emptyImage = [UIImage imageNamed:@"empty-data"]; self.emptyView.emptyTitle = gMeshQuickSetup.sdnGlobalDashboardNoSite; [self setupViewModel]; self.vmPermissionInfo = [VMSDNGlobalPermissionInfo new]; if ([self isMSP]) { [self.vmPermissionInfo updateMSPPremissionWithDMSDNUser:[TPSDNControllerClient currentInstance].userComponent.curUserInfo]; } else { [self.vmPermissionInfo updateWithDMSDNUser:[TPSDNControllerClient currentInstance].userComponent.curUserInfo]; } if ([[TPSDNControllerClient currentInstance].transport isKindOfClass:[TPSDNControllerTransport class]]) { TPSDNControllerTransport *transport = (TPSDNControllerTransport *)[TPSDNControllerClient currentInstance].transport; self.selectedCustomerID = transport.omadacId; self.selectedCustomerName = [TPSDNControllerClient currentInstance].maintenanceComponent.controllerInfo.name; } self.isUserGuideShowing = NO; self.currentBounds = CGRectZero; self.manageButton.hidden = NO; } - (void)tpbSetupInitialData { [super tpbSetupInitialData]; self.emptyView.emptyImage = [UIImage imageNamed:@"empty-data"]; self.emptyView.emptyTitle = gMeshQuickSetup.sdnGlobalDashboardNoSite; [self setupViewModel]; self.vmPermissionInfo = [VMSDNGlobalPermissionInfo new]; if ([self isMSP]) { [self.vmPermissionInfo updateMSPPremissionWithDMSDNUser:[TPSDNControllerClient currentInstance].userComponent.curUserInfo]; } else { [self.vmPermissionInfo updateWithDMSDNUser:[TPSDNControllerClient currentInstance].userComponent.curUserInfo]; } if ([[TPSDNControllerClient currentInstance].transport isKindOfClass:[TPSDNControllerTransport class]]) { TPSDNControllerTransport *transport = (TPSDNControllerTransport *)[TPSDNControllerClient currentInstance].transport; self.selectedCustomerID = transport.omadacId; self.selectedCustomerName = [TPSDNControllerClient currentInstance].maintenanceComponent.controllerInfo.name; } self.isUserGuideShowing = NO; self.currentBounds = CGRectZero; } - (void)tpbSetupSubviews { [super tpbSetupSubviews]; [self.view addSubview:self.searchBar]; [self.view addSubview:self.manageButton]; } - (void)tpbMakeConstraint { [super tpbMakeConstraint]; [self.searchBar mas_remakeConstraints:^(MASConstraintMaker *make) { make.leading.equalTo(self.view).offset(TPBDesign.list.contentLeading); make.trailing.equalTo(self.view).offset(-TPBDesign.list.contentLeading); make.top.equalTo(self.view).offset(TPBDesign.list.sectionHeaderHeight); // if (![self needShowSiteCustomerSegment]) { make.bottom.equalTo(self.tableView.mas_top); // } }]; // if ([self needShowSiteCustomerSegment]) { // self.siteCustomerControl.hidden = NO; // [self.siteCustomerControl mas_remakeConstraints:^(MASConstraintMaker *make) { // make.top.equalTo(self.searchBar.mas_bottom).offset(TPBDesign.list.contentLeading); // make.height.equalTo(@(TPBDesign.segment.roundRectHeight)); // make.bottom.equalTo(self.tableView.mas_top); // make.leading.equalTo(self.view).offset(TPBDesign.list.contentLeading); // make.trailing.equalTo(self.view).offset(-TPBDesign.list.contentLeading); // }]; // } else { // self.siteCustomerControl.hidden = YES; // } [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) { // make.top.equalTo(self.mas_tpSafeAreaLayoutGuide); make.leading.trailing.equalTo(self.mas_tpSafeAreaLayoutGuide); make.bottom.equalTo(self.manageButton.mas_top).offset(-16); }]; [self.manageButton mas_remakeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.view).offset(-40); make.leading.equalTo(self.view).offset(TPBDesign.list.contentLeading); make.trailing.equalTo(self.view).offset(-TPBDesign.list.contentLeading); }]; } - (void)setupViewModel { if ([self isCentral]) { self.centralViewModel = [[SDNCentralPlatformSiteListPageLoadViewModel alloc] initWithTableView:self.tableView addRefreshFooter:YES pageSize:50 searchForTableHeaderView:NO]; [self.centralViewModel updatePreparedData]; self.centralViewModel.delegate = self; self.searchBar.delegate = self.centralViewModel; } else { self.searchBar.delegate = self.viewModel; } } - (void)reloadView { if ([self isMSP] && [[SDNPermissionTool shareInstance] isMSPSitesBlock]){ self.emptyView.emptyTitle = gMeshQuickSetup.siteDropdownNoMSPSite; self.emptyView.hidden = NO; self.sectionArray = [NSMutableArray new]; }else{ NSMutableArray *sectionArray = [NSMutableArray new]; for (int i = 0; i < self.siteSearchResultList.count; i++) { DMSDNGlobalSiteSummary *tempSite = self.siteSearchResultList[i]; NSMutableArray *rowModelArray = [NSMutableArray new]; [rowModelArray addObject:[self cellModelWithSiteSummary:tempSite forindex:i]]; TPBTableSectionModel *sectionModel = [TPBTableSectionModel new]; sectionModel.cellModelArray = [rowModelArray copy]; if (self.controllerCoordinator.loginStatus == SDNControllerLaunchStatusFailureSiteNotExist && [tempSite.siteId isEqualToString:TPSDNControllerClient.currentInstance.currentSite.siteKey]){ //在launch流程为site 不存在时,在列表中移除当前site }else{ [sectionArray addObject:sectionModel]; } } if (self.siteSearchResultList.count == 0) { self.emptyView.emptyTitle = gMeshQuickSetup.sdnGlobalDashboardNoSite; self.emptyView.hidden = NO; } else { self.emptyView.hidden = YES; } self.sectionArray = [sectionArray copy]; } } - (UIView *)headerView { if (!_headerView) { _headerView = [UIView new]; CGRect frame = CGRectMake(0, 0, self.view.bounds.size.width, 82); _headerView.frame = frame; } return _headerView; } - (TPBSearchBar *)searchBar { if (!_searchBar) { _searchBar = [[TPBSearchBar alloc] init]; _searchBar.backgroundColor = [UIColor clearColor]; _searchBar.placeholder = gSDNGlobal.search; } return _searchBar; } - (TPBButton *)manageButton { if (!_manageButton) { _manageButton = [TPBButton secondaryButtonWithTitle:gMeshQuickSetup.userGuideGlobalOverviewTitle]; TPBWeakSelf _manageButton.onClickCallback = ^(TPBButton * _Nonnull button) { TPBStrongSelf if ([_self isMSP]) { if ([_self.delegate respondsToSelector:@selector(switchSite_clickCustomerManagement)]) { [[NSNotificationCenter defaultCenter] postNotificationName:TPOmadaSiteDeviceVersionTipResetNotification object:nil]; [_self.delegate switchSite_clickCustomerManagement]; } } else { if ([_self.delegate respondsToSelector:@selector(switchSite_clickSitesManagement)]) { [[NSNotificationCenter defaultCenter] postNotificationName:TPOmadaSiteDeviceVersionTipResetNotification object:nil]; [_self.delegate switchSite_clickSitesManagement]; } } }; } return _manageButton; } - (SDNSitePageLoadViewModel *)viewModel{ if(!_viewModel){ _viewModel = [[SDNSitePageLoadViewModel alloc] initWithTableView:self.tableView addRefreshFooter:YES]; [_viewModel updatePreparedData]; _viewModel.delegate = self; } return _viewModel; } - (void)updatePremission { DMSDNUser *userInfo = [TPSDNControllerClient currentInstance].userComponent.curUserInfo; [self.vmPermissionInfo updateWithDMSDNUser:userInfo]; } - (void)updateHiddenStatus:(BOOL)hidden needSlow:(BOOL) needSlow{ TPWeakSelf self.isInAnimation = YES; NSTimeInterval duration = needSlow ? 0.3 : 0.3; if (hidden) { [UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ CGRect temp = self.view.frame; temp.origin.y -= self.view.frame.size.height; self.view.frame = temp; } completion:^(BOOL finished) { TPStrongSelf _self.view.hidden = hidden; CGRect temp = _self.view.frame; temp.origin.y += _self.view.frame.size.height; _self.view.frame = temp; if (needSlow){ if ([_self.delegate respondsToSelector:@selector(switchSite_dropDownIsHidden)]){ [_self.delegate switchSite_dropDownIsHidden]; } }else{ if ([_self.delegate respondsToSelector:@selector(switchSite_needRefreshWithNeedLoading:)]){ [_self.delegate switchSite_needRefreshWithNeedLoading:NO]; } } _self.isInAnimation = NO; }]; } else { [self tpbSetupInitialData]; [self requestInfo]; CGRect temp = self.view.frame; temp.origin.y -= self.view.frame.size.height; self.view.frame = temp; self.view.hidden = hidden; [UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ CGRect temp = self.view.frame; temp.origin.y += self.view.frame.size.height; self.view.frame = temp; } completion:^(BOOL finished) { TPStrongSelf _self.isInAnimation = NO; }]; } } // 工具判断 //- (BOOL)needChooseCustomer { // // 5.12.7适配 // if ([self isMSP] && ![TPSDNControllerClient currentInstance].mspSitesComponent.isSupported){ // return YES; // } // // // 被邀请的只有customer权限的cloudUser 登陆本地localController // if ([self customerUserLocalAccessLocalController]) { // return YES; // } // // // 被邀请的只有customer权限的cloudUser 上云登陆localController // if ([self customerUserCloudAccessLocalController]) { // return YES; // } // // return NO; //} - (BOOL)showAddButton { if (![self.controllerCoordinator launchSuccess]){ return NO; }else if ([self isMSP]) { return NO; }else if (self.vmPermissionInfo.isAllowedDeleteOrAddInstance && ![self needHideForCentralBlock]){ return YES; }else{ return NO; } } - (BOOL)needHideForCentralBlock { return [TPSDNControllerClient currentInstance].ecDevice.isCentral && ![TPSDNControllerClient currentInstance].ecDevice.centralEnable; } - (void)requestData { [self requestInfo]; } // 被邀请的只有customer权限的cloudUser 上云登陆localController - (BOOL)customerUserCloudAccessLocalController { return [self isCloudUser] && [self isCustomer] && ![TPSDNControllerClient currentInstance].ecDevice.hasMspPermission && [TPSDNControllerClient currentInstance].ecDevice.mspMode; } // 被邀请的只有customer权限的cloudUser 登陆本地localController - (BOOL)customerUserLocalAccessLocalController { return [self isCloudUser] && [self isCustomer] && [TPSDNControllerClient currentInstance].discoveredDevice; } - (BOOL)needShowSiteCustomerSegment { return [self isMSP] || [self customerUserCloudAccessLocalController] || [self customerUserLocalAccessLocalController]; } - (BOOL)isMSP { return TPSDNControllerClient.currentInstance.userComponent.curUserInfo.userLevel == DMSDNUserLevelMSP; } - (BOOL)isCustomer { return TPSDNControllerClient.currentInstance.userComponent.curUserInfo.userLevel == DMSDNUserLevelCustomer; } - (BOOL)isCloudUser { return TPSDNControllerClient.currentInstance.userComponent.curUserInfo.userType == DMSDNUserTypeCloudUser; } - (BOOL)isCentral { return [TPSDNControllerClient currentInstance].ecDevice.isInCentralPlatform; } - (BOOL)isSiteStatisticListSupport { return [TPSDNControllerClient currentInstance].siteListComponent.isSupported; } - (BOOL)isSiteSettingAccessible { return [TPSDNControllerClient currentInstance].userComponent.curUserInfo.roleDetail.globalDashboard == DMSDNRoleAccessModifyOrAccess && [[SDNPermissionTool shareInstance] isSupportMSPManagement]; } - (BOOL)isSiteSettingReadonly { return [TPSDNControllerClient currentInstance].userComponent.curUserInfo.roleDetail.globalDashboard == DMSDNRoleAccessRead && [[SDNPermissionTool shareInstance] isSupportMSPManagement]; } - (NSString *)currentOmadaCID { if ([[TPSDNControllerClient currentInstance].transport isKindOfClass:[TPSDNControllerTransport class]]) { TPSDNControllerTransport *transport = (TPSDNControllerTransport *)[TPSDNControllerClient currentInstance].transport; return transport.omadacId; } return @""; } - (void)updateSiteData { // 更新site列表 central目前没有收藏功能 if ([self isCentral] && self.centralViewModel) { self.siteSearchResultList = [self.centralViewModel.siteList copy]; return; } if (!self.viewModel){ return; } // 建立索引 NSArray<DMSDNGlobalSiteAlertInfo *> *tmpAlertInfoList = [TPSDNControllerClient currentInstance].mspGlobalComponent.siteAlertList; NSMutableDictionary<NSString *, DMSDNGlobalSiteAlertInfo *> *alertInfoDict = [NSMutableDictionary new]; for (DMSDNGlobalSiteAlertInfo *alertInfo in tmpAlertInfoList) { alertInfoDict[alertInfo.siteId] = alertInfo; } // 更新Site Alert NSMutableArray<DMSDNGlobalSiteSummary *> *siteList = [[NSMutableArray alloc] init]; [siteList addObjectsFromArray:self.viewModel.allSiteList]; for (DMSDNGlobalSiteSummary *siteInfo in siteList) { if (alertInfoDict[siteInfo.siteId]) { DMSDNGlobalSiteAlertInfo *alertInfo = alertInfoDict[siteInfo.siteId]; siteInfo.alertInfo.alertNum = alertInfo.alertNum; siteInfo.alertInfo.obscured = alertInfo.obscured; } } // 更新bookmark标记 // 建立索引 NSArray<NSString *> *tmpFavoriteSiteIdList = [TPSDNControllerClient currentInstance].userComponent.curUserInfo.favoriteSiteIdList; NSMutableDictionary<NSString *, NSString *> *favoriteSiteDict = [NSMutableDictionary new]; for (NSString *favoriteSiteId in tmpFavoriteSiteIdList) { favoriteSiteDict[favoriteSiteId] = favoriteSiteId; } // 更新 for (DMSDNGlobalSiteSummary *siteInfo in siteList) { if (favoriteSiteDict[siteInfo.siteId]) { siteInfo.isBookmarked = YES; } else { siteInfo.isBookmarked = NO; } } self.siteSearchResultList = [siteList copy]; } - (void)updateInitData { [self requestSiteListInfo]; } - (TPBBaseTableCellModel *)cellModelWithCustomerSummary:(DMSDNCustomerStatInfo *)customerInfo forindex:(int)i { TPTitleSubTitleCounterArrowCellModel *customerCellModel = [[TPTitleSubTitleCounterArrowCellModel alloc] initItemCellModel]; VMSDNGlobalCustomerInfo *vmCustomerInfo = [[VMSDNGlobalCustomerInfo alloc] init]; [vmCustomerInfo updateWithCustomerStatInfo:customerInfo]; customerCellModel.titleText = vmCustomerInfo.customerName; // customerUserLocalAccessLocalController这种情况下的customer list接口不返回site数量 if (![self customerUserLocalAccessLocalController]) { customerCellModel.subTitleText = vmCustomerInfo.siteNumString; } customerCellModel.isObscured = customerInfo.alertInfo.obscured; customerCellModel.alertNum = customerInfo.alertInfo.alertNum; customerCellModel.hiddeArrow = YES; customerCellModel.isCurrentCustomerOrSite = [customerInfo.key isEqualToString:[self currentOmadaCID]]; TPWeakSelf customerCellModel.didClickItem = ^{ TPStrongSelf if ([_self customerUserCloudAccessLocalController] || [_self customerUserLocalAccessLocalController]) { [_self switchToCustomerWithSelectedInfo:customerInfo]; } else { [_self clickSwitchToCustomerWithInfo:customerInfo]; } }; return customerCellModel; } - (TPBBaseTableCellModel *)cellModelWithSiteSummary:(DMSDNGlobalSiteSummary *)siteInfo forindex:(int)i { if ([self isCentral] || ([self isSiteStatisticListSupport] && ![self isMSP]) ) { SDNControllerCentralPlatformSiteCellModel *siteCellModel = [[SDNControllerCentralPlatformSiteCellModel alloc] initItemCellModel]; siteCellModel.titleStr = siteInfo.name; siteCellModel.isPro = siteInfo.type == ControllerSiteTypePro && TPSDNControllerClient.currentInstance.proSiteMixManagerComponent.isSupported; siteCellModel.region = siteInfo.regin; siteCellModel.isBookmark = siteInfo.isBookmarked; siteCellModel.centralSiteNetworkStatistic = siteInfo.centralSiteNetworkStatistic; siteCellModel.centralSiteNetworkStatistic.alerts = siteInfo.alertInfo.alertNum; siteCellModel.canShowEdit = NO; siteCellModel.isCurrentSite = [siteInfo.siteId isEqualToString:TPSDNControllerClient.currentInstance.currentSite.siteKey]; siteCellModel.isSupportEdit = NO; //siteCellModel.isSupportEdit = [self isSiteSettingAccessible]; // siteCellModel.isSupportDelete = self.vmPermissionInfo.isAllowedDeleteOrAddInstance && ![self needHideForCentralBlock]; // siteCellModel.isSupportBookmark = [TPSDNControllerClient currentInstance].mspSitesComponent.isSupported; siteCellModel.isSupportBookmark = NO; siteCellModel.canShowRegion = !([TPSDNControllerClient currentInstance].ecDevice.isCentral && [TPSDNControllerClient currentInstance].ecDevice.centralEnable); TPWeakSelf siteCellModel.didClickItem = ^{ TPStrongSelf if ([_self customerUserCloudAccessLocalController] || [_self customerUserLocalAccessLocalController]) { [_self switchSiteWithSelectedSite:siteInfo]; } else { [_self clickSwitchToSiteWithInfo:siteInfo]; } }; return siteCellModel; } else { TPTitleSubTitleCounterArrowCellModel *siteCellModel = [[TPTitleSubTitleCounterArrowCellModel alloc] initItemCellModel]; VMSDNGlobalSiteInfo *vmSiteInfo = [[VMSDNGlobalSiteInfo alloc] init]; [vmSiteInfo updateWithDMSDNSiteSettings:siteInfo]; siteCellModel.titleText = vmSiteInfo.siteName; siteCellModel.isPro = siteInfo.type == ControllerSiteTypePro && TPSDNControllerClient.currentInstance.proSiteMixManagerComponent.isSupported; siteCellModel.subTitleText = vmSiteInfo.country; siteCellModel.isObscured = siteInfo.alertInfo.obscured; siteCellModel.alertNum = siteInfo.alertInfo.alertNum; if (![self isMSP]){ siteCellModel.isBookmarked = siteInfo.isBookmarked; } siteCellModel.customerName = siteInfo.customerName; siteCellModel.hiddeArrow = YES; siteCellModel.isCurrentCustomerOrSite = [siteInfo.siteId isEqualToString:TPSDNControllerClient.currentInstance.currentSite.siteKey]; TPWeakSelf siteCellModel.didClickItem = ^{ TPStrongSelf if ([_self customerUserCloudAccessLocalController] || [_self customerUserLocalAccessLocalController]) { [_self switchSiteWithSelectedSite:siteInfo]; } // 5.12.7适配 else if ([_self isMSP] && ![TPSDNControllerClient currentInstance].mspSitesComponent.isSupported) { [_self clickSwitchCustomerAndSite:siteInfo]; } // msp需要如果非当前customer的site需先换customer再换site,切换不同customer下的site else if ([_self isMSP] && ![siteInfo.customerId isEqualToString:TPSDNControllerClient.currentInstance.mspManagementComponent.customerInfo.key]) { [_self clickSwitchCustomerAndSite:siteInfo]; } else { [_self clickSwitchToSiteWithInfo:siteInfo]; } }; return siteCellModel; } } - (TPAbstractHandle *)requestSiteList:(NSString *)customerID customerName:(NSString *)customerName { if ([[TPSDNControllerClient currentInstance].transport isKindOfClass:[TPSDNControllerTransport class]]) { TPSDNControllerTransport *transport = (TPSDNControllerTransport *)[TPSDNControllerClient currentInstance].transport; NSString *oldCustomerID = [transport.omadacId copy]; NSString *oldCustomerName = [[TPSDNControllerClient currentInstance].maintenanceComponent.controllerInfo.name copy]; self.selectedCustomerID = customerID; self.selectedCustomerName = customerName; [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:customerID]; [[TPSDNControllerClient currentInstance].maintenanceComponent updateControllerInfoName:customerName]; TPAbstractHandle *siteListHandle = [self requestSiteListInfo]; TPBWeakSelf; [siteListHandle addCompletionOnMainThread:^(TPHandleResult * _Nonnull result) { TPBStrongSelf; [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:oldCustomerID]; [[TPSDNControllerClient currentInstance].maintenanceComponent updateControllerInfoName:oldCustomerName]; if ([_self.delegate respondsToSelector:@selector(switchSite_didSelectCustomer)]) { [_self.delegate switchSite_didSelectCustomer]; } }]; return siteListHandle; } else { return [TPGCDHandle failureHandleInMainQueue]; } } - (TPAbstractHandle *)requestUserInfo { TPSDNControllerTransport *transport = (TPSDNControllerTransport *)[TPSDNControllerClient currentInstance].transport; NSString *currentOmadacId = transport.omadacId; NSMutableArray *handleArray = [NSMutableArray new]; //该流程为返回Site层级后,判断当前omadacid是否与currentUser中的omadacid相符 //如不相符需要静默调用switchCustomer接口,并请求currentUser 数据 if (![TPSDNControllerClient.currentInstance.userComponent.curUserInfo.omadacID isEqualToString:currentOmadacId] && !IsEmptyString(currentOmadacId) && TPSDNControllerClient.currentInstance.userComponent.curUserInfo.userLevel == DMSDNUserLevelMSP){ TPQueueHandleFactoryBlock switchCustomerBlock = ^TPAbstractHandle* (TPQueueHandleBlockContext* context) { return [ALSDNMSPDashBoard.currentInstance switchCustomerWithCustomerKey:currentOmadacId]; }; [handleArray addObject:switchCustomerBlock]; } TPQueueHandleFactoryBlock requestUserInfoBlock = ^TPAbstractHandle* (TPQueueHandleBlockContext* context) { if (context.lastResult.success){ return [[ALSDNMspGlobal currentInstance] requestUserInfo]; }else{ return nil; } }; [handleArray addObject:requestUserInfoBlock]; TPGCDQueueHandle* queueHandle = [[TPGCDQueueHandle alloc] initWithQueue:dispatch_get_main_queue() factoryBlockArray:handleArray timeout:-1]; return queueHandle; } - (TPAbstractHandle *)requestSiteListInfo{ if (self.controllerCoordinator.loginStatus != SDNControllerLaunchStatusSuccess){ return nil; } if (self.siteSearchResultList.count == 0){ [self omd_changePageStatusConfig:[OmadaPageStatusConfig loadingConfigWithContent:nil]]; } if ([self isCentral] && self.centralViewModel) { TPAbstractHandle * siteHandle = [self.centralViewModel reloadFirstPageData]; TPWeakSelf; [siteHandle addCompletionOnMainThread:^(TPHandleResult *result) { TPStrongSelf; [_self omd_changePageStatusConfig:[OmadaPageStatusConfig normalConfig]]; if (result.success) { [_self updateSiteData]; [_self reloadView]; } }]; return siteHandle; } if (!self.viewModel){ return [TPGCDHandle failureHandleInMainQueue]; } //1、请求site列表和userInfo信息(bookmark) TPWeakSelf; TPQueueHandleFactoryBlock blck0 = ^TPAbstractHandle* (TPQueueHandleBlockContext* context) { TPStrongSelfNoReturn NSMutableArray<TPAbstractHandle *> *handleArray = [[NSMutableArray alloc] init]; [handleArray addObject:[self requestUserInfo]]; if ([self isMSP] && [TPSDNControllerClient currentInstance].mspSitesComponent.isSupported) { [handleArray addObject:[_self.viewModel reloadFirstPageDataAndAlert]]; } else if ([TPSDNControllerClient currentInstance].siteListComponent.isSupported) { [handleArray addObject:[_self.viewModel reloadDeviceSummaryFirstPageData]]; } else { [handleArray addObject:[_self.viewModel reloadFirstPageData]]; } return [[TPGCDMergeHandle alloc] initWithQueue:dispatch_get_main_queue() handleArray:handleArray timeout:-1]; }; //2、如果site列表不为空则请求ALert信息,否则直接更新界面 TPQueueHandleFactoryBlock alertBlck= ^TPAbstractHandle* (TPQueueHandleBlockContext* context) { if (!context.lastResult.failure){ // msp reloadFirstPageDataAndAlert 已请求alert 不用再次请求 if ([self isMSP] && [TPSDNControllerClient currentInstance].mspSitesComponent.isSupported) { return [TPGCDHandle successHandleInMainQueue]; } else { return [[TPSDNControllerClient currentInstance].mspGlobalComponent requestSiteAlertList]; } } else{ context.stop = YES; context.stopResult = context.lastResult; return nil; } }; TPQueueHandleFactoryBlock blck1 = ^TPAbstractHandle* (TPQueueHandleBlockContext* context) { TPStrongSelfNoReturn; [_self omd_changePageStatusConfig:[OmadaPageStatusConfig normalConfig]]; if (!context.lastResult.failure){ [_self updateSiteData]; [_self reloadView]; return nil; } else{ context.stop = YES; context.stopResult = context.lastResult; return nil; } }; TPGCDQueueHandle* queueHandle = [[TPGCDQueueHandle alloc] initWithQueue:dispatch_get_main_queue() factoryBlockArray:@[blck0, alertBlck, blck1] timeout:-1]; [queueHandle addCompletionOnMainThread:^(TPHandleResult * _Nonnull result) { TPStrongSelfNoReturn [_self omd_changePageStatusConfig:[OmadaPageStatusConfig normalConfig]]; [_self reloadView]; }]; return queueHandle; } - (TPAbstractHandle *)requestInfo { [self reloadView]; return [self requestSiteListInfo]; } #pragma mark - SDNSitePageLoadViewModelDelegate - (void)sitePageDataLoadEndWithPage:(NSUInteger)page success:(BOOL)success { [self updateSiteData]; [self reloadView]; } - (void)sitePageDidEndSearchEditing { [self updateSiteData]; [self reloadView]; } - (void)sitePageDidChangeSearchKey:(NSString *)searchKey { if (IsEmptyString(searchKey)) { [self requestInfo]; return; } } - (void)sitePageHideKeyboard { TPWeakSelf; [[self requestSiteListInfo] addCompletionOnMainThread:^(TPHandleResult *result) { TPStrongSelf; if (!result.success && !(result.cancel || result.timeout)) { [_self showSDNFailedToastViewWithErrorCode:result.sdnControllerRequestResult.errorCode]; } }]; } #pragma mark - SDNCommonPageLoadViewModelDelegate - (void)pageDataLoadEndWithPageWithPage:(NSInteger)page success:(BOOL)success { [self updateSiteData]; [self reloadView]; } - (void)pageDidEndSearchEditing { [self updateSiteData]; [self reloadView]; } - (void)pageDidChangeSearchKeyWithSearchKey:(NSString *)searchKey { if (IsEmptyString(searchKey)) { [self requestInfo]; return; } } - (void)pageHideKeyboard { TPWeakSelf; [[self requestSiteListInfo] addCompletionOnMainThread:^(TPHandleResult *result) { TPStrongSelf; if (!result.success && !(result.cancel || result.timeout)) { [_self showSDNFailedToastViewWithErrorCode:result.sdnControllerRequestResult.errorCode]; } }]; } #pragma mark - TableViewDelegate - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { if (![self.controllerCoordinator launchSuccess]) { return NO; } BOOL centralPermission = NO; if ([self isCentral]){ SDNCentralUserInfo *curLogInUser = TPSDNControllerClient.currentInstance.currentCentral.accountComponent.currentUserInfo; if ([curLogInUser isPermissionModify:kRoleGlobalDashboard]){ centralPermission = YES; } } if ([self isMSP]) { return NO; } if (self.vmPermissionInfo.isAllowedDeleteOrAddInstance || [self isSiteSettingAccessible]) { if ([TPSDNControllerClient currentInstance].ecDevice.isCentral && ![TPSDNControllerClient currentInstance].ecDevice.centralEnable) { return NO; } return YES; } else if (![self isMSP] && [TPSDNControllerClient currentInstance].mspSitesComponent.isSupported) { return YES; } else if (centralPermission){ return YES; } else { return NO; } } - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{ // NSInteger section = [self needChooseCustomer] ? (indexPath.section - 1) : indexPath.section; NSInteger section = indexPath.section; [self hideKeyboard]; NSMutableArray<UITableViewRowAction *> *actionArr = [[NSMutableArray alloc] init]; TPWeakSelf BOOL forbidDeletSite = NO; // if (self.siteCustomerControl.selectedIndex == 0) { if ((indexPath.row < self.siteSearchResultList.count) && self.siteSearchResultList[indexPath.row].isPrimary) { forbidDeletSite = YES; } // } BOOL centralPermission = NO; if ([self isCentral]){ SDNCentralUserInfo *curLogInUser = TPSDNControllerClient.currentInstance.currentCentral.accountComponent.currentUserInfo; if ([curLogInUser isPermissionModify:kRoleGlobalDashboard]){ centralPermission = YES; } } BOOL isCurrent = [self.siteSearchResultList[section].siteId isEqualToString:TPSDNControllerClient.currentInstance.currentSite.siteKey]; BOOL nonCentralDeletePermission = self.vmPermissionInfo.isAllowedDeleteOrAddInstance && !forbidDeletSite && ![self isCentral]; if ((nonCentralDeletePermission || centralPermission) && !isCurrent) { UITableViewRowAction *action = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:gSDNGlobal.delete handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath){ TPStrongSelf; [_self didClickDeleteSiteWithSiteId:_self.siteSearchResultList[section]]; }]; action.backgroundColor = [UIColor tpbRed]; [actionArr addObject:action]; } if ([TPSDNControllerClient currentInstance].mspSitesComponent.isSupported && ![self isCentral]) { // bookmark功能 UITableViewRowAction *action = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:self.siteSearchResultList[section].isBookmarked ? gMeshQuickSetup.sdnUnbookmarkSiteTitle : gMeshQuickSetup.sdnBookmarkSiteTitle handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath){ TPStrongSelf; if (_self.siteSearchResultList[section].isBookmarked) { [_self didClickUnbookmarkSiteWithSite:_self.siteSearchResultList[section]]; } else { [_self didClickBookmarkSiteWithSite:_self.siteSearchResultList[section]]; } }]; action.backgroundColor = [UIColor tpbOrange]; [actionArr addObject:action]; } BOOL nonCentralEditPermission = [self isSiteSettingAccessible] && ![self isCentral]; if (nonCentralEditPermission || centralPermission) { NSString *tempString = gSDNGlobal.edit; if (([self isMSP] && self.vmPermissionInfo.isAllowedReadCustomerSetting) || (![self isMSP] && [self isSiteSettingReadonly])) { tempString = gSDNMore.sdnLogDetail; } UITableViewRowAction *action = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:tempString handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath){ TPStrongSelf; if (![self isMSP]) { //5.11版本的权限判定有误,需要获得site setting和customer dashboard modify两个权限,若没有则弹窗提示 //controller版本号为5.11,6.0 site settings 权限调整无需修改 if ([TPSDNControllerClient currentInstance].userComponent.curUserInfo.roleDetail.siteSettings == DMSDNRoleAccessBlock && [[TPSDNControllerClient currentInstance].systemComponent.controllerInfo.version containsString:@"5.11."]) { TPTitleAlertView *alertView = [[TPTitleAlertView alloc] init]; [alertView updateTitle:gMeshQuickSetup.sDNEditSiteAlertTip]; [alertView setButtonTitleArray:@[gSDNGlobal.ok]]; [alertView setDidDismissWithButtonIndexBlock:nil]; [alertView show]; } else { [_self didClickEditSiteWithDMSDNGlobalSiteSummary:self.siteSearchResultList[section]]; } } else { [_self didClickEditSiteWithDMSDNGlobalSiteSummary:self.siteSearchResultList[section]]; } }]; action.backgroundColor = [UIColor tpbPrimary]; [actionArr addObject:action]; } return [actionArr copy]; } // 点击事件 - (void)jumpToCustomerSelect { NSMutableDictionary<NSString *, NSString *> *dict = [NSMutableDictionary new]; NSMutableArray<NSString *> *selectItemArray = [NSMutableArray new]; for (DMSDNCustomerStatInfo *info in self.allCustomerList) { dict[info.name] = info.key; [selectItemArray addObject:info.name]; } TPBGeneralSelectionController *selectVC = [[TPBGeneralSelectionController alloc] initWithTitle:gMeshQuickSetup.sdnSiteJumpChangeCustomer isPresented:NO allItemArray:selectItemArray selectedItem:self.selectedCustomerName]; TPBWeakSelf selectVC.selectionDidChangeCallback = ^(NSUInteger selectedIndex, NSString * _Nonnull selectedItem) { TPBStrongSelf if (dict[selectedItem]){ [_self requestSiteList:dict[selectedItem] customerName:selectedItem]; } }; [self.tpbNavigationController pushViewController:selectVC animated:NO]; } - (void)clickSwitchCustomerAndSite:(DMSDNGlobalSiteSummary * )site { if (IsEmptyString(site.customerId)) { site.customerId = self.selectedCustomerID; } if ([site.siteId isEqualToString:TPSDNControllerClient.currentInstance.currentSite.siteKey] && self.controllerCoordinator.loginStatus != SDNControllerLaunchStatusFailureSiteNotExist){ if ([self.delegate respondsToSelector:@selector(switchSite_closeDropDownWithNeedSlow:)]) { [self.delegate switchSite_closeDropDownWithNeedSlow:NO]; } return; } if ([self.delegate respondsToSelector:@selector(switchSite_closeDropDownWithNeedSlow:)]) { [self.delegate switchSite_closeDropDownWithNeedSlow:YES]; } TPWeakSelf [[[SDNControllerCoordinator sharedInstance] connectToSiteWithSite:site] addCompletionOnMainThread:^(TPHandleResult *result) { TPStrongSelf; if (result.success) { [[NSNotificationCenter defaultCenter] postNotificationName:TPOmadaSiteDeviceVersionTipResetNotification object:nil]; [_self reloadView]; if ([_self.delegate respondsToSelector:@selector(switchSite_needRefreshWithNeedLoading:)]) { [_self.delegate switchSite_needRefreshWithNeedLoading:YES]; } } else { [_self.delegate switchSite_needRefreshWithNeedLoading:NO]; [_self showSDNFailedToastViewWithErrorCode:result.sdnControllerRequestResult.errorCode]; } }]; } - (void)clickSwitchToSiteWithInfo:(DMSDNGlobalSiteSummary * )site { if ([site.siteId isEqualToString:TPSDNControllerClient.currentInstance.currentSite.siteKey] && self.controllerCoordinator.loginStatus != SDNControllerLaunchStatusFailureSiteNotExist){ if ([self.delegate respondsToSelector:@selector(switchSite_closeDropDownWithNeedSlow:)]) { [self.delegate switchSite_closeDropDownWithNeedSlow:NO]; } return; } if ([self.delegate respondsToSelector:@selector(switchSite_closeDropDownWithNeedSlow:)]) { [self.delegate switchSite_closeDropDownWithNeedSlow:YES]; } TPWeakSelf [[[SDNControllerCoordinator sharedInstance] connectToSiteWithSite:site] addCompletionOnMainThread:^(TPHandleResult *result) { TPStrongSelf; if (result.success) { [[NSNotificationCenter defaultCenter] postNotificationName:TPOmadaSiteDeviceVersionTipResetNotification object:nil]; [_self reloadView]; if ([_self.delegate respondsToSelector:@selector(switchSite_needRefreshWithNeedLoading:)]) { [_self.delegate switchSite_needRefreshWithNeedLoading:YES]; } } else { [_self showSDNFailedToastViewWithErrorCode:result.sdnControllerRequestResult.errorCode]; [_self.delegate switchSite_needRefreshWithNeedLoading:NO]; } }]; // [[TPSDNControllerClient.currentInstance.siteConfigComponent switchToSiteWithKey:site.siteId siteName:site.name] addCompletionOnMainThread:^(TPHandleResult *result) { // TPStrongSelf; // if (result.success) { // [_self reloadView]; // if ([_self.delegate respondsToSelector:@selector(switchSite_needRefreshWithNeedLoading:)]) { // [_self.delegate switchSite_needRefreshWithNeedLoading:YES]; // } // } else { // [_self dismissToastViewWithCompleteBlock:nil]; // [_self showSDNFailedToastViewWithErrorCode:result.sdnControllerRequestResult.errorCode]; // } // }]; } - (void)clickSwitchToCustomerWithInfo:(DMSDNCustomerStatInfo *)customerInfo { // [self showWaitingToastView]; TPWeakSelf; [[ALSDNMSPDashBoard.currentInstance switchCustomerWithCustomerKey:customerInfo.key] addCompletionOnMainThread:^(TPHandleResult * _Nonnull result) { TPStrongSelf; // [_self dismissToastViewWithCompleteBlock:nil]; if (result.success) { [[NSNotificationCenter defaultCenter] postNotificationName:TPOmadaSiteDeviceVersionTipResetNotification object:nil]; [_self reloadView]; [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:customerInfo.key]; [TPSDNMspLevelTool setIsInCustomerLevel:YES]; [TPSDNMspLevelTool setIsInMspLevel:NO]; [[TPSDNControllerClient currentInstance].maintenanceComponent updateControllerInfoName:customerInfo.name]; TPSDNControllerClient.currentInstance.userComponent.isMspLevel = NO; if ([_self.delegate respondsToSelector:@selector(switchSite_switchToCustomerWithInfo:)]) { [_self.delegate switchSite_switchToCustomerWithInfo:customerInfo]; } } else { [_self showSDNFailedToastViewWithErrorCode:result.sdnControllerRequestResult.errorCode]; } }]; } // 当前的customer和site列表不一定对应,5.12.7特殊适配 - (void)switchCustomerWithSelectedCustomerKey { TPBWeakSelf [[ALSDNMSPDashBoard.currentInstance switchCustomerWithCustomerKey:self.selectedCustomerID] addCompletionOnMainThread:^(TPHandleResult * _Nonnull result) { TPBStrongSelf if (result.success) { [[TPSDNControllerClient currentInstance].maintenanceComponent updateControllerInfoName:_self.selectedCustomerName]; [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:_self.selectedCustomerID]; if ([_self.delegate respondsToSelector:@selector(switchSite_clickSitesManagement)]) { [_self.delegate switchSite_clickSitesManagement]; } } else { [_self showSDNFailedToastViewWithErrorCode:result.sdnControllerRequestResult.errorCode]; } }]; } // 被邀请的customer权限cloudUser登陆localController适配点击SiteManagement - (void)clickSiteManagementWithoutSwitch { [[TPSDNControllerClient currentInstance].maintenanceComponent updateControllerInfoName:self.selectedCustomerName]; [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:self.selectedCustomerID]; if ([self.delegate respondsToSelector:@selector(switchSite_clickSitesManagement)]) { [self.delegate switchSite_clickSitesManagement]; } } // 被邀请的customer权限cloudUser登陆localController适配切换site - (void)switchSiteWithSelectedSite:(DMSDNGlobalSiteSummary * )site { if ([site.siteId isEqualToString:TPSDNControllerClient.currentInstance.currentSite.siteKey]){ if ([self.delegate respondsToSelector:@selector(switchSite_closeDropDownWithNeedSlow:)]) { [self.delegate switchSite_closeDropDownWithNeedSlow:NO]; } return; } if ([self.delegate respondsToSelector:@selector(switchSite_closeDropDownWithNeedSlow:)]) { [self.delegate switchSite_closeDropDownWithNeedSlow:YES]; } if ([[TPSDNControllerClient currentInstance].transport isKindOfClass:TPSDNControllerTransport.class]) { //保存旧值 TPSDNControllerTransport *transport = (TPSDNControllerTransport *)[TPSDNControllerClient currentInstance].transport; NSString *oldCustomerID = [transport.omadacId copy]; NSString *oldCustomerName = [[TPSDNControllerClient currentInstance].maintenanceComponent.controllerInfo.name copy]; [[TPSDNControllerClient currentInstance].maintenanceComponent updateControllerInfoName:self.selectedCustomerName]; [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:self.selectedCustomerID]; TPWeakSelf; NSDictionary <NSString *, NSNumber *> *siteComponent = [TPSDNControllerClient.currentInstance.negotiateComponent fetchSiteComponentWithSiteType:site.type]; BOOL hasSiteComponent = siteComponent != nil; TPAbstractHandle *switchSiteHandle; if (hasSiteComponent){ switchSiteHandle = [TPSDNControllerClient.currentInstance.siteConfigComponent switchToSiteLoadCacheComponentWithSite:site]; }else{ switchSiteHandle = [TPSDNControllerClient.currentInstance.siteConfigComponent switchToSiteWithKey:site.siteId siteName:site.name]; } [switchSiteHandle addCompletionOnMainThread:^(TPHandleResult *result) { TPStrongSelf; if (result.success) { [[SDNControllerCoordinator sharedInstance] siteChanged]; [_self reloadView]; if ([_self.delegate respondsToSelector:@selector(switchSite_needRefreshWithNeedLoading:)]) { [_self.delegate switchSite_needRefreshWithNeedLoading:YES]; } } else { [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:oldCustomerID]; [[TPSDNControllerClient currentInstance].maintenanceComponent updateControllerInfoName:oldCustomerName]; [_self dismissToastViewWithCompleteBlock:nil]; [_self showSDNFailedToastViewWithErrorCode:result.sdnControllerRequestResult.errorCode]; } }]; } } // 被邀请的customer权限cloudUser登陆localController适配切换customer - (void)switchToCustomerWithSelectedInfo:(DMSDNCustomerStatInfo *)customerInfo { [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:customerInfo.key]; [TPSDNMspLevelTool setIsInCustomerLevel:YES]; [TPSDNMspLevelTool setIsInMspLevel:NO]; TPSDNControllerClient.currentInstance.userComponent.isMspLevel = NO; if ([self.delegate respondsToSelector:@selector(switchSite_switchToCustomerWithInfo:)]) { [self.delegate switchSite_switchToCustomerWithInfo:customerInfo]; } } - (void)didClickDeleteSiteWithSiteId:(DMSDNGlobalSiteSummary *)site { if ([[TPSDNControllerClient currentInstance].transport isKindOfClass:[TPSDNControllerTransport class]]) { TPSDNControllerTransport *transport = (TPSDNControllerTransport *)[TPSDNControllerClient currentInstance].transport; NSString *oldCustomerID = [transport.omadacId copy]; NSString *oldCustomerName = [[TPSDNControllerClient currentInstance].maintenanceComponent.controllerInfo.name copy]; DeleteSiteBaffleView *deleteView = [[DeleteSiteBaffleView alloc] init]; [deleteView updateWithSiteName:site.name]; TPWeakSelf; __weak typeof(deleteView) _deletework = deleteView; deleteView.clickDelete = ^{ TPStrongSelf; if (!IsEmptyString(site.customerId)) { [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:site.customerId]; } [_deletework dismissAnimate]; [_self showWaitingToastView]; TPAbstractHandle *deleteHandle; if ([self isCentral]){ deleteHandle = [TPSDNControllerClient.currentInstance.siteConfigComponent deleteCentralSiteWithSiteKey:site.siteId]; }else{ deleteHandle = [TPSDNControllerClient.currentInstance.siteConfigComponent deleteSiteWithSiteKey:site.siteId]; } [deleteHandle addCompletionOnMainThread:^(TPHandleResult *result) { [_self dismissToastViewWithCompleteBlock:^{ NSMutableDictionary *daDict = [[NSMutableDictionary alloc] init]; NSTimeInterval launchID = [GoogleAnalyticsDefine getControllerLoginLaunchID]; daDict[kTPGALabelKeyLaunchID] = @(launchID); daDict[kTPGALabelKeyFunction] = TPCTGAActionDelete; daDict[TPCTGALabelSuccess] = @(result.success); // 大数据埋点 [GoogleAnalyticsDefine tpGASendEventWithCategory:kTPGACategorySiteManagement action:kTPGAActionManage dictionary:daDict]; if (result.success){ [_self requestInfo]; } else{ [_self showSDNFailedToastViewWithErrorCode:result.sdnControllerRequestResult.errorCode]; } }]; }]; [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:oldCustomerID]; [[TPSDNControllerClient currentInstance].maintenanceComponent updateControllerInfoName:oldCustomerName]; }; [deleteView showAnimate]; } } - (void)didClickBookmarkSiteWithSite:(DMSDNGlobalSiteSummary *)site { if ([[TPSDNControllerClient currentInstance].transport isKindOfClass:[TPSDNControllerTransport class]]) { TPSDNControllerTransport *transport = (TPSDNControllerTransport *)[TPSDNControllerClient currentInstance].transport; NSString *oldCustomerID = [transport.omadacId copy]; NSString *oldCustomerName = [[TPSDNControllerClient currentInstance].maintenanceComponent.controllerInfo.name copy]; if (!IsEmptyString(site.customerId)) { [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:site.customerId]; } TPWeakSelf; [[TPSDNControllerClient.currentInstance.mspSitesComponent requestBookmarkSiteWithSite:site] addCompletionOnMainThread:^(TPHandleResult *result) { TPStrongSelf; if (result.success){ // 请求site列表和favorite列表 [_self showSucceededToastViewWithTitle:gSDNGlobal.success]; [_self requestInfo]; } else{ [_self showSDNFailedToastViewWithErrorCode:result.sdnControllerRequestResult.errorCode]; } }]; [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:oldCustomerID]; [[TPSDNControllerClient currentInstance].maintenanceComponent updateControllerInfoName:oldCustomerName]; } } - (void)didClickUnbookmarkSiteWithSite:(DMSDNGlobalSiteSummary *)site { if ([[TPSDNControllerClient currentInstance].transport isKindOfClass:[TPSDNControllerTransport class]]) { TPSDNControllerTransport *transport = (TPSDNControllerTransport *)[TPSDNControllerClient currentInstance].transport; NSString *oldCustomerID = [transport.omadacId copy]; NSString *oldCustomerName = [[TPSDNControllerClient currentInstance].maintenanceComponent.controllerInfo.name copy]; if (!IsEmptyString(site.customerId)) { [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:site.customerId]; } TPWeakSelf; [[TPSDNControllerClient.currentInstance.mspSitesComponent requestUnbookmarkSiteWithSite:site] addCompletionOnMainThread:^(TPHandleResult *result) { TPStrongSelf; if (result.success){ // 请求site列表和favorite列表 [_self showSucceededToastViewWithTitle:gSDNGlobal.success]; [_self requestInfo]; } else{ [_self showSDNFailedToastViewWithErrorCode:result.sdnControllerRequestResult.errorCode]; } }]; [[TPSDNControllerClient currentInstance].transport updateLocalAccessBaseUrlWithOmadacId:oldCustomerID]; [[TPSDNControllerClient currentInstance].maintenanceComponent updateControllerInfoName:oldCustomerName]; } } - (void)didClickEditSiteWithDMSDNGlobalSiteSummary:(DMSDNGlobalSiteSummary *)siteInfo { SDNMoreAddOrEditSiteVC *vc = [[SDNMoreAddOrEditSiteVC alloc] initForEditModeWithDMSDNGlobalSiteSummary:[siteInfo copy] andIsInCentralPlatform: [self isCentral]]; // vc.hidesBottomBarWhenPushed = YES; vc.isAllowedReadSiteSetting = [self isSiteSettingReadonly] || [self isMSP]; [self.navigationController pushViewController:vc animated:YES]; } - (void)setIsInAnimation:(BOOL)isInAnimation{ _isInAnimation = isInAnimation; if (_isInAnimation){ self.view.userInteractionEnabled = NO; }else{ self.view.userInteractionEnabled = YES; } } - (void)showUserGuideWithBounds:(CGRect)maskBounds { self.currentBounds = maskBounds; CGRect absoluteFrame = [self.manageButton convertRect:self.manageButton.bounds toView:nil]; //按gui规范,高亮区域在按钮周围留一定间距 absoluteFrame.origin.x -= 8; absoluteFrame.size.width += 16; absoluteFrame.origin.y -= 6; absoluteFrame.size.height += 12; CGFloat guideBottomOffset = absoluteFrame.origin.y - 19; UIBezierPath *highlightPath = [UIBezierPath bezierPathWithRoundedRect:absoluteFrame cornerRadius:10]; // 高亮区域 UIImage *guideImage = TPISiPad ? [UIImage imageNamed:@"PadSiteManagementGuide"] : [UIImage imageNamed:@"SiteManagementGuide"]; [NewUserGuideTool sharedInstance].viewLayoutType = NewUserGuideLayoutTypeFromBottom; [NewUserGuideTool sharedInstance].guideBottomOffsetFromBottom = guideBottomOffset; [NewUserGuideTool sharedInstance].triangleYOffset = absoluteFrame.origin.y - 30; [NewUserGuideTool sharedInstance].triangleXOffset = absoluteFrame.origin.x + absoluteFrame.size.width * 0.5 - 11.5; [[NewUserGuideTool sharedInstance] setupMaskViewWithBounds:maskBounds andHighlightPathList:@[highlightPath]]; [[NewUserGuideTool sharedInstance] updateWithGuideImage:guideImage andGuideTitle:gMeshQuickSetup.sdnGlobalDashboardSiteManageMentTitle andGuideInfo:gMeshQuickSetup.userGuideSiteManagementTips andButtonName:gSDNGlobal.ok andIsExitButtonHidden:YES andIsTriangleHidden:NO]; self.isUserGuideShowing = YES; TPWeakSelf [NewUserGuideTool sharedInstance].didClickNextBtn = ^{ TPStrongSelf _self.isUserGuideShowing = NO; if ([_self.delegate respondsToSelector:@selector(switchSite_closeDropDownWithNeedSlow:)]) { [_self.delegate switchSite_closeDropDownWithNeedSlow:NO]; } [[TSSUserDefaults standardUserDefaults] setInteger:kUserGuideVersion forKey:TPSiteManagementUserGuideKey]; [[NewUserGuideTool sharedInstance] dismissGuide]; }; } @end
最新发布
12-03
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值