lss
2020-06-12 9c16d3614d9b88c637f967518a329f239fcd3aaf
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
@@ -33,7 +33,7 @@
            if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false)
            {
                //不管结果怎么样,如果调用了这个函数,需要重头获取Token,所以必须返回失败
                await ReInitUserAccoutInfo();
                await ReInitUserAccoutInfo(listNotShowError);
                return false;
            }
            //获取接口的连接模式
@@ -74,7 +74,7 @@
            if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false)
            {
                //不管结果怎么样,如果调用了这个函数,需要重头获取Token,所以必须返回失败
                await ReInitUserAccoutInfo();
                await ReInitUserAccoutInfo(listNotShowError);
                return "Error";
            }
@@ -95,6 +95,10 @@
                }
            }
            var revertObj = JsonConvert.DeserializeObject<ResponsePack>(Encoding.UTF8.GetString(byteData));
            if (revertObj == null)
            {
                return "Error";
            }
            return revertObj.StateCode;
        }
@@ -115,7 +119,7 @@
            if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false)
            {
                //不管结果怎么样,如果调用了这个函数,需要重头获取Token,所以必须返回失败
                await ReInitUserAccoutInfo();
                await ReInitUserAccoutInfo(listNotShowError);
                return null;
            }
            //获取接口的连接模式
@@ -143,7 +147,7 @@
            }
            if (revertObj == null || revertObj.ResponseData == null)
            {
                return string.Empty;
                return null;
            }
            return revertObj.ResponseData.ToString();
        }
@@ -165,7 +169,7 @@
            if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false)
            {
                //不管结果怎么样,如果调用了这个函数,需要重头获取Token,所以必须返回失败
                await ReInitUserAccoutInfo();
                await ReInitUserAccoutInfo(listNotShowError);
                return null;
            }
            //获取接口的连接模式
@@ -423,87 +427,73 @@
                    int index = UserCenterResourse.listActionFormId.IndexOf(UserCenterResourse.NowActionFormID) - 1;
                    //初始值
                    UserCenterResourse.NowActionFormID = string.Empty;
                    var actionForm = UserView.HomePage.Instance.GetChildren(UserView.HomePage.Instance.ChildrenCount - 1);
                    if (index >= 0)
                    {
                        var actionForm = UserView.HomePage.Instance.GetChildren(UserView.HomePage.Instance.ChildrenCount - 1);
                        if (actionForm != null && actionForm is CommonFormBase)
                        {
                            //设置当前激活的画面ID
                            UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
                            //追加条件一:关闭的界面为EditorCommonForm的时候才处理
                            if ((form is EditorCommonForm) && UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
                            string formId = ((CommonFormBase)actionForm).FormID;
                            //对应徐梅继承了底层,但是不初始化数据的问题
                            if (UserCenterResourse.listActionFormId.Contains(formId) == true)
                            {
                                try
                                {
                                    EditorCommonForm Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID] as EditorCommonForm;
                                    if (Myform != null)
                                    {
                                        //重置左滑使能
                                        Myform.ScrollEnabled = Myform.ScrollEnabled;
                                        //触发界面再次激活的事件
                                        int value = Myform.FormActionAgainEvent();
                                        if (value == 1)
                                        {
                                            //Log出力
                                            HdlLogLogic.Current.WriteLog(1, Myform.FormID + " 被激活");
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    //出现未知错误,数据丢失
                                    var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
                                    alert.Show();
                                    //Log出力
                                    HdlLogLogic.Current.WriteLog(ex);
                                }
                                //调用界面重新激活的函数
                                CallFormActionAgainEvent(form, index);
                            }
                        }
                        else if (actionForm != null && actionForm is UserView.UserPage)
                        {
                            //这里它已经退到主页了,如果它包含个人中心主页的话
                            if (UserCenterResourse.listActionFormId.Contains("UserMainForm") == true)
                            {
                                //设置当前激活的画面ID
                                UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
                                //追加条件一:关闭的界面为EditorCommonForm的时候才处理
                                if ((form is EditorCommonForm) && UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
                                {
                                    try
                                    {
                                        EditorCommonForm Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID] as EditorCommonForm;
                                        if (Myform != null)
                                        {
                                            //重置左滑使能
                                            Myform.ScrollEnabled = Myform.ScrollEnabled;
                                            //触发界面再次激活的事件
                                            int value = Myform.FormActionAgainEvent();
                                            if (value == 1)
                                            {
                                                //Log出力
                                                HdlLogLogic.Current.WriteLog(1, Myform.FormID + " 被激活");
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        //出现未知错误,数据丢失
                                        var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
                                        alert.Show();
                                        //Log出力
                                        HdlLogLogic.Current.WriteLog(ex);
                                    }
                                }
                            }
                        }
                    }
                    else if (actionForm != null && actionForm is UserView.UserPage)
                    {
                        //这里它已经退到主页了
                        var nowForm = UserView.UserPage.Instance.GetNowActionForm();
                        nowForm?.FormActionAgainEvent();
                    }
                }
                //移除ID
                UserCenterResourse.listActionFormId.Remove(UserCenterResourse.DicActionForm[formName].FormID);
                //移除画面
                UserCenterResourse.DicActionForm.Remove(formName);
            }
        }
        /// <summary>
        /// 调用界面重新激活的函数
        /// </summary>
        /// <param name="form">关闭的界面对象</param>
        /// <param name="index">当前需要重新激活界面的索引</param>
        private static void CallFormActionAgainEvent(CommonFormBase form, int index)
        {
            //设置当前激活的画面ID
            UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
            //追加条件一:关闭的界面为EditorCommonForm的时候才处理
            if ((form is EditorCommonForm) && UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
            {
                try
                {
                    var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID] as EditorCommonForm;
                    //点击很快时,这个东西会是null,但是DicActionForm里面不是null,不知道为什么
                    if (Myform != null)
                    {
                        //重置左滑使能
                        Myform.ScrollEnabled = Myform.ScrollEnabled;
                        //触发界面再次激活的事件
                        int value = Myform.FormActionAgainEvent();
                        if (value == 1)
                        {
                            //Log出力
                            HdlLogLogic.Current.WriteLog(1, Myform.FormID + " 被激活");
                        }
                    }
                }
                catch (Exception ex)
                {
                    //出现未知错误,数据丢失
                    //var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
                    //alert.Show();
                    //Log出力
                    HdlLogLogic.Current.WriteLog(ex, "界面重新激活异常 " + UserCenterResourse.NowActionFormID);
                }
            }
        }
@@ -554,7 +544,7 @@
            //需优先于刷新房间,同步云端的网关id,如果本地拥有云端不存在的id,则表示应该被换绑了,直接删除
            HdlGatewayLogic.Current.SynchronizeDbGateway();
            //从本地重新加载全部的房间
            Common.Room.RefreshAllRoomByLocation();
            HdlRoomLogic.Current.RefreshAllRoomByLocation();
        }
        /// <summary>
@@ -570,7 +560,7 @@
            double Longitude = Config.Instance.Home.Longitude;
            double Latitude = Config.Instance.Home.Latitude;
            //还原住宅对象
            Config.Instance.Home = House.GetHouseByHouseId(Config.Instance.Home.Id);
            Config.Instance.Home = HdlResidenceLogic.Current.GetHouseByHouseId(Config.Instance.Home.Id);
            Config.Instance.Home.IsOthreShare = isOthreShare;
            Config.Instance.Home.AccountType = accountType;
            Config.Instance.Home.MainUserDistributedMark = mainMark;
@@ -646,7 +636,29 @@
        /// <param name="noticeDb">是否通知云端</param>
        public static void ReLoginAgain(string account = "", bool noticeDb = true)
        {
            UserCenterResourse.Option.OldAccountId = string.Empty;
            if (Config.Instance.Home.IsVirtually == true)
            {
                //如果是虚拟住宅
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //设定一个时间
                    Config.Instance.LoginDateTime = new DateTime(1970, 1, 1);
                    //清空当前住宅id
                    Config.Instance.HomeId = string.Empty;
                    Config.Instance.Save();
                    //收起左菜单
                    CommonPage.Instance.CloseLeftMenu();
                    //关闭所有打开了的界面
                    CloseAllOpenForm();
                    //显示登陆画面
                    var formLogin = new Login.AccountLoginForm();
                    Shared.Common.CommonPage.Instance.AddChidren(formLogin);
                    formLogin.ShowForm(account);
                });
                return;
            }
            UserCenterResourse.AccountOption.OldAccountId = string.Empty;
            //关闭所有接收
            HdlGatewayReceiveLogic.Current.RemoveAllEvent();
            //清除升级列表
@@ -655,7 +667,7 @@
            HdlThreadLogic.Current.RunThread(async () =>
            {
                //检测APP是否能够退出
                while (UserCenterResourse.Option.AppCanSignout == false)
                while (UserCenterResourse.AccountOption.AppCanSignout == false)
                {
                    await Task.Delay(500);
                }
@@ -664,24 +676,26 @@
                Config.Instance.Save();
                //清空当前住宅id
                Shared.Common.Config.Instance.HomeId = string.Empty;
                Config.Instance.HomeId = string.Empty;
                HdlGatewayLogic.Current.ClearAllRealGateway();
                try
                //断开远程Mqtt连接
                HdlThreadLogic.Current.RunThread(async () =>
                {
                    //断开远程Mqtt连接
                    ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
                }
                catch { }
                    await ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
                }, ShowErrorMode.NO);
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //收起左菜单
                    CommonPage.Instance.CloseLeftMenu();
                    //关闭所有打开了的界面
                    CloseAllOpenForm();
                    //显示登陆画面
                    var formLogin = new Shared.Phone.Device.Account.AccountLogin();
                    var formLogin = new Login.AccountLoginForm();
                    Shared.Common.CommonPage.Instance.AddChidren(formLogin);
                    formLogin.Show(account);
                    formLogin.ShowForm(account);
                });
                if (noticeDb == true)
@@ -696,11 +710,18 @@
        /// 关闭所有打开了的界面
        /// </summary>
        /// <param name="tagetFrom">目标界面,如果指定了的话,则关闭目标界面上层的全部界面(它自身不关闭)</param>
        public static void CloseAllOpenForm(string tagetFrom = "")
        public static void CloseAllOpenForm(string tagetFrom = null)
        {
            while (UserView.HomePage.Instance.ChildrenCount > 0)
            {
                var view = UserView.HomePage.Instance.GetChildren(UserView.HomePage.Instance.ChildrenCount - 1);
                //(因底层控件修改了, 父控件移除时, 不触发子控件的移除事件)
                if (view is ViewGroup)
                {
                    //关闭加载在ViewGroup里面的自定义界面Form
                    CloseViewGroupChildren((ViewGroup)view);
                }
                if (view is CommonFormBase)
                {
                    if (((CommonFormBase)view).FormID == tagetFrom)
@@ -721,38 +742,20 @@
            }
        }
        #endregion
        #region ■ 子控件的Y轴坐标____________________
        /// <summary>
        /// 指定位置类型获取Rowlayout的子控件的Y轴坐标(请确保子控件不大于父容器)
        /// 关闭加载在ViewGroup里面的自定义界面Form(因底层控件修改了,父控件移除时,不触发子控件的移除事件)
        /// </summary>
        /// <param name="fatherCtrHeight">父控件的真实高度</param>
        /// <param name="ctrHeight">子控件的真实高度</param>
        /// <param name="alignment">位置对齐方式</param>
        /// <param name="Space">上下间的空白间距,省略时,取行控件共通变量的值。设置为-1时,不计算空白间距</param>
        /// <returns></returns>
        public static int GetControlChidrenYaxis(int fatherCtrHeight, int ctrHeight, UViewAlignment alignment, int Space = 0)
        /// <param name="group"></param>
        private static void CloseViewGroupChildren(ViewGroup group)
        {
            if (Space < 0)
            for (int i = 0; i < group.ChildrenCount; i++)
            {
                //不计算间距值
                Space = 0;
            }
            if (alignment == UViewAlignment.Center)
            {
                return fatherCtrHeight / 2 - ctrHeight / 2;
            }
            else if (alignment == UViewAlignment.Top)
            {
                return (fatherCtrHeight / 2 - Space / 2) / 2 - ctrHeight / 2;
            }
            else
            {
                int top = fatherCtrHeight / 2 + Space / 2;
                return top + (fatherCtrHeight - top) / 2 - ctrHeight / 2;
                var view = group.GetChildren(i);
                if (view is CommonFormBase)
                {
                    ((CommonFormBase)view).CloseForm();
                    i--;
                }
            }
        }
@@ -801,13 +804,24 @@
            string errorMsgBase = strResultData;
            if (errorMsgBase == null)
            {
                Type myType = resultData.GetType();
                object errorObj = myType.InvokeMember("errorMessageBase", System.Reflection.BindingFlags.GetField, null, resultData, null);
                if (errorObj == null)
                if (resultData is ReceiptGatewayResult)
                {
                    return errorMsg;
                    errorMsgBase = string.Empty;
                    if (((ReceiptGatewayResult)resultData).ErrorMsgDiv == 0)
                    {
                        errorMsgBase = "回复超时";
                    }
                }
                errorMsgBase = errorObj.ToString();
                else
                {
                    Type myType = resultData.GetType();
                    object errorObj = myType.InvokeMember("errorMessageBase", System.Reflection.BindingFlags.GetField, null, resultData, null);
                    if (errorObj == null)
                    {
                        return errorMsg;
                    }
                    errorMsgBase = errorObj.ToString();
                }
            }
            if (errorMsgBase.Contains("回复超时") == false)
@@ -839,44 +853,48 @@
        /// <returns></returns>
        public async static Task<bool> InitUserCenterMenmoryAndThread(bool ShowPrompted = true)
        {
            //调用这个方法,都需要重新刷新主页
            UserView.UserPage.Instance.RefreshForm = true;
            //如果是虚拟住宅
            if (Config.Instance.Home.IsVirtually == true)
            {
                //初始化虚拟住宅的个人中心的数据(切换住宅使用)
                InitUserCenterMenmoryByVirtualHome();
                return true;
            }
            //APP缓存加载开始
            UserCenterResourse.Option.AppCanSignout = false;
            //还原远程连接变量
            UserCenterResourse.AccountOption.AppCanSignout = false;
            //还原远程连接权限变量
            ZigBee.Device.ZbGateway.AllowRemoteCtrl = true;
            //只有在住宅ID不一样的时候才做这个操作
            if (Common.Config.Instance.HomeId != UserCenterResourse.Option.OldHomeStringId
                || Common.Config.Instance.Account != UserCenterResourse.Option.OldAccountId)
            if (Common.Config.Instance.HomeId != UserCenterResourse.AccountOption.OldHomeStringId
                || Common.Config.Instance.Account != UserCenterResourse.AccountOption.OldAccountId)
            {
                try
                //断开远程Mqtt连接
                HdlThreadLogic.Current.RunThread(async () =>
                {
                    //断开远程Mqtt连接
                    await ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
                }
                catch { }
                }, ShowErrorMode.NO);
                //消息记录重新读取及检测
                ControlCommonResourse.ReadMessageAgain = true;
                ControlCommonResourse.HadNewMessage = false;
                HdlThreadLogic.Current.RunMain(() =>
                {
                    for (int i = 0; i < ControlCommonResourse.listMessageManaContr.Count; i++)
                    {
                        //显示角标特效
                        ControlCommonResourse.listMessageManaContr[i].IsSelected = false;
                    }
                });
                //清空所有成员缓存
                ClearAllMemberMemory();
                //加载账号配置信息
                var optionInfo = UserCenterResourse.Option.Load();
                UserCenterResourse.Option = optionInfo;
                var optionInfo = UserCenterResourse.AccountOption.Load();
                UserCenterResourse.AccountOption = optionInfo;
                //变更根用户图片目录路径
                UserCenterResourse.Option.UserPictruePath = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, DirNameResourse.UserPictrueDirectory);
                UserCenterResourse.AccountOption.UserPictruePath = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, DirNameResourse.UserPictrueDirectory);
                //加载住宅配置信息
                UserCenterResourse.ResidenceOption = UserCenterResourse.ResidenceOption.Load();
                //初始化登陆账号的信息
                var hadNet = await InitUserAccoutInfo();
                var hadNet = await InitUserAccoutInfo(true);
                //如果有网络的话
                if (hadNet == true)
                if (hadNet == 1)
                {
                    //重新发送命令去绑定断网情况下备份的网关
                    HdlGatewayLogic.Current.ResetComandToBindBackupGateway();
@@ -898,12 +916,12 @@
                //保存用户的登陆信息到本地
                SaveUserInformationToLocation();
                UserCenterResourse.Option.OldHomeStringId = Common.Config.Instance.HomeId;
                UserCenterResourse.Option.OldAccountId = Common.Config.Instance.Account;
                UserCenterResourse.AccountOption.OldHomeStringId = Common.Config.Instance.HomeId;
                UserCenterResourse.AccountOption.OldAccountId = Common.Config.Instance.Account;
                //同步数据(二次调用没关系)
                int result = -1;
                if (hadNet == true)
                if (hadNet == 1)
                {
                    result = await HdlAutoBackupLogic.SynchronizeDbAutoBackupData();
                }
@@ -911,16 +929,16 @@
                //初始化本地的网关信息
                HdlGatewayLogic.Current.ReFreshByLocal();
                //初始化本地的设备信息
                Common.LocalDevice.Current.ReFreshByLocal();
                LocalDevice.Current.ReFreshByLocal();
                if (hadNet == true)
                //初始化房间(郭雪城那边不做处理,需要这里特殊执行一步)
                HdlRoomLogic.Current.RefreshAllRoomByLocation();
                if (hadNet == 1)
                {
                    //同步云端的网关id,如果本地拥有云端不存在的id,则表示应该被换绑了,直接删除
                    HdlGatewayLogic.Current.SynchronizeDbGateway();
                }
                //初始化房间(郭雪城那边不做处理,需要这里特殊执行一步)
                Room.RefreshAllRoomByLocation();
                //刷新APP前一次选择的网关ID(可以反复调用,需要在网关初始化完了之后才能调用)
                HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId();
@@ -928,16 +946,61 @@
                //0:已经同步过,不需要同步,这个时候需要提示备份
                if (result == 0 && ShowPrompted == true)
                {
                    //开启自动备份提示
                    //开启自动备份
                    HdlAutoBackupLogic.ShowAutoBackupPromptedForm();
                }
                //显示引导界面
                ShowGuideForm(result);
            }
            //APP缓存加载完成
            UserCenterResourse.Option.AppCanSignout = true;
            UserCenterResourse.AccountOption.AppCanSignout = true;
            return true;
        }
        /// <summary>
        /// 初始化虚拟住宅的个人中心的数据(切换住宅使用)
        /// </summary>
        private static void InitUserCenterMenmoryByVirtualHome()
        {
            UserCenterResourse.AccountOption.OldHomeStringId = Common.Config.Instance.Home.Id;
            //清空所有成员缓存
            ClearAllMemberMemory();
            //预创建个人中心全部的文件夹
            CreatAllUserCenterDirectory();
            //关闭所有接收
            HdlGatewayReceiveLogic.Current.RemoveAllEvent();
            //初始化本地的网关信息
            HdlGatewayLogic.Current.ReFreshByLocal();
            //初始化本地的设备信息
            Common.LocalDevice.Current.ReFreshByLocal();
            //初始化房间(郭雪城那边不做处理,需要这里特殊执行一步)
            HdlRoomLogic.Current.RefreshAllRoomByLocation();
            //刷新左边刷新房间视图列表
            HdlRoomLogic.Current.RefreshRoomListView();
        }
        /// <summary>
        /// 清空所有成员缓存
        /// </summary>
        private static void ClearAllMemberMemory()
        {
            //消息记录重新读取及检测
            ControlCommonResourse.ReadMessageAgain = true;
            ControlCommonResourse.HadNewMessage = false;
            HdlThreadLogic.Current.RunMain(() =>
            {
                for (int i = 0; i < ControlCommonResourse.listMessageManaContr.Count; i++)
                {
                    //显示角标特效
                    ControlCommonResourse.listMessageManaContr[i].IsSelected = false;
                }
            });
            //切换住宅清除之前逻辑缓存数据;
            Common.Logic.LogicList.Clear();
            Common.Logic.LockLogicList.Clear();
            Common.Logic.SoneLogicList.Clear();
        }
        #endregion
