From 691dbe24f5724f153e07947c7b75bdfea5f0b6d5 Mon Sep 17 00:00:00 2001 From: wxr <wxr@hdlchina.com.cn> Date: 星期二, 24 九月 2024 16:15:15 +0800 Subject: [PATCH] 离线控制模式 --- HDL_ON/Common/ApiUtlis.cs | 110 ++++++++++++++++++++++++++++++++---------------------- 1 files changed, 65 insertions(+), 45 deletions(-) diff --git a/HDL_ON/Common/ApiUtlis.cs b/HDL_ON/Common/ApiUtlis.cs index d4666d5..93b3a72 100644 --- a/HDL_ON/Common/ApiUtlis.cs +++ b/HDL_ON/Common/ApiUtlis.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using HDL_ON.DAL.Server; using HDL_ON.Entity; +using HDL_ON.UI; using HDL_ON.UI.UI2.FuntionControlView.Video; using HDL_ON.UI.UI2.Intelligence.Automation; using Newtonsoft.Json; @@ -104,7 +105,7 @@ string code = StateCode.SUCCESS; Inverter.Ins.H5Page = null;//閲嶇疆鍏変紡椤甸潰 - var downloadDataThread = new System.Threading.Thread(async() => + var downloadDataThread = new System.Threading.Thread(() => { try { @@ -279,26 +280,6 @@ return; } MainPage.Log($"鍒锋柊涓汉淇℃伅鎴愬姛"); - - //int count = 0; - //while (count < 10) - //{ - // if (DB_ResidenceData.Instance.CheckWhetherGatewayIdIsNull()) - // { - // System.Threading.Thread.Sleep(200); - // } - // else - // { - // break; - // } - // count++; - //} - //if (DB_ResidenceData.Instance.CheckWhetherGatewayIdIsNull()) - //{ - // return; - //} - - //return; try { @@ -746,6 +727,34 @@ catch (Exception ex){ MainPage.Log("Error", $"璇诲彇鏈湴鏁版嵁寮傚父锛歿ex.StackTrace}"); } + + try + { + HomePage.LoadEvent_CheckTokenValid(); + if (IsValidToken && !UserInfo.Current.IsTipedInvalidToken) + { + UserInfo.Current.IsTipedInvalidToken = true; + UserInfo.Current.SaveUserInfo(); + Application.RunOnMainThread(() => + { + try + { + new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.TokenInvalidTipMsg, StringId.OfflineControl, StringId.GoLogin, () => + { + HDLCommon.Current.Logout(); + }); + } + catch (Exception ex) + { + MainPage.Log("Error", $"鎻愮ず鐧诲綍鍑瘉绐楀彛鍔犺浇寮傚父:{ex.StackTrace}"); + } + }); + } + } + catch (Exception ex) + { + MainPage.Log("Error", $"鏇存柊鐧诲綍鍑瘉鏂规硶璋冪敤寮傚父:{ex.StackTrace}"); + } } } }) @@ -778,39 +787,50 @@ { lock (FunctionList.List.securities) { - var pack = Ins.HttpRequest.GetSecurityList(); - if (pack.Code == StateCode.SUCCESS) + try { - var packList = JsonConvert.DeserializeObject<List<SecurityAlarm>>(pack.Data.ToString()); - Console.WriteLine("瀹夐槻鎬绘暟锛�" + packList.Count); - var sidList = new List<string>(); - foreach (var function in packList) + var pack = Ins.HttpRequest.GetSecurityList(); + if (pack.Code == StateCode.SUCCESS) { - sidList.Add(function.sid); - } - var infoListPack = Ins.httpRequest.GetSecurityInfo(sidList, new List<string>()); - var infoList = JsonConvert.DeserializeObject<List<SecurityAlarm>>(infoListPack.Data.ToString()); - if (infoList != null) - { - var filePathList = FileUtlis.Files.ReadFiles().FindAll((obj) => obj.StartsWith("SecurityData_")); - if (filePathList != null) + var packList = JsonConvert.DeserializeObject<List<SecurityAlarm>>(pack.Data.ToString()); + Console.WriteLine("瀹夐槻鎬绘暟锛�" + packList.Count); + var sidList = new List<string>(); + foreach (var function in packList) { - foreach (var file in filePathList) + sidList.Add(function.sid); + } + if (sidList.Count == 0) + { + return; + } + var infoListPack = Ins.httpRequest.GetSecurityInfo(sidList, new List<string>()); + var infoList = JsonConvert.DeserializeObject<List<SecurityAlarm>>(infoListPack.Data.ToString()); + if (infoList != null) + { + var filePathList = FileUtlis.Files.ReadFiles().FindAll((obj) => obj.StartsWith("SecurityData_")); + if (filePathList != null) { - FileUtlis.Files.DeleteFile(file); + foreach (var file in filePathList) + { + FileUtlis.Files.DeleteFile(file); + } + } + FunctionList.List.securities.Clear(); + foreach (var function in infoList) + { + function.SaveFile(); + FunctionList.List.IniFunctionList(function.savePath, true); } } - FunctionList.List.securities.Clear(); - foreach (var function in infoList) - { - function.SaveFile(); - FunctionList.List.IniFunctionList(function.savePath, true); - } + } + else + { + MainPage.Log($"璇诲彇瀹夐槻鍒楄〃澶辫触:Code:{pack.Code}; Msg:{pack.message}"); } } - else + catch (Exception ex) { - MainPage.Log($"璇诲彇瀹夐槻鍒楄〃澶辫触:Code:{pack.Code}; Msg:{pack.message}"); + MainPage.Log("Error", $"璇诲彇瀹夐槻鍒楄〃澶辫触:Code:{ex.StackTrace}"); } } } -- Gitblit v1.8.0