From 3aba1c7fea5f0adb1b169e8060ce956188e80a2b Mon Sep 17 00:00:00 2001 From: wxr <wxr@hdlchina.com.cn> Date: 星期二, 24 九月 2024 10:46:18 +0800 Subject: [PATCH] 删除解锁APP的模式 --- HDL_ON/Common/ApiUtlis.cs | 71 ++++++++++++++++++++++++++++++++--- 1 files changed, 64 insertions(+), 7 deletions(-) diff --git a/HDL_ON/Common/ApiUtlis.cs b/HDL_ON/Common/ApiUtlis.cs index 2992899..d4666d5 100644 --- a/HDL_ON/Common/ApiUtlis.cs +++ b/HDL_ON/Common/ApiUtlis.cs @@ -1,7 +1,7 @@ 锘縰sing System; using System.Collections.Generic; -using HDL_ON; -using HDL_ON.DAL; +using System.Net.Http; +using System.Threading.Tasks; using HDL_ON.DAL.Server; using HDL_ON.Entity; using HDL_ON.UI.UI2.FuntionControlView.Video; @@ -76,7 +76,7 @@ /// <summary> /// token鏄惁鏈夋晥 /// </summary> - public bool tokenInvalid = false; + public bool IsValidToken = false; public bool hadInternet = true; /// <summary> @@ -104,12 +104,12 @@ string code = StateCode.SUCCESS; Inverter.Ins.H5Page = null;//閲嶇疆鍏変紡椤甸潰 - var downloadDataThread = new System.Threading.Thread(() => + var downloadDataThread = new System.Threading.Thread(async() => { try { //澧炲姞3绉掍簯鏈嶅姟鍣ㄨ繛鎺ユ娴嬶紝杩炰笉涓婃湇鍔″櫒鐨勬椂鍊欎笉鍒锋柊鏁版嵁 - hadInternet = true; + //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); @@ -163,6 +163,7 @@ } finally { + MainPage.Log("鏈嶅姟鍣ㄨ繛鎺ョ姸鎬�:" + hadInternet); if (!hadInternet) { Application.RunOnMainThread(() => @@ -178,9 +179,44 @@ MainPage.Log($"杩涘叆璇诲彇浜戠鏁版嵁绾跨▼"); //===================鍒锋柊Token======================= code = Ins.HttpRequest.RefreshToken(); - if (code != StateCode.SUCCESS) { + DownloadDataComplete = true; + IsValidToken= 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澶辫触"); + + if (waitPage != null) { Application.RunOnMainThread(() => @@ -194,8 +230,11 @@ catch { } }); } - MainPage.Log($"鍒锋柊token澶辫触"); return; + } + else + { + hadInternet = true; } MainPage.Log($"鍒锋柊token鎴愬姛"); //===================鍒锋柊浣忓畢淇℃伅======================= @@ -784,6 +823,24 @@ var pack = Ins.HttpRequest.GetSecurityList(); } + //public async Task<bool> CanConnectToHost() + //{ + // try + // { + // using (HttpClient client = new HttpClient()) + // { + // client.Timeout = TimeSpan.FromSeconds(3); // 瓒呮椂鏃堕棿 + // HttpResponseMessage response = await client.GetAsync(HttpUtil.GlobalRequestHttpsHost); + // return response.IsSuccessStatusCode; + // } + // } + // catch (Exception ex) + // { + // MainPage.Log(ex.StackTrace); + // return false; + // } + //} + } } -- Gitblit v1.8.0