黄学彪
2020-04-15 23532fa8ad34c89b6d24b01eaef6475fd0aad898
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
@@ -29,6 +29,13 @@
        /// </param>
        public static async Task<bool> GetResultStatuByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null)
        {
            //检测是否已经完成账号信息初始化
            if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false)
            {
                //不管结果怎么样,如果调用了这个函数,需要重头获取Token,所以必须返回失败
                await ReInitUserAccoutInfo();
                return false;
            }
            //获取接口的连接模式
            var connectMode = GetHttpConnectMode(checkAuthority);
            //获取从接口那里取到的比特数据
@@ -63,6 +70,14 @@
        /// </param>
        public static async Task<string> GetResultCodeByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null)
        {
            //检测是否已经完成账号信息初始化
            if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false)
            {
                //不管结果怎么样,如果调用了这个函数,需要重头获取Token,所以必须返回失败
                await ReInitUserAccoutInfo();
                return "Error";
            }
            //获取接口的连接模式
            var connectMode = GetHttpConnectMode(checkAuthority);
            //获取从接口那里取到的比特数据
@@ -96,6 +111,13 @@
        /// </param>
        public static async Task<string> GetResponseDataByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null)
        {
            //检测是否已经完成账号信息初始化
            if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false)
            {
                //不管结果怎么样,如果调用了这个函数,需要重头获取Token,所以必须返回失败
                await ReInitUserAccoutInfo();
                return null;
            }
            //获取接口的连接模式
            var connectMode = GetHttpConnectMode(checkAuthority);
            //获取从接口那里取到的比特数据
@@ -139,6 +161,13 @@
        /// </param>
        public static async Task<byte[]> GetByteResponseDataByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null)
        {
            //检测是否已经完成账号信息初始化
            if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false)
            {
                //不管结果怎么样,如果调用了这个函数,需要重头获取Token,所以必须返回失败
                await ReInitUserAccoutInfo();
                return null;
            }
            //获取接口的连接模式
            var connectMode = GetHttpConnectMode(checkAuthority);
            //获取从接口那里取到的比特数据
@@ -259,6 +288,11 @@
        /// <param name="pra">请求的参数</param>
        public static bool CheckNotEorrorMsg(ResponsePack revertObj, string RequestName, List<string> listNotShowError = null, object pra = null)
        {
            if (listNotShowError != null && listNotShowError.Contains("NotCheck") == true)
            {
                //不检测
                return true;
            }
            if (revertObj == null)
            {
                Application.RunOnMainThread(() =>
@@ -315,7 +349,7 @@
            {
                return HttpConnectMode.Normal;
            }
            if (Config.Instance.isAdministrator == true)
            if (Config.Instance.Home.IsOthreShare == true)
            {
                return HttpConnectMode.Admin;
            }
@@ -394,70 +428,22 @@
                        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
                                {
                                    var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID];
                                    if (Myform is EditorCommonForm)
                                    {
                                        //触发界面再次激活的事件
                                        int value = ((EditorCommonForm)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.uUnknownErrorAndDataLost));
                                    alert.Show();
                                    //Log出力
                                    HdlLogLogic.Current.WriteLog(ex);
                                }
                                //调用界面重新激活的函数
                                CallFormActionAgainEvent(form, index);
                            }
                        }
                        else if (actionForm != null && actionForm is UserView.UserPage)
                        {
                            //这里它已经退到主页了,如果它包含个人中心主页的话
                            if (UserCenterResourse.listActionFormId.Contains("UserMainForm") == true)
                            //这里它已经退到主页了
                            if (UserCenterResourse.listActionFormId.Contains("UserMainForm") == true//个人中心
                                || UserCenterResourse.listActionFormId.Contains("HomeMainPageForm") == true)//
                            {
                                //设置当前激活的画面ID
                                UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
                                //追加条件一:关闭的界面为EditorCommonForm的时候才处理
                                if ((form is EditorCommonForm) && UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
                                {
                                    try
                                    {
                                        var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID];
                                        if (Myform is EditorCommonForm)
                                        {
                                            //触发界面再次激活的事件
                                            int value = ((EditorCommonForm)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.uUnknownErrorAndDataLost));
                                        alert.Show();
                                        //Log出力
                                        HdlLogLogic.Current.WriteLog(ex);
                                    }
                                }
                                //调用界面重新激活的函数
                                CallFormActionAgainEvent(form, index);
                            }
                        }
                    }
