| | |
| | | } else { |
| | | instance = temp; |
| | | } |
| | | } catch{} |
| | | } catch{ |
| | | instance = new UserConfig { }; |
| | | instance.HideDeviceTypes.Add (SimpleControl.R.MyInternationalizationString.Projector); |
| | | instance.HideDeviceTypes.Add (SimpleControl.R.MyInternationalizationString.DoorLock); |
| | | instance.HideDeviceTypes.Add (SimpleControl.R.MyInternationalizationString.FreshAir); |
| | | instance.HideDeviceTypes.Add (SimpleControl.R.MyInternationalizationString.Sensor); |
| | | instance.HideDeviceTypes.Add (SimpleControl.R.MyInternationalizationString.Environmental); |
| | | instance.HideDeviceTypes.Add (SimpleControl.R.MyInternationalizationString.MusicModel); |
| | | } |
| | | } |
| | | return instance; |
| | | } |
| | |
| | | public Dictionary<string, string> RemoteDoorLockPasswordList = new Dictionary<string, string> (); |
| | | |
| | | //public string CountryCode = "CN"; |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public int SkinCode = 1; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 住宅列表 |
| | | /// </summary> |
| | | public List<RegionInfoRes> HomeLists = new List<RegionInfoRes> (); |
| | | |
| | | /// <summary> |
| | | /// 当前住宅 |
| | | /// </summary> |
| | | RegionInfoRes currentRegion = new RegionInfoRes (); |
| | | public RegionInfoRes CurrentRegion { |
| | | set { |
| | |
| | | CheckIfNeedGetMasterAccountToken (); |
| | | //切换住宅 设置本地加密Key |
| | | SetLocalEncryptKey (); |
| | | |
| | | |
| | | } |
| | | get { |
| | | if (currentRegion == null) { |
| | | currentRegion = new RegionInfoRes (); |
| | | } |
| | | return currentRegion; |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | public bool CheckHomeGateways () |
| | | /// <summary> |
| | | /// 网关详细信息 |
| | | /// </summary> |
| | | public HomeGatewayInfo HomeGateway; |
| | | /// <summary> |
| | | /// 检测住宅是否绑定了网关 |
| | | /// gatewayId 判空 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public bool CheckWhetherGatewayIdNotNull () |
| | | { |
| | | if (CurrentRegion != null && CurrentRegion.HomeGateways != null && CurrentRegion.HomeGateways.Count > 0) { |
| | | if (HomeGateway != null && !string.IsNullOrEmpty (HomeGateway.gatewayId)) { |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检测住宅是否绑定了网关 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public bool CheckHomeGatewaysNotEmpty () |
| | | { |
| | | if (CheckHomeGateways () && !string.IsNullOrEmpty (currentRegion.HomeGateways [0].GatewayUniqueId)) { |
| | | if (HomeGateway != null && !string.IsNullOrEmpty (HomeGateway.mac)) { |
| | | 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 = ""; |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string GatewayMAC { |
| | | get { |
| | | if (CheckHomeGatewaysNotEmpty ()) { |
| | | return currentRegion.HomeGateways [0].GatewayUniqueId; |
| | | return HomeGateway.mac; |
| | | } else { |
| | | return ""; |
| | | } |
| | | } |
| | | set { |
| | | if (CheckHomeGateways ()) { |
| | | currentRegion.HomeGateways [0].GatewayUniqueId = value; |
| | | if (CheckHomeGatewaysNotEmpty()) { |
| | | HomeGateway.mac = 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; |
| | | if (HomeGateway != null) { |
| | | HomeGateway.mac = value; |
| | | } else { |
| | | HomeGateway = new HomeGatewayInfo () { mac = value}; |
| | | } |
| | | } |
| | | } |
| | |
| | | mac.GatewayUniqueId = mGatewayRes.GatewayUniqueId; |
| | | mMacList.Add (mac); |
| | | } |
| | | currentRegion.HomeGateways = mMacList; |
| | | //HomeGateways = mMacList; |
| | | } |
| | | } |
| | | } catch { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public List<string> RometoUserInfoKeys = new List<string> (); |
| | | |
| | | //public List<string> RometoUserInfoKeys = new List<string> (); |
| | | |
| | | /// <summary> |
| | | /// 本地通信加密Key |
| | |
| | | /// 是否加密密码验证通过 |
| | | /// </summary> |
| | | public bool EncryptedPasswordCorrect = true; |
| | | |
| | | /// <summary> |
| | | /// 是否加密 |
| | | /// </summary> |
| | |
| | | { |
| | | if (bGetting) return; |
| | | |
| | | //2020-01-08 判断是否分享过来的住宅 |
| | | if (currentRegion != null && currentRegion.IsOthreShare) { |
| | | //MainPage.IsAdministrator = UserConfig.Instance.CurrentRegion.IsOthreShare; |
| | | //请求主账号token |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | try { |
| | | bGetting = true; |
| | | var requestObj = new GetSharedHomeApiControlObj () { |
| | | LoginAccessToken = MainPage.LoginUser.LoginTokenString, |
| | | MainAccountId = currentRegion.MainUserDistributedMark, |
| | | SharedHid = currentRegion.Id, |
| | | ////2020-01-08 判断是否分享过来的住宅 |
| | | //if (currentRegion != null && currentRegion.IsOthreShare) { |
| | | // //MainPage.IsAdministrator = UserConfig.Instance.CurrentRegion.IsOthreShare; |
| | | // //请求主账号token |
| | | // 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 { |
| | | // }; |
| | | // var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | // var revertObj = MainPage.RequestHttps (API.GetSharedHomeApiControl, requestJson); |
| | | // if (revertObj.StateCode.ToUpper () == StateCode.SUCCESS) { |
| | | // var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<MemberAdministratorResult> (revertObj.ResponseData.ToString ()); |
| | | // if (responseDataObj != null) { |
| | | // MasterAccountToken = responseDataObj.RequestToken; |
| | | // MasterAccountRequestBaseUrl = responseDataObj.RequestBaseUrl; |
| | | // } |
| | | // } |
| | | // } catch { |
| | | |
| | | } finally { |
| | | bGetting = false; |
| | | } |
| | | }); |
| | | } |
| | | // } finally { |
| | | // bGetting = false; |
| | | // } |
| | | // }); |
| | | //} |
| | | } |
| | | |
| | | } |