xm
2020-07-31 ecba45c93391066bc30c7bd602c3a7683fbb99a7
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
@@ -22,19 +22,24 @@
        /// <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 = true)
        /// <param name="setAgain">当发送失败时,是否重发,默认不重发</param>
        public static bool GetResultStatuByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = false)
        {
            if (HdlWifiLogic.Current.CanAccessHttp == false && setAgain == false)
            {
                //当前无法访问网络(当需要重新发送时,跳过这个判断)
                ShowNotNetMsg(listNotShowError);
                return false;
            }
            //获取接口的连接模式
            var connectMode = GetHttpConnectMode(checkAuthority);
            //获取从接口那里取到的比特数据
            var byteData = GettByteResponsePack(RequestName, connectMode, obj);
            if (byteData == null)
            if (byteData == null && setAgain == true)
            {
                if (setAgain == false)
                {
                    //当前无法访问网络
                    ShowNotNetMsg(RequestName, listNotShowError);
                    //不指定重发
                    return false;
                }
                byteData = ResetByteRequestHttps(RequestName, checkAuthority, obj);
@@ -56,10 +61,17 @@
        /// <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 = true)
        public static string GetResultCodeByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = false)
        {
            if (HdlWifiLogic.Current.CanAccessHttp == false && setAgain == false)
            {
                //当前无法访问网络(当需要重新发送时,跳过这个判断)
                ShowNotNetMsg(listNotShowError);
                return "Error";
            }
            //获取接口的连接模式
            var connectMode = GetHttpConnectMode(checkAuthority);
            //获取从接口那里取到的比特数据
@@ -68,8 +80,7 @@
            {
                if (setAgain == false)
                {
                    //当前无法访问网络
                    ShowNotNetMsg(RequestName, listNotShowError);
                    //不指定重发
                    return "Error";
                }
                byteData = ResetByteRequestHttps(RequestName, checkAuthority, obj);
@@ -94,10 +105,16 @@
        /// <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 = true)
        public static string GetResponseDataByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = false)
        {
            if (HdlWifiLogic.Current.CanAccessHttp == false && setAgain == false)
            {
                //当前无法访问网络(当需要重新发送时,跳过这个判断)
                ShowNotNetMsg(listNotShowError);
                return null;
            }
            //获取接口的连接模式
            var connectMode = GetHttpConnectMode(checkAuthority);
            //获取从接口那里取到的比特数据
@@ -106,8 +123,7 @@
            {
                if (setAgain == false)
                {
                    //当前无法访问网络
                    ShowNotNetMsg(RequestName, listNotShowError);
                    //不指定重发
                    return null;
                }
                byteData = ResetByteRequestHttps(RequestName, checkAuthority, obj);
@@ -138,9 +154,15 @@
        /// <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 = true)
        /// <param name="setAgain">当发送失败时,是否重发,默认不重发</param>
        public static byte[] GetByteResponseDataByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = false)
        {
            if (HdlWifiLogic.Current.CanAccessHttp == false && setAgain == false)
            {
                //当前无法访问网络(当需要重新发送时,跳过这个判断)
                ShowNotNetMsg(listNotShowError);
                return null;
            }
            //获取接口的连接模式
            var connectMode = GetHttpConnectMode(checkAuthority);
            //获取从接口那里取到的比特数据
@@ -150,8 +172,7 @@
            {
                if (setAgain == false)
                {
                    //当前无法访问网络
                    ShowNotNetMsg(RequestName, listNotShowError);
                    //不指定重发
                    return null;
                }
                revertObj = ResetByteRequestHttps(RequestName, checkAuthority, obj);
@@ -206,7 +227,7 @@
                if (count == 3)
                {
                    //显示没有网络的Msg
                    ShowNotNetMsg(RequestName, null);
                    ShowNotNetMsg(null);
                    break;
                }
            }
@@ -328,15 +349,13 @@
        /// <summary>
        /// 显示没有网络的Msg
        /// </summary>
        private static void ShowNotNetMsg(string RequestName, List<string> listNotShowError)
        private static void ShowNotNetMsg(List<string> listNotShowError)
        {
            if (listNotShowError != null && listNotShowError.Contains("NotCheck") == true)
            {
                //不检测
                return;
            }
            //HdlLogLogic.Current.WriteLog(-1, "当前无网络连接:" + RequestName);
            HdlThreadLogic.Current.RunMain(() =>
            {
                // 当前无网络连接,请确认网络
@@ -500,18 +519,13 @@
        #endregion
        #region ■ 刷新本地缓存_______________________
        /// <summary>
        /// 刷新本地所有缓存(目前此方法只提供给恢复备份数据使用)
        /// 刷新本地所有缓存
        /// </summary>
        public static void RefreshAllMemory()
        {
            //刷新住宅对象
            RefreshHomeObject();
            //根据模板文件,恢复数据
            TemplateData.TemplateCommonLogic.Current.RecoverDataByTemplateBinFile();
            //强制生成设备和网关文件
            TemplateData.TemplateCommonLogic.Current.CreatDeviceAndGatewayFileFromMemoryByForce();
            //刷新本地网关文件
            HdlGatewayLogic.Current.ReFreshByLocal();
            //刷新本地设备
@@ -523,7 +537,7 @@
            //断开远程Mqtt连接,重新连接
            HdlThreadLogic.Current.RunThread(async () =>
            {
                HdlGatewayLogic.Current.ClearAllRealGatewayConection(true);
                HdlGatewayLogic.Current.ClearAllRealGateway();
                await ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
            }, ShowErrorMode.NO);
        }
@@ -604,7 +618,7 @@
                //清空当前住宅id
                Config.Instance.HomeId = string.Empty;
                HdlGatewayLogic.Current.ClearAllRealGatewayConection(false);
                HdlGatewayLogic.Current.ClearAllRealGateway();
                //断开远程Mqtt连接
                HdlThreadLogic.Current.RunThread(async () =>
@@ -660,8 +674,8 @@
                }
                else if (view is UserView.UserPage)
                {
                    //刷新主页
                    UserView.UserPage.Instance.ReFreshControl();
                    var form = ((UserView.UserPage)view).GetNowActionForm();
                    form?.FormActionAgainEvent();
                    return;
                }
                else
@@ -847,15 +861,12 @@
                //断开远程Mqtt连接,重新连接
                HdlThreadLogic.Current.RunThread(async () =>
                {
                    HdlGatewayLogic.Current.ClearAllRealGatewayConection(true);
                    HdlGatewayLogic.Current.ClearAllRealGateway();
                    await ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
                }, ShowErrorMode.NO);
                //刷新APP前一次选择的网关ID(可以反复调用,需要在网关初始化完了之后才能调用)
                HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId();
                //加载模板缓存
                //TemplateData.TemplateCommonLogic.Current.LoadLocalTemplateMemoryData();
                //0:已经同步过,不需要同步,这个时候需要提示备份
                if (result == 0 && ShowPrompted == true)
@@ -922,8 +933,6 @@
            HdlRoomLogic.Current.RefreshAllRoomByLocation();
            //刷新左边刷新房间视图列表
            HdlRoomLogic.Current.RefreshRoomListView();
            //加载模板缓存
            //TemplateData.TemplateCommonLogic.Current.LoadLocalTemplateMemoryData();
        }
        /// <summary>