From c47c3ec2488961b3a006aaebcb03dba582f8b19b Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期四, 12 三月 2020 17:08:42 +0800
Subject: [PATCH] 2020-03-12-1

---
 ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TemporaryPassword.cs |  241 +++++++++++++++++++++++++++++-------------------
 1 files changed, 145 insertions(+), 96 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TemporaryPassword.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TemporaryPassword.cs
index 0987e21..6e5ce47 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TemporaryPassword.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TemporaryPassword.cs
@@ -19,14 +19,38 @@
             ZigBee.Device.ZbGateway.StatusList.Add(this);
         }
 
-        #region 鈼� 鍙橀噺鐢虫槑__________________________
+        #region  鍙橀噺鐢虫槑
+        /// <summary>
+        /// 褰撳墠闂ㄩ攣
+        /// </summary>
         ZigBee.Device.DoorLock doorLock;
-        public System.Collections.Generic.List<Button> pawButtonList = new System.Collections.Generic.List<Button> { };//涓存椂瀵嗙爜涓殑6浣嶆暟瀛�
-        Button passwordText; //涓存椂瀵嗙爜
+        /// <summary>
+        /// 涓存椂瀵嗙爜涓殑6浣嶆暟瀛�
+        /// </summary>
+        public System.Collections.Generic.List<Button> pawButtonList = new System.Collections.Generic.List<Button> { };
+        /// <summary>
+        /// 涓存椂瀵嗙爜
+        /// </summary>
+        Button passwordText;
+        /// <summary>
+        /// 涓儴甯冪殑椤堕儴甯冨眬
+        /// </summary>
         FrameLayout MidTopFrameLayout;
-        Action<string, string> action;//鎺ユ敹閫氱煡
+        /// <summary>
+        /// 鎺ユ敹閫氱煡
+        /// </summary>
+        Action<string, string> action;
+        /// <summary>
+        /// 淇濆瓨瀹屾垚鎸夐挳
+        /// </summary>
         Button btnFinifh;
+        /// <summary>
+        /// 褰撳墠鏈夋晥鏃ユ湡鏃堕棿
+        /// </summary>
         DateTime cunVDateTime;
+        /// <summary>
+        /// 褰撳墠澶辨晥鏃ユ湡鏃堕棿
+        /// </summary>
         DateTime cunIVDateTime;
         #endregion
 
@@ -68,78 +92,7 @@
 
             EventHandler<MouseEventArgs> eHandler = (sender, e) =>
             {
-                var dialog = new Dialog { };
-                dialog.Show();
-
-                var flMain = new FrameLayout { BackgroundColor = 0x00000000 };
-                dialog.AddChidren(flMain);
-                flMain.MouseUpEventHandler += (sender11, e11) =>
-                {
-                    dialog.Close();
-                };
-
-                var delBackgroundFrameLayout = new FrameLayout
-                {
-                    X = Application.GetRealWidth(596),
-                    Y = Application.GetRealHeight(164),
-                    Height = Application.GetRealHeight(173),
-                    Width = Application.GetRealWidth(449),
-                    BackgroundImagePath = "DoorLock/DelBackground.png",
-                };
-                flMain.AddChidren(delBackgroundFrameLayout);
-
-                var btnDelIcon2 = new Button
-                {
-                    Height = Application.GetRealHeight(81),
-                    Width = Application.GetRealWidth(81),
-                    X = Application.GetRealWidth(81),
-                    Y = Application.GetRealHeight(55),
-                    UnSelectedImagePath = "DoorLock/DelIcon.png",
-                };
-                delBackgroundFrameLayout.AddChidren(btnDelIcon2);
-
-                var btnDelText = new Button
-                {
-                    Height = Application.GetRealHeight(58),
-                    Width = Application.GetRealWidth(311),
-                    X = Application.GetRealWidth(173),
-                    Y = Application.GetRealHeight(69),
-                    TextAlignment = TextAlignment.CenterLeft,
-                    Text = Language.StringByID(R.MyInternationalizationString.ClearTempPassword),
-                    TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
-                    TextSize = 12,
-                };
-                delBackgroundFrameLayout.AddChidren(btnDelText);
-
-                EventHandler<MouseEventArgs> eHandler2 = (sender2, e2) =>
-                {
-                    var dialog1 = new Dialog { };
-                    var doorDialog = new Shared.Phone.UserCenter.DoorLock.DoorlockDialog(dialog1, Language.StringByID(R.MyInternationalizationString.Tip));
-                    doorDialog.Show();
-                    doorDialog.dialogMidFraFrameLayout.Width = Application.GetRealWidth(415);
-                    doorDialog.dialogMidFraFrameLayout.Height = Application.GetRealHeight(58);
-                    doorDialog.dialogMidFraFrameLayout.X = Application.GetRealWidth(190);
-                    doorDialog.dialogMidFraFrameLayout.Y = Application.GetRealHeight(202);
-                    doorDialog.dialogMidFraFrameLayout.AddChidren(doorDialog.dialogMidText);
-                    doorDialog.dialogMidText.Text = Language.StringByID(R.MyInternationalizationString.SureToDeleteTempPassword);
-                    doorDialog.dialogMidText.TextSize = 14;
-                    doorDialog.dialogMidFraFrameLayout.AddChidren(doorDialog.dialogMidText);
-                    doorDialog.dialogBtnConfirm.Text = Language.StringByID(R.MyInternationalizationString.Confrim);
-                    doorDialog.dialogBtnCancel.MouseUpEventHandler += (sender1, e1) =>
-                    {
-                        dialog.Close();
-                        dialog1.Close();
-                    };
-                    doorDialog.dialogBtnConfirm.MouseUpEventHandler += (sender1, e1) =>
-                    {
-                        dialog.Close();
-                        dialog1.Close();
-                        ClearEventHandler(btnDelText, dialog1);
-                    };
-                };
-                delBackgroundFrameLayout.MouseDownEventHandler += eHandler2;
-                btnDelIcon2.MouseDownEventHandler += eHandler2;
-                btnDelText.MouseDownEventHandler += eHandler2;
+                ClearDialog();
             };
             btnDelFrameLayout.MouseDownEventHandler += eHandler;
             btnDelIcon.MouseDownEventHandler += eHandler;
