JLChen
2021-01-11 5a5a2b696866f947b6025d26c3302e8ffef46435
Crabtree/SmartHome/HDL/Operation/UserConfig.cs
@@ -167,9 +167,12 @@
        public RegionInfoRes CurrentRegion {
            set {
                currentRegion = value;
                CheckIfNeedGetMasterAccountToken ();
                //CheckIfNeedGetMasterAccountToken ();
                //切换住宅 设置本地加密Key
                SetLocalEncryptKey ();
                //清空之前网关的信息,重新获取
                HomeGateway = null;
                GetHomeGatewayList ();
            }
            get {
                if (currentRegion == null) {
@@ -179,10 +182,57 @@
            }
        }
        #region HomeGateway
        /// <summary>
        /// 是否获取中
        /// 2020-01-11
        /// </summary>
        bool bGettingMac = false;
        //public static List<string> LocalFiles = IO.FileUtils.ReadFiles ();
        /// <summary>
        /// 检查是否需要获取控制分享项目(住宅)请求信息
        /// </summary>
        /// <param name="mMainAccountId"></param>
        /// <param name="mSharedHid"></param>
        public void GetHomeGatewayList ()
        {
            //System.Threading.Tasks.Task.Run (() => {
            //if (bGettingMac) return;
            HttpServerRequest.Current.GetHomeGatewayList ();
            //});
        }
        /// <summary>
        /// 网关详细信息
        /// </summary>
        public HomeGatewayInfo HomeGateway;
        /// <summary>
        /// 是否允许远程控制
        /// </summary>
        public bool AllowRemoteControl {
            get {
                if (HomeIsOtherShare) {
                    //等于0是允许远程控制
                    return UserConfig.Instance.CurrentRegion.isRemoteControl;
                } else {
                    //住宅是自己本人的允许控制
                    return true;
                }
            }
        }
        /// <summary>
        /// 是否是管理员权限(变更了,成员的时候,这个也为ture。为什么会声明这样变量,因为有些接口必须使用原来的Token)
        /// </summary>
        public bool HomeIsOtherShare {
            get {
                if (UserConfig.Instance == null || UserConfig.Instance.CurrentRegion == null) {
                    return false;
                } else {
                    return UserConfig.Instance.CurrentRegion.IsOthreShare;
                }
            }
        }
        /// <summary>
        /// 检测住宅是否绑定了网关
        /// gatewayId 判空
@@ -236,28 +286,30 @@
        }
        /// <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);
                        }
                        //HomeGateways = mMacList;
                    }
                }
            } catch {
        #endregion
            }
        }
        ///// <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);
        //                }
        //                //HomeGateways = mMacList;
        //            }
        //        }
        //    } catch {
        //    }
        //}
        //public List<string> RometoUserInfoKeys = new List<string> ();
@@ -265,7 +317,6 @@
        /// 本地通信加密Key
        /// </summary>
        public string LocalEncryptKey = string.Empty;
        /// <summary>
        /// 是否加密密码验证通过