wxr
2024-06-04 e4acb04670cee588ad45ef7d57a50dc3c928f2d9
HDL_ON/Common/ApiUtlis.cs
@@ -72,6 +72,8 @@
        /// 下载数据完成标记
        /// </summary>
        public bool DownloadDataComplete = false;
        public bool hadInternet = true;
        /// <summary>
        /// 下载数据
        /// </summary>
@@ -93,19 +95,22 @@
            MainPage.BaseView.AddChidren(waitPage);
            waitPage.Start(Language.StringByID(StringId.PleaseWait));
            string code = StateCode.SUCCESS;
            var downloadDataThread = new System.Threading.Thread(() =>
            {
                try
                {//增加3秒云服务器连接检测,连不上服务器的时候不刷新数据
                {
                    //增加3秒云服务器连接检测,连不上服务器的时候不刷新数据
                    hadInternet = true;
                        var dataList = new List<GlobalRegionListRes>();
                        var requestJson = HttpUtil.GetSignRequestJson(new GetRegionListObj() { regionMark = HttpUtil.RegionMark });
                    var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GlobalRegionList, requestJson, HttpUtil.GlobalRequestHttpsHost, "", 3);
                    if (revertObj == null || revertObj.Code != StateCode.SUCCESS)
                    {
                        DownloadDataComplete = true;
                        hadInternet = false;
                        try
                        {
                            var spatialInfoDataBytes = FileUtlis.Files.ReadFile("SpatialInfoData");
@@ -138,7 +143,12 @@
                            MainPage.Log($"{this.GetType()}:加载缓存设备数据异常:{ex.Message}");
                        }
                        return;
                    }
                    else
                    {
                        hadInternet = true;
                    }
                }
                catch (Exception ex)
@@ -147,7 +157,20 @@
                    DownloadDataComplete = true;
                    return;
                }
                finally
                {
                    if (!hadInternet)
                    {
                        Application.RunOnMainThread(() =>
                        {
                            if (waitPage != null)
                            {
                                waitPage.Hide();
                                waitPage.RemoveFromParent();
                            }
                        });
                    }
                }
                MainPage.Log($"进入读取云端数据线程");
                //===================刷新Token=======================
                code = Ins.HttpRequest.RefreshToken();
@@ -240,13 +263,26 @@
                    if (roomResult.Code == StateCode.SUCCESS)
                    {
                        MainPage.Log($"读取房间信息成功");
                        var revData = Newtonsoft.Json.JsonConvert.DeserializeObject<SpatialApiPack>(roomResult.Data.ToString());
                        var revData = JsonConvert.DeserializeObject<SpatialApiPack>(roomResult.Data.ToString());
                        if (revData == null)
                        {
                            revData = new SpatialApiPack();
                        }
                        {
                            SpatialInfo.CurrentSpatial.UpdateSpatialList(revData.list);
                            new System.Threading.Thread(() =>
                            {
                                try
                                {
                                    var ssd = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(revData.list));
                                    FileUtlis.Files.WriteFileByBytes("SpatialInfoData", ssd);
                                }
                                catch (Exception ex)
                                {
                                    MainPage.Log($"{this.GetType()}:保存房间信息异常:{ex.Message}");
                                }
                            })
                            { IsBackground = true }.Start();
                        }
                    }
                    else
@@ -353,6 +389,7 @@
                                            isInterphoneType_HDL = true;
                                            DB_ResidenceData.Instance.SupportFacePass = true;
                                            DB_ResidenceData.Instance.SaveResidenceData();
                                        }
                                    }
                                }
@@ -379,12 +416,14 @@
                                        HDLLinphone.Current.LogoutAllAccount();
                                    }
                                }
                            }
                            else
                            {
                                MainPage.Log($"读取云端设备数据失败:Code:{deviceResult.Code};  Msg:{deviceResult.message}");
                            }
                        }catch (Exception ex)
                        }
                        catch (Exception ex)
                        {
                            MainPage.Log($"============设备============{ex.Message}");
                        }
@@ -512,7 +551,8 @@
                            {
                                MainPage.Log($"读取云端场景数据失败:Code:{pack.Code}; Msg:{pack.message}");
                            }
                        }catch(Exception ex)
                        }
                        catch (Exception ex)
                        {
                            MainPage.Log($"===场景==={ex.Message}");
                        }
@@ -554,7 +594,8 @@
                    try
                    {
                        FunctionList.List.Read3tyFunctionStatus();
                    }catch(Exception ex)
                    }
                    catch (Exception ex)
                    {
                        MainPage.Log("读取第三方设备状态失败:"+ex.Message);
                    }