@@ -156,6 +109,9 @@
             MidFrameLayoutContent();
         }
 
+        /// <summary>
+        /// 涓儴甯冨眬
+        /// </summary>
         public void MidFrameLayoutContent()
         {
             MidTopFrameLayout.RemoveAll();
@@ -181,7 +137,7 @@
                 Y = Application.GetRealHeight(48),
                 TextAlignment = TextAlignment.Center,
                 Text = Language.StringByID(R.MyInternationalizationString.ClickGenerate),
-                TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
+                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                 TextSize = 12,
                 Visible = true,
                 Enable = true,
@@ -226,7 +182,7 @@
                 Height = Application.GetRealHeight(49),
                 Width = Application.GetRealWidth(84 + 135),
                 Y = Application.GetRealHeight(441),
-                TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
+                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                 TextSize = 12,
                 TextAlignment = TextAlignment.CenterRight,
             };
@@ -250,7 +206,7 @@
                 Width = Application.GetRealWidth(717 - 508),
                 X = Application.GetRealWidth(508),
                 Y = Application.GetRealHeight(444),
-                TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
+                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                 TextAlignment = TextAlignment.CenterLeft,
                 TextSize = 12,
             };
@@ -331,7 +287,9 @@
             };
             #endregion
         }
-        //搴曢儴鐣岄潰鍜屾暟鎹鐞�
+        /// <summary>
+        /// 搴曢儴甯冨眬澶勭悊
+        /// </summary>
         public void BottomFrameLayoutContent()
         {
             var bottomFrameLayout = new FrameLayout()
@@ -341,6 +299,7 @@
                 BackgroundColor = ZigbeeColor.Current.XMWhite,
             };
             this.midFrameLayout.AddChidren(bottomFrameLayout);
+            bottomFrameLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
 
             var informationEdit = new Button()
             {
@@ -393,7 +352,7 @@
                 {
                     Width = Application.GetRealWidth(58),
                     Height = Application.GetRealHeight(58),
-                    UnSelectedImagePath = "Item/Next.png",
+                    UnSelectedImagePath = "Item/RightNext.png",
                     SelectedImagePath = "Item/Down.png",
                 };
                 btnNextFrameLayout.AddChidren(btnNext);
@@ -401,7 +360,7 @@
                 var btnLine = new FrameLayout()
                 {
                     Width = Application.GetRealWidth(965),
-                    Height = Application.GetRealHeight(5),
+                    Height = 1,
                     X = Application.GetRealWidth(58),
                     BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                 };
@@ -508,6 +467,7 @@
                 BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect,
                 TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                 TextSize = 16,
+                IsBold = true,
                 Enable = false,
             };
             bottomFrameLayout.AddChidren(btnFinifh);
