From eda3fb873e59544ff36301b51e05aef64f87b0f9 Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期五, 27 八月 2021 13:21:21 +0800 Subject: [PATCH] Merge branch 'newBranch1' of http://172.16.1.23:6688/r/~wxr/HDL_APP_Project into newBranch1 --- HDL_ON/Common/ApiUtlis.cs | 386 +++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 276 insertions(+), 110 deletions(-) diff --git a/HDL_ON/Common/ApiUtlis.cs b/HDL_ON/Common/ApiUtlis.cs index d1aace8..65338b6 100644 --- a/HDL_ON/Common/ApiUtlis.cs +++ b/HDL_ON/Common/ApiUtlis.cs @@ -4,6 +4,8 @@ using HDL_ON.DAL; using HDL_ON.DAL.Server; using HDL_ON.Entity; +using HDL_ON.UI.UI2.FuntionControlView.Video; +using Newtonsoft.Json; using Shared; namespace HDL_ON.Common @@ -19,7 +21,7 @@ { get { - if(apiUtlis == null) + if (apiUtlis == null) { apiUtlis = new ApiUtlis(); } @@ -33,7 +35,7 @@ { get { - if(httpRequest == null) + if (httpRequest == null) { httpRequest = new HttpServerRequest(); } @@ -46,8 +48,8 @@ public bool GatewayOnlineVerification() { bool result = DB_ResidenceData.Instance.HomeGateway.gatewayStatus; - - if(!result) + DriverLayer.Control.Ins.GatewayOnline_Cloud = result; + if (!result) { } @@ -61,21 +63,24 @@ /// </summary> public void DownloadData() { - if (MainPage.InternetStatus == 0) + if (MainPage.InternetStatus == 0 || MainPage.NoLoginMode) return; //绾跨▼寮�濮嬫椂闂� - var beginTime = DateTime.Now.AddSeconds(6); + var endTime = DateTime.Now.AddSeconds(5); + + MainPage.Log($"寮�濮嬪悓姝ヤ簯绔暟鎹�"); DownloadDataComplete = false; var waitPage = new Loading(); MainPage.BaseView.AddChidren(waitPage); - waitPage.Start(); + waitPage.Start(Language.StringByID(StringId.PleaseWait)); string code = StateCode.SUCCESS; var downloadDataThread = new System.Threading.Thread(() => { + MainPage.Log($"杩涘叆璇诲彇浜戠鏁版嵁绾跨▼"); //===================鍒锋柊Token======================= code = Ins.HttpRequest.RefreshToken(); if (code != StateCode.SUCCESS) @@ -83,6 +88,7 @@ MainPage.Log($"鍒锋柊token澶辫触"); return; } + endTime = DateTime.Now.AddSeconds(5); MainPage.Log($"鍒锋柊token鎴愬姛"); //===================鍒锋柊浣忓畢淇℃伅======================= code = Ins.HttpRequest.GetHomePager(); @@ -91,6 +97,7 @@ MainPage.Log($"鍒锋柊浣忓畢淇℃伅澶辫触"); return; } + endTime = DateTime.Now.AddSeconds(5); MainPage.Log($"鍒锋柊浣忓畢淇℃伅鎴愬姛"); //===================鍒锋柊涓汉淇℃伅======================= code = Ins.HttpRequest.GetUserInfo(); @@ -99,25 +106,26 @@ MainPage.Log($"鍒锋柊涓汉淇℃伅澶辫触"); return; } + endTime = DateTime.Now.AddSeconds(5); 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; - } + //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; + //} try @@ -126,12 +134,17 @@ var roomResult = Ins.HttpRequest.GetRoomList(); if (roomResult.Code == StateCode.SUCCESS) { + endTime = DateTime.Now.AddSeconds(100); MainPage.Log($"璇诲彇鎴块棿淇℃伅鎴愬姛"); var revData = Newtonsoft.Json.JsonConvert.DeserializeObject<SpatialApiPack>(roomResult.Data.ToString()); - if (revData != null) + if (revData == null) { - SpatialInfo.CurrentSpatial.UpdateSpatialList(revData.list, OptionType.Cover); + revData = new SpatialApiPack(); } + { + SpatialInfo.CurrentSpatial.UpdateSpatialList(revData.list); + } + endTime = DateTime.Now.AddSeconds(5); } else { @@ -141,49 +154,44 @@ var deviceResult = Ins.HttpRequest.GetDeviceList(); if (deviceResult.Code == StateCode.SUCCESS) { + endTime = DateTime.Now.AddSeconds(100); MainPage.Log($"璇诲彇璁惧淇℃伅鎴愬姛"); var deviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString()); - if (deviceList != null) + if (deviceList == null) { - if (FunctionList.List.GetDeviceFunctionList().Count > 0) + deviceList = new DevcieApiPack(); + } + string delFile = ""; + if (FunctionList.List.GetDeviceFunctionList().Count > 0) + { + + for (int i = 0; i < FunctionList.List.GetDeviceFunctionList().Count;) { - for (int i = 0; i < FunctionList.List.GetDeviceFunctionList().Count;) + var localFunction = FunctionList.List.GetDeviceFunctionList()[i]; + if (localFunction.Spk_Prefix == FunctionCategory.Music || string.IsNullOrEmpty(localFunction.Spk_Prefix)) { - var localFunction = FunctionList.List.GetDeviceFunctionList()[i]; - if (localFunction.functionCategory == FunctionCategory.Music) - { - i++; - continue; - } - var newFunction = deviceList.list.Find((obj) => obj.deviceId == localFunction.deviceId); - if (newFunction == null)//濡傛灉浜戠鏈�鏂版暟鎹病鏈夎鏉℃暟鎹紝鍒欐湰鍦伴渶瑕佸垹鎺夎鏁版嵁璁板綍 - { - FunctionList.List.DeleteFunction(localFunction); - } - else - { - MainPage.Log($"deviceType:{localFunction.spk} local:{localFunction.modifyTime} server:{newFunction.modifyTime}"); - i++; - if (localFunction.modifyTime != newFunction.modifyTime) - { - localFunction.name = newFunction.name; - localFunction.collect = newFunction.collect; - localFunction.modifyTime = newFunction.modifyTime; - localFunction.roomIds = newFunction.roomIds; - localFunction.bus = newFunction.bus; - localFunction.SaveFunctionData(false); - } - deviceList.list.Remove(newFunction);//鎿嶄綔瀹岀殑鏁版嵁娓呯悊鎺夛紝鍓╀笅鐨勫氨鏄柊澧炵殑鍔熻兘 - } + i++; + continue; } - } - //澶勭悊鍓╀笅鐨勬柊澧炲姛鑳� - foreach (var newFunction in deviceList.list) - { - newFunction.SaveFunctionData(false); - FunctionList.List.IniFunctionList(newFunction.savePath); + 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 { @@ -194,44 +202,49 @@ var pack = Ins.HttpRequest.GetSceneList(); if (pack.Code == StateCode.SUCCESS) { + endTime = DateTime.Now.AddSeconds(100); MainPage.Log($"璇诲彇鍦烘櫙鏁版嵁鎴愬姛"); - var sceneList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(pack.Data.ToString()); - if (sceneList != null) + var sceneList = JsonConvert.DeserializeObject<List<Scene>>(pack.Data.ToString()); + if (sceneList == null) { - for (int i = 0; i < FunctionList.List.scenes.Count;) + 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) { - var localScene = FunctionList.List.scenes[i]; - if (localScene == null) + 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) { - FunctionList.List.scenes.Remove(localScene); - continue; - } - var newScene = sceneList.Find((obj) => obj.userSceneId == localScene.userSceneId); - if (newScene == null)//濡傛灉浜戠鏈�鏂版暟鎹病鏈夎鏉℃暟鎹紝鍒欐湰鍦伴渶瑕佸垹鎺夎鏁版嵁璁板綍 - { - FunctionList.List.DeleteScene(localScene, false); - } - else - { - i++; - if (localScene.modifyTime != newScene.modifyTime) + var serverTemp = serverTempList.Find((obj) => obj.userSceneId == localScene.userSceneId); + if (serverTemp != null) { - localScene.name = newScene.name; - localScene.collect = newScene.collect; - localScene.modifyTime = newScene.modifyTime; - localScene.roomIds = newScene.roomIds; - localScene.SaveSceneData(false); + localScene.functions = serverTemp.functions; + localScene.SaveSceneFile(); } - sceneList.Remove(newScene);//鎿嶄綔瀹岀殑鏁版嵁娓呯悊鎺夛紝鍓╀笅鐨勫氨鏄柊澧炵殑鍔熻兘 } } - //澶勭悊鍓╀笅鐨勬柊澧炲姛鑳� - foreach (var newScene in sceneList) + else { - newScene.SaveSceneData(false); - FunctionList.List.scenes.Add(newScene); + IMessageCommon.Current.ShowErrorInfoAlter(packInfo.Code); } } + endTime = DateTime.Now.AddSeconds(5); } else { @@ -240,6 +253,61 @@ //===================璇诲彇閫昏緫鍒楄〃========================== UI.UI2.Intelligence.Automation.MainView.GetLogicList(); + + //===================璇诲彇鍙瀵硅鏁版嵁========================== + //鍒ゆ柇鏄惁鏈夊彲瑙嗗璁叉暟鎹紝鏈夊垯鏄剧ず鍙瀵硅icon + //var flVideoInfo = HttpRequest.CheckFlVideo(); + //if(flVideoInfo.Code == StateCode.SUCCESS) + //{ + // FunctionList.List.videoIntercom1111 = Newtonsoft.Json.JsonConvert.DeserializeObject<UI.UI2.FuntionControlView.Video.VideoClouds>(flVideoInfo.Data.ToString()); + //} + + //======================鑾峰彇鍙瀵硅璁惧鍒楄〃==================== + bool isInterphoneType_HDL = false;//鏄惁涓篐DLLinphone鍙瀵硅 + var videoInfo= VideoSend.GetVideoInfoList(); + if (videoInfo.Code == StateCode.SUCCESS) + { + string videoList = videoInfo.Data.ToString(); + FunctionList.List.videoIntercom = JsonConvert.DeserializeObject<List<UI.UI2.FuntionControlView.Video.Video>>(videoList); + + foreach (var video in FunctionList.List.videoIntercom) + { + if (video.interphoneType == InterphoneType.IMOUVISIAL.ToString()) + { + UI.UI2.PersonalCenter.PirDevice.PirSend.LcSubAccessToken = video.subAccountToken; + } else if (video.interphoneType == InterphoneType.HDL.ToString()) { + isInterphoneType_HDL = true; + } + else if(video.interphoneType == InterphoneType.HDL.ToString()) + { + DB_ResidenceData.Instance.SupportFacePass = true; + DB_ResidenceData.Instance.SaveResidenceData(); + } + } + } + + + //======================瀹夐槻==================== + GetSecurityList(); + //======================SIP璐﹀彿==================== + + //======================鑾峰彇Sip璐﹀彿骞朵笖鍒濆鍖朣DK鍙瀵硅璁惧鍒楄〃==================== + //濡傛灉妫�娴嬬嚎绋嬫病鍚姩锛屾墠缁х画涓嬮潰鎿嶄綔 鍥犱负App鏈夊彲鑳藉垰鍚姩椹笂鏀跺埌鎺ㄩ�佷簡锛岀劧鍚庢墠鎵ц鍒拌繖閲� + if (HDLLinphone.Current.CheckIncomingCallThreadIsNull()) { + //褰撳墠浣忓畢鏄疕DL鍙瀵硅绫诲瀷鐨勮澶� + if (isInterphoneType_HDL) + { + //HDLLinphone鍙瀵硅,鑾峰彇Sip璐﹀彿骞跺垵濮嬪寲SDK + HDLLinphone.Current.GetHDLSipInfoAndInitSDK(DB_ResidenceData.Instance.CurrentRegion.id); + } + else + { + Utlis.WriteLine("褰撳墠浣忓畢涓嶆敮鎸丠DL鍙瀵硅,閫�鍑虹櫥褰曟墍鏈夎处鍙�"); + //褰撳墠浣忓畢涓嶆敮鎸丠DL鍙瀵硅 + HDLLinphone.Current.LogoutAllAccount(); + } + } + } catch (Exception ex) { @@ -249,43 +317,141 @@ { Application.RunOnMainThread(() => { - beginTime = DateTime.MinValue; + MainPage.Log($"缁撴潫璇诲彇浜戠鏁版嵁绾跨▼"); + endTime = DateTime.MinValue; DownloadDataComplete = true; - waitPage.Hide(); - waitPage.RemoveFromParent(); + if (waitPage != null) + { + waitPage.RemoveFromParent(); + waitPage = null; + } }); + //涓嶈�冭檻缃戝叧鎯呭喌锛岀洿鎺ヨ闃� + DAL.Mqtt.MqttClient.InitState(); + + FunctionList.List.Read3tyFunctionStatus(); } }); downloadDataThread.IsBackground = true; + downloadDataThread.Priority = System.Threading.ThreadPriority.Highest; downloadDataThread.Start(); //缃戠粶鍗¢】锛岀粓姝笅杞界嚎绋� new System.Threading.Thread(() => { - while (beginTime < DateTime.Now) + try { - if (DownloadDataComplete) + while (endTime > DateTime.Now) { - break; + if (DownloadDataComplete) + { + break; + } + System.Threading.Thread.Sleep(100); } - System.Threading.Thread.Sleep(100); - } - if (!DownloadDataComplete) - { - downloadDataThread.Abort(); - } - DownloadDataComplete = true; - Application.RunOnMainThread(() => - { - waitPage.Hide(); - waitPage.RemoveFromParent(); - }); - //鍒濆鍖栨暟鎹� - //SpatialInfo.CurrentSpatial.Clear(); + if (!DownloadDataComplete) + { + //downloadDataThread.Abort(); + } + DownloadDataComplete = true; + Application.RunOnMainThread(() => + { + if (waitPage != null) + { + waitPage.RemoveFromParent(); + waitPage = null; + } + }); + //鍒濆鍖栨暟鎹� + //SpatialInfo.CurrentSpatial.Clear(); - + } + catch { } + finally + { + if (DB_ResidenceData.Instance.CurrentRegion != null) + { + #region 璇诲彇鏈湴鏁版嵁 + //璇诲彇闊充箰淇℃伅 + UI.Music.A31MusicModel.ReadMusicStates(); + //鎼滅储缃戝叧 + DriverLayer.Control.Ins.SearchLoaclGateway(); + //閲嶆柊杩炴帴mqtt + DAL.Mqtt.MqttClient.DisConnectRemote("鍒锋柊鏁版嵁锛岄噸杩瀖qtt",false); + #endregion + } + } }) { IsBackground = true }.Start(); } + + /// <summary> + /// 鑾峰彇鍔熻兘淇℃伅 + /// </summary> + public void GetFunctionInfo(string functionId) + { + var deviceResult = Ins.HttpRequest.GetDeviceInfo(functionId); + if (deviceResult.Code == StateCode.SUCCESS) + { + MainPage.Log($"璇诲彇璁惧淇℃伅鎴愬姛"); + var packList = JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString()); + + foreach(var function in packList.list) + { + function.SaveFunctionFile(); + FunctionList.List.IniFunctionList(function.savePath,true); + } + } + } + + /// <summary> + /// 鑾峰彇瀹夐槻鍒楄〃 + /// </summary> + public void GetSecurityList() + { + var pack = Ins.HttpRequest.GetSecurityList(); + if (pack.Code == StateCode.SUCCESS) + { + var packList = JsonConvert.DeserializeObject<List<SecurityAlarm>>(pack.Data.ToString()); + var sidList = new List<string>(); + foreach (var function in packList) + { + 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) + { + foreach (var file in filePathList) + { + FileUtlis.Files.DeleteFile(file); + } + } + foreach (var function in infoList) + { + function.SaveFile(); + FunctionList.List.IniFunctionList(function.savePath, true); + } + } + } + else + { + MainPage.Log($"璇诲彇瀹夐槻鍒楄〃澶辫触:Code:{pack.Code}; Msg:{pack.message}"); + } + + } + + /// <summary> + /// 鑾峰彇SIP璐﹀彿淇℃伅 + /// </summary> + public void GetSipInfo() + { + var pack = Ins.HttpRequest.GetSecurityList(); + } + + } -} +} \ No newline at end of file -- Gitblit v1.8.0