From fab43407e01474cc4f7b1d0f4b5e43ce1a038ce4 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 16 三月 2021 16:51:14 +0800 Subject: [PATCH] Merge branch 'dev-tzy' into temp-wxr --- HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection4Page.cs | 152 ++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 126 insertions(+), 26 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection4Page.cs b/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection4Page.cs index 490f4a8..3d66b86 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection4Page.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection4Page.cs @@ -61,12 +61,9 @@ //杩欎釜鐣岄潰鐨勮儗鏅渶瑕佺櫧鑹� bodyFrameLayout.BackgroundColor = UI.CSS.CSS_Color.MainBackgroundColor; -#if __IOS__ -#endif -#if __Android__ //娣诲姞鎺ユ敹钃濈墮鍙嶉鐨勪簨浠� - HdlAndroidBluetoothLogic.Current.AddReceiveEvent(this.BluetoothReceiveEvent); -#endif + HdlBluetoothLogic.Current.AddReceiveEvent(this.BluetoothReceiveEvent); + //娣诲姞浜戠鍙嶉浜嬩欢 HdlCloudReceiveLogic.Current.AddCloudReceiveEvent("AddMiniRemoteControlDirection4Page", this.CloudReceiveEvent); @@ -212,6 +209,19 @@ bodyFrameLayout.AddChidren(btnUse); btnUse.ButtonClickEvent += (sender, e) => { + //鍏虫帀鐣岄潰 + this.CloseForm(); + HdlFormLogic.Current.CloseFormByFormName("AddThirdPartyDeviceMenuListPage"); + HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.GetPirDeviceList(this, () => + { + Application.RunOnMainThread(() => + { + var page = new UI2.PersonalCenter.PirDevice.PirMain(); + MainPage.BasePageView.AddChidren(page); + page.Show(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }); + }); }; } @@ -255,7 +265,9 @@ btnReDo.ButtonClickEvent += (sender, e) => { //閲嶆柊鍒濆鍖栦腑閮ㄤ俊鎭� - this.InitMiddleFrame(); + this.CloseForm(); + var form = new AddMiniRemoteControlDirection2Page(); + form.AddForm(this.wifiName, this.wifiPsw); }; } @@ -268,14 +280,99 @@ /// </summary> private void SendAccountAndPswToBluetooth() { -#if __IOS__ -#endif -#if __Android__ //鑾峰彇鍙戦�佸埌钃濈墮鐨勬暟鎹� var sendData = this.GetSendToBluetoothData(); //涓嶇瓑寰� - HdlAndroidBluetoothLogic.Current.SendData(sendData); -#endif + HdlBluetoothLogic.Current.SendData(sendData); + } + + #endregion + + #region 鈻� 绾㈠瀹濈浉鍏虫柟娉昣____________________ + + /// <summary> + /// 妫�娴嬫槸鍚︽槸鏂扮殑绾㈠瀹� + /// </summary> + /// <param name="pushEnum">鎺ㄩ�佹灇涓�</param> + /// <param name="i_data">鎺ㄩ�佺殑鏁版嵁</param> + /// <returns></returns> + private bool CheckIsNewMiniRemoteControl(CloudPushEnum pushEnum, string i_data) + { + if (pushEnum != CloudPushEnum.A鏂拌澶囦笂鎶�) { return false; } + + try + { + var strSpk = string.Empty; + //杞负json + var json = Newtonsoft.Json.Linq.JObject.Parse(i_data); + var linqArry = json["objects"] as Newtonsoft.Json.Linq.JArray; + if (linqArry != null) + { + //鏁扮粍绫诲瀷 + if (linqArry.Count == 0) { return false; } + strSpk = linqArry[0]["spk"].ToString(); + } + else + { + //闈炴暟缁勭被鍨� + strSpk = json["objects"]["spk"].ToString(); + } + if (strSpk != Entity.SPK.IrModule) + { + //濡傛灉涓嶆槸绾㈠瀹濈殑璇� + return false; + } + return true; + } + catch { return false; } + } + + /// <summary> + /// 鍒锋柊绾㈠瀹濅俊鎭� + /// </summary> + /// <param name="successEvent">鎴愬姛鐨勫洖璋冧簨浠�</param> + private void RefreshMiniRemoteControlInfo(Action successEvent) + { + var pra = new Dictionary<string, object>(); + pra.Add("homeId", Entity.DB_ResidenceData.Instance.CurrentRegion.RegionID); + pra.Add("spk", Entity.SPK.IrModule); + + var requestJson = DAL.Server.HttpUtil.GetSignRequestJson(pra); + HdlThreadLogic.Current.RunThread(() => + { + int count = 0; + while (this.Parent != null) + { + try + { + //瓒呰繃5娆¢兘涓嶆垚鍔�,鐪熶笉澶勭悊浜� + count++; + if (count > 5) { return; } + + //鑾峰彇鍏ㄩ儴绾㈠瀹濆垪琛� + var result = DAL.Server.HttpUtil.RequestHttpsPostFroHome(DAL.Server.NewAPI.Api_Post_GetDevcieList, requestJson); + if (result == null || result.Code != DAL.Server.StateCode.SUCCESS) + { + System.Threading.Thread.Sleep(3000); + continue; + } + var listDevice = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.DevcieApiPack>(result.Data.ToString()); + foreach (var newFunction in listDevice.list) + { + //娣诲姞鍒扮紦瀛樺綋涓� + newFunction.SaveFunctionFile(); + Entity.FunctionList.List.IniFunctionList(newFunction.savePath, true); + } + //璋冪敤鍥炶皟鍑芥暟 + successEvent?.Invoke(); + return; + } + catch + { + System.Threading.Thread.Sleep(3000); + } + } + }); } #endregion @@ -289,15 +386,22 @@ /// <param name="i_data">鎺ㄩ�佺殑鍐呭</param> private void CloudReceiveEvent(CloudPushEnum pushEnum, string i_data) { - if (pushEnum != CloudPushEnum.A鏂拌澶囦笂鎶�) { return; } + //妫�娴嬫槸鍚︽槸鏂扮殑绾㈠瀹� + if (this.CheckIsNewMiniRemoteControl(pushEnum, i_data) == false) + { + return; + } + //鍒锋柊绾㈠瀹濅俊鎭� + this.RefreshMiniRemoteControlInfo(() => + { + //绉婚櫎杩欎釜浜嬩欢 + HdlCloudReceiveLogic.Current.RemoveCloudReceiveEvent("AddMiniRemoteControlDirection4Page"); + //鍋滄绾跨▼ + this.timeoutThreadActivity = false; - //鎺ユ敹鍒板氨绉婚櫎杩欎釜浜嬩欢 - HdlCloudReceiveLogic.Current.RemoveCloudReceiveEvent("AddMiniRemoteControlDirection4Page"); - //鍋滄绾跨▼ - this.timeoutThreadActivity = false; - - //娣诲姞璁惧鎴愬姛涔嬪悗,澶勭悊涓�浜涗笢瑗� - this.DoSomethingAfterAddDeviceSuccess(); + //娣诲姞璁惧鎴愬姛涔嬪悗,澶勭悊涓�浜涗笢瑗� + this.DoSomethingAfterAddDeviceSuccess(); + }); } /// <summary> @@ -367,8 +471,8 @@ { HdlThreadLogic.Current.RunThread(() => { - //300绉掕秴鏃� - int timeout = 300; + //360绉掕秴鏃� + int timeout = 360; while (this.timeoutThreadActivity == false && this.Parent != null) { System.Threading.Thread.Sleep(1000); @@ -399,11 +503,7 @@ public override void CloseFormBefore() { //鎽ф瘉钃濈墮 -#if __IOS__ -#endif -#if __Android__ - HdlAndroidBluetoothLogic.Current.Dispone(); -#endif + HdlBluetoothLogic.Current.Dispone(); HdlCloudReceiveLogic.Current.RemoveCloudReceiveEvent("AddMiniRemoteControlDirection4Page"); base.CloseFormBefore(); -- Gitblit v1.8.0