From 9c6bd67d66859e48f0e794cd2746aef9310ce71d Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期五, 13 十二月 2019 18:01:37 +0800
Subject: [PATCH] 2019-12-13-2

---
 ZigbeeApp/Shared/Phone/UserCenter/DoorLock/EntryStatusPage.cs |   95 ++++++++++++++++++++++++++++++++++-------------
 1 files changed, 68 insertions(+), 27 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/EntryStatusPage.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/EntryStatusPage.cs
old mode 100644
new mode 100755
index f6c38e6..d8c9401
--- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/EntryStatusPage.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/EntryStatusPage.cs
@@ -26,7 +26,6 @@
         Shared.Phone.UserCenter.MemberInfoRes curAccountObj;
         string currentType = string.Empty;
         FrameLayout bottomFrameLayout;
-
         #endregion
 
         /// <summary>
@@ -169,7 +168,6 @@
                 TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                 TextAlignment = TextAlignment.CenterLeft,
                 TextSize = 14,
-                Text = curAccountObj.UserName,
             };
             personRemarkRemarkFrameLayout.AddChidren(btnMatchPersonContent);
 
@@ -183,7 +181,7 @@
                 TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                 Gravity = Gravity.CenterHorizontal,
                 BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack,
-                Radius = 10,
+                Radius = (uint)Application.GetRealHeight(127 / 2),
                 TextSize = 16,
             };
             bottomFrameLayout.AddChidren(completeBtn);
@@ -203,11 +201,29 @@
                 btnPasswordRemark.Text = Language.StringByID(R.MyInternationalizationString.ProximityRemark);
                 btnPasswordRemarkContent.PlaceholderText = Language.StringByID(R.MyInternationalizationString.ProximityCard) + "-" + doorLock.doorLockProgrammingEventNotificationCommand.UserID;
             }
+            if (curAccountObj.UserName != "" && curAccountObj.UserName != null)
+            {
+                btnMatchPersonContent.Text = curAccountObj.UserName;
+            }
+            else
+            {
+                btnMatchPersonContent.Text = curAccountObj.Account;
+            }
 
             completeBtn.MouseDownEventHandler += async (sender, e) =>
              {
                  completeBtn.Enable = false;
+                 if (doorLock.doorLockProgrammingEventNotificationCommand == null)
+                 {
+                     return;
+                 }
                  var addLockInfo = new ZigBee.Device.DoorLock.AddDoorLockData();
+                 if (UserCenterResourse.UserInfo.AuthorityNo != 1)
+                 {
+                     addLockInfo.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
+                     addLockInfo.IsOtherAccountCtrl = true;
+                 }
+
                  addLockInfo.CloudAccountId = curAccountObj.SubAccountDistributedMark;
                  if (doorLock.DeviceAddr != null)
                  {
@@ -215,7 +231,6 @@
                  }
                  addLockInfo.OpenLockMode = doorLock.doorLockProgrammingEventNotificationCommand.ProgramEventSoure;
                  addLockInfo.DoorLockLocalUserId = doorLock.doorLockProgrammingEventNotificationCommand.UserID.ToString();
-                 //var entryTime = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetLocalTime(doorLock.doorLockProgrammingEventNotificationCommand.ZigbeeLocalTime);
                  addLockInfo.EntryTime = System.DateTime.Now;
                  if (btnPasswordRemarkContent.Text != "")
                  {
@@ -227,47 +242,73 @@
                  }
                  try
                  {
+                     Application.RunOnMainThread(() => { CommonPage.Loading.Start("Loading..."); });
                      var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/AddDoorLock", addLockInfo);
-                     if (result != null && result.StateCode == "Success")
+                     if (result != null)
                      {
-                         if (doorLock.localDoorLockUserList.ContainsKey(doorLock.doorLockProgrammingEventNotificationCommand.UserID))
+                         if (result.StateCode == "Success")
                          {
-                             doorLock.localDoorLockUserList.Remove(doorLock.doorLockProgrammingEventNotificationCommand.UserID);
-
-                             var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
-                             localDoorLockObj.UserID = doorLock.doorLockProgrammingEventNotificationCommand.UserID;
-                             localDoorLockObj.UnlockType = addLockInfo.OpenLockMode;
-                             localDoorLockObj.EntryTime = addLockInfo.EntryTime;
-                             localDoorLockObj.UserName = addLockInfo.UserIdRemarks;
-                             localDoorLockObj.ConnectedAccount = curAccountObj.SubAccountDistributedMark;
-                             doorLock.localDoorLockUserList.Add(doorLock.doorLockProgrammingEventNotificationCommand.UserID, localDoorLockObj);
-
-                             completeBtn.Enable = true;
-                             this.RemoveFromParent();
-
-                             for (int i = UserView.HomePage.Instance.ChildrenCount - 1; i >= 0; i--)
+                             if (doorLock.localDoorLockUserList.ContainsKey(doorLock.doorLockProgrammingEventNotificationCommand.UserID))
                              {
-                                 var form = UserView.HomePage.Instance.GetChildren(i);
-
-                                 if (form is UnLockMethod)
+                                 //瀛橀棬閿佷俊鎭�
+                                 var resultList = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetCloudLocalDoorLocklist(doorLock, curAccountObj.SubAccountDistributedMark);
+                                 if (resultList != null)
                                  {
-                                     ((UnLockMethod)form).RefreshList();
-                                     break;
+                                     if (resultList.ContainsKey(doorLock.doorLockProgrammingEventNotificationCommand.UserID) == true)
+                                     {
+                                         var a = resultList[doorLock.doorLockProgrammingEventNotificationCommand.UserID];
+                                         if (a?.ConnectedAccount == curAccountObj.SubAccountDistributedMark)
+                                         {
+                                             completeBtn.Enable = true;
+                                             this.RemoveFromParent();
+                                             for (int i = UserView.HomePage.Instance.ChildrenCount - 1; i >= 0; i--)
+                                             {
+                                                 var form = UserView.HomePage.Instance.GetChildren(i);
+
+                                                 if (form is UnLockMethod)
+                                                 {
+                                                     doorLock.currentUserDisplayMethod = "";
+                                                     ((UnLockMethod)form).RefreshList();
+                                                     break;
+                                                 }
+                                                 else
+                                                 {
+                                                     form.RemoveFromParent();
+                                                 }
+                                             }
+                                         }
+                                         else
+                                         {
+                                             completeBtn.Enable = true;
+                                             new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnPasswordRemarkContent);
+                                         }
+                                     }
                                  }
                                  else
                                  {
-                                     form.RemoveFromParent();
+                                     completeBtn.Enable = true;
+                                     new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnPasswordRemarkContent);
                                  }
+
                              }
+                         }
+                         else
+                         {
+                             completeBtn.Enable = true;
+                             new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AddFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnPasswordRemarkContent);
                          }
                      }
                      else
                      {
                          completeBtn.Enable = true;
-                         new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ModigfyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnPasswordRemarkContent);
+                         new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnPasswordRemarkContent);
                      }
                  }
                  catch { }
+                 finally
+                 {
+                     CommonPage.Loading.Hide();
+                 }
              };
         }
 

--
Gitblit v1.8.0