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 | 45 +++++++++++++++++++++++++++++++-------------- 1 files changed, 31 insertions(+), 14 deletions(-) diff --git a/HDL_ON/Common/ApiUtlis.cs b/HDL_ON/Common/ApiUtlis.cs index 1dc09e1..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(() => @@ -181,7 +182,7 @@ if (code != StateCode.SUCCESS) { DownloadDataComplete = true; - hadInternet = false; + IsValidToken= false; try { var spatialInfoDataBytes = FileUtlis.Files.ReadFile("SpatialInfoData"); @@ -214,14 +215,8 @@ MainPage.Log("Error", $"{this.GetType()}:鍔犺浇缂撳瓨璁惧鏁版嵁寮傚父:{ex.StackTrace}"); } MainPage.Log($"鍒锋柊token澶辫触"); - return; - } - else - { - hadInternet = true; - } - if (code != StateCode.SUCCESS) - { + + if (waitPage != null) { Application.RunOnMainThread(() => @@ -236,6 +231,10 @@ }); } return; + } + else + { + hadInternet = true; } MainPage.Log($"鍒锋柊token鎴愬姛"); //===================鍒锋柊浣忓畢淇℃伅======================= @@ -824,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