| | |
| | | |
| | | public List<RegionInfoRes> HomeLists = new List<RegionInfoRes> (); |
| | | |
| | | public RegionInfoRes CurrentRegion = new RegionInfoRes (); |
| | | RegionInfoRes currentRegion = new RegionInfoRes (); |
| | | public RegionInfoRes CurrentRegion { |
| | | set { |
| | | currentRegion = value; |
| | | CheckIfNeedGetMasterAccountToken (); |
| | | } |
| | | get { |
| | | return currentRegion; |
| | | } |
| | | |
| | | } |
| | | |
| | | public bool CheckHomeGateways () |
| | | { |
| | | if (CurrentRegion.HomeGateways != null && CurrentRegion.HomeGateways.Count > 0) { |
| | | if (CurrentRegion != null && CurrentRegion.HomeGateways != null && CurrentRegion.HomeGateways.Count > 0) { |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public List<GatewayRes> GatewayList = new List<GatewayRes> (); |
| | | public bool CheckHomeGatewaysNotEmpty () |
| | | { |
| | | if (CheckHomeGateways () && !string.IsNullOrEmpty (currentRegion.HomeGateways [0].GatewayUniqueId)) { |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public List<string> GatewayMACList { |
| | | //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 { |
| | | List<string> macList = new List<string> (); |
| | | foreach (var mac in GatewayList) { |
| | | macList.Add (mac.GatewayUniqueId); |
| | | } |
| | | return macList; |
| | | if (CheckHomeGatewaysNotEmpty ()) { |
| | | return currentRegion.HomeGateways [0].GatewayUniqueId; |
| | | } else { |
| | | return ""; |
| | | } |
| | | } |
| | | public string GatewayMAC = ""; |
| | | set { |
| | | if (CheckHomeGateways ()) { |
| | | currentRegion.HomeGateways [0].GatewayUniqueId = value; |
| | | } else { |
| | | if (currentRegion != null && currentRegion.HomeGateways == null) { |
| | | var mHomeGateways = new HomeGateways () { GatewayUniqueId = value }; |
| | | List<HomeGateways> HomeGateways = new List<HomeGateways> (); |
| | | HomeGateways.Add (mHomeGateways); |
| | | currentRegion.HomeGateways = HomeGateways; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public List<string> RometoUserInfoKeys = new List<string> (); |
| | | |
| | | public string MasterAccountToken = ""; |
| | | public string MasterAccountRequestBaseUrl = ""; |
| | | |
| | | //public static List<string> LocalFiles = IO.FileUtils.ReadFiles (); |
| | | /// <summary> |
| | | /// 获取控制分享项目(住宅)请求信息 |
| | | /// </summary> |
| | | /// <param name="mMainAccountId"></param> |
| | | /// <param name="mSharedHid"></param> |
| | | public void CheckIfNeedGetMasterAccountToken () |
| | | { |
| | | //2020-01-08 判断是否分享过来的住宅 |
| | | if (CurrentRegion != null && CurrentRegion.IsOthreShare) { |
| | | //MainPage.IsAdministrator = UserConfig.Instance.CurrentRegion.IsOthreShare; |
| | | //请求主账号token |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | try { |
| | | //var mMainAccountId = UserConfig.Instance.CurrentRegion.MainUserDistributedMark; |
| | | //var mSharedHid = UserConfig.Instance.CurrentRegion.Id; |
| | | var requestObj = new GetSharedHomeApiControlObj () { |
| | | LoginAccessToken = MainPage.LoginUser.LoginTokenString, |
| | | MainAccountId = UserConfig.Instance.CurrentRegion.MainUserDistributedMark, |
| | | SharedHid = UserConfig.Instance.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 { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |