From 160785587667cc0d927f85e44c139ec9dde13a9e Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 25 十一月 2019 14:30:13 +0800
Subject: [PATCH] 原来的 IOS 工程舍弃(注:没有合并其他组员的代码)

---
 ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs |  205 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 152 insertions(+), 53 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs
index 7b5c669..78144d0 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs
@@ -32,6 +32,28 @@
                 Application.RunOnMainThread(() => { CommonPage.Loading.Start("Loading..."); });
                 try
                 {
+                    //await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetLocaDoorLocklist(doorLock, curAccountObj);
+                    var list = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockAllAcountUserlist(doorLock);
+                }
+                catch { }
+                finally
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        RefreshList();
+                        CommonPage.Loading.Hide();
+                    });
+                }
+            });
+        }
+
+        void ReadDoorLockUserInfo1()
+        {
+            System.Threading.Tasks.Task.Run(async () =>
+            {
+                Application.RunOnMainThread(() => { CommonPage.Loading.Start("Loading..."); });
+                try
+                {
                     var getDoorLockInfo = await doorLock.GetDoorlockUserInfoAsync();
                     if (getDoorLockInfo != null && getDoorLockInfo.doorLockUserDetailData != null)
                     {
@@ -69,34 +91,61 @@
                             {
                                 foreach (var curDoorLockUser in getDoorLockInfoList.PageData)
                                 {
+                                    if (curDoorLockUser.DoorLockLocalUserId == null || curDoorLockUser.DoorLockLocalUserId == "")
+                                    {
+                                        continue;
+                                    }
                                     if (doorLock.localDoorLockUserList.ContainsKey(int.Parse(curDoorLockUser.DoorLockLocalUserId)))
                                     {
-                                        doorLock.localDoorLockUserList.Remove(int.Parse(curDoorLockUser.DoorLockLocalUserId));
+                                        var doorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
+                                        doorLockObj.UserID = int.Parse(curDoorLockUser.DoorLockLocalUserId);
+                                        doorLockObj.UnlockType = curDoorLockUser.OpenLockMode;
+                                        doorLockObj.PrimaryId = curDoorLockUser.Id;
+                                        doorLockObj.EntryTime = curDoorLockUser.EntryTime;
+                                        doorLockObj.UserName = curDoorLockUser.UserIdRemarks;
+                                        doorLockObj.ConnectedAccount = curDoorLockUser.CloudAccountId;
+                                        doorLock.localDoorLockUserList[int.Parse(curDoorLockUser.DoorLockLocalUserId)] = doorLockObj;
                                     }
-                                    var doorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
-                                    doorLockObj.UserID = int.Parse(curDoorLockUser.DoorLockLocalUserId);
-                                    doorLockObj.UnlockType = curDoorLockUser.OpenLockMode;
-                                    doorLockObj.PrimaryId = curDoorLockUser.Id;
-                                    doorLockObj.EntryTime = curDoorLockUser.EntryTime;
-                                    doorLockObj.UserName = curDoorLockUser.UserIdRemarks;
-                                    doorLockObj.ConnectedAccount = curDoorLockUser.CloudAccountId;
-                                    doorLock.localDoorLockUserList.Add(int.Parse(curDoorLockUser.DoorLockLocalUserId), doorLockObj);
+                                    else
+                                    {
+                                        if (curDoorLockUser.DoorLockLocalUserId != null)
+                                        {
+                                            //闂ㄩ攣涓病鏈夛紝浜戠鏈夌敤鎴稩D锛屽悗鍙板垹闄や簯绔繖浜汭D
+                                            var deleteDoorLockData = new ZigBee.Device.DoorLock.DeleteDoorLockData();
+                                            if (UserCenterResourse.UserInfo.AuthorityNo != 1)
+                                            {
+                                                deleteDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
+                                                deleteDoorLockData.IsOtherAccountCtrl = true;
+                                            }
+                                            if (doorLock.DeviceAddr != null)
+                                            {
+                                                deleteDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
+                                            }
+                                            deleteDoorLockData.DoorLockLocalUserId = curDoorLockUser.DoorLockLocalUserId;
+                                            deleteDoorLockData.PrimaryId = curDoorLockUser.Id;
+                                            deleteDoorLockData.DelDoorLockDelType = 2;
+                                            var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/DelDoorLock", deleteDoorLockData);
+                                            int i = 0;
+                                        }
+                                    }
                                 }
                             }
                             else
                             {
                                 Application.RunOnMainThread(() =>
                                 {
-                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
+                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                                    return;
                                 });
                             }
                         }
                     }
                     else
                     {
+                        //鏁版嵁濡傛灉鍦ㄩ棬閿佷笂闈㈡槸绌虹殑鏃跺�欙紝鏁版嵁涔熸槸娌℃湁鐨�
                         Application.RunOnMainThread(() =>
                         {
-                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
+                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                         });
                     }
                 }
@@ -122,13 +171,16 @@
             EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
             {
                 RemoveFromParent();
-                this.btnTip.Visible = false;
             };
             this.btnBack.MouseUpEventHandler += eHandlerBack;
             this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
             this.MidFrameLayout(this);
-
-            ReadDoorLockUserInfo();
+            MidFrameLayoutContent();
+            if (doorLock.localDoorLockUserList.Count == 0)
+            {
+                ReadDoorLockUserInfo();
+            }
+            RefreshList();
         }
 
         public void MidFrameLayoutContent()
@@ -146,8 +198,8 @@
                 Width = Application.GetRealWidth(141 + 100),
                 Y = Application.GetRealHeight(35),
                 X = Application.GetRealWidth(812 - 100),
-                TextAlignment = TextAlignment.Center,
-                Text = Language.StringByID(R.MyInternationalizationString.LockMethod),
+                TextAlignment = TextAlignment.CenterRight,
+                Text = Language.StringByID(R.MyInternationalizationString.AllMethod),
                 TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
                 TextSize = 12,
             };
@@ -168,18 +220,27 @@
                 SideslipFramelayout();
             };
 
+            var btnLine = new Button
+            {
+                Y = midTopFrameLayout.Bottom,
+                Height = 1,
+                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTitleLine,
+            };
+            this.midFrameLayout.AddChidren(btnLine);
+
             bodyView = new VerticalScrolViewLayout()
             {
                 Y = midTopFrameLayout.Bottom,
+                Height = Application.GetRealHeight(1921 - 184 - 115 - 1),
             };
             this.midFrameLayout.AddChidren(bodyView);
-
-            RefreshList();
         }
 
         void RefreshList()
         {
             bodyView.RemoveAll();
+            var curLocalDoorLockUserList = new Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj>();
+
             foreach (var curUserId in doorLock.localDoorLockUserList.Keys)
             {
                 var curDoorLockUser = doorLock.localDoorLockUserList[curUserId];
@@ -191,12 +252,19 @@
                 {
                     continue;
                 }
-                var RowView = new FrameLayout()
+                curLocalDoorLockUserList.Add(curUserId, curDoorLockUser);
+            }
+
+            int i = 0;
+            foreach (var curUserId in curLocalDoorLockUserList.Keys)
+            {
+                var curDoorLockUser = curLocalDoorLockUserList[curUserId];
+                var rowFrameLayout = new FrameLayout()
                 {
-                    Height = Application.GetRealHeight(161),
+                    Height = Application.GetRealHeight(127 + 23),
                     BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                 };
-                bodyView.AddChidren(RowView);
+                bodyView.AddChidren(rowFrameLayout);
 
                 var btnDistributeUnlockIconFrameLayout = new FrameLayout()
                 {
@@ -205,7 +273,7 @@
                     X = Application.GetRealWidth(58),
                     Y = Application.GetRealHeight(43),
                 };
-                RowView.AddChidren(btnDistributeUnlockIconFrameLayout);
+                rowFrameLayout.AddChidren(btnDistributeUnlockIconFrameLayout);
 
                 var btnDistributeUnlockIcon = new Button()
                 {
@@ -224,19 +292,24 @@
                     TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                     Gravity = Gravity.CenterVertical,
                 };
-                RowView.AddChidren(btnText);
+                rowFrameLayout.AddChidren(btnText);
 
                 var line2 = new Button()
                 {
-                    Y = RowView.Height - 1,
+                    Y = rowFrameLayout.Height - 1,
                     X = Application.GetRealWidth(58),
                     Width = Application.GetRealWidth(965),
                     Height = 1,
                     BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                 };
-                RowView.AddChidren(line2);
+                rowFrameLayout.AddChidren(line2);
 
                 #region 鏁版嵁澶勭悊
+                int currentIndex = i;
+                if (currentIndex == curLocalDoorLockUserList.Keys.Count - 1)
+                {
+                    line2.Visible = false;
+                }
                 switch (curDoorLockUser.UnlockType)
                 {
                     case 0:
@@ -277,9 +350,10 @@
                 };
                 btnDistributeUnlockIcon.MouseUpEventHandler += eHandler;
                 btnDistributeUnlockIconFrameLayout.MouseUpEventHandler += eHandler;
-                RowView.MouseUpEventHandler += eHandler;
+                rowFrameLayout.MouseUpEventHandler += eHandler;
                 btnText.MouseUpEventHandler += eHandler;
                 #endregion
+                i++;
             }
         }
 
@@ -441,7 +515,7 @@
                     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);
+                        new Tip() { MaxWidth = 150, Text = btnUserName.Text + Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                         return;
                     }
 
@@ -537,35 +611,42 @@
 
                     addLockInfo.EntryTime = curDoorLockUser.EntryTime;
                     var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/AddDoorLock", addLockInfo);
-                    if (result != null && result.StateCode == "Success")
+                    if (result != null)
                     {
-                        //瀛樿处鎴蜂俊鎭�
-                        //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)
+                        if (result.StateCode == "Success")
                         {
-                            foreach (var a in resultList.Keys)
+                            //瀛橀棬閿佷俊鎭�
+                            var resultList = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetCloudLocalDoorLocklist(doorLock, curAccountId);
+                            var uList = new List<int> { };
+                            if (resultList != null)
                             {
-                                uList.Add(a);
+                                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();
+                            var d = uList.Find((value) => { return value == curDoorLockUser.UserID; });
+                            if (d != null)
+                            {
+                                RefreshList();
+                                flMain.RemoveFromParent();
+                                bottomFrameLayout.RemoveAll();
+                            }
+                            else
+                            {
+                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                            }
                         }
                         else
                         {
-                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
+                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                            flMain.RemoveFromParent();
+                            bottomFrameLayout.RemoveAll();
                         }
                     }
                     else
                     {
-                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
+                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
                         flMain.RemoveFromParent();
                         bottomFrameLayout.RemoveAll();
                     }
@@ -736,6 +817,9 @@
         void DisplayByType(int unlockMethod)
         {
             bodyView.RemoveAll();
+
+            var curLocalDoorLockUserList = new Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj>();
+
             foreach (var curUserId in doorLock.localDoorLockUserList.Keys)
             {
                 var curDoorLockUser = doorLock.localDoorLockUserList[curUserId];
@@ -743,12 +827,20 @@
                 {
                     continue;
                 }
-                var RowView = new FrameLayout()
+                curLocalDoorLockUserList.Add(curUserId, curDoorLockUser);
+            }
+
+            int i = 0;
+            foreach (var curUserId in curLocalDoorLockUserList.Keys)
+            {
+                var curDoorLockUser = curLocalDoorLockUserList[curUserId];
+
+                var rowFrameLayout = new FrameLayout()
                 {
-                    Height = Application.GetRealHeight(161),
+                    Height = Application.GetRealHeight(150),
                     BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                 };
-                bodyView.AddChidren(RowView);
+                bodyView.AddChidren(rowFrameLayout);
 
                 var btnDistributeUnlockIconFrameLayout = new FrameLayout()
                 {
@@ -757,7 +849,7 @@
                     X = Application.GetRealWidth(58),
                     Y = Application.GetRealHeight(43),
                 };
-                RowView.AddChidren(btnDistributeUnlockIconFrameLayout);
+                rowFrameLayout.AddChidren(btnDistributeUnlockIconFrameLayout);
 
                 var btnDistributeUnlockIcon = new Button()
                 {
@@ -776,19 +868,25 @@
                     TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                     Gravity = Gravity.CenterVertical,
                 };
-                RowView.AddChidren(btnText);
+                rowFrameLayout.AddChidren(btnText);
 
                 var line2 = new Button()
                 {
-                    Y = RowView.Height - 1,
+                    Y = rowFrameLayout.Height - 1,
                     X = Application.GetRealWidth(58),
                     Width = Application.GetRealWidth(965),
                     Height = 1,
                     BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                 };
-                RowView.AddChidren(line2);
+                rowFrameLayout.AddChidren(line2);
 
                 #region 鏁版嵁澶勭悊
+                int currentIndex = i;
+                if (currentIndex == curLocalDoorLockUserList.Keys.Count - 1)
+                {
+                    line2.Visible = false;
+                }
+
                 switch (curDoorLockUser.UnlockType)
                 {
                     case 0:
@@ -829,9 +927,10 @@
                 };
                 btnDistributeUnlockIcon.MouseUpEventHandler += eHandler;
                 btnDistributeUnlockIconFrameLayout.MouseUpEventHandler += eHandler;
-                RowView.MouseUpEventHandler += eHandler;
+                rowFrameLayout.MouseUpEventHandler += eHandler;
                 btnText.MouseUpEventHandler += eHandler;
                 #endregion
+                i++;
             }
         }
         #region 鈼� 鎺ュ彛瀹炵幇__________________________

--
Gitblit v1.8.0