From 3f6685c77beeb12baf840733fb890860f4c26e7c Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 25 七月 2024 17:25:59 +0800
Subject: [PATCH] 2024年07月25日17:24:45

---
 HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockUserManagerPage.cs |   84 ++++++++++++++++++++++++++++++++---------
 1 files changed, 65 insertions(+), 19 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockUserManagerPage.cs b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockUserManagerPage.cs
index 9520088..5c17463 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockUserManagerPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockUserManagerPage.cs
@@ -23,8 +23,9 @@
         Function device;
         VideoDoorlockUser doorlockUser;
         public Action delCallBackAction;
-
+        public Action<string> updataUserNameAction;
         Loading waitPage;
+
 
         public VideoDoorlockUserManagerPage(Function function,VideoDoorlockUser user)
         {
@@ -33,12 +34,23 @@
             doorlockUser = user;
             BackgroundColor = CSS_Color.BackgroundColor;
             waitPage = new Loading();
-            bodyView.AddChidren(waitPage);
-            waitPage.Hide();
+
+        }
+
+        public override void RemoveFromParent()
+        {
+            base.RemoveFromParent();
+            bodyView = null;
+            if (waitPage != null)
+            {
+                waitPage.RemoveFromParent();
+                waitPage = null;
+            }
         }
 
         public void LoadPage()
         {
+            bodyView.AddChidren(waitPage);
             new TopViewDiv(bodyView, Language.StringByID(StringId.UserManagement)).LoadTopView();
 
             contentView = new VerticalScrolViewLayout()
@@ -47,6 +59,8 @@
                 Height = Application.GetRealHeight(667 - 70),
             };
             bodyView.AddChidren(contentView);
+
+          
 
             #region 鐢ㄦ埛鍚嶇О
             var userNameView = new FrameLayout()
@@ -113,7 +127,7 @@
                     {
                         return;
                     }
-                    if (System.Text.Encoding.Default.GetBytes(str).Length > 20)
+                    if (System.Text.Encoding.Unicode.GetBytes(str).Length > 20)
                     {
                         new Tip()
                         {
@@ -123,23 +137,42 @@
                         }.Show(bodyView);
                         return;
                     }
-                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
                     new System.Threading.Thread(() =>
                     {
                         try
                         {
-                            var resultObj = ApiUtlis.Ins.HttpRequest.EditDoorlockUserName(device.deviceId, doorlockUser.extUserId, str);
-                            if (resultObj.Code == StateCode.SUCCESS)
+                            Application.RunOnMainThread(() => {
+                                waitPage.Start(Language.StringByID(StringId.PleaseWait));
+                            });
+                            var pack = ApiUtlis.Ins.HttpRequest.EditDoorlockUserName(device.deviceId, doorlockUser.extUserId, str);
+                            if (pack.Code == StateCode.SUCCESS)
                             {
                                 Application.RunOnMainThread(() =>
                                 {
                                     btnUserName.Text = str;
+                                    updataUserNameAction?.Invoke(str);
                                 });
                             }
                             else
                             {
                                 //澶辫触鎻愮ず
-                                IMessageCommon.Current.ShowErrorInfoAlter(resultObj.Code);
+                                Application.RunOnMainThread(() =>
+                                {
+                                    if (string.IsNullOrEmpty(pack.message))
+                                    {
+                                        pack.message = Language.StringByID(StringId.OperationFailed);
+                                    }
+                                    {
+                                        var tip = new Tip()
+                                        {
+                                            MaxWidth = Application.GetRealWidth(300),
+                                            Text = $"{pack.message}({pack.Code})",
+                                            CloseTime = 3,
+                                            Direction = AMPopTipDirection.None
+                                        };
+                                        tip.Show(MainPage.BaseView);
+                                    }
+                                });
                             }
                         }
                         catch (Exception ex)
@@ -158,7 +191,7 @@
                 };
                 var pa = new PublicAssmebly();
                 pa.entryMaxLength = 20;
-                pa.LoadDialog_EditParater(StringId.ChangeName, doorlockUser.lockUserName, callBack, StringId.UesrNameCannotBeEmpty, 0, new List<string>());
+                pa.LoadDialog_EditParater(StringId.ChangeName, "", callBack, StringId.UesrNameCannotBeEmpty, 0, new List<string>());
             };
             btnUserName.MouseUpEventHandler = eventHandler;
             btnEditUserNameIcon.MouseUpEventHandler = eventHandler;
@@ -169,7 +202,7 @@
         void initOptionView(bool isEdit)
         {
             if(doorlockUser.faceCount == 0&&
-                doorlockUser.faceCount == 0 &&
+                doorlockUser.fingerCount == 0 &&
                 doorlockUser.pwdCount == 0 &&
                 doorlockUser.cardCount == 0)
             {
@@ -183,17 +216,17 @@
 
 
             int childrenViewHeight = Application.GetRealWidth(116);
-            int permissionsViewHeight = Application.GetRealHeight(291 + 92);
+            int permissionsViewHeight = Application.GetRealHeight(291 + 92 + 100);
             if (userPermissionsView!= null)
             {
                 userPermissionsView.RemoveAll();
 
                 if (isEdit)
                 {
-                    permissionsViewHeight = Application.GetRealHeight(391 + 50);
+                    permissionsViewHeight = Application.GetRealHeight(391 + 50 + 100);
                     childrenViewHeight = Application.GetRealWidth(156);
                 }
-                userPermissionsView.Height = permissionsViewHeight;
+                userPermissionsView.Height = permissionsViewHeight ;
             }
             else
             {
@@ -315,11 +348,13 @@
                     fingerprintView.AddChidren(btnClearFingerprints);
                     btnClearFingerprints.MouseUpEventHandler = (sender, e) =>
                     {
-                        waitPage.Start(Language.StringByID(StringId.PleaseWait));
                         new System.Threading.Thread(() =>
                         {
                             try
                             {
+                                Application.RunOnMainThread(() => {
+                                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
+                                });
                                 var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUserFingerPassword(device.deviceId, doorlockUser.lockUserIndex);
                                 if (pack != null && pack.Code == StateCode.SUCCESS)
                                 {
@@ -425,11 +460,13 @@
                     digitalPasswordView.AddChidren(btnClearDigitalPassword);
                     btnClearDigitalPassword.MouseUpEventHandler = (sender, e) =>
                     {
-                        waitPage.Start(Language.StringByID(StringId.PleaseWait));
                         new System.Threading.Thread(() =>
                         {
                             try
                             {
+                                Application.RunOnMainThread(() => {
+                                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
+                                });
                                 var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUserNumberPassword(device.deviceId, doorlockUser.lockUserIndex);
                                 if (pack != null && pack.Code == StateCode.SUCCESS)
                                 {
@@ -534,11 +571,13 @@
                     };
                     nfcView.AddChidren(btnClearNfc);
                     btnClearNfc.MouseUpEventHandler = (sender, e) => {
-                        waitPage.Start(Language.StringByID(StringId.PleaseWait));
                         new System.Threading.Thread(() =>
                         {
                             try
                             {
+                                Application.RunOnMainThread(() => {
+                                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
+                                });
                                 var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUserCardPassword(device.deviceId, doorlockUser.lockUserIndex);
                                 if (pack != null && pack.Code == StateCode.SUCCESS)
                                 {
@@ -642,11 +681,13 @@
                     };
                     faceView.AddChidren(btnClearFace);
                     btnClearFace.MouseUpEventHandler = (sender, e) => {
-                        waitPage.Start(Language.StringByID(StringId.PleaseWait));
                         new System.Threading.Thread(() =>
                         {
                             try
                             {
+                                Application.RunOnMainThread(() => {
+                                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
+                                });
                                 var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUserFacePassword(device.deviceId, doorlockUser.lockUserIndex);
                                 if (pack != null && pack.Code == StateCode.SUCCESS)
                                 {
@@ -699,7 +740,7 @@
             var delUserView = new FrameLayout()
             {
                 Y = unlockOptionView.Bottom,
-                Height = Application.GetRealHeight(110),
+                Height = Application.GetRealHeight(310),
                 BackgroundColor = CSS_Color.BackgroundColor,
             };
             userPermissionsView.AddChidren(delUserView);
@@ -722,11 +763,13 @@
             {
                 new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.DeleteDoorlockUserTip, () =>
                 {
-                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
                     new System.Threading.Thread(() =>
                     {
                         try
                         {
+                            Application.RunOnMainThread(() => {
+                                waitPage.Start(Language.StringByID(StringId.PleaseWait));
+                            });
                             var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUser(device.deviceId, doorlockUser.lockUserIndex);
                             if (pack != null && pack.Code == StateCode.SUCCESS)
                             {
@@ -743,6 +786,9 @@
                             {
                                 Application.RunOnMainThread(() =>
                                 {
+                                    if (string.IsNullOrEmpty(pack.message)) {
+                                        pack.message = Language.StringByID(StringId.OperationFailed);
+                                    }
                                     //澶辫触鎻愮ず
                                     var tip = new Tip()
                                     {

--
Gitblit v1.8.0