From ac2ee45fadc64fe840bbba6264df3ca4622adb15 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期日, 12 一月 2020 16:06:13 +0800 Subject: [PATCH] 2020-01-12 1.优化修改。 --- Crabtree/SmartHome/HDL/Operation/UserConfig.cs | 162 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 149 insertions(+), 13 deletions(-) diff --git a/Crabtree/SmartHome/HDL/Operation/UserConfig.cs b/Crabtree/SmartHome/HDL/Operation/UserConfig.cs index d1bb9e7..93db11b 100644 --- a/Crabtree/SmartHome/HDL/Operation/UserConfig.cs +++ b/Crabtree/SmartHome/HDL/Operation/UserConfig.cs @@ -124,7 +124,7 @@ } public string VersionNumber { - get { return MainPage.CodeIDString; } + get { return MainPage.RequestVersion; } } public string TipVersionBackup = string.Empty; @@ -149,24 +149,160 @@ public List<RegionInfoRes> HomeLists = new List<RegionInfoRes> (); - public RegionInfoRes CurrentRegion = new RegionInfoRes (); - - public List<GatewayRes> GatewayList = new List<GatewayRes> (); - - public List<string> GatewayMACList { + RegionInfoRes currentRegion = new RegionInfoRes (); + public RegionInfoRes CurrentRegion { + set { + currentRegion = value; + CheckIfNeedGetMasterAccountToken (); + } get { - List<string> macList = new List<string> (); - foreach (var mac in GatewayList) { - macList.Add (mac.MAC); + if (currentRegion == null) { + currentRegion = new RegionInfoRes (); } - return macList; + return currentRegion; + + } + + } + + public bool CheckHomeGateways () + { + if (CurrentRegion != null && CurrentRegion.HomeGateways != null && CurrentRegion.HomeGateways.Count > 0) { + return true; + } else { + return false; } } - public string GatewayMAC = ""; + + public bool CheckHomeGatewaysNotEmpty () + { + if (CheckHomeGateways () && !string.IsNullOrEmpty (currentRegion.HomeGateways [0].GatewayUniqueId)) { + return true; + } else { + return false; + } + } + + public bool CheckThisHomeGatewaysNotEmpty (RegionInfoRes mRegionInfoRes) + { + if (mRegionInfoRes != null && mRegionInfoRes.HomeGateways != null && mRegionInfoRes.HomeGateways.Count > 0 && !string.IsNullOrEmpty (mRegionInfoRes.HomeGateways [0].GatewayUniqueId)) { + return true; + } else { + return false; + } + } + + //public List<GatewayRes> GatewayList = new List<GatewayRes> (); + + //public List<string> GatewayMACList { + // get { + // List<string> macList = new List<string> (); + // foreach (var mac in GatewayList) { + // macList.Add (mac.GatewayUniqueId); + // } + // return macList; + // } + //} + //public string GatewayMAC = ""; + + public string GatewayMAC { + get { + if (CheckHomeGatewaysNotEmpty ()) { + return currentRegion.HomeGateways [0].GatewayUniqueId; + } else { + return ""; + } + } + set { + if (CheckHomeGateways ()) { + currentRegion.HomeGateways [0].GatewayUniqueId = value; + } else { + //2020-01-11 + if (currentRegion != null) { + var mHomeGateways = new HomeGateways () { GatewayUniqueId = value }; + var mList = new List<HomeGateways> (); + mList.Add (mHomeGateways); + currentRegion.HomeGateways = mList; + } + } + } + + } + + /// <summary> + /// 鏇存柊璁剧疆褰撳墠浣忓畢缃戝叧 + /// 2020-01-11 + /// </summary> + /// <param name="mGatewayDataList"></param> + public void SetNowHomeGateways (List<GatewayRes> mGatewayDataList) { + try { + if (currentRegion != null) { + if (mGatewayDataList != null && mGatewayDataList.Count > 0) { + var mMacList = new List<HomeGateways> (); + foreach (var mGatewayRes in mGatewayDataList) { + var mac = new HomeGateways (); + mac.GatewayUniqueId = mGatewayRes.GatewayUniqueId; + mMacList.Add (mac); + } + currentRegion.HomeGateways = mMacList; + } + } + } catch { + + } + } + + public List<string> RometoUserInfoKeys = new List<string> (); + public string MasterAccountToken = ""; + public string MasterAccountRequestBaseUrl = ""; + /// <summary> + /// 鏄惁鑾峰彇涓� + /// 2020-01-11 + /// </summary> + bool bGetting = false; //public static List<string> LocalFiles = IO.FileUtils.ReadFiles (); + /// <summary> + /// 鑾峰彇鎺у埗鍒嗕韩椤圭洰(浣忓畢)璇锋眰淇℃伅 + /// </summary> + /// <param name="mMainAccountId"></param> + /// <param name="mSharedHid"></param> + public void CheckIfNeedGetMasterAccountToken () + { + if (bGetting) return; - } -} \ No newline at end of file + //2020-01-08 鍒ゆ柇鏄惁鍒嗕韩杩囨潵鐨勪綇瀹� + if (currentRegion != null && currentRegion.IsOthreShare) { + //MainPage.IsAdministrator = UserConfig.Instance.CurrentRegion.IsOthreShare; + //璇锋眰涓昏处鍙穞oken + System.Threading.Tasks.Task.Run (() => { + try { + bGetting = true; + var requestObj = new GetSharedHomeApiControlObj () { + LoginAccessToken = MainPage.LoginUser.LoginTokenString, + MainAccountId = currentRegion.MainUserDistributedMark, + SharedHid = currentRegion.Id, + + }; + var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); + var revertObj = MainPage.RequestHttps (API.GetSharedHomeApiControl, requestJson); + if (revertObj.StateCode.ToUpper () == "SUCCESS") { + var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<MemberAdministratorResult> (revertObj.ResponseData.ToString ()); + if (responseDataObj != null) { + MasterAccountToken = responseDataObj.RequestToken; + MasterAccountRequestBaseUrl = responseDataObj.RequestBaseUrl; + } + } + } catch { + + } finally { + bGetting = false; + } + }); + } + } + + } + } \ No newline at end of file -- Gitblit v1.8.0