From a4924de3136289d10cabbf2f61a228387d44ded7 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期四, 07 十一月 2019 13:48:36 +0800
Subject: [PATCH] Merge branch 'dev-tzy' into DEV_GXC

---
 ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs |  189 +++++++++++++++++++++++++++++------------------
 1 files changed, 116 insertions(+), 73 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs
index 180c7d7..7b5c669 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs
@@ -54,13 +54,17 @@
 
                         foreach (var curAccountObj in doorLock.localAllAccountList)
                         {
+                            if (UserCenterResourse.UserInfo.AuthorityNo != 1)
+                            {
+                                localDoorLockObj.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
+                                localDoorLockObj.IsOtherAccountCtrl = true;
+                            }
                             localDoorLockObj.CloudAccountId = curAccountObj.SubAccountDistributedMark;
                             if (doorLock.DeviceAddr != null)
                             {
                                 localDoorLockObj.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
                             }
-
-                            var getDoorLockInfoList = await ZigBee.Device.DoorLock.GetDoorLockInfoFromServer("App/GetDoorLockPager", localDoorLockObj);
+                            var getDoorLockInfoList = await ZigBee.Device.DoorLock.GetDoorLockInfoFromServer("DoorLock/GetDoorLockPager", localDoorLockObj);
                             if (getDoorLockInfoList != null)
                             {
                                 foreach (var curDoorLockUser in getDoorLockInfoList.PageData)
@@ -79,7 +83,21 @@
                                     doorLock.localDoorLockUserList.Add(int.Parse(curDoorLockUser.DoorLockLocalUserId), doorLockObj);
                                 }
                             }
+                            else
+                            {
+                                Application.RunOnMainThread(() =>
+                                {
+                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
+                                });
+                            }
                         }
+                    }
+                    else
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
+                        });
                     }
                 }
                 catch { }
@@ -87,7 +105,7 @@
                 {
                     Application.RunOnMainThread(() =>
                     {
-                        RefreshList();
+                        MidFrameLayoutContent();
                         CommonPage.Loading.Hide();
                     });
                 }
@@ -95,7 +113,7 @@
         }
 
         /// <summary>
-        /// UI鏄剧ず 
+        /// UI鏄剧ず
         /// </summary>
         public void Show()
         {
@@ -104,22 +122,72 @@
             EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
             {
                 RemoveFromParent();
+                this.btnTip.Visible = false;
             };
             this.btnBack.MouseUpEventHandler += eHandlerBack;
             this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
             this.MidFrameLayout(this);
 
-            MidFrameLayoutContent();
             ReadDoorLockUserInfo();
         }
 
-        public void RefreshList()
+        public void MidFrameLayoutContent()
+        {
+            var midTopFrameLayout = new FrameLayout()
+            {
+                Height = Application.GetRealHeight(115),
+                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTopFrameLayout,
+            };
+            this.midFrameLayout.AddChidren(midTopFrameLayout);
+
+            var btnAllMethod = new Button()
+            {
+                Height = Application.GetRealHeight(49),
+                Width = Application.GetRealWidth(141 + 100),
+                Y = Application.GetRealHeight(35),
+                X = Application.GetRealWidth(812 - 100),
+                TextAlignment = TextAlignment.Center,
+                Text = Language.StringByID(R.MyInternationalizationString.LockMethod),
+                TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
+                TextSize = 12,
+            };
+            midTopFrameLayout.AddChidren(btnAllMethod);
+
+            var btnNext = new Button()
+            {
+                X = Application.GetRealWidth(953),
+                Y = Application.GetRealHeight(20),
+                Height = Application.GetRealHeight(69),
+                Width = Application.GetRealWidth(69),
+                UnSelectedImagePath = "DoorLock/UnLockSideslipIcon.png",
+                SelectedImagePath = "DoorLock/UnLockSideslipIcon.png",
+            };
+            midTopFrameLayout.AddChidren(btnNext);
+            btnNext.MouseUpEventHandler += (sender, e) =>
+            {
+                SideslipFramelayout();
+            };
+
+            bodyView = new VerticalScrolViewLayout()
+            {
+                Y = midTopFrameLayout.Bottom,
+            };
+            this.midFrameLayout.AddChidren(bodyView);
+
+            RefreshList();
+        }
+
+        void RefreshList()
         {
             bodyView.RemoveAll();
             foreach (var curUserId in doorLock.localDoorLockUserList.Keys)
             {
                 var curDoorLockUser = doorLock.localDoorLockUserList[curUserId];
                 if (curDoorLockUser.ConnectedAccount != "")
+                {
+                    continue;
+                }
+                if (curDoorLockUser.UserID > 245)
                 {
                     continue;
                 }
@@ -172,7 +240,7 @@
                 switch (curDoorLockUser.UnlockType)
                 {
                     case 0:
-                        if (curDoorLockUser.UserName != "")
+                        if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                         {
                             btnText.Text = curDoorLockUser.UserName;
                         }
@@ -182,7 +250,7 @@
                         }
                         break;
                     case 3:
-                        if (curDoorLockUser.UserName != "")
+                        if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                         {
                             btnText.Text = curDoorLockUser.UserName;
                         }
@@ -192,7 +260,7 @@
                         }
                         break;
                     case 15:
-                        if (curDoorLockUser.UserName != "")
+                        if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                         {
                             btnText.Text = curDoorLockUser.UserName;
                         }
@@ -215,57 +283,11 @@
             }
         }
 
-        public void MidFrameLayoutContent()
-        {
-            var midTopFrameLayout = new FrameLayout()
-            {
-                Height = Application.GetRealHeight(115),
-                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTopFrameLayout,
-            };
-            this.midFrameLayout.AddChidren(midTopFrameLayout);
-
-            var btnAllMethod = new Button()
-            {
-                Height = Application.GetRealHeight(49),
-                Width = Application.GetRealWidth(141 + 100),
-                Y = Application.GetRealHeight(35),
-                X = Application.GetRealWidth(812 - 100),
-                TextAlignment = TextAlignment.Center,
-                Text = Language.StringByID(R.MyInternationalizationString.LockMethod),
-                TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
-                TextSize = 12,
-            };
-            midTopFrameLayout.AddChidren(btnAllMethod);
-
-            var btnNext = new Button()
-            {
-                X = Application.GetRealWidth(953),
-                Y = Application.GetRealHeight(20),
-                Height = Application.GetRealHeight(69),
-                Width = Application.GetRealWidth(69),
-                UnSelectedImagePath = "DoorLock/UnLockSideslipIcon.png",
-                SelectedImagePath = "DoorLock/UnLockSideslipIcon.png",
-            };
-            midTopFrameLayout.AddChidren(btnNext);
-            btnNext.MouseUpEventHandler += (sender, e) =>
-            {
-                SideslipFramelayout();
-            };
-
-            bodyView = new VerticalScrolViewLayout()
-            {
-                Y = midTopFrameLayout.Bottom,
-            };
-            this.midFrameLayout.AddChidren(bodyView);
-
-            RefreshList();
-        }
-
         //鏈湴璐︽埛
-        public void MatchUsersFrameLayout(ZigBee.Device.DoorLock.LocaDoorLockObj curDoorLockUser)
+        void MatchUsersFrameLayout(ZigBee.Device.DoorLock.LocaDoorLockObj curDoorLockUser)
         {
             #region  UI
-            var flMain = new FrameLayout { BackgroundColor = 0x0f000000 };
+            FrameLayout flMain = new FrameLayout { BackgroundColor = 0x0f000000 };
             this.midFrameLayout.AddChidren(flMain);
             flMain.MouseUpEventHandler += (sender11, e11) =>
             {
@@ -397,7 +419,7 @@
                     BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                 };
                 rowFrameLayout.AddChidren(btnLine);
-                #endregion 
+                #endregion
                 #region 鏁版嵁澶勭悊
                 int currentIndex = i;
                 if (currentIndex == localAccountList.Count - 1)
@@ -416,6 +438,13 @@
 
                 EventHandler<MouseEventArgs> eHandler = (sender, e) =>
                 {
+                    if (doorLock.IsFreezeAccount[currentAccount.SubAccountDistributedMark] == true)
+                    {
+
+                        new Tip() { MaxWidth = 150, Text = btnUserName.Text + Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
+                        return;
+                    }
+
                     if (!btnChoose.IsSelected)
                     {
                         if (oldbuttonChoose != null)
@@ -459,6 +488,11 @@
                 else
                 {
                     var addLockInfo = new ZigBee.Device.DoorLock.AddDoorLockData();
+                    if (UserCenterResourse.UserInfo.AuthorityNo != 1)
+                    {
+                        addLockInfo.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
+                        addLockInfo.IsOtherAccountCtrl = true;
+                    }
                     addLockInfo.CloudAccountId = curAccountId;
                     if (doorLock.DeviceAddr != null)
                     {
@@ -470,7 +504,7 @@
                     switch (curDoorLockUser.UnlockType)
                     {
                         case 0:
-                            if (curDoorLockUser.UserName != "")
+                            if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                             {
                                 addLockInfo.UserIdRemarks = curDoorLockUser.UserName;
                             }
@@ -480,7 +514,7 @@
                             }
                             break;
                         case 3:
-                            if (curDoorLockUser.UserName != "")
+                            if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                             {
                                 addLockInfo.UserIdRemarks = curDoorLockUser.UserName;
                             }
@@ -490,7 +524,7 @@
                             }
                             break;
                         case 15:
-                            if (curDoorLockUser.UserName != "")
+                            if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                             {
                                 addLockInfo.UserIdRemarks = curDoorLockUser.UserName;
                             }
@@ -502,22 +536,31 @@
                     }
 
                     addLockInfo.EntryTime = curDoorLockUser.EntryTime;
-                    var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("App/AddDoorLock", addLockInfo);
-                    if (result.StateCode == "Success")
+                    var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/AddDoorLock", addLockInfo);
+                    if (result != null && result.StateCode == "Success")
                     {
-                        if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID))
+                        //瀛樿处鎴蜂俊鎭�
+                        //var resultList1 = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetCloudLocalAccountlist(doorLock, curAccountId);
+                        //瀛橀棬閿佷俊鎭�
+                        var resultList = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetCloudLocalDoorLocklist(doorLock, curAccountId);
+                        var uList = new List<int> { };
+                        if (resultList != null)
                         {
-                            doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID);
-                            var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
-                            localDoorLockObj.UserID = curDoorLockUser.UserID;
-                            localDoorLockObj.UnlockType = curDoorLockUser.UnlockType;
-                            localDoorLockObj.EntryTime = curDoorLockUser.EntryTime;
-                            localDoorLockObj.UserName = curDoorLockUser.UserName;
-                            localDoorLockObj.ConnectedAccount = curAccountId;
-                            doorLock.localDoorLockUserList.Add(curDoorLockUser.UserID, localDoorLockObj);
+                            foreach (var a in resultList.Keys)
+                            {
+                                uList.Add(a);
+                            }
+                        }
+                        var d = uList.Find((value) => { return value == doorLock.doorLockProgrammingEventNotificationCommand.UserID; });
+                        if (d != null)
+                        {
                             RefreshList();
                             flMain.RemoveFromParent();
                             bottomFrameLayout.RemoveAll();
+                        }
+                        else
+                        {
+                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
                         }
                     }
                     else
@@ -610,7 +653,7 @@
                         btnAllMethod.IsSelected = true;
                         oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
 
-                        // 绫诲瀷鍖哄垎 
+                        // 绫诲瀷鍖哄垎
                         if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.AllMethod))
                         {
                             RefreshList();

--
Gitblit v1.8.0