From f461949beb54ae5d3e0353fa49d94800d0af6fbb Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 15 三月 2022 11:23:14 +0800 Subject: [PATCH] 增加离线推送 --- HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs | 46 +++++++ HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs | 4 HDL_ON/UI/UI2/3-Intelligence/Automation/FunTpye.cs | 4 HDL_ON/UI/UI2/1-HomePage/HomePage.cs | 53 +++++--- HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs | 14 + HDL_ON/UI/UI2/2-Classification/FunctionPage.cs | 33 +++++ HDL_ON/DAL/Server/HttpUtil.cs | 4 HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs | 47 +++++++ HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs | 4 HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs | 97 ++++++++------- HDL_ON/DAL/Mqtt/MqttClient.cs | 33 +++++ SiriIntents/Server/HttpUtil.cs | 4 12 files changed, 265 insertions(+), 78 deletions(-) diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs index c74affe..2adbeba 100644 --- a/HDL_ON/DAL/Mqtt/MqttClient.cs +++ b/HDL_ON/DAL/Mqtt/MqttClient.cs @@ -218,6 +218,12 @@ Topic = $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/thing/event/appDeviceRefresh/up", QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce }; + //璁惧鍦ㄧ嚎绂荤嚎鐘舵�佹帹閫� + var deviceOnlinePush = new MqttTopicFilter() + { + Topic = $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/son/session/online", + QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce + }; //appRoomRefresh锛氭埧闂存暟鎹埛鏂伴�氱煡 var appRoomRefresh = new MqttTopicFilter() { @@ -253,6 +259,7 @@ pirStatus,pirStudy, appDeviceRefresh,appHomeRefresh,appRoomRefresh,residenceChange, topicFilterPush2, topicAlinkStatus ,mqttkeyChange, + deviceOnlinePush, securityStatusChange}); if (result.Items[0].ResultCode == MQTTnet.Client.Subscribing.MqttClientSubscribeResultCode.GrantedQoS0) { @@ -345,6 +352,32 @@ //鏂版尋涓嬬嚎涓婚鏂规 鏀跺埌鎸や笅绾夸富棰� ReceiveNotifySqueezeAsync(mMes); } + //璁惧鍦ㄧ嚎绂荤嚎鐘舵�佹帹閫� + else if(topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/son/session/online") + { + try + { + var mMes = Encoding.UTF8.GetString(e.ApplicationMessage.Payload); + Newtonsoft.Json.Linq.JObject pairs = Newtonsoft.Json.Linq.JObject.Parse(mMes); + var pairSid = pairs.GetValue("sid").ToString(); + var pairOnline = pairs.GetValue("online"); + if (!string.IsNullOrEmpty(pairSid.ToString())) + { + var function_online = FunctionList.List.Functions.Find((obj) => obj.sid == pairSid); + if (function_online != null){ + function_online.online = (bool)pairOnline; + HomePage.LoadEvent_RefreshDevcieOnline(function_online); + FunctionPage.UpdataOnline(function_online); + RoomPage.UpdataOnline(function_online); + } + } + + } + catch(Exception ex) + { + + } + } //App璁㈤槄绾㈠瀹�/缃戝叧閬ユ帶鍣ㄦ坊鍔犳垚鍔熼�氱煡 else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/thing/topo/found") { diff --git a/HDL_ON/DAL/Server/HttpUtil.cs b/HDL_ON/DAL/Server/HttpUtil.cs index 4917487..72fa068 100644 --- a/HDL_ON/DAL/Server/HttpUtil.cs +++ b/HDL_ON/DAL/Server/HttpUtil.cs @@ -17,8 +17,8 @@ /// 鍥哄畾鍩熷悕,姝e紡鐜 /// 鍏叡鍩熷悕灏辫繎瑙f瀽 /// </summary> - public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com"; - //public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";//mmmm + //public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com"; + public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";//mmmm /// <summary> /// RegionMark /// </summary> diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePage.cs b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs index 2d42531..d93097d 100644 --- a/HDL_ON/UI/UI2/1-HomePage/HomePage.cs +++ b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs @@ -189,22 +189,35 @@ //鏇存柊閾炬帴鐘舵�乮con棰滆壊 - + int ddd = 0; #if DEBUG btnResidenceName.MouseUpEventHandler = (sender, e) => { - if (UserInfo.Current.VerOpenDoorPw || string.IsNullOrEmpty(UserInfo.Current.doorPasswordString)) + //if (UserInfo.Current.VerOpenDoorPw || string.IsNullOrEmpty(UserInfo.Current.doorPasswordString)) + //{ + // var page = new DoorLockUnlockPage(new Function()); + // MainPage.BasePageView.AddChidren(page); + // page.LoadView(); + // MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + //} + //else + //{ + // Control.Ins.OneKeyUnlocking(new Function(), UserInfo.Current.doorPasswordString); + //} + + ddd++; + Function function_online = FunctionList.List.GetLightList().Find((obj) => obj.sid == "0001017DB92D2602020100010101"); + if(ddd%2 == 0) { - var page = new DoorLockUnlockPage(new Function()); - MainPage.BasePageView.AddChidren(page); - page.LoadView(); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + function_online.online = true; } else { - Control.Ins.OneKeyUnlocking(new Function(), UserInfo.Current.doorPasswordString); + function_online.online = false; } + HomePage.LoadEvent_RefreshDevcieOnline(function_online); + }; #endif @@ -1327,22 +1340,20 @@ UpdataFunctionStates(function); } - - if (!function.online) + var btnOffline = new Button() { - var btnOffline = new Button() - { - X = btnIcon.Right, - Y = Application.GetRealWidth(16), - Height = Application.GetMinRealAverage(32), - TextID = StringId.DeviceOffline, - TextColor = CSS_Color.WarningColor, - TextSize = CSS_FontSize.PromptFontSize_FirstLevel, - TextAlignment = TextAlignment.CenterLeft - }; - view.AddChidren(btnOffline); + X = btnIcon.Right, + Y = Application.GetRealWidth(16), + Height = Application.GetMinRealAverage(32), + TextID = StringId.DeviceOffline, + TextColor = CSS_Color.WarningColor, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + TextAlignment = TextAlignment.CenterLeft, + Tag = "OnlineTag", + Visible = !function.online + }; + view.AddChidren(btnOffline); - } } catch (Exception ex) { diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs index 0bbd7a4..342d1d5 100644 --- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs +++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs @@ -10,6 +10,52 @@ public partial class HomePage { /// <summary> + /// 鏇存柊璁惧鍦ㄧ嚎鐘舵�� + /// </summary> + public static void LoadEvent_RefreshDevcieOnline(Function function) + { + Application.RunOnMainThread(() => + { + if (bodyView != null) + { + foreach (var view in bodyView.functionViews) + { + if (view.Tag.ToString() == function.sid) + { + for (int i = 0; i < view.ChildrenCount; i++) + { + if (view.GetChildren(i).GetType() == typeof(Button)) + { + var btn = view.GetChildren(i) as Button; + if(btn.Tag == null) + { + continue; + } + if (btn.Tag.ToString() == function.sid) + { + if (function.online) + { + btn.UnSelectedImagePath = "Collection/Functionbg.png"; + btn.IsSelected = false; + } + else + { + btn.UnSelectedImagePath = "Collection/FunctionOfflineBg.png"; + btn.IsSelected = false; + } + } + else if (btn.Tag.ToString() == "OnlineTag") + { + btn.Visible = !function.online; + } + } + } + } + } + } + }); + } + /// <summary> /// 鏇存柊涓婚〉澶╂皵 /// </summary> public static void LoadEvent_RefreshAir() diff --git a/HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs b/HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs index 09b860a..2cb9b13 100644 --- a/HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs @@ -1,5 +1,6 @@ 锘縰sing System; using HDL_ON.Entity; +using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI @@ -16,7 +17,7 @@ /// <param name="updataFunction"></param> public void UpdataStates(Function updataFunction, FrameLayout view, VerticalScrolViewLayout scrolView, Room room = null) { - Application.RunOnMainThread((Action)(() => + Application.RunOnMainThread((() => { try { @@ -181,5 +182,49 @@ } })); } + + public void UpdataOnlineStatus(Function updataFunction, FrameLayout view, VerticalScrolViewLayout scrolView, Room room = null) + { + Application.RunOnMainThread(() => + { + try + { + if (view == null || scrolView == null || updataFunction == null) + { + return; + } + if (!scrolView.ScrollEnabled) + { + return; + } + if (room != null) + { + if (!updataFunction.roomIds.Contains(room.roomId)) + { + return; + } + } + for (int i = 0; i < scrolView.ChildrenCount; i++) + { + if (scrolView.GetChildren(i).Tag == null || scrolView.GetChildren(i).Tag.ToString() == "") + { + continue; + } + var viewTag = scrolView.GetChildren(i).Tag.ToString(); + if (scrolView.GetChildren(i).Tag != null && viewTag == updataFunction.spk + updataFunction.sid) + { + if (scrolView.GetChildren(i).GetType() == typeof(FunctionControlZone)) { + var fcView = scrolView.GetChildren(i) as FunctionControlZone; + fcView.UpdataOnline(updataFunction.online); + } + } + } + }catch (Exception ex) + { + MainPage.Log("Function Online status error : " + ex.Message); + } + }); + } + } } \ No newline at end of file diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs b/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs index 436d5f9..8185dc9 100644 --- a/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs +++ b/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs @@ -1,7 +1,6 @@ 锘縰sing System; using HDL_ON.Entity; using HDL_ON.UI.CSS; -using HDL_ON.UI.Music; using Shared; namespace HDL_ON.UI @@ -9,7 +8,7 @@ public partial class FunctionControlZone : FrameLayout { #region 鍖哄煙鎺т欢 - static FrameLayout bodyDiv; + FunctionControlZone bodyDiv; /// <summary> /// 鍔熻兘/鍦烘櫙icon /// </summary> @@ -26,6 +25,11 @@ /// 鏀惰棌鎸夐挳 /// </summary> Button btnCollectionIcon; + /// <summary> + /// 绂荤嚎鏂囨湰 + /// </summary> + Button btnOffline; + #endregion #region 鍖哄煙鍙橀噺 @@ -61,8 +65,8 @@ } LoadDiv(); - - btnIcon.UnSelectedImagePath = $"FunctionIcon/Icon/{function.IconName}.png"; + + btnIcon.UnSelectedImagePath = $"FunctionIcon/Icon/{function.IconName}.png"; if (SPK.CurtainSpkList().Contains(function.spk)) {//绐楀笜娌℃湁寮�鍏虫寜閽� @@ -229,7 +233,7 @@ if (!function.online) { bodyDiv.BackgroundColor = CSS_Color.PromptingColor2; - var btnOffline = new Button() + btnOffline = new Button() { X = Application.GetRealWidth(8 + 10 + 32), Y = Application.GetRealHeight(28 + 24), diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs b/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs index d579862..ac47acd 100644 --- a/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using HDL_ON.DriverLayer; using HDL_ON.Entity; +using HDL_ON.UI.CSS; using HDL_ON.UI.Music; using Shared; @@ -9,54 +10,60 @@ { public partial class FunctionControlZone { - /// <summary> - /// 鏇存柊寮�鍏崇姸鎬� - /// </summary> - /// <param name="upfunc"></param> - public static void UpdataOnOffState(Function upfunc) - { - if(bodyDiv!= null) - { - Application.RunOnMainThread(() => { - if(bodyDiv.Tag.ToString() == upfunc.sid) - { - for (var o = 0; o < bodyDiv.ChildrenCount; o++) - { - if (bodyDiv.GetChildren(o).GetType() == typeof(Button)) - { - var btn = bodyDiv.GetChildren(o) as Button; - if (btn.Tag != null) - { - if (btn.Tag.ToString() == upfunc.sid + "_Switch")// + "_DimmerBar") - { - btn.IsSelected = upfunc.trait_on_off.curValue.ToString() == "on"; - } - } - } - else if (bodyDiv.GetChildren(o).GetType() == typeof(DiyImageSeekBar)) - { - var btn = bodyDiv.GetChildren(o) as DiyImageSeekBar; - if (btn.Tag != null) - { - if (btn.Tag.ToString() == upfunc.sid + "_DimmerBar") - { - btn.Progress = Convert.ToInt32(upfunc.GetAttrState(FunctionAttributeKey.Brightness)); - } - } - } - } + // /// <summary> + // /// 鏇存柊寮�鍏崇姸鎬� + // /// </summary> + // /// <param name="upfunc"></param> + // public static void UpdataOnOffState(Function upfunc) + // { + // if(bodyDiv!= null) + // { + // Application.RunOnMainThread(() => { + // if(bodyDiv.Tag.ToString() == upfunc.sid) + // { + // for (var o = 0; o < bodyDiv.ChildrenCount; o++) + // { + // if (bodyDiv.GetChildren(o).GetType() == typeof(Button)) + // { + // var btn = bodyDiv.GetChildren(o) as Button; + // if (btn.Tag != null) + // { + // if (btn.Tag.ToString() == upfunc.sid + "_Switch")// + "_DimmerBar") + // { + // btn.IsSelected = upfunc.trait_on_off.curValue.ToString() == "on"; + // } + // } + // } + // else if (bodyDiv.GetChildren(o).GetType() == typeof(DiyImageSeekBar)) + // { + // var btn = bodyDiv.GetChildren(o) as DiyImageSeekBar; + // if (btn.Tag != null) + // { + // if (btn.Tag.ToString() == upfunc.sid + "_DimmerBar") + // { + // btn.Progress = Convert.ToInt32(upfunc.GetAttrState(FunctionAttributeKey.Brightness)); + // } + // } + // } + // } - } + // } + // }); + // } + // } + /// <summary> + /// 鏇存柊鍦ㄧ嚎鐘舵�� + /// </summary> + public void UpdataOnline(bool online) + { + if (bodyDiv != null) + { + Application.RunOnMainThread(() => + { + bodyDiv.BackgroundColor = online ? CSS_Color.MainBackgroundColor : CSS_Color.PromptingColor2; + bodyDiv.btnOffline.Visible = !online; }); } - } - /// <summary> - /// 鏇存柊浜害鐘舵�� - /// </summary> - /// <param name="upfunc"></param> - static void UpdataBrightnessState(Function upfunc) - { - } /// <summary> diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs b/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs index 3db5ac0..0d410f0 100644 --- a/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs +++ b/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs @@ -37,6 +37,7 @@ public void LoadPage(int titleId) { + bodyView.BackgroundColor = CSS_Color.BackgroundColor; if (titleId == StringId.Lights) { @@ -65,6 +66,38 @@ { new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView(); } + + + +#if DEBUG + Button testBtn = new Button() + { + X = Application.GetRealWidth(80), + Height = Application.GetRealHeight(64), + BackgroundColor = 0xFFFF0000 + }; + bodyView.AddChidren(testBtn); + int ddd = 0; + testBtn.MouseUpEventHandler = (sender, e) => { + ddd++; + + Function function_online = FunctionList.List.GetLightList().Find((obj) => obj.sid == "0001017DB92D2602020100010101"); + if (ddd % 2 == 0) + { + function_online.online = true; + } + else + { + function_online.online = false; + } + HomePage.LoadEvent_RefreshDevcieOnline(function_online); + FunctionPage.UpdataOnline(function_online); + RoomPage.UpdataOnline(function_online); + + + }; +#endif + /// <summary> /// 鎴块棿鍐呭鏄剧ず鍖哄煙 /// </summary> diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs b/HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs index d2ee507..8e87e01 100644 --- a/HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs @@ -13,6 +13,10 @@ new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView); } + public static void UpdataOnline(Function function) + { + new ClassificaitionPublicBLL().UpdataOnlineStatus(function, bodyView, functionListView); + } } diff --git a/HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs b/HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs index 6ca0ac5..5323666 100644 --- a/HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs @@ -14,6 +14,10 @@ { new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView,room); } + public static void UpdataOnline(Function function) + { + new ClassificaitionPublicBLL().UpdataOnlineStatus(function, bodyView, functionListView); + } /// <summary> /// 鍔犺浇浜嬩欢鍒楄〃 diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/FunTpye.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/FunTpye.cs index 4dccee2..4cf6765 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/FunTpye.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/FunTpye.cs @@ -221,9 +221,9 @@ funAllAreaView.btnText2.Text = areaView.btnClick.Tag.ToString(); UserInfo.Current.logicselectedFunction = areaView.btnClick.Tag.ToString(); ///鑾峰彇鍗曚釜绫诲瀷锛堜緥濡傦細鐏厜绫汇�傘�傦級璁惧FunctionType鍒楄〃<绠�绉�:spk鍒楄〃> - var typeFunctionList = LogicMethod.CurrLogicMethod.GetDeviceTypeFunctionList(UserInfo.Current.logicselectedFunction); + var typeFunctionList2 = LogicMethod.CurrLogicMethod.GetDeviceTypeFunctionList(UserInfo.Current.logicselectedFunction); ///鑾峰彇鍗曚釜鐏厜绫诲瀷锛堜緥濡傦細鐏厜1,鐏厜2銆傘�傦級璁惧鍒楄〃 - var lists2 = LogicMethod.CurrLogicMethod.GetShowDeviceList(typeFunctionList, functionList); + var lists2 = LogicMethod.CurrLogicMethod.GetShowDeviceList(typeFunctionList2, functionList); DeviceListView(vv, lists2); }; diff --git a/SiriIntents/Server/HttpUtil.cs b/SiriIntents/Server/HttpUtil.cs index f61de04..56a78a0 100644 --- a/SiriIntents/Server/HttpUtil.cs +++ b/SiriIntents/Server/HttpUtil.cs @@ -16,8 +16,8 @@ /// 鍥哄畾鍩熷悕,姝e紡鐜 /// 鍏叡鍩熷悕灏辫繎瑙f瀽 /// </summary> - public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com"; - //public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";//mmmm + //public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com"; + public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";//mmmm /// <summary> /// RegionMark /// </summary> -- Gitblit v1.8.0