@@ -945,16 +1008,20 @@
        #region ■ 初始化登陆账号的信息_______________
        /// <summary>
        /// 初始化登陆账号的信息
        /// 初始化登陆账号的信息 -1:无网 1:正常 2:其他错误
        /// </summary>
        /// <param name="reLoad">是否从新从本地加载(重新初始化登陆账号的信息,不需要重新加载)</param>
        /// <returns></returns>
        private async static Task<bool> InitUserAccoutInfo()
        private async static Task<int> InitUserAccoutInfo(bool reLoad)
        {
            //初始化个人信息的标识
            UserCenterResourse.UserInfo.InitUserInfoSuccess = false;
            //获取本地记录的用户信息
            UserCenterResourse.UserInfo = GetUserInformationFromLocation();
            UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, "Admin.png");
            if (reLoad == true)
            {
                //获取本地记录的用户信息
                UserCenterResourse.UserInfo = GetUserInformationFromLocation();
                UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, "Admin.png");
            }
            //获取登录账号的信息
            var pra = new AccountInfoPra();
@@ -964,13 +1031,13 @@
            byte[] byteData = await CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync("ZigbeeUsers/GetAccountInfo", Encoding.UTF8.GetBytes(requestJson));
            if (byteData == null)
            {
                return false;
                return -1;
            }
            //检测错误
            var revertObj = JsonConvert.DeserializeObject<ResponsePack>(Encoding.UTF8.GetString(byteData));
            if (revertObj.StateCode.ToUpper() != "SUCCESS")
            {
                return false;
                return 2;
            }
            var userInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInformation>(revertObj.ResponseData.ToString());
@@ -1032,7 +1099,7 @@
            }
            UserCenterResourse.UserInfo = userInfo;
            UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, "Admin.png");
            UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, "Admin.png");
            if (UserCenterResourse.UserInfo.HeadImage != null)
            {
                //写入头像内容
@@ -1040,16 +1107,16 @@
            }
            UserCenterResourse.UserInfo.HeadImage = null;
            //手势密码
            UserCenterResourse.Option.GestureAuthentication = UserCenterResourse.UserInfo.GesturePwd == null ? string.Empty : UserCenterResourse.UserInfo.GesturePwd;
            UserCenterResourse.AccountOption.GestureAuthentication = UserCenterResourse.UserInfo.GesturePwd == null ? string.Empty : UserCenterResourse.UserInfo.GesturePwd;
            UserCenterResourse.UserInfo.GesturePwd = null;
            //密码验证
            UserCenterResourse.Option.PswAuthentication = UserCenterResourse.UserInfo.StringPwd == null ? string.Empty : UserCenterResourse.UserInfo.StringPwd;
            UserCenterResourse.AccountOption.PswAuthentication = UserCenterResourse.UserInfo.StringPwd == null ? string.Empty : UserCenterResourse.UserInfo.StringPwd;
            UserCenterResourse.UserInfo.StringPwd = null;
            //初始化管理员控制主人的连接地址(因为这个连接Token是不会改变的,所以只需要初始化一次)
            bool flage = await InitAdminConnectMainInfo();
            var flage = await InitAdminConnectMainInfo();
            //初始化个人信息的标识
            UserCenterResourse.UserInfo.InitUserInfoSuccess = flage;
            UserCenterResourse.UserInfo.InitUserInfoSuccess = flage == 1;
            return flage;
        }
@@ -1074,20 +1141,36 @@
        /// 重新初始化登陆账号的信息(旨在对应那一瞬间,网络不好,导致误判的情况)
        /// </summary>
        /// <returns></returns>
        private async static Task<bool> ReInitUserAccoutInfo()
        private async static Task<bool> ReInitUserAccoutInfo(List<string> listNotShowError)
        {
            //重新初始化账号信息
            var result = await InitUserAccoutInfo();
            if (result == false)
            var result = await InitUserAccoutInfo(false);
            //连接不了外网的时候
            if (result == -1)
            {
                return result;
                if (listNotShowError != null &&
                    (listNotShowError.Contains("NotSetAgain") == true || listNotShowError.Contains("NotCheck") == true))
                {
                    //有这两个标识时,不提示错误
                    return false;
                }
                Application.RunOnMainThread(() =>
                {
                    //当前无网络连接,请确认网络
                    var alert = new ShowMsgControl(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uNowIsDonotNetworkAndCheckNetwork));
                    alert.Show();
                });
            }
            //同步云端的网关id,如果本地拥有云端不存在的id,则表示应该被换绑了,直接删除
            HdlGatewayLogic.Current.SynchronizeDbGateway();
            //初始化个人信息的标识
            UserCenterResourse.UserInfo.InitUserInfoSuccess = true;
            if (result == 1)
            {
                //同步云端的网关id,如果本地拥有云端不存在的id,则表示应该被换绑了,直接删除
                HdlGatewayLogic.Current.SynchronizeDbGateway();
                //初始化个人信息的标识
                UserCenterResourse.UserInfo.InitUserInfoSuccess = true;
            return true;
                return true;
            }
            return false;
        }
        /// <summary>
@@ -1118,15 +1201,15 @@
        #region ■ 初始化管理员权限远程连接___________
        /// <summary>
        /// 初始化管理员权限远程连接主人的信息
        /// 初始化管理员权限远程连接主人的信息 -1:无网 1:正常 2:其他错误
        /// </summary>
        /// <returns></returns>
        private static async Task<bool> InitAdminConnectMainInfo()
        private static async Task<int> InitAdminConnectMainInfo()
        {
            if (UserCenterResourse.UserInfo.AuthorityNo != 2 && UserCenterResourse.UserInfo.AuthorityNo != 3)
            {
                //时代变了,这里管理员和成员都能调用
                return true;
                return 1;
            }
            var pra = new
            {
@@ -1142,13 +1225,13 @@
            byte[] byteData = await CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync("App/GetSharedHomeApiControl", Encoding.UTF8.GetBytes(requestJson));
            if (byteData == null)
            {
                return false;
                return -1;
            }
            //检测错误
            var revertObj = JsonConvert.DeserializeObject<ResponsePack>(Encoding.UTF8.GetString(byteData));
            if (revertObj.StateCode.ToUpper() != "SUCCESS")
            {
                return false;
                return 2;
            }
            //分享链接
@@ -1156,7 +1239,7 @@
            Config.Instance.AdminRequestBaseUrl = info.RequestBaseUrl;
            Config.Instance.AdminRequestToken = info.RequestToken;
            return true;
            return 1;
        }
        #endregion
@@ -1234,9 +1317,9 @@
            Global.CreateEmptyDirectory(directory);
            //用户图片目录路径【文件夹】
            if (UserCenterResourse.Option.UserPictruePath != string.Empty && !System.IO.Directory.Exists(UserCenterResourse.Option.UserPictruePath))
            if (UserCenterResourse.AccountOption.UserPictruePath != string.Empty && !System.IO.Directory.Exists(UserCenterResourse.AccountOption.UserPictruePath))
            {
                System.IO.Directory.CreateDirectory(UserCenterResourse.Option.UserPictruePath);
                System.IO.Directory.CreateDirectory(UserCenterResourse.AccountOption.UserPictruePath);
            }
        }
@@ -1424,25 +1507,76 @@
        /// <param name="obj">需要序列化的东西</param>
        public static void SaveFileContent(string fullName, object obj)
        {
            var data = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
            var byteData = System.Text.Encoding.UTF8.GetBytes(data);
            //写入内容
            Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData);
            var data = JsonConvert.SerializeObject(obj);
            SaveTexToFile(fullName, data);
        }
        /// <summary>
        /// 读取文件(文件不存在返回null,整天忘记,所以建一个函数来玩玩)
        /// 文件保存(整天忘记,所以建一个函数来玩玩)
        /// </summary>
        /// <param name="fullName">全路径</param>
        /// <param name="obj">需要序列化的东西</param>
        public static void SaveTexToFile(string fullName, string textValue)
        {
            var byteData = Encoding.UTF8.GetBytes(textValue);
            //写入内容
            System.IO.FileStream fileStream = null;
            try
            {
                fileStream = new System.IO.FileStream(fullName, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                fileStream.Write(byteData, 0, byteData.Length);
                fileStream.Flush();
            }
            catch { }
            finally
            {
                fileStream?.Close();
            }
        }
        /// <summary>
        /// 读取文件,不限制住宅(文件不存在返回null,整天忘记,所以建一个函数来玩玩)
        /// </summary>
        /// <param name="fullName">全路径</param>
        /// <returns></returns>
        public static string LoadFileContent(string fullName)
        {
            //读取文件
            var varByte = ReadFileContent(fullName);
            if (varByte == null)
            {
                return null;
            }
            return Encoding.UTF8.GetString(varByte);
        }
        /// <summary>
        /// 读取文件,不限制住宅,文件不存在返回null
        /// </summary>
        /// <param name="fullName">全路径</param>
        /// <returns></returns>
        public static byte[] ReadFileContent(string fullName)
        {
            if (System.IO.File.Exists(fullName) == false)
            {
                return null;
            }
            var varByte = Shared.IO.FileUtils.ReadFile(fullName);
            return System.Text.Encoding.UTF8.GetString(varByte);
            System.IO.FileStream fileStream = null;
            try
            {
                fileStream = new System.IO.FileStream(fullName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                byte[] array = new byte[fileStream.Length];
                fileStream.Read(array, 0, array.Length);
                return array;
            }
            catch
            {
                return null;
            }
            finally
            {
                fileStream?.Close();
            }
        }
        #endregion