黄学彪
2020-07-24 0087dd7734e71dfcfd1bb54db394ad7855021ffd
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
@@ -22,15 +22,9 @@
        /// <param name="checkAuthority">是否检测权限,该参数不能省略</param>
        /// <param name="obj">一个类</param>
        /// <param name="listNotShowError">不需要显示错误的错误类别(接口返回的错误类别),如果包含,则会返回【true】</param>
        /// <param name="setAgain">当发送失败时,是否重发,默认不重发</param>
        public static bool GetResultStatuByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = false)
        /// <param name="setAgain">当发送失败时,是否重发,默认重发</param>
        public static bool GetResultStatuByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = true)
        {
            if (HdlWifiLogic.Current.CanAccessHttp == false && setAgain == false)
            {
                //当前无法访问网络(当需要重新发送时,跳过这个判断)
                ShowNotNetMsg(listNotShowError);
                return false;
            }
            //获取接口的连接模式
            var connectMode = GetHttpConnectMode(checkAuthority);
            //获取从接口那里取到的比特数据
@@ -39,7 +33,8 @@
            {
                if (setAgain == false)
                {
                    //不指定重发
                    //当前无法访问网络
                    ShowNotNetMsg(listNotShowError);
                    return false;
                }
                byteData = ResetByteRequestHttps(RequestName, checkAuthority, obj);
@@ -61,17 +56,10 @@
        /// <param name="checkAuthority">是否检测权限,该参数不能省略</param>
        /// <param name="obj">一个类</param>
        /// <param name="listNotShowError">不需要显示错误的错误类别(接口返回的错误类别),如果包含,则会返回【true】</param>
        /// <param name="setAgain">当发送失败时,是否重发,默认不重发</param>
        /// <param name="setAgain">当发送失败时,是否重发,默认重发</param>
        /// </param>
        public static string GetResultCodeByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = false)
        public static string GetResultCodeByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = true)
        {
            if (HdlWifiLogic.Current.CanAccessHttp == false && setAgain == false)
            {
                //当前无法访问网络(当需要重新发送时,跳过这个判断)
                ShowNotNetMsg(listNotShowError);
                return "Error";
            }
            //获取接口的连接模式
            var connectMode = GetHttpConnectMode(checkAuthority);
            //获取从接口那里取到的比特数据
@@ -80,7 +68,8 @@
            {
                if (setAgain == false)
                {
                    //不指定重发
                    //当前无法访问网络
                    ShowNotNetMsg(listNotShowError);
                    return "Error";
                }
                byteData = ResetByteRequestHttps(RequestName, checkAuthority, obj);
@@ -105,16 +94,10 @@
        /// <param name="checkAuthority">是否检测权限,该参数不能省略</param>
        /// <param name="obj">一个类</param>
        /// <param name="listNotShowError">不需要显示错误的错误类别(接口返回的错误类别),如果包含,则会返回【true】</param>
        /// <param name="setAgain">当发送失败时,是否重发,默认不重发</param>
        /// <param name="setAgain">当发送失败时,是否重发,默认重发</param>
        /// </param>
        public static string GetResponseDataByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = false)
        public static string GetResponseDataByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = true)
        {
            if (HdlWifiLogic.Current.CanAccessHttp == false && setAgain == false)
            {
                //当前无法访问网络(当需要重新发送时,跳过这个判断)
                ShowNotNetMsg(listNotShowError);
                return null;
            }
            //获取接口的连接模式
            var connectMode = GetHttpConnectMode(checkAuthority);
            //获取从接口那里取到的比特数据
@@ -123,7 +106,8 @@
            {
                if (setAgain == false)
                {
                    //不指定重发
                    //当前无法访问网络
                    ShowNotNetMsg(listNotShowError);
                    return null;
                }
                byteData = ResetByteRequestHttps(RequestName, checkAuthority, obj);
@@ -154,15 +138,9 @@
        /// <param name="checkAuthority">是否检测权限,该参数不能省略</param>
        /// <param name="obj">一个类</param>
        /// <param name="listNotShowError">不需要显示错误的错误类别(接口返回的错误类别),如果包含,则会返回【true】</param>
        /// <param name="setAgain">当发送失败时,是否重发,默认不重发</param>
        public static byte[] GetByteResponseDataByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = false)
        /// <param name="setAgain">当发送失败时,是否重发,默认重发</param>
        public static byte[] GetByteResponseDataByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = true)
        {
            if (HdlWifiLogic.Current.CanAccessHttp == false && setAgain == false)
            {
                //当前无法访问网络(当需要重新发送时,跳过这个判断)
                ShowNotNetMsg(listNotShowError);
                return null;
            }
            //获取接口的连接模式
            var connectMode = GetHttpConnectMode(checkAuthority);
            //获取从接口那里取到的比特数据
@@ -172,7 +150,8 @@
            {
                if (setAgain == false)
                {
                    //不指定重发
                    //当前无法访问网络
                    ShowNotNetMsg(listNotShowError);
                    return null;
                }
                revertObj = ResetByteRequestHttps(RequestName, checkAuthority, obj);
@@ -537,7 +516,7 @@
            //断开远程Mqtt连接,重新连接
            HdlThreadLogic.Current.RunThread(async () =>
            {
                HdlGatewayLogic.Current.ClearAllRealGateway();
                HdlGatewayLogic.Current.ClearAllRealGatewayConection(true);
                await ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
            }, ShowErrorMode.NO);
        }
@@ -582,11 +561,13 @@
                {
                    //设定一个时间
                    Config.Instance.LoginDateTime = new DateTime(1970, 1, 1);
                    Config.Instance.Save();
                    //清空当前住宅id
                    Config.Instance.HomeId = string.Empty;
                    Config.Instance.Save();
                    //收起左菜单
                    CommonPage.Instance.CloseLeftMenu();
                    //关闭全部弹窗
                    ShowMsgControl.CloseAllMsgDialog();
                    //关闭所有打开了的界面
                    CloseAllOpenForm();
@@ -616,7 +597,7 @@
                //清空当前住宅id
                Config.Instance.HomeId = string.Empty;
                HdlGatewayLogic.Current.ClearAllRealGateway();
                HdlGatewayLogic.Current.ClearAllRealGatewayConection(false);
                //断开远程Mqtt连接
                HdlThreadLogic.Current.RunThread(async () =>
@@ -672,6 +653,8 @@
                }
                else if (view is UserView.UserPage)
                {
                    //刷新主页
                    UserView.UserPage.Instance.ReFreshControl();
                    return;
                }
                else
@@ -792,6 +775,10 @@
            if (Common.Config.Instance.HomeId != UserCenterResourse.AccountOption.OldHomeStringId
                || Common.Config.Instance.Account != UserCenterResourse.AccountOption.OldAccountId)
            {
                //借用一下这个变量(检测能否广播到网关)
                UserCenterResourse.DicReceiveGatewayTest = new Dictionary<string, ZigBee.Device.ZbGateway>();
                UserCenterResourse.HideOption.CheckCanReceiveGateway = 1;
                //清空所有成员缓存
                ClearAllMemberMemory();
@@ -804,6 +791,9 @@
                //加载住宅配置信息
                UserCenterResourse.ResidenceOption = UserCenterResourse.ResidenceOption.Load();
                //预创建个人中心全部的文件夹
                HdlFileLogic.Current.CreatAllUserCenterDirectory();
                //初始化登陆账号的信息
                var hadNet = InitUserAccoutInfo(true);
                //如果有网络的话
@@ -814,8 +804,6 @@
                    //读取隐匿配置
                    HdlBackupLogic.Current.LoadHideOption();
                }
                //预创建个人中心全部的文件夹
                HdlFileLogic.Current.CreatAllUserCenterDirectory();
                //关闭所有接收
                HdlGatewayReceiveLogic.Current.RemoveAllEvent();
@@ -852,7 +840,7 @@
                //断开远程Mqtt连接,重新连接
                HdlThreadLogic.Current.RunThread(async () =>
                {
                    HdlGatewayLogic.Current.ClearAllRealGateway();
                    HdlGatewayLogic.Current.ClearAllRealGatewayConection(true);
                    await ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
                }, ShowErrorMode.NO);
@@ -867,6 +855,36 @@
                }
                //显示引导界面
                ShowGuideForm(result);
                //关闭debug广播
                UserCenterResourse.HideOption.CheckCanReceiveGateway = 0;
                System.Threading.Thread.Sleep(30);
                if (hadNet == 1)
                {
                    try
                    {
                        bool canReceiveGw = false;
                        foreach (var gateway in UserCenterResourse.DicReceiveGatewayTest.Values)
                        {
                            if (gateway.HomeId == Config.Instance.Home.Id)
                            {
                                //能够搜索得到网关
                                canReceiveGw = true;
                                break;
                            }
                        }
                        UserCenterResourse.DicReceiveGatewayTest = null;
                        //设置远程连接的初始值
                        ZigBee.Device.ZbGateway.IsRemote = canReceiveGw == false;
                        if (canReceiveGw == false)
                        {
                            //如果是远程的话,追加等待时间
                            System.Threading.Thread.Sleep(1500);
                        }
                    }
                    catch { }
                }
                UserCenterResourse.DicReceiveGatewayTest = null;
            }
            //APP缓存加载完成
            UserCenterResourse.AccountOption.AppCanSignout = true;
@@ -1022,7 +1040,7 @@
            if (UserCenterResourse.UserInfo.HeadImage != null)
            {
                //写入头像内容
                Shared.IO.FileUtils.WriteFileByBytes(UserCenterResourse.UserInfo.UserIconFile, UserCenterResourse.UserInfo.HeadImage);
                HdlFileLogic.Current.SaveByteToFile(UserCenterResourse.UserInfo.UserIconFile, UserCenterResourse.UserInfo.HeadImage);
            }
            UserCenterResourse.UserInfo.HeadImage = null;
            //手势密码
@@ -1246,7 +1264,7 @@
        {
            try
            {
                if (strPsw == string.Empty)
                if (string.IsNullOrEmpty(strPsw) == true)
                {
                    return strPsw;
                }