黄学彪
2019-11-07 82a773d1783549caca563831aac8affc059deedf
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UnLockMethod.cs
@@ -28,13 +28,32 @@
        bool isSecondDel;
        #endregion
        void ReadDoorLockUserInfo()
        {
            System.Threading.Tasks.Task.Run(async () =>
            {
                Application.RunOnMainThread(() => { CommonPage.Loading.Start("Loading..."); });
                try
                {
                    await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetLocaDoorLocklist(doorLock, curAccountObj);
                }
                catch { }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        RefreshList();
                        CommonPage.Loading.Hide();
                    });
                }
            });
        }
        /// <summary>
        /// UI显示 
        /// </summary>
        public void Show()
        {
            //ReadDoorLockUserInfo();
            this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.LockMethod));
            this.btnTitleLine.Visible = false;
            EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
@@ -62,12 +81,18 @@
            btnAddFrameLayout.AddChidren(btnAdd);
            btnAdd.MouseDownEventHandler += (sender, e) =>
            {
                if (doorLock.IsFreezeAccount[curAccountObj.SubAccountDistributedMark] == true)
                {
                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
                }
                else
                {
                var addUnLockMethod = new Shared.Phone.UserCenter.DoorLock.AddUnLockMethod(doorLock, curAccountObj);
                Shared.Phone.UserView.HomePage.Instance.AddChidren(addUnLockMethod);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                addUnLockMethod.Show();
                }
            };
            MidFrameLayoutContent();
        }
        //中部布局
@@ -157,8 +182,14 @@
            {
                SideslipFramelayout();
            };
            if (doorLock.IsFailedToGetDoorLockInfo[curAccountObj.SubAccountDistributedMark] == true)
            {
                ReadDoorLockUserInfo();
            }
            else
            {
            RefreshList();
            }
        }
        /// <summary>
@@ -168,6 +199,11 @@
        /// <param name="key"></param>
        public void RefreshList()
        {
            if (doorLock.IsFailedToGetDoorLockInfo[curAccountObj.SubAccountDistributedMark] == true)
            {
                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
                return;
            }
            bodyView.RemoveAll();
            var curAccountDoorLockUserList = new Dictionary<int, ZigBee.Device.DoorLock.LocaDoorLockObj>();
@@ -271,7 +307,7 @@
                switch (curDoorLockUser.UnlockType)
                {
                    case 0:
                        if (curDoorLockUser.UserName != "")
                        if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                        {
                            btnDoorlockUser.Text = curDoorLockUser.UserName;
                        }
@@ -281,7 +317,7 @@
                        }
                        break;
                    case 3:
                        if (curDoorLockUser.UserName != "")
                        if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                        {
                            btnDoorlockUser.Text = curDoorLockUser.UserName;
                        }
@@ -291,7 +327,7 @@
                        }
                        break;
                    case 15:
                        if (curDoorLockUser.UserName != "")
                        if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                        {
                            btnDoorlockUser.Text = curDoorLockUser.UserName;
                        }
@@ -302,7 +338,7 @@
                        break;
                }
                if (curAccountObj.UserName == "")
                if (curAccountObj.UserName == "" || curAccountObj.UserName == null)
                {
                    btnMember.Text = curAccountObj.Account;
                }
@@ -319,7 +355,6 @@
                         refreshDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
                         refreshDoorLockData.IsOtherAccountCtrl = true;
                     }
                     refreshDoorLockData.CloudAccountId = curAccountObj.SubAccountDistributedMark;
                     if (doorLock.DeviceAddr != null)
                     {
                         refreshDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
@@ -329,7 +364,9 @@
                     refreshDoorLockData.PrimaryId = curDoorLockUser.PrimaryId;
                     refreshDoorLockData.UserIdRemarks = btnDoorlockUser.Text;
                     var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/UpdateDoorLock", refreshDoorLockData);
                     if (result != null && result.StateCode == "Success")
                     if (result != null)
                     {
                         if (result.StateCode == "Success")
                     {
                         if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID))
                         {
@@ -347,6 +384,11 @@
                     else
                     {
                         new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ModigfyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                         }
                     }
                     else
                     {
                         new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                     }
                 };
                btnDoorlockUser.EditorEnterAction += action;
