From 579450c9b6e6706a74c7c8a2b64340a7c19722ad Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期一, 23 九月 2024 16:54:04 +0800
Subject: [PATCH] 刷新token失败,进入离线控制模式

---
 HDL_ON/Common/ApiUtlis.cs |   42 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 41 insertions(+), 1 deletions(-)

diff --git a/HDL_ON/Common/ApiUtlis.cs b/HDL_ON/Common/ApiUtlis.cs
index 2992899..1dc09e1 100644
--- a/HDL_ON/Common/ApiUtlis.cs
+++ b/HDL_ON/Common/ApiUtlis.cs
@@ -178,7 +178,48 @@
                 MainPage.Log($"杩涘叆璇诲彇浜戠鏁版嵁绾跨▼");
                 //===================鍒锋柊Token=======================
                 code = Ins.HttpRequest.RefreshToken();
+                if (code != StateCode.SUCCESS)
+                {
+                    DownloadDataComplete = true;
+                    hadInternet = false;
+                    try
+                    {
+                        var spatialInfoDataBytes = FileUtlis.Files.ReadFile("SpatialInfoData");
+                        if (spatialInfoDataBytes != null)
+                        {
+                            var spatialInfoDataString = System.Text.Encoding.UTF8.GetString(spatialInfoDataBytes);
+                            if (spatialInfoDataString != null && !string.IsNullOrEmpty(spatialInfoDataString))
+                            {
+                                var spatialInfoDataList = JsonConvert.DeserializeObject<List<SpatialInfo>>(spatialInfoDataString);
+                                SpatialInfo.CurrentSpatial.UpdateSpatialList(spatialInfoDataList);
+                            }
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        MainPage.Log("Error", $"{this.GetType()}:鍔犺浇缂撳瓨鎴块棿鏁版嵁寮傚父:{ex.StackTrace}");
+                    }
 
+                    try
+                    {
+                        var fileList = Common.FileUtlis.Files.ReadFiles();
+                        foreach (var file in fileList)
+                        {
+                            FunctionList.List.IniFunctionList(file, true);
+                        }
+                        Room.CurrentSpatial.InitRoomListFunctions();
+                    }
+                    catch (Exception ex)
+                    {
+                        MainPage.Log("Error", $"{this.GetType()}:鍔犺浇缂撳瓨璁惧鏁版嵁寮傚父:{ex.StackTrace}");
+                    }
+                    MainPage.Log($"鍒锋柊token澶辫触");
+                    return;
+                }
+                else
+                {
+                    hadInternet = true;
+                }
                 if (code != StateCode.SUCCESS)
                 {
                     if (waitPage != null)
@@ -194,7 +235,6 @@
                             catch { }
                         });
                     }
-                    MainPage.Log($"鍒锋柊token澶辫触");
                     return;
                 }
                 MainPage.Log($"鍒锋柊token鎴愬姛");

--
Gitblit v1.8.0