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/UI/UI2/1-HomePage/HomePageBLL.cs | 195 +++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 159 insertions(+), 36 deletions(-) diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs index 649b4c8..6093297 100644 --- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs +++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs @@ -1,8 +1,10 @@ 锘縰sing System; using System.Collections.Generic; +using HDL_ON.Common; using HDL_ON.DAL.Server; using HDL_ON.DriverLayer; using HDL_ON.Entity; +using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI @@ -33,7 +35,7 @@ } if (btn.Tag.ToString() == function.sid) { - if (function.online) + if (function.isOnline()) { btn.UnSelectedImagePath = "Collection/Functionbg.png"; btn.IsSelected = false; @@ -46,7 +48,7 @@ } else if (btn.Tag.ToString() == "OnlineTag") { - btn.Visible = !function.online; + btn.Visible = !function.isOnline(); } } } @@ -254,7 +256,87 @@ } } + void CheckTokenValid() + { + //Dome妯″紡 + if (MainPage.NoLoginMode) + { + return; + } + try + { + #region 璐﹀彿鐧诲綍鐘舵�侊紙鐧诲綍token鏄惁鏈夋晥锛� + if (ApiUtlis.Ins.IsValidToken) + { + if (tokenInvalidMsgView == null) + { + tokenInvalidMsgView = new FrameLayout() + { + Y = Application.GetRealHeight(113) - Application.GetRealWidth(24), + Height = Application.GetRealWidth(24), + BackgroundColor = 0xFF69A0F7, + }; + topView.AddChidren(tokenInvalidMsgView); + + Button btnTokenInvalidIcon = new Button() + { + X = Application.GetRealWidth(16), + Gravity = Gravity.CenterVertical, + Width = Application.GetRealWidth(20), + Height = Application.GetRealWidth(20), + UnSelectedImagePath = "Collection/TokenInvalidTipIcon.png" + }; + tokenInvalidMsgView.AddChidren(btnTokenInvalidIcon); + var btnTokenInvalidTip = new Button() + { + X = btnTokenInvalidIcon.Right + Application.GetRealWidth(4), + TextAlignment = TextAlignment.CenterLeft, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + TextColor = CSS_Color.MainBackgroundColor, + TextID = StringId.TokenInvalidMsg, + }; + btnTokenInvalidTip.Width = btnTokenInvalidTip.GetTextWidth() + Application.GetRealWidth(8); + tokenInvalidMsgView.AddChidren(btnTokenInvalidTip); + btnTokenInvalidTip.MouseUpEventHandler = (sender, e) => { + new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.TokenInvalidTipMsg,StringId.Cancel,StringId.GoLogin, () => { + HDLCommon.Current.Logout(); + }); + }; + + var btnRight = new Button() + { + X= btnTokenInvalidTip.Right, + Gravity = Gravity.CenterVertical, + Width = Application.GetMinRealAverage(8), + Height = Application.GetMinRealAverage(8), + UnSelectedImagePath = "Public/RightIcon2.png", + }; + + tokenInvalidMsgView.AddChidren(btnRight); + + } + } + else + { + if (tokenInvalidMsgView != null) + { + if (tokenInvalidMsgView.Parent != null) + { + tokenInvalidMsgView.RemoveAll(); + tokenInvalidMsgView.RemoveFromParent(); + tokenInvalidMsgView = null; + } + } + } + #endregion + bodyView.linkStateMsgView.Y = ApiUtlis.Ins.IsValidToken ? Application.GetRealHeight(113) : Application.GetRealHeight(113) - Application.GetRealWidth(24); + } + catch (Exception ex) + { + MainPage.Log("Error", $"HomePage 璐﹀彿鐧诲綍鐘舵�佷俊鎭樉绀哄紓甯�:{ex.StackTrace}"); + } + } /// <summary> /// 鏇存柊杩炴帴鐘舵�佸浘鏍� @@ -267,17 +349,15 @@ return; } + bodyView.linkStateMsgView.Y = ApiUtlis.Ins.IsValidToken ? Application.GetRealHeight(113) : Application.GetRealHeight(113) - Application.GetRealWidth(24); + if (!Control.Ins.GatewayOnline_Local && !Control.Ins.GatewayOnline_Cloud) { - bodyView.btnLinkStateTip.BackgroundColor = CSS.CSS_Color.LinkTipFail; - bodyView.btnLinkStateTip.TextID = StringId.NetworkAnomaly; - bodyView.environmentalView.Y = Application.GetRealHeight(8) + btnResidenceName.Bottom; + bodyView.linkStateMsgView.Visible = true; } else { - bodyView.btnLinkStateTip.BackgroundColor = 0x00000000; - bodyView.btnLinkStateTip.Text = ""; - bodyView.environmentalView.Y = Application.GetRealHeight(1) + btnResidenceName.Bottom; + bodyView.linkStateMsgView.Visible = false; } } @@ -297,6 +377,26 @@ }catch(Exception ex) { MainPage.Log($"LoadEvent_CheckLinkStatus : {ex.Message}"); + } + }); + } + /// <summary> + /// 纭Token鏄惁鏈夋晥 + /// </summary> + public static void LoadEvent_CheckTokenValid() + { + Application.RunOnMainThread(() => + { + try + { + if (bodyView != null) + { + bodyView.CheckTokenValid(); + } + } + catch (Exception ex) + { + MainPage.Log("Error",$"LoadEvent_CheckTokenValid : {ex.StackTrace}"); } }); } @@ -351,11 +451,17 @@ } } + object lockObj = new object(); + /// <summary> /// 鏇存柊鏄剧ず鐘舵�� /// </summary> public static void UpdataFunctionStates(Function function) { + if(bodyView == null) + { + return; + } Application.RunOnMainThread(() => { try @@ -424,12 +530,28 @@ } } } - else if(function.spk == SPK.SensorHelp) + else if (function.spk == SPK.SensorHelp) { var tempStatus = function.attributes.Find((sta) => sta.key == FunctionAttributeKey.AlarmStatus); - if(tempStatus != null) + if (tempStatus != null) { state = tempStatus.curValue.ToString() == "alarm"; + } + } + else if (function.spk == SPK.SensorPir || function.spk == SPK.SensorPirHold) + { + var tempStatus = function.attributes.Find((sta) => sta.key == "people_status"); + if (tempStatus != null) + { + state = tempStatus.curValue.ToString() == "true"; + } + } + else if (function.spk == SPK.SensorDryContact || function.spk == SPK.SensorDryContact2) + { + var tempStatus = function.attributes.Find((sta) => sta.key == "contact_status"); + if (tempStatus != null) + { + state = tempStatus.curValue.ToString() == "open"; } } else @@ -546,7 +668,7 @@ { btnSwitch.MouseUpEventHandler = (sender, e) => { - if (!function.online)//绂荤嚎涓嶅厑璁告搷浣� + if (!function.isOnline())//绂荤嚎涓嶅厑璁告搷浣� { new Tip() { @@ -566,6 +688,7 @@ btnSwitch.IsSelected = !btnSwitch.IsSelected; }); } + function.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off"; Dictionary<string, string> d = new Dictionary<string, string>(); if (function.spk == SPK.LightDimming || function.spk == SPK.LightRGB) @@ -614,7 +737,7 @@ { btnSwitch.MouseUpEventHandler = (sender, e) => { - if (!function.online)//绂荤嚎涓嶅厑璁告搷浣� + if (!function.isOnline())//绂荤嚎涓嶅厑璁告搷浣� { new Tip() { @@ -658,16 +781,16 @@ { btnClose.MouseUpEventHandler = (sender, e) => { - if (!curtain.online)//绂荤嚎涓嶅厑璁告搷浣� - { - new Tip() - { - CloseTime = 1, - Text = Language.StringByID(StringId.DeviceOfflineCannotOption), - Direction = AMPopTipDirection.None, - }.Show(MainPage.BaseView); - return; - } + //if (!curtain.isOnline())//绂荤嚎涓嶅厑璁告搷浣� + //{ + // new Tip() + // { + // CloseTime = 1, + // Text = Language.StringByID(StringId.DeviceOfflineCannotOption), + // Direction = AMPopTipDirection.None, + // }.Show(MainPage.BaseView); + // return; + //} btnClose.IsSelected = true; curtain.trait_on_off.curValue = "off"; curtain.SetAttrState(FunctionAttributeKey.Percent, 0); @@ -675,23 +798,23 @@ d.Add(FunctionAttributeKey.OnOff, curtain.trait_on_off.curValue.ToString()); Control.Ins.SendWriteCommand(curtain, d); }; - btnOpen.MouseUpEventHandler = (sender, e) => { - if (!curtain.online)//绂荤嚎涓嶅厑璁告搷浣� - { - new Tip() - { - CloseTime = 1, - Text = Language.StringByID(StringId.DeviceOfflineCannotOption), - Direction = AMPopTipDirection.None, - }.Show(MainPage.BaseView); - return; - } + //if (!curtain.isOnline())//绂荤嚎涓嶅厑璁告搷浣� + //{ + // new Tip() + // { + // CloseTime = 1, + // Text = Language.StringByID(StringId.DeviceOfflineCannotOption), + // Direction = AMPopTipDirection.None, + // }.Show(MainPage.BaseView); + // return; + //} btnOpen.IsSelected = true; + Dictionary<string, string> d = new Dictionary<string, string>(); + curtain.trait_on_off.curValue = "on"; curtain.SetAttrState(FunctionAttributeKey.Percent, 100); - Dictionary<string, string> d = new Dictionary<string, string>(); d.Add(FunctionAttributeKey.OnOff, curtain.trait_on_off.curValue.ToString()); Control.Ins.SendWriteCommand(curtain, d); }; @@ -708,7 +831,7 @@ }; btnUp.MouseUpEventHandler = (sender, e) => { - if (!function.online)//绂荤嚎涓嶅厑璁告搷浣� + if (!function.isOnline())//绂荤嚎涓嶅厑璁告搷浣� { new Tip() { @@ -739,7 +862,7 @@ }; btnDown.MouseUpEventHandler = (sender, e) => { - if (!function.online)//绂荤嚎涓嶅厑璁告搷浣� + if (!function.isOnline())//绂荤嚎涓嶅厑璁告搷浣� { new Tip() { -- Gitblit v1.8.0