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 |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 106 insertions(+), 2 deletions(-)

diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
index dd9844d..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
@@ -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,13 +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.divLinkStateTip.Visible = true;
+                bodyView.linkStateMsgView.Visible = true;
             }
             else
             {
-                bodyView.divLinkStateTip.Visible = false;
+                bodyView.linkStateMsgView.Visible = false;
             }
         }
 
@@ -296,6 +380,26 @@
                 }
             });
         }
+        /// <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}");
+                }
+            });
+        }
 
         /// <summary>
         /// 鍔犺浇鍔熻兘鏀惰棌鎸夐挳浜嬩欢

--
Gitblit v1.8.0