From 05ce435c3b58e53eeab04c672affdeeab75f3036 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期五, 15 十一月 2019 14:41:39 +0800 Subject: [PATCH] 2019.11.15-1 --- ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UnLockMethod.cs | 291 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 211 insertions(+), 80 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UnLockMethod.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UnLockMethod.cs index 53eec42..7580a18 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UnLockMethod.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UnLockMethod.cs @@ -2,11 +2,39 @@ using System.Collections.Generic; using System.ComponentModel; using Shared.Common; +using ZigBee.Device; namespace Shared.Phone.UserCenter.DoorLock { - public class UnLockMethod : DoorLockCommonLayout + public class UnLockMethod : DoorLockCommonLayout, ZigBee.Common.IStatus { + /// <summary> + /// 澶勭悊鍙樺寲浜嬩欢 + /// </summary> + /// <param name="common"></param> + /// <param name="typeTag"></param> + public void DeviceInfoChange(CommonDevice tempDevice, string typeTag) + { + if (typeTag == "DoorLockProgrammingEventNotificationCommand" && tempDevice != null) + { + if (tempDevice != null) + { + if (tempDevice.DeviceEpoint == doorLock.DeviceEpoint + && tempDevice.DeviceAddr == doorLock.DeviceAddr) + { + var doorLock = tempDevice as ZigBee.Device.DoorLock; + if (doorLock.doorLockProgrammingEventNotificationCommand != null) + { + + Application.RunOnMainThread(() => + { + + }); + } + } + } + } + } /// 鏋勯�犲嚱鏁� /// </summary> /// <param name="doorLock"></param> @@ -28,18 +56,37 @@ 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) => { - RemoveFromParent(); + this.RemoveFromParent(); }; this.btnBack.MouseUpEventHandler += eHandlerBack; this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack; @@ -47,7 +94,7 @@ var btnAddFrameLayout = new FrameLayout { - X = Application.GetRealWidth(953), + X = Application.GetRealWidth(953 - 116), Height = Application.GetRealHeight(72), Width = Application.GetRealWidth(72), }; @@ -60,14 +107,32 @@ UnSelectedImagePath = "DoorLock/AddIcon.png", }; btnAddFrameLayout.AddChidren(btnAdd); + if (UserCenterResourse.UserInfo.AuthorityNo != 1) + { + btnAdd.Width = 0; + } 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(); - }; - + } + }; + if (UserCenterResourse.UserInfo.AuthorityNo == 3) + { + btnAddFrameLayout.Width = 0; + } + else + { + btnAddFrameLayout.Width = Application.GetRealWidth(72); + } MidFrameLayoutContent(); } //涓儴甯冨眬 @@ -149,7 +214,8 @@ bodyView = new VerticalScrolViewLayout() { - Y = btnLine.Bottom, + Y = midTopFrameLayout.Bottom, + Height = Application.GetRealHeight(1921 - 184 - 115 - 1), }; this.midFrameLayout.AddChidren(bodyView); @@ -157,8 +223,14 @@ { SideslipFramelayout(); }; - - RefreshList(); + if (doorLock.IsFailedToGetDoorLockInfo[curAccountObj.SubAccountDistributedMark] == true) + { + ReadDoorLockUserInfo(); + } + else + { + RefreshList(); + } } /// <summary> @@ -168,6 +240,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 +348,7 @@ switch (curDoorLockUser.UnlockType) { case 0: - if (curDoorLockUser.UserName != "") + if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) { btnDoorlockUser.Text = curDoorLockUser.UserName; } @@ -281,7 +358,7 @@ } break; case 3: - if (curDoorLockUser.UserName != "") + if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) { btnDoorlockUser.Text = curDoorLockUser.UserName; } @@ -291,7 +368,7 @@ } break; case 15: - if (curDoorLockUser.UserName != "") + if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) { btnDoorlockUser.Text = curDoorLockUser.UserName; } @@ -302,7 +379,7 @@ break; } - if (curAccountObj.UserName == "") + if (curAccountObj.UserName == "" || curAccountObj.UserName == null) { btnMember.Text = curAccountObj.Account; } @@ -319,7 +396,6 @@ refreshDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); refreshDoorLockData.IsOtherAccountCtrl = true; } - refreshDoorLockData.CloudAccountId = curAccountObj.SubAccountDistributedMark; if (doorLock.DeviceAddr != null) { refreshDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint; @@ -329,24 +405,31 @@ 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 (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID)) + if (result.StateCode == "Success") { - 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 = refreshDoorLockData.UserIdRemarks; - localDoorLockObj.ConnectedAccount = curAccountObj.SubAccountDistributedMark; - doorLock.localDoorLockUserList.Add(curDoorLockUser.UserID, localDoorLockObj); - RefreshList(); + if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID)) + { + 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 = refreshDoorLockData.UserIdRemarks; + localDoorLockObj.ConnectedAccount = curAccountObj.SubAccountDistributedMark; + doorLock.localDoorLockUserList.Add(curDoorLockUser.UserID, localDoorLockObj); + RefreshList(); + } + } + 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.ModigfyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); } }; btnDoorlockUser.EditorEnterAction += action; @@ -380,22 +463,31 @@ 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) { - isSecondDel = false; - if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID)) + if (result.StateCode == "Success") { - doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID); - var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { }; - localDoorLockObj.UserID = curDoorLockUser.UserID; - doorLock.localDoorLockUserList.Remove(curUserId); - RefreshList(); + isSecondDel = false; + if (doorLock.localDoorLockUserList.ContainsKey(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 + { + //寮�鍏冲浘鏍� + 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.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); } } else @@ -416,22 +508,29 @@ 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) { - isSecondDel = false; - if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID)) + if (result.StateCode == "Success") { - doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID); - var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { }; - localDoorLockObj.UserID = curDoorLockUser.UserID; - doorLock.localDoorLockUserList.Remove(curUserId); - RefreshList(); + isSecondDel = false; + if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID)) + { + doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID); + var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { }; + localDoorLockObj.UserID = curDoorLockUser.UserID; + doorLock.localDoorLockUserList.Remove(curUserId); + RefreshList(); + } + } + else + { + 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.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); } } else @@ -449,7 +548,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 +828,7 @@ switch (curDoorLockUser.UnlockType) { case 0: - if (curDoorLockUser.UserName != "") + if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) { btnDoorlockUser.Text = curDoorLockUser.UserName; } @@ -739,7 +838,7 @@ } break; case 3: - if (curDoorLockUser.UserName != "") + if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) { btnDoorlockUser.Text = curDoorLockUser.UserName; } @@ -749,7 +848,7 @@ } break; case 15: - if (curDoorLockUser.UserName != "") + if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) { btnDoorlockUser.Text = curDoorLockUser.UserName; } @@ -760,7 +859,7 @@ break; } - if (curAccountObj.UserName == "") + if (curAccountObj.UserName == "" || curAccountObj.UserName == null) { btnMember.Text = curAccountObj.Account; } @@ -777,7 +876,6 @@ refreshDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); refreshDoorLockData.IsOtherAccountCtrl = true; } - refreshDoorLockData.CloudAccountId = curAccountObj.SubAccountDistributedMark; if (doorLock.DeviceAddr != null) { refreshDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint; @@ -787,24 +885,31 @@ 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 (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID)) + if (result.StateCode == "Success") { - 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 = refreshDoorLockData.UserIdRemarks; - localDoorLockObj.ConnectedAccount = curAccountObj.SubAccountDistributedMark; - doorLock.localDoorLockUserList.Add(curDoorLockUser.UserID, localDoorLockObj); - RefreshList(); + if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID)) + { + 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 = refreshDoorLockData.UserIdRemarks; + localDoorLockObj.ConnectedAccount = curAccountObj.SubAccountDistributedMark; + doorLock.localDoorLockUserList.Add(curDoorLockUser.UserID, localDoorLockObj); + RefreshList(); + } + } + 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.ModigfyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); } }; btnDoorlockUser.EditorEnterAction += action; @@ -838,29 +943,34 @@ 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 (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID)) + if (result.StateCode == "Success") { - 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(); + if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID)) + { + doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID); + var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { }; + localDoorLockObj.UserID = curDoorLockUser.UserID; + doorLock.localDoorLockUserList.Remove(curUserId); + RefreshList(); + } + } + else + { + 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.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); + } } } else { - if (curDoorLockUser.UserID < 10) - { - - } - 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.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); } } else @@ -871,7 +981,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); } } }; @@ -880,5 +990,26 @@ } } + /// <summary> + /// 閲嶅啓绉婚櫎鏂规硶 + /// </summary> + public override void RemoveFromParent() + { + ZbGateway.StatusList.Remove(this); + base.RemoveFromParent(); + } + + + + public void Changed(CommonDevice common) + { + } + public void ChangedILogicStatus(ZigBee.Device.Logic logic) + { + } + + public void ChangedISceneStatus(Scene scene) + { + } } } -- Gitblit v1.8.0