From 5a5a2b696866f947b6025d26c3302e8ffef46435 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期一, 11 一月 2021 16:11:20 +0800 Subject: [PATCH] 2021-01-11 1.更新MQTT连接和本地搜索网关方法。2.子账号相关接口完善 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs | 70 ++++++++++++++++++++++++++++++---- 1 files changed, 61 insertions(+), 9 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs index 1a363c3..49afd5a 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs @@ -83,10 +83,11 @@ etRemark.EditorEnterAction += (obj) => { Application.HideSoftInput (); }; - if (MainPage.LoginUser.AccountType == 1) { - etRemark.Enable = false; - etRemark.BorderWidth = 0; - } + + //if (MainPage.LoginUser.AccountType == 1) { + // etRemark.Enable = false; + // etRemark.BorderWidth = 0; + //} var BottomView = new FrameLayout () { Y = Application.GetRealHeight (400 - 88), @@ -283,6 +284,8 @@ }; EventHandler<MouseEventArgs> eHandler = (sender, e) => { + //璺宠浆涔嬪墠鍏堢粦瀹欰PP + MainPage.Loading.Start ("Please wait..."); bool needHide = true; new System.Threading.Thread (() => { @@ -299,8 +302,14 @@ bool goNext = false; System.Threading.Tasks.Task.Run (() => { try { - + // goNext = CheckIfGoNext (common); + if (goNext) { + //鍏堥噸缃� + goNext = false; + //缃戝叧鐗堟湰绗﹀悎瑕佹眰锛岀户缁垽鏂槸鍚︾粦瀹氱綉鍏虫垚鍔�,缁戝畾鎴愬姛浜嗘墠鑳借繘琛屼笅涓�姝ヨ烦杞澶囨悳绱㈤〉闈� + goNext = CheckIfBindGatewaySuccess (common); + } } catch (Exception ex) { Utlis.WriteLine (ex.Message); @@ -313,6 +322,7 @@ inThisView = false; if (inView != null) { Utlis.WriteLine ("inView != null"); + //璺宠浆璁惧鎼滅储椤甸潰 var deviceListView = new GuideSettingGateway (common); (inView.Parent as PageLayout).AddChidren (deviceListView); deviceListView.ShowPage (); @@ -341,7 +351,49 @@ } } + /// <summary> + /// 妫�娴嬫槸鍚︾粦瀹氱綉鍏虫垚鍔� + /// </summary> + /// <returns></returns> + static bool CheckIfBindGatewaySuccess (GatewayBase gatewayBase) + { + try { + if (UserConfig.Instance.CheckHomeGatewaysNotEmpty ()) { + //涔嬪墠缁戝畾杩囩綉鍏筹紝骞朵笖鍜屽綋鍓嶆悳绱㈠埌鍒扮綉鍏充竴鑷�,瀛愮綉鍙疯澶囧彿閮借涓�鑷� + if (UserConfig.Instance.HomeGateway.mac.ToUpper () == gatewayBase.MAC.Replace (".", "").ToUpper () + && UserConfig.Instance.HomeGateway.subnetId == gatewayBase.SubnetID + && UserConfig.Instance.HomeGateway.deviceId == gatewayBase.DeviceID + ) { + return true; + } + } + var gatewayMAC = gatewayBase.MAC.Replace (".", ""); + //閲嶆柊缁戝畾 + var bindGatewayObj = new BindGatewayObj () { + homeId = UserConfig.Instance.CurrentRegion.Id, + subnetId = gatewayBase.SubnetID, + deviceId = gatewayBase.DeviceID, + gatewayType = GatewayType.BUSUDPGATEWAY.ToString (), + mac = gatewayMAC + }; + var revertObj = HttpServerRequest.Current.BindGateway (bindGatewayObj); + if (revertObj.Code == StateCode.SUCCESS) { + var homeGatewayInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<HomeGatewayInfo> (revertObj.Data.ToString ()); + if (homeGatewayInfo != null && !string.IsNullOrEmpty (homeGatewayInfo.gatewayId)) { + //缁戝畾缃戝叧鎴愬姛锛屽苟涓旀垚鍔熻幏鍙栧埌鏂扮粦瀹氱殑gatewayId + UserConfig.Instance.HomeGateway = homeGatewayInfo; + UserConfig.Instance.SaveUserConfig (); + return true; + } + } else { + IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code); + } + } catch { + Utlis.WriteLine ("缁戝畾缃戝叧澶辫触"); + } + return false; + } static bool inThisView = false; @@ -353,7 +405,7 @@ void SearchGatewayList () { if (UserConfig.Instance.internetStatus == 0 || UserConfig.Instance.internetStatus == 1) { - Alert checkInternetAlert = new Alert ("", "Your phone in not connected to WIFI network, please connet", "Close", "Search again"); + Alert checkInternetAlert = new Alert ("", ErrorCode.NotConnectedToWIFI, "Close", "Search again"); checkInternetAlert.Show (); @@ -445,7 +497,7 @@ } else { if (this != null && this.Parent != null) { if (inThisView) {// this.Parent.GetChildren (this.Parent.ChildrenCount - 1) == this) { - Alert confirmAlert1 = new Alert ("", "If not all the gateways are in the list,you can search again.", "Close", "Search again"); + Alert confirmAlert1 = new Alert ("", ErrorCode.IfAllTheGatewaysAreNotInTheList, "Close", "Search again"); confirmAlert1.Show (); confirmAlert1.ResultEventHandler += (ddf, ddd) => { @@ -472,7 +524,7 @@ if (UserConfig.Instance.IsLocalEncrypt) { //瀵嗙爜妫�楠屾纭� if (UserConfig.Instance.EncryptedPasswordCorrect) { - Alert confirmAlert = new Alert ("", "Please make sure gateway is powered up and comect to WiFi router.", "Close", "Search again"); + Alert confirmAlert = new Alert ("", ErrorCode.MakeSureGatewayIsPoweredUp, "Close", "Search again"); confirmAlert.Show (); confirmAlert.ResultEventHandler += (ddf, ddd) => { MainPage.Loading.Hide (); @@ -492,7 +544,7 @@ } } else { - Alert confirmAlert = new Alert ("", "Please make sure gateway is powered up and comect to WiFi router.", "Close", "Search again"); + Alert confirmAlert = new Alert ("", ErrorCode.MakeSureGatewayIsPoweredUp, "Close", "Search again"); confirmAlert.Show (); confirmAlert.ResultEventHandler += (ddf, ddd) => { MainPage.Loading.Hide (); -- Gitblit v1.8.0