From bbd6b592a6b883e013ff1e0a574976ceba5009ea Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期四, 27 十月 2022 09:11:33 +0800 Subject: [PATCH] Merge branch 'dev--wxr' --- HDL_ON/Common/ApiUtlis.cs | 298 +++++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 186 insertions(+), 112 deletions(-) diff --git a/HDL_ON/Common/ApiUtlis.cs b/HDL_ON/Common/ApiUtlis.cs index c618e15..8369a48 100644 --- a/HDL_ON/Common/ApiUtlis.cs +++ b/HDL_ON/Common/ApiUtlis.cs @@ -43,6 +43,15 @@ } } /// <summary> + /// 璇诲彇璁惧鍔熻兘鏁版嵁瀹屾垚 + /// </summary> + bool complateDevice = false; + /// <summary> + /// 璇诲彇鍦烘櫙鏁版嵁瀹屾垚 + /// </summary> + bool complateScene = false; + + /// <summary> /// 鏍¢獙缃戝叧鏄惁鍦ㄧ嚎 /// </summary> public bool GatewayOnlineVerification() @@ -79,6 +88,8 @@ waitPage.Start(Language.StringByID(StringId.PleaseWait)); string code = StateCode.SUCCESS; + + Inverter.Ins.H5Page = null;//閲嶇疆鍏変紡椤甸潰 var downloadDataThread = new System.Threading.Thread(() => { @@ -152,128 +163,164 @@ { MainPage.Log($"璇诲彇鎴块棿鏁版嵁澶辫触:Code:{roomResult.Code}; msg:{roomResult.message}"); } - //===================璁惧======================= - var deviceResult = Ins.HttpRequest.GetDeviceList("30","1"); - if (deviceResult.Code == StateCode.SUCCESS) - { - endTime = DateTime.Now.AddSeconds(5); - MainPage.Log($"璇诲彇璁惧淇℃伅鎴愬姛"); - MainPage.Log($"sid鍒楄〃鑾峰彇===="+ deviceResult.Data.ToString()); - var deviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString()); - if (deviceList == null) - { - deviceList = new DevcieApiPack(); - } + //===================璁惧======================= + new System.Threading.Thread(() => + { try { - while (deviceList.totalPage != deviceList.pageNo) + complateDevice = false; + var deviceResult = Ins.HttpRequest.GetDeviceList("30", "1"); + if (deviceResult.Code == StateCode.SUCCESS) { - var deviceResult2 = Ins.HttpRequest.GetDeviceList("30", Convert.ToInt32(deviceList.pageNo) + 1 + ""); - if (deviceResult2.Code == StateCode.SUCCESS) + endTime = DateTime.Now.AddSeconds(5); + + MainPage.Log($"璇诲彇璁惧淇℃伅鎴愬姛"); + MainPage.Log($"sid鍒楄〃鑾峰彇====" + deviceResult.Data.ToString()); + var deviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString()); + if (deviceList == null) { - var deviceList2 = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString()); - deviceList.pageNo = deviceList2.pageNo; - deviceList.list.AddRange(deviceList2.list); + deviceList = new DevcieApiPack(); } - } - }catch(Exception ex) - { - - } - - string delFile = ""; - if (FunctionList.List.GetDeviceFunctionList().Count > 0) - { - - for (int i = 0; i < FunctionList.List.GetDeviceFunctionList().Count;) - { - var localFunction = FunctionList.List.GetDeviceFunctionList()[i]; - //if (SPK.MusicSpkList().Contains(localFunction.spk)) - //{ - // i++; - // continue; - //} - var newFunction = deviceList.list.Find((obj) => obj.deviceId == localFunction.deviceId); - - if (delFile == localFunction.savePath) + try { - i++; - continue; - } - delFile = localFunction.savePath; - FunctionList.List.DeleteFunction(localFunction); - } - } - //澶勭悊鍓╀笅鐨勬柊澧炲姛鑳� - foreach (var newFunction in deviceList.list) - { - newFunction.AssembleStatus(); - newFunction.SaveFunctionFile(); - FunctionList.List.IniFunctionList(newFunction.savePath); - } - endTime = DateTime.Now.AddSeconds(5); - } - else - { - MainPage.Log($"璇诲彇浜戠璁惧鏁版嵁澶辫触:Code:{deviceResult.Code}; Msg:{deviceResult.message}"); - } - - //===================鍦烘櫙========================== - var pack = Ins.HttpRequest.GetSceneList(); - if (pack.Code == StateCode.SUCCESS) - { - endTime = DateTime.Now.AddSeconds(100); - MainPage.Log($"璇诲彇鍦烘櫙鏁版嵁鎴愬姛"); - var sceneList = JsonConvert.DeserializeObject<List<Scene>>(pack.Data.ToString()); - if (sceneList == null) - { - sceneList = new List<Scene>(); - } - FunctionList.List.scenes.Clear(); - - //澶勭悊鍓╀笅鐨勬柊澧炲姛鑳� - foreach (var tempScene in sceneList) - { - tempScene.SaveSceneFile(); - FunctionList.List.scenes.Add(tempScene); - } - //濡傛灉鏄竴绔彛闇�瑕佹彁鍓嶄笅杞藉満鏅暟鎹紝鍚﹀垯鎺у埗涓嶄簡涓�绔彛鍦烘櫙 - if (DB_ResidenceData.Instance.GatewayType == 0) - { - var sceneIds = new List<string>(); - foreach (var tempScene in FunctionList.List.scenes) - { - sceneIds.Add(tempScene.userSceneId); - } - var packInfo = HttpRequest.GetSceneListInfo(sceneIds); - if (packInfo.Code == StateCode.SUCCESS) - { - var serverTempList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(packInfo.Data.ToString()); - foreach (var localScene in FunctionList.List.scenes) - { - var serverTemp = serverTempList.Find((obj) => obj.userSceneId == localScene.userSceneId); - if (serverTemp != null) + while (deviceList.totalPage != deviceList.pageNo) { - localScene.functions = serverTemp.functions; - localScene.SaveSceneFile(); + var deviceResult2 = Ins.HttpRequest.GetDeviceList("30", Convert.ToInt32(deviceList.pageNo) + 1 + ""); + if (deviceResult2.Code == StateCode.SUCCESS) + { + var deviceList2 = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString()); + deviceList.pageNo = deviceList2.pageNo; + deviceList.list.AddRange(deviceList2.list); + } } } + catch (Exception ex) + { + + } + finally + { + complateDevice = true; + } + + string delFile = ""; + if (FunctionList.List.GetDeviceFunctionList().Count > 0) + { + + for (int i = 0; i < FunctionList.List.GetDeviceFunctionList().Count;) + { + var localFunction = FunctionList.List.GetDeviceFunctionList()[i]; + //if (SPK.MusicSpkList().Contains(localFunction.spk)) + //{ + // i++; + // continue; + //} + var newFunction = deviceList.list.Find((obj) => obj.deviceId == localFunction.deviceId); + + if (delFile == localFunction.savePath) + { + i++; + continue; + } + delFile = localFunction.savePath; + FunctionList.List.DeleteFunction(localFunction); + } + } + //澶勭悊鍓╀笅鐨勬柊澧炲姛鑳� + foreach (var newFunction in deviceList.list) + { + newFunction.AssembleStatus(); + newFunction.SaveFunctionFile(); + FunctionList.List.IniFunctionList(newFunction.savePath); + } + endTime = DateTime.Now.AddSeconds(5); } else { - IMessageCommon.Current.ShowErrorInfoAlter(packInfo.Code); + MainPage.Log($"璇诲彇浜戠璁惧鏁版嵁澶辫触:Code:{deviceResult.Code}; Msg:{deviceResult.message}"); } + }catch (Exception ex) + { + MainPage.Log($"============璁惧============{ex.Message}"); } - endTime = DateTime.Now.AddSeconds(5); - } - else + finally + { + complateDevice = true; + } + }) + { IsBackground = true }.Start(); + + //===================鍦烘櫙========================== + new System.Threading.Thread(() => { - MainPage.Log($"璇诲彇浜戠鍦烘櫙鏁版嵁澶辫触:Code:{pack.Code}; Msg:{pack.message}"); - } + try + { + complateScene = true; + var pack = Ins.HttpRequest.GetSceneList(); + if (pack.Code == StateCode.SUCCESS) + { + endTime = DateTime.Now.AddSeconds(100); + MainPage.Log($"璇诲彇鍦烘櫙鏁版嵁鎴愬姛"); + var sceneList = JsonConvert.DeserializeObject<List<Scene>>(pack.Data.ToString()); + if (sceneList == null) + { + sceneList = new List<Scene>(); + } + FunctionList.List.scenes.Clear(); + + //澶勭悊鍓╀笅鐨勬柊澧炲姛鑳� + foreach (var tempScene in sceneList) + { + tempScene.SaveSceneFile(); + FunctionList.List.scenes.Add(tempScene); + } + //濡傛灉鏄竴绔彛闇�瑕佹彁鍓嶄笅杞藉満鏅暟鎹紝鍚﹀垯鎺у埗涓嶄簡涓�绔彛鍦烘櫙 + if (DB_ResidenceData.Instance.GatewayType == 0) + { + var sceneIds = new List<string>(); + foreach (var tempScene in FunctionList.List.scenes) + { + sceneIds.Add(tempScene.userSceneId); + } + var packInfo = HttpRequest.GetSceneListInfo(sceneIds); + if (packInfo.Code == StateCode.SUCCESS) + { + var serverTempList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(packInfo.Data.ToString()); + foreach (var localScene in FunctionList.List.scenes) + { + var serverTemp = serverTempList.Find((obj) => obj.userSceneId == localScene.userSceneId); + if (serverTemp != null) + { + localScene.functions = serverTemp.functions; + localScene.SaveSceneFile(); + } + } + } + else + { + IMessageCommon.Current.ShowErrorInfoAlter(packInfo.Code); + } + } + endTime = DateTime.Now.AddSeconds(5); + } + else + { + MainPage.Log($"璇诲彇浜戠鍦烘櫙鏁版嵁澶辫触:Code:{pack.Code}; Msg:{pack.message}"); + } + }catch(Exception ex) + { + MainPage.Log($"===鍦烘櫙==={ex.Message}"); + } + finally + { + complateScene = true; + } + }) + { IsBackground = true }.Start(); //===================璇诲彇閫昏緫鍒楄〃========================== - UI.UI2.Intelligence.Automation.MainView.GetLogicList(); + UI.UI2.Intelligence.Automation.MainView.GetLogicList(true); //===================璇诲彇鍙瀵硅鏁版嵁========================== //鍒ゆ柇鏄惁鏈夊彲瑙嗗璁叉暟鎹紝鏈夊垯鏄剧ず鍙瀵硅icon @@ -358,6 +405,9 @@ //======================瀹夐槻==================== GetSecurityList(); + //======================娉ㄥ唽鎺ㄩ��==================== + httpRequest.RegisteredPush(); + } catch (Exception ex) @@ -394,15 +444,11 @@ { while (endTime > DateTime.Now) { - if (DownloadDataComplete) + if (DownloadDataComplete && complateDevice && complateScene) { break; } System.Threading.Thread.Sleep(100); - } - if (!DownloadDataComplete) - { - //downloadDataThread.Abort(); } DownloadDataComplete = true; Application.RunOnMainThread(() => @@ -413,9 +459,6 @@ waitPage = null; } }); - //鍒濆鍖栨暟鎹� - //SpatialInfo.CurrentSpatial.Clear(); - } catch { } finally @@ -433,6 +476,37 @@ } }) { IsBackground = true }.Start(); + + + + + ////涓嬭浇鍏変紡鏁版嵁 + //new System.Threading.Thread(() => { + // try + // {//00 + // HttpServerRequest http = new HttpServerRequest(); + // var packData = http.GetInverterList(); + // if (packData != null) + // { + // if (packData.Code == StateCode.SUCCESS) + // { + // var inverterList = JsonConvert.DeserializeObject<List<InverterInfo>>(packData.Data.ToString()); + // if (inverterList!= null) + // { + // FunctionList.List.InverterList = inverterList; + // } + // } + // } + // } + // catch (Exception ex) + // { + // MainPage.Log($"璇诲彇鍏変紡鏁版嵁寮傚父:{ex.Message}"); + // } + + //}) { IsBackground = true }.Start(); + + + } /// <summary> -- Gitblit v1.8.0