@@ -380,22 +422,30 @@
                                    deleteDoorLockData.PrimaryId = curDoorLockUser.PrimaryId;
                                    deleteDoorLockData.DelDoorLockDelType = 2;
                                    var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/DelDoorLock", deleteDoorLockData);
                                    if (result != null && result.StateCode == "Success")
                                    if (result != null)
                                    {
                                        if (result.StateCode == "Success")
                                    {
                                        isSecondDel = false;
                                        if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID))
                                        {
                                            doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID);
                                                doorLock.localDoorLockAccountList.Remove(curDoorLockUser.ConnectedAccount);
                                            var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
                                            localDoorLockObj.UserID = curDoorLockUser.UserID;
                                            doorLock.localDoorLockUserList.Remove(curUserId);
                                                doorLock.ReSave();
                                            RefreshList();
                                        }
                                    }
                                    else
                                    {
                                        isSecondDel = true;
                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                                        }
                                    }
                                    else
                                    {
                                        isSecondDel = true;
                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                                    }
                                }
                                else
@@ -416,7 +466,9 @@
                                        deleteDoorLockData.PrimaryId = curDoorLockUser.PrimaryId;
                                        deleteDoorLockData.DelDoorLockDelType = 2;
                                        var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/DelDoorLock", deleteDoorLockData);
                                        if (result != null && result.StateCode == "Success")
                                        if (result != null)
                                        {
                                            if (result.StateCode == "Success")
                                        {
                                            isSecondDel = false;
                                            if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID))
@@ -430,8 +482,13 @@
                                        }
                                        else
                                        {
                                            isSecondDel = true;
                                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                                            }
                                        }
                                        else
                                        {
                                            isSecondDel = true;
                                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                                        }
                                    }
                                    else
@@ -449,7 +506,7 @@
                            }
                            else
                            {
                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
                            }
                        }
                    };
@@ -729,7 +786,7 @@
                switch (curDoorLockUser.UnlockType)
                {
                    case 0:
                        if (curDoorLockUser.UserName != "")
                        if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                        {
                            btnDoorlockUser.Text = curDoorLockUser.UserName;
                        }
@@ -739,7 +796,7 @@
                        }
                        break;
                    case 3:
                        if (curDoorLockUser.UserName != "")
                        if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                        {
                            btnDoorlockUser.Text = curDoorLockUser.UserName;
                        }
@@ -749,7 +806,7 @@
                        }
                        break;
                    case 15:
                        if (curDoorLockUser.UserName != "")
                        if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                        {
                            btnDoorlockUser.Text = curDoorLockUser.UserName;
                        }
@@ -760,7 +817,7 @@
                        break;
                }
                if (curAccountObj.UserName == "")
                if (curAccountObj.UserName == "" || curAccountObj.UserName == null)
                {
                    btnMember.Text = curAccountObj.Account;
                }
@@ -777,7 +834,6 @@
                        refreshDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
                        refreshDoorLockData.IsOtherAccountCtrl = true;
                    }
                    refreshDoorLockData.CloudAccountId = curAccountObj.SubAccountDistributedMark;
                    if (doorLock.DeviceAddr != null)
                    {
                        refreshDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
@@ -787,7 +843,9 @@
                    refreshDoorLockData.PrimaryId = curDoorLockUser.PrimaryId;
                    refreshDoorLockData.UserIdRemarks = btnDoorlockUser.Text;
                    var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/UpdateDoorLock", refreshDoorLockData);
                    if (result != null && result.StateCode == "Success")
                    if (result != null)
                    {
                        if (result.StateCode == "Success")
                    {
                        if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID))
                        {
@@ -805,6 +863,11 @@
                    else
                    {
                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ModigfyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                        }
                    }
                    else
                    {
                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                    }
                };
                btnDoorlockUser.EditorEnterAction += action;
@@ -838,15 +901,15 @@
                                    deleteDoorLockData.PrimaryId = curDoorLockUser.PrimaryId;
                                    deleteDoorLockData.DelDoorLockDelType = 2;
                                    var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/DelDoorLock", deleteDoorLockData);
                                    if (result != null && result.StateCode == "Success")
                                    if (result != null)
                                    {
                                        if (result.StateCode == "Success")
                                    {
                                        if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID))
                                        {
                                            doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID);
                                            var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
                                            localDoorLockObj.UserID = curDoorLockUser.UserID;
                                            //new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveSuccess), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
                                            doorLock.localDoorLockUserList.Remove(curUserId);
                                            RefreshList();
                                        }
@@ -855,12 +918,17 @@
                                    {
                                        if (curDoorLockUser.UserID < 10)
                                        {
                                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.OnlyBeDeletedOnTheDevice), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                                        }
                                        else
                                        {
                                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ModigfyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                                        }
                                        }
                                    }
                                    else
                                    {
                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                                    }
                                }
                                else
@@ -871,7 +939,7 @@
                            }
                            else
                            {
                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
                            }
                        }
                    };