@@ -518,7 +478,10 @@
             };
         }
 
-        //纭畾浜嬩欢澶勭悊
+        /// <summary>
+        /// 纭畾浜嬩欢澶勭悊
+        /// </summary>
+        /// <param name="btnFinifh"></param>
         void FinifhEventHandler(Button btnFinifh)
         {
             System.Threading.Tasks.Task.Run(async () =>
@@ -606,7 +569,10 @@
                                     addDoorLockTempPasswordData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
                                     addDoorLockTempPasswordData.IsOtherAccountCtrl = true;
                                 }
-                                addDoorLockTempPasswordData.TempPwd = doorLock.tempPasswordObject.TempPassword;
+                                //瀵瑰瘑鐮佽繘琛屽姞瀵嗗鐞�
+                                string hdlKey = "hD1(La3o";
+                                var enPsw = UserCenterLogic.EncryptPassword(hdlKey, doorLock.tempPasswordObject.TempPassword); 
+                                addDoorLockTempPasswordData.TempPwd = enPsw;
                                 if (doorLock.DeviceAddr != null)
                                 {
                                     addDoorLockTempPasswordData.LocalDoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
@@ -678,8 +644,77 @@
             });
         }
 
-        //娓呴櫎浜嬩欢澶勭悊
-        async void ClearEventHandler(Button btnDelText = null, Dialog dialog = null)
+        /// <summary>
+        /// 娓呴櫎UI
+        /// </summary>
+        void ClearDialog()
+        {
+            var dialog = new Dialog { };
+            dialog.Show();
+
+            var flMain = new FrameLayout { BackgroundColor = 0x00000000 };
+            dialog.AddChidren(flMain);
+            flMain.MouseUpEventHandler += (sender11, e11) =>
+            {
+                dialog.Close();
+            };
+
+            var delBackgroundFrameLayout = new FrameLayout
+            {
+                X = Application.GetRealWidth(596),
+                Y = Application.GetRealHeight(164),
+                Height = Application.GetRealHeight(173),
+                Width = Application.GetRealWidth(449),
+                BackgroundImagePath = "DoorLock/DelBackground.png",
+            };
+            flMain.AddChidren(delBackgroundFrameLayout);
+
+            var btnDelIcon2 = new Button
+            {
+                Height = Application.GetRealHeight(81),
+                Width = Application.GetRealWidth(81),
+                X = Application.GetRealWidth(81),
+                Y = Application.GetRealHeight(55),
+                UnSelectedImagePath = "DoorLock/DelIcon.png",
+            };
+            delBackgroundFrameLayout.AddChidren(btnDelIcon2);
+
+            var btnDelText = new Button
+            {
+                Height = Application.GetRealHeight(58),
+                Width = Application.GetRealWidth(311),
+                X = Application.GetRealWidth(173),
+                Y = Application.GetRealHeight(69),
+                TextAlignment = TextAlignment.CenterLeft,
+                Text = Language.StringByID(R.MyInternationalizationString.ClearTempPassword),
+                TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
+                TextSize = 14,
+                IsBold = true,
+            };
+            delBackgroundFrameLayout.AddChidren(btnDelText);
+
+            EventHandler<MouseEventArgs> eHandler2 = (sender2, e2) =>
+            {
+                dialog.Close();
+                string msg = Language.StringByID(R.MyInternationalizationString.SureToDeleteTempPassword);
+                var alert = new Shared.Phone.UserCenter.ShowMsgControl(ShowMsgType.Confirm, msg, Language.StringByID(R.MyInternationalizationString.DoorlockConfirm));
+                alert.Show();
+                //浣跨敤纭鍨嬪脊妗嗘椂,鐨勫洖璋冨嚱鏁�
+                alert.ConfirmClickEvent += () =>
+                {
+                    ClearEventHandler(btnDelText);
+                };
+            };
+            delBackgroundFrameLayout.MouseDownEventHandler += eHandler2;
+            btnDelIcon2.MouseDownEventHandler += eHandler2;
+            btnDelText.MouseDownEventHandler += eHandler2;
+        }
+
+        /// <summary>
+        /// 娓呴櫎浜嬩欢澶勭悊
+        /// </summary>
+        /// <param name="btnDelText"></param>
+        async void ClearEventHandler(Button btnDelText = null)
         {
             if (btnDelText == null)
             {
@@ -694,7 +729,7 @@
                     var resultData = await doorLock.DefaultControlAsync(passData);
                     if (resultData != null && resultData.defaultControlResponseData != null)
                     {
-                        if (resultData.defaultControlResponseData.status == 0)
+                        if (resultData.defaultControlResponseData.status == 0 || resultData.defaultControlResponseData.status == 2)
                         {
                             var delDoorLockTempPasswordData = new ZigBee.Device.DoorLock.DelDoorLockTempPasswordData();
                             if (UserCenterResourse.UserInfo.AuthorityNo != 1)
@@ -753,17 +788,16 @@
             {
                 Application.RunOnMainThread(() =>
                 {
-                    if (dialog != null)
-                    {
-                        dialog.Close();
-                    }
+
                     MidFrameLayoutContent();
                     CommonPage.Loading.Hide();
                 });
             }
         }
 
-        //璇诲彇浜戠瀛樺偍鏁版嵁
+        /// <summary>
+        /// 璇诲彇浜戠瀛樺偍鏁版嵁
+        /// </summary>
         void ReadTempPasswordData()
         {
             System.Threading.Tasks.Task.Run(async () =>
@@ -792,7 +826,10 @@
                                 tpObj.UserId = int.Parse(curDoorLockTempPaw.TempPwdId);
                                 tpObj.ValidTime = curDoorLockTempPaw.ValidBeginTime;
                                 tpObj.InValidTime = curDoorLockTempPaw.ValidEndTime;
-                                doorLock.LocalTempPassword = tpObj.TempPassword = curDoorLockTempPaw.TempPwd;
+                                //瑙e瘑瀵嗙爜
+                                string hdlKey = "hD1(La3o";
+                                var desPsw= UserCenterLogic.DecryptPassword(hdlKey, curDoorLockTempPaw.TempPwd);
+                                doorLock.LocalTempPassword = tpObj.TempPassword = desPsw;
                                 doorLock.tempPasswordObject = tpObj;
                                 TimeDateData(doorLock.tempPasswordObject.ValidTime, doorLock.tempPasswordObject.InValidTime);
                             }
@@ -823,7 +860,12 @@
             });
         }
 
-        //鏈湴鏃堕棿鏁版嵁澶勭悊
+        /// <summary>
+        /// 鏈湴鏃堕棿鏁版嵁澶勭悊
+        /// </summary>
+        /// <param name="validTimeDateTime"></param>
+        /// <param name="inValidTime"></param>
+        /// <param name="isClearLocalTime"></param>
         void TimeDateData(DateTime validTimeDateTime, DateTime inValidTime, bool isClearLocalTime = false)
         {
             if (doorLock.tempPasswordObject != null)
@@ -858,7 +900,14 @@
             }
         }
 
-        //鏃堕棿鏄剧ず鏁版嵁澶勭悊
+        /// <summary>
+        /// 鏃堕棿鏄剧ず鏁版嵁澶勭悊
+        /// </summary>
+        /// <param name="validTime"></param>
+        /// <param name="validTimeDate"></param>
+        /// <param name="inValidTime"></param>
+        /// <param name="inValidTimeDate"></param>
+        /// <param name="isDefaultTime"></param>
         void TimeDisplay(Button validTime, Button validTimeDate, Button inValidTime, Button inValidTimeDate, bool isDefaultTime)
         {
             string hour = "";
@@ -935,7 +984,7 @@
             inValidTimeDate.Text = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMonth + Language.StringByID(R.MyInternationalizationString.Month) + Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateDay + Language.StringByID(R.MyInternationalizationString.Day);
         }
 
-        #region 鈼� 鎺ュ彛瀹炵幇__________________________
+        #region 鎺ュ彛瀹炵幇
         /// <summary>
         /// 澶勭悊鍙樺寲浜嬩欢 --灏嗗純鐢� 鏀圭敤DeviceInfoChange()
         /// </summary>

--
Gitblit v1.8.0