@@ -466,6 +452,43 @@
                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;
                    //重置左滑使能
                    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, "界面重新激活异常");
                }
            }
        }
@@ -516,7 +539,7 @@
            //需优先于刷新房间,同步云端的网关id,如果本地拥有云端不存在的id,则表示应该被换绑了,直接删除
            HdlGatewayLogic.Current.SynchronizeDbGateway();
            //从本地重新加载全部的房间
            Common.Room.RefreshAllRoomByLocation();
            HdlRoomLogic.Current.RefreshAllRoomByLocation();
        }
        /// <summary>
@@ -608,17 +631,16 @@
        /// <param name="noticeDb">是否通知云端</param>
        public static void ReLoginAgain(string account = "", bool noticeDb = true)
        {
            UserCenterResourse.Option.OldAccountId = string.Empty;
            UserCenterResourse.AccountOption.OldAccountId = string.Empty;
            //关闭所有接收
            HdlGatewayReceiveLogic.Current.RemoveAllEvent();
            //清除升级列表
            FirmwareUpdateResourse.dicDeviceUpdateList.Clear();
            FirmwareUpdateResourse.dicGatewayUpdateList.Clear();
            FirmwareUpdateResourse.dicUpdateList.Clear();
            HdlThreadLogic.Current.RunThread(async () =>
            {
                //检测APP是否能够退出
                while (UserCenterResourse.Option.AppCanSignout == false)
                while (UserCenterResourse.AccountOption.AppCanSignout == false)
                {
                    await Task.Delay(500);
                }
@@ -638,11 +660,13 @@
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //收起左菜单
                    CommonPage.Instance.CloseLeftMenu();
                    //关闭所有打开了的界面
                    CloseAllOpenForm();
                    //显示登陆画面
                    var formLogin = new Shared.Phone.Device.Account.AccountLogin();
                    var formLogin = new Login.AccountLogin();
                    Shared.Common.CommonPage.Instance.AddChidren(formLogin);
                    formLogin.Show(account);
                });
@@ -659,11 +683,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)
@@ -684,38 +715,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--;
                }
            }
        }
@@ -803,13 +816,13 @@
        public async static Task<bool> InitUserCenterMenmoryAndThread(bool ShowPrompted = 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
                {
@@ -818,13 +831,17 @@
                }
                catch { }
                //消息记录重新读取及检测
                ControlCommonResourse.ReadMessageAgain = true;
                //清空所有成员缓存
                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();
@@ -851,8 +868,8 @@
                //保存用户的登陆信息到本地
                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;
@@ -866,14 +883,14 @@
                //初始化本地的设备信息
                Common.LocalDevice.Current.ReFreshByLocal();
                //初始化房间(郭雪城那边不做处理,需要这里特殊执行一步)
                HdlRoomLogic.Current.RefreshAllRoomByLocation();
                if (hadNet == true)
                {
                    //同步云端的网关id,如果本地拥有云端不存在的id,则表示应该被换绑了,直接删除
                    HdlGatewayLogic.Current.SynchronizeDbGateway();
                }
                //初始化房间(郭雪城那边不做处理,需要这里特殊执行一步)
                Room.RefreshAllRoomByLocation();
                //刷新APP前一次选择的网关ID(可以反复调用,需要在网关初始化完了之后才能调用)
                HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId();
@@ -884,11 +901,36 @@
                    //开启自动备份提示
                    HdlAutoBackupLogic.ShowAutoBackupPromptedForm();
                }
                //显示引导界面
                ShowGuideForm(result);
            }
            //APP缓存加载完成
            UserCenterResourse.Option.AppCanSignout = true;
            UserCenterResourse.AccountOption.AppCanSignout = true;
            return true;
        }
        /// <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;
                }
            });
            //当前主页,场景和功能所选择的分支 1:场景 2:功能
            UserCenterResourse.ResidenceOption.HomeMainPageSwitchIndex = 1;
            //当前分类,场景和功能所选择的分支 0:场景 1:功能 2:自动化
            UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex = 0;
        }
        #endregion
@@ -901,22 +943,30 @@
        /// <returns></returns>
        private async static Task<bool> InitUserAccoutInfo()
        {
            //初始化个人信息的标识
            UserCenterResourse.UserInfo.InitUserInfoSuccess = false;
            //获取本地记录的用户信息
            UserCenterResourse.UserInfo = GetUserInformationFromLocation();
            UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, "Admin.png");
            UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, "Admin.png");
            //获取登录账号的信息
            var pra = new AccountInfoPra();
            var listNotShow = new List<string>() { "NotSetAgain" };
            string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetAccountInfo", false, pra, listNotShow);
            if (string.IsNullOrEmpty(result) == true)
            //序列化对象
            var requestJson = JsonConvert.SerializeObject(pra);
            //访问接口
            byte[] byteData = await CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync("ZigbeeUsers/GetAccountInfo", Encoding.UTF8.GetBytes(requestJson));
            if (byteData == null)
            {
                //断网的话,该干嘛就干嘛吧,总之不能控主人的东西
                Config.Instance.isAdministrator = false;
                return false;
            }
            //检测错误
            var revertObj = JsonConvert.DeserializeObject<ResponsePack>(Encoding.UTF8.GetString(byteData));
            if (revertObj.StateCode.ToUpper() != "SUCCESS")
            {
                return false;
            }
            var userInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInformation>(result);
            var userInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInformation>(revertObj.ResponseData.ToString());
            userInfo.Account = Common.Config.Instance.Account;
            if (string.IsNullOrEmpty(userInfo.UserName) == true)
            {
@@ -949,22 +999,23 @@
                string dirPath = CombinePath();
                if (System.IO.Directory.Exists(dirPath) == true)
                {
                    //先记录起住宅的一些信息
                    var house = House.GetHouseByHouseId(Config.Instance.HomeId);
                    //删除整个文件夹
                    System.IO.Directory.Delete(dirPath, true);
                    try
                    {
                        //同步数据的判断文件(以防万一删除整个文件夹失败的时候,这个文件被删的话,应该没什么大问题)
                        string SynchronizeFile = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoDownLoadBackupCheckFile);
                        //如果本地已经拥有了这个文件,则说明不是新手机,不再自动还原
                        if (System.IO.File.Exists(SynchronizeFile) == true)
                        {
                            System.IO.File.Delete(SynchronizeFile);
                        }
                        //删除整个文件夹
                        System.IO.Directory.Delete(dirPath, true);
                    }
                    catch { }
                    //创建住宅文件夹
                    Global.CreateHomeDirectory(Config.Instance.HomeId);
                    //预创建个人中心全部的文件夹
                    CreatAllUserCenterDirectory();
                    var newHouse = new House();
                    newHouse.Id = house.Id;
                    newHouse.Name = house.Name;
                    newHouse.IsOthreShare = house.IsOthreShare;
                    newHouse.AccountType = house.AccountType;
                    newHouse.MainUserDistributedMark = house.MainUserDistributedMark;
                    newHouse.Save(false);
                }
            }
            if (string.IsNullOrEmpty(userInfo.UserName) == true)
@@ -974,7 +1025,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)
            {
                //写入头像内容
@@ -982,16 +1033,18 @@
            }
            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是不会改变的,所以只需要初始化一次)
            await InitAdminConnectMainInfo();
            bool flage = await InitAdminConnectMainInfo();
            //初始化个人信息的标识
            UserCenterResourse.UserInfo.InitUserInfoSuccess = flage;
            return true;
            return flage;
        }
        /// <summary>
@@ -1008,6 +1061,26 @@
            }
            var info = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInformation>(value);
            return info;
        }
        /// <summary>
        /// 重新初始化登陆账号的信息(旨在对应那一瞬间,网络不好,导致误判的情况)
        /// </summary>
        /// <returns></returns>
        private async static Task<bool> ReInitUserAccoutInfo()
        {
            //重新初始化账号信息
            var result = await InitUserAccoutInfo();
            if (result == false)
            {
                return result;
            }
            //同步云端的网关id,如果本地拥有云端不存在的id,则表示应该被换绑了,直接删除
            HdlGatewayLogic.Current.SynchronizeDbGateway();
            //初始化个人信息的标识
            UserCenterResourse.UserInfo.InitUserInfoSuccess = true;
            return true;
        }
        /// <summary>
@@ -1041,13 +1114,8 @@
        /// 初始化管理员权限远程连接主人的信息
        /// </summary>
        /// <returns></returns>
        public static async Task<bool> InitAdminConnectMainInfo()
        private static async Task<bool> InitAdminConnectMainInfo()
        {
            //先清空
            Config.Instance.isAdministrator = false;
            Config.Instance.AdminRequestBaseUrl = string.Empty;
            Config.Instance.AdminRequestToken = string.Empty;
            if (UserCenterResourse.UserInfo.AuthorityNo != 2 && UserCenterResourse.UserInfo.AuthorityNo != 3)
            {
                //时代变了,这里管理员和成员都能调用
@@ -1061,16 +1129,23 @@
                SharedHid = Config.Instance.Home.Id
            };
            var listNotShow = new List<string>() { "NotSetAgain" };
            var result = await GetResponseDataByRequestHttps("App/GetSharedHomeApiControl", false, pra, listNotShow);
            if (string.IsNullOrEmpty(result) == true)
            //序列化对象
            var requestJson = JsonConvert.SerializeObject(pra);
            //访问接口
            byte[] byteData = await CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync("App/GetSharedHomeApiControl", Encoding.UTF8.GetBytes(requestJson));
            if (byteData == null)
            {
                return false;
            }
            //检测错误
            var revertObj = JsonConvert.DeserializeObject<ResponsePack>(Encoding.UTF8.GetString(byteData));
            if (revertObj.StateCode.ToUpper() != "SUCCESS")
            {
                return false;
            }
            Config.Instance.isAdministrator = true;
            //分享链接
            var info = JsonConvert.DeserializeObject<MemberAdministratorResult>(result);
            var info = JsonConvert.DeserializeObject<MemberAdministratorResult>(revertObj.ResponseData.ToString());
            Config.Instance.AdminRequestBaseUrl = info.RequestBaseUrl;
            Config.Instance.AdminRequestToken = info.RequestToken;
@@ -1152,9 +1227,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);
            }
        }
@@ -1169,11 +1244,41 @@
        public static string GetConnectMainToken()
        {
            //启用管理员权限
            if (Config.Instance.isAdministrator == true)
            if (Config.Instance.Home.IsOthreShare == true)
            {
                return Config.Instance.AdminRequestToken;
            }
            return Config.Instance.Token;
        }
        #endregion
        #region ■ 引导界面___________________________
        /// <summary>
        /// 显示引导界面
        /// </summary>
        /// <param name="result">同步结果 -1:异常   0:已经同步过,不需要同步  1:正常同步  2:没有自动备份数据</param>
        private static void ShowGuideForm(int result)
        {
            var checkFile = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, DirNameResourse.GuideFile);
            if (System.IO.File.Exists(checkFile) == true)
            {
                //不需要显示
                return;
            }
            if (result == 2 && Config.Instance.Home.IsOthreShare == false)
            {
                HdlThreadLogic.Current.RunMain(() =>
                {
                    var form = new Guide.GuideHouseForm();
                    form.ShowFrom();
                });
            }
            //创建一个空文件(标识已经完成引导)
            var file = System.IO.File.Create(checkFile);
            file.Close();
        }
        #endregion
@@ -1288,6 +1393,21 @@
        }
        #endregion
        #region ■ 时间转换___________________________
        /// <summary>
        /// 将utc时间类型的字符串,转换为本地时间
        /// </summary>
        /// <param name="timeText"></param>
        /// <returns></returns>
        public static DateTime ConvertUtcTimeToLocalTime(string timeText)
        {
            var utcTime = Convert.ToDateTime(timeText);
            return TimeZoneInfo.ConvertTimeFromUtc(utcTime, TimeZoneInfo.Local);
        }
        #endregion
        #region ■ 文件保存和读取_____________________
        /// <summary>