From ec35d79add60d1438dff5291389f7e69c579d9f9 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期四, 21 十一月 2019 18:18:25 +0800 Subject: [PATCH] 完成面板楼层显示处理和下拉刷新处理,请合并最新代码 --- ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UnLockMethod.cs | 1102 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 623 insertions(+), 479 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UnLockMethod.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UnLockMethod.cs old mode 100755 new mode 100644 index e1fb9f2..76083c2 --- 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> @@ -19,7 +47,7 @@ #region 鈼� 鍙橀噺鐢虫槑__________________________ ZigBee.Device.DoorLock doorLock; - VerticalScrolViewLayout bodyView; + VerticalRefreshLayout bodyView; Button currentMethod;// 褰撳墠閫夋嫨鐨勬柟寮� Shared.Phone.UserCenter.MemberInfoRes curAccountObj; Button entryStatusPic; @@ -28,62 +56,20 @@ bool isSecondDel; #endregion - /// <summary> - /// 鑾峰彇鏈�鏂颁俊鎭� - /// </summary> void ReadDoorLockUserInfo() { System.Threading.Tasks.Task.Run(async () => { - Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); }); try { - // 璇诲彇璁惧涓殑淇℃伅 - var getDoorLockInfo = await doorLock.GetDoorlockUserInfoAsync(); - if (getDoorLockInfo != null && getDoorLockInfo.doorLockUserDetailData != null) + var list = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockAllAcountUserlist(doorLock); + if (doorLock.IsFailedToGetDoorLockInfo[curAccountObj.SubAccountDistributedMark] == true) { - var dataList = getDoorLockInfo.doorLockUserDetailData.UserObjList; - foreach (var doorData in dataList) + //鏁版嵁濡傛灉鍦ㄩ棬閿佷笂闈㈡槸绌虹殑鏃跺�欙紝鏁版嵁涔熸槸娌℃湁鐨� + Application.RunOnMainThread(() => { - var localDoorLockObj1 = new ZigBee.Device.DoorLock.LocaDoorLockObj() - { - UserID = doorData.UserId, - UnlockType = doorData.UserType - }; - if ((doorLock.localDoorLockUserList.ContainsKey(localDoorLockObj1.UserID)) == false) - { - doorLock.localDoorLockUserList.Add(localDoorLockObj1.UserID, localDoorLockObj1); - } - } - } - - // 璇诲彇浜戠闂ㄩ攣璁惧涓殑淇℃伅 - var localDoorLockObj = new ZigBee.Device.DoorLock.GetDoorLockData() { }; - localDoorLockObj.CloudAccountId = curAccountObj.SubAccountDistributedMark; - if (doorLock.DeviceAddr != null) - { - localDoorLockObj.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint; - } - - var getDoorLockInfoList = await ZigBee.Device.DoorLock.GetDoorLockInfoFromServer("App/GetDoorLockPager", localDoorLockObj); - - if (getDoorLockInfoList != null) - { - foreach (var curDoorLockUser in getDoorLockInfoList.PageData) - { - 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.Add(int.Parse(curDoorLockUser.DoorLockLocalUserId), doorLockObj); - } + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); + }); } } catch { } @@ -103,12 +89,11 @@ /// </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; @@ -116,7 +101,7 @@ var btnAddFrameLayout = new FrameLayout { - X = Application.GetRealWidth(953), + X = Application.GetRealWidth(953 - 116), Height = Application.GetRealHeight(72), Width = Application.GetRealWidth(72), }; @@ -129,19 +114,48 @@ UnSelectedImagePath = "DoorLock/AddIcon.png", }; btnAddFrameLayout.AddChidren(btnAdd); + if (UserCenterResourse.UserInfo.AuthorityNo != 1) + { + btnAdd.Width = 0; + } btnAdd.MouseDownEventHandler += (sender, e) => { - 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 (doorLock.IsFreezeAccount[curAccountObj.SubAccountDistributedMark] == true) + { + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); + } + 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(); + if (doorLock.IsFailedToGetDoorLockInfo[curAccountObj.SubAccountDistributedMark] == true) + { + CommonPage.Loading.Start("Loading..."); + ReadDoorLockUserInfo(); + } + else + { + MidFrameLayoutContent(); + RefreshList(); + } } //涓儴甯冨眬 void MidFrameLayoutContent() { + #region 寮�閿佹柟寮廢I var midTopFrameLayout = new FrameLayout() { Height = Application.GetRealHeight(115), @@ -155,8 +169,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, }; @@ -173,22 +187,33 @@ }; midTopFrameLayout.AddChidren(btnNext); + btnNext.MouseUpEventHandler += (sender, e) => + { + SideslipFramelayout(); + }; + var btnLine = new Button + { + Y = midTopFrameLayout.Bottom, + Height = 1, + BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTitleLine, + }; + this.midFrameLayout.AddChidren(btnLine); + #endregion + entryStatusPic = new Button { X = Application.GetRealWidth(164), - Y = Application.GetRealHeight(492), - Height = Application.GetRealHeight(435), - Width = Application.GetRealWidth(757), + Y = Application.GetRealHeight(377), Visible = false, UnSelectedImagePath = "DoorLock/UnLockBlankPic.png", }; this.midFrameLayout.AddChidren(entryStatusPic); + #region 绌哄浘鐗� btnPicTip = new Button { X = Application.GetRealWidth(397), - Y = Application.GetRealHeight(1143 - 184), - Height = Application.GetRealHeight(98 / 2), + Y = Application.GetRealHeight(844), Text = Language.StringByID(R.MyInternationalizationString.NoPasswordInformation), TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, Gravity = Gravity.CenterHorizontal, @@ -200,34 +225,25 @@ { X = Application.GetRealWidth(397), Y = btnPicTip.Bottom, - Height = Application.GetRealHeight(98 / 2), Text = Language.StringByID(R.MyInternationalizationString.NoPasswordInformation1), TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, Gravity = Gravity.CenterHorizontal, Visible = false, }; this.midFrameLayout.AddChidren(btnPicTip1); + #endregion - var btnLine = new Button - { - Y = midTopFrameLayout.Bottom, - Height = 1, - BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTitleLine, - }; - this.midFrameLayout.AddChidren(btnLine); - - bodyView = new VerticalScrolViewLayout() + bodyView = new VerticalRefreshLayout() { Y = btnLine.Bottom, }; this.midFrameLayout.AddChidren(bodyView); - - btnNext.MouseUpEventHandler += (sender, e) => + bodyView.BeginHeaderRefreshingAction += () => { - SideslipFramelayout(); + bodyView.BeginHeaderRefreshing(); + ReadDoorLockUserInfo(); + bodyView.EndHeaderRefreshing(); }; - - RefreshList(); } /// <summary> @@ -237,9 +253,10 @@ /// <param name="key"></param> public void RefreshList() { + this.midFrameLayout.RemoveAll(); + MidFrameLayoutContent(); bodyView.RemoveAll(); var curAccountDoorLockUserList = new Dictionary<int, ZigBee.Device.DoorLock.LocaDoorLockObj>(); - foreach (var curUserId in doorLock.localDoorLockUserList.Keys) { var curDoorLockUser = doorLock.localDoorLockUserList[curUserId]; @@ -259,209 +276,214 @@ entryStatusPic.Visible = true; btnPicTip.Visible = true; btnPicTip1.Visible = true; + entryStatusPic.Height = Application.GetRealHeight(435); + entryStatusPic.Width = Application.GetRealHeight(757); + btnPicTip.Height = Application.GetRealHeight(98 / 2); + btnPicTip1.Height = Application.GetRealHeight(98 / 2); + bodyView.Height = Application.GetRealHeight(0); } else { + bodyView.Height = Application.GetRealHeight(1921 - 184 - 116); entryStatusPic.Visible = false; btnPicTip.Visible = false; btnPicTip1.Visible = false; - } - - foreach (var curUserId in curAccountDoorLockUserList.Keys) - { - var curDoorLockUser = curAccountDoorLockUserList[curUserId]; - #region UI - var rowFrameLayout = new RowLayout() + entryStatusPic.Height = Application.GetRealHeight(0); + entryStatusPic.Width = Application.GetRealHeight(0); + btnPicTip.Height = Application.GetRealHeight(0); + btnPicTip1.Height = Application.GetRealHeight(0); + var frameLayoutRow = new FrameLayout() { - Height = Application.GetRealHeight(173), - X = Application.GetRealWidth(58), - Width = Application.GetRealWidth(965), - LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine, + Height = Application.GetMinRealAverage(0), + BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite, }; - bodyView.AddChidren(rowFrameLayout); - - var btnPicFrameLayout = new FrameLayout() + bodyView.AddChidren(frameLayoutRow); + int i = 0; + foreach (var curUserId in curAccountDoorLockUserList.Keys) { - Width = Application.GetRealWidth(81), - Height = Application.GetRealHeight(81), - X = Application.GetRealWidth(40), - Y = Application.GetRealHeight(49), - }; - rowFrameLayout.AddChidren(btnPicFrameLayout); - - var btnPic = new Button() - { - Width = Application.GetRealWidth(84), - Height = Application.GetRealHeight(84), - UnSelectedImagePath = "DoorLock/DoorLockUserPic.png", - }; - btnPicFrameLayout.AddChidren(btnPic); - - var btnDoorlockUser = new EditText() - { - Width = Application.GetRealWidth(1080 - 173), - Height = Application.GetRealHeight(60), - X = Application.GetRealWidth(173), - Y = Application.GetRealHeight(35), - TextSize = 14, - PlaceholderTextColor = Shared.Common.ZigbeeColor.Current.XMGray3, - TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, - TextAlignment = TextAlignment.CenterLeft, - }; - rowFrameLayout.AddChidren(btnDoorlockUser); - - var btnMember = new Button() - { - Width = Application.GetRealWidth(1080 - 173), - Height = Application.GetRealHeight(49), - X = Application.GetRealWidth(173), - Y = Application.GetRealHeight(95), - TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, - TextSize = 14, - TextAlignment = TextAlignment.CenterLeft, - }; - rowFrameLayout.AddChidren(btnMember); - - var btnDel = new Button() - { - Width = Application.GetRealWidth(1080 - 173), - Height = Application.GetRealHeight(49), - X = Application.GetRealWidth(173), - Y = Application.GetRealHeight(95), - Text = Language.StringByID(R.MyInternationalizationString.Delete), - TextColor = Shared.Common.ZigbeeColor.Current.XMWhite, - TextSize = 12, - TextAlignment = TextAlignment.Center, - BackgroundColor = Shared.Common.ZigbeeColor.Current.XMDel, - }; - rowFrameLayout.AddRightView(btnDel); - #endregion - #region 鏁版嵁澶勭悊 - switch (curDoorLockUser.UnlockType) - { - case 0: - if (curDoorLockUser.UserName != "") - { - btnDoorlockUser.Text = curDoorLockUser.UserName; - } - else - { - btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Password) + "ID" + curDoorLockUser.UserID; - } - break; - case 3: - if (curDoorLockUser.UserName != "") - { - btnDoorlockUser.Text = curDoorLockUser.UserName; - } - else - { - btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.IcCard) + "ID" + curDoorLockUser.UserID; - } - break; - case 15: - if (curDoorLockUser.UserName != "") - { - btnDoorlockUser.Text = curDoorLockUser.UserName; - } - else - { - btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "ID" + +curDoorLockUser.UserID; - } - break; - } - - if (curAccountObj.UserName == "") - { - btnMember.Text = curAccountObj.Account; - } - else - { - btnMember.Text = curAccountObj.UserName; - } - - Action<Shared.View> action = async (obj) => - { - var refreshDoorLockData = new ZigBee.Device.DoorLock.RefreshDoorLockData(); - refreshDoorLockData.CloudAccountId = curAccountObj.SubAccountDistributedMark; - if (doorLock.DeviceAddr != null) - { - refreshDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint; - } - refreshDoorLockData.OpenLockMode = curDoorLockUser.UnlockType; - refreshDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString(); - refreshDoorLockData.PrimaryId = curDoorLockUser.PrimaryId; - refreshDoorLockData.UserIdRemarks = btnDoorlockUser.Text; - var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("App/UpdateDoorLock", refreshDoorLockData); - 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; - 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); - } - }; - btnDoorlockUser.EditorEnterAction += action; - - btnDel.MouseUpEventHandler += (sender, e) => - { - var alert = new Alert(Language.StringByID(R.MyInternationalizationString.Tip), Language.StringByID(R.MyInternationalizationString.SureToDelUnlockMethod), - Language.StringByID(R.MyInternationalizationString.Cancel), Language.StringByID(R.MyInternationalizationString.Confrim)); - alert.Show(); - alert.ResultEventHandler += async (sender1, e1) => + var curDoorLockUser = curAccountDoorLockUserList[curUserId]; + #region UI + var rowFrameLayout = new RowLayout() { - if (e1) - { - var passData = doorLock.SetUserAccessData(curDoorLockUser.UserID, ZigBee.Device.DoorLock.AccessType.DelCurrentUser); - var resultData = await doorLock.DefaultControlAsync(passData); - if (resultData != null && resultData.defaultControlResponseData != null) + Height = Application.GetRealHeight(127 + 23), + X = Application.GetRealWidth(58), + Y = i * Application.GetRealHeight(150), + Width = Application.GetRealWidth(965), + LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine, + BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite, + }; + frameLayoutRow.AddChidren(rowFrameLayout); + + var btnPicFrameLayout = new FrameLayout() + { + Width = Application.GetRealWidth(81), + Height = Application.GetRealHeight(81), + X = Application.GetRealWidth(40), + Y = Application.GetRealHeight(49), + }; + rowFrameLayout.AddChidren(btnPicFrameLayout); + + var btnPic = new Button() + { + Width = Application.GetRealWidth(84), + Height = Application.GetRealHeight(84), + UnSelectedImagePath = "DoorLock/DoorLockUserPic.png", + }; + btnPicFrameLayout.AddChidren(btnPic); + + var btnDoorlockUser = new EditText() + { + Width = Application.GetRealWidth(1080 - 173), + Height = Application.GetRealHeight(60), + X = Application.GetRealWidth(173), + Y = Application.GetRealHeight(35), + TextSize = 14, + PlaceholderTextColor = Shared.Common.ZigbeeColor.Current.XMGray3, + TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, + TextAlignment = TextAlignment.CenterLeft, + }; + rowFrameLayout.AddChidren(btnDoorlockUser); + + var btnMember = new Button() + { + Width = Application.GetRealWidth(1080 - 173), + Height = Application.GetRealHeight(49), + X = Application.GetRealWidth(173), + Y = Application.GetRealHeight(95), + TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, + TextSize = 14, + TextAlignment = TextAlignment.CenterLeft, + }; + rowFrameLayout.AddChidren(btnMember); + + var btnDel = new Button() + { + Width = Application.GetRealWidth(184), + Text = Language.StringByID(R.MyInternationalizationString.DelBindDevice), + TextColor = Shared.Common.ZigbeeColor.Current.XMWhite, + TextSize = 12, + TextAlignment = TextAlignment.Center, + BackgroundColor = Shared.Common.ZigbeeColor.Current.XMDel, + }; + rowFrameLayout.AddRightView(btnDel); + #endregion + #region 鏁版嵁澶勭悊 + int currentIndex = i; + if (currentIndex == curAccountDoorLockUserList.Keys.Count - 1) + { + rowFrameLayout.LineColor = Shared.Common.ZigbeeColor.Current.XMWhite; + } + + switch (curDoorLockUser.UnlockType) + { + case 0: + if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) { - if (resultData.defaultControlResponseData.status == 0) + btnDoorlockUser.Text = curDoorLockUser.UserName; + } + else + { + btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Password) + "ID" + curDoorLockUser.UserID; + } + break; + case 3: + if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) + { + btnDoorlockUser.Text = curDoorLockUser.UserName; + } + else + { + btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.IcCard) + "ID" + curDoorLockUser.UserID; + } + break; + case 15: + if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) + { + btnDoorlockUser.Text = curDoorLockUser.UserName; + } + else + { + btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "ID" + +curDoorLockUser.UserID; + } + break; + } + + if (curAccountObj.UserName == "" || curAccountObj.UserName == null) + { + btnMember.Text = curAccountObj.Account; + } + else + { + btnMember.Text = curAccountObj.UserName; + } + + Action<Shared.View> action = async (obj) => + { + var refreshDoorLockData = new ZigBee.Device.DoorLock.RefreshDoorLockData(); + if (UserCenterResourse.UserInfo.AuthorityNo != 1) + { + refreshDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); + refreshDoorLockData.IsOtherAccountCtrl = true; + } + if (doorLock.DeviceAddr != null) + { + refreshDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint; + } + refreshDoorLockData.OpenLockMode = curDoorLockUser.UnlockType; + refreshDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString(); + refreshDoorLockData.PrimaryId = curDoorLockUser.PrimaryId; + refreshDoorLockData.UserIdRemarks = btnDoorlockUser.Text; + var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/UpdateDoorLock", refreshDoorLockData); + 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; + 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.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); + } + }; + btnDoorlockUser.EditorEnterAction += action; + + btnDel.MouseUpEventHandler += (sender, e) => + { + var alert = new Alert(Language.StringByID(R.MyInternationalizationString.Tip), Language.StringByID(R.MyInternationalizationString.SureToDelUnlockMethod), + Language.StringByID(R.MyInternationalizationString.Cancel), Language.StringByID(R.MyInternationalizationString.Confrim)); + alert.Show(); + alert.ResultEventHandler += async (sender1, e1) => + { + if (e1) + { + var passData = doorLock.SetUserAccessData(curDoorLockUser.UserID, ZigBee.Device.DoorLock.AccessType.DelCurrentUser); + var resultData = await doorLock.DefaultControlAsync(passData); + if (resultData != null && resultData.defaultControlResponseData != null) { - var deleteDoorLockData = new ZigBee.Device.DoorLock.DeleteDoorLockData(); - if (doorLock.DeviceAddr != null) - { - deleteDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint; - } - deleteDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString(); - deleteDoorLockData.PrimaryId = curDoorLockUser.PrimaryId; - deleteDoorLockData.DelDoorLockDelType = 2; - var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("App/DelDoorLock", deleteDoorLockData); - if (result.StateCode == "Success") - { - 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 - { - isSecondDel = true; - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); - } - } - else - { - if (isSecondDel) + if (resultData.defaultControlResponseData.status == 0 || resultData.defaultControlResponseData.status == 2) { 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; @@ -469,46 +491,101 @@ deleteDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString(); deleteDoorLockData.PrimaryId = curDoorLockUser.PrimaryId; deleteDoorLockData.DelDoorLockDelType = 2; - var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("App/DelDoorLock", deleteDoorLockData); - if (result.StateCode == "Success") + var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/DelDoorLock", deleteDoorLockData); + 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 { - if (curDoorLockUser.UserID < 10) + if (isSecondDel) { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.OnlyBeDeletedOnTheDevice), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); + 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.UserID.ToString(); + deleteDoorLockData.PrimaryId = curDoorLockUser.PrimaryId; + deleteDoorLockData.DelDoorLockDelType = 2; + var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/DelDoorLock", deleteDoorLockData); + if (result != null) + { + if (result.StateCode == "Success") + { + 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.CloudServerResponseOvertime), 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); + 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 + { + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel); + } } - else - { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel); - } - } + }; }; - }; - #endregion + #endregion + i++; + } + frameLayoutRow.Height = i * Application.GetRealHeight(150); } } @@ -695,234 +772,301 @@ if (curAccountDoorLockUserList.Count == 0) { + bodyView.Height = Application.GetRealHeight(0); entryStatusPic.Visible = true; btnPicTip.Visible = true; btnPicTip1.Visible = true; + entryStatusPic.Height = Application.GetRealHeight(435); + entryStatusPic.Width = Application.GetRealHeight(757); + btnPicTip.Height = Application.GetRealHeight(98 / 2); + btnPicTip1.Height = Application.GetRealHeight(98 / 2); } else { entryStatusPic.Visible = false; btnPicTip.Visible = false; btnPicTip1.Visible = false; - } + entryStatusPic.Height = Application.GetRealHeight(0); + entryStatusPic.Width = Application.GetRealHeight(0); + btnPicTip.Height = Application.GetRealHeight(0); + btnPicTip1.Height = Application.GetRealHeight(0); + bodyView.Height = Application.GetRealHeight(1921 - 184 - 116); - foreach (var curUserId in curAccountDoorLockUserList.Keys) - { - var curDoorLockUser = curAccountDoorLockUserList[curUserId]; - if (curDoorLockUser.UnlockType != unlockMethod) + var frameLayoutRow = new FrameLayout() { - continue; - } - #region UI - var rowFrameLayout = new RowLayout() - { - Height = Application.GetRealHeight(173), - X = Application.GetRealWidth(58), - Width = Application.GetRealWidth(965), - LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine, + Height = Application.GetMinRealAverage(0), + BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite, }; - bodyView.AddChidren(rowFrameLayout); - - var btnPicFrameLayout = new FrameLayout() + bodyView.AddChidren(frameLayoutRow); + int i = 0; + foreach (var curUserId in curAccountDoorLockUserList.Keys) { - Width = Application.GetRealWidth(81), - Height = Application.GetRealHeight(81), - X = Application.GetRealWidth(40), - Y = Application.GetRealHeight(49), - }; - rowFrameLayout.AddChidren(btnPicFrameLayout); - - var btnPic = new Button() - { - Width = Application.GetRealWidth(84), - Height = Application.GetRealHeight(84), - UnSelectedImagePath = "DoorLock/DoorLockUserPic.png", - }; - btnPicFrameLayout.AddChidren(btnPic); - - var btnDoorlockUser = new EditText() - { - Width = Application.GetRealWidth(1080 - 173), - Height = Application.GetRealHeight(60), - X = Application.GetRealWidth(173), - Y = Application.GetRealHeight(35), - TextSize = 14, - PlaceholderTextColor = Shared.Common.ZigbeeColor.Current.XMGray3, - TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, - TextAlignment = TextAlignment.CenterLeft, - }; - rowFrameLayout.AddChidren(btnDoorlockUser); - - var btnMember = new Button() - { - Width = Application.GetRealWidth(1080 - 173), - Height = Application.GetRealHeight(49), - X = Application.GetRealWidth(173), - Y = Application.GetRealHeight(95), - TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, - TextSize = 14, - TextAlignment = TextAlignment.CenterLeft, - }; - rowFrameLayout.AddChidren(btnMember); - - var btnDel = new Button() - { - Width = Application.GetRealWidth(1080 - 173), - Height = Application.GetRealHeight(49), - X = Application.GetRealWidth(173), - Y = Application.GetRealHeight(95), - Text = Language.StringByID(R.MyInternationalizationString.Delete), - TextColor = Shared.Common.ZigbeeColor.Current.XMWhite, - TextSize = 12, - TextAlignment = TextAlignment.Center, - BackgroundColor = Shared.Common.ZigbeeColor.Current.XMDel, - }; - rowFrameLayout.AddRightView(btnDel); - #endregion - #region 鏁版嵁澶勭悊 - switch (curDoorLockUser.UnlockType) - { - case 0: - if (curDoorLockUser.UserName != "") - { - btnDoorlockUser.Text = curDoorLockUser.UserName; - } - else - { - btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Password) + "ID" + curDoorLockUser.UserID; - } - break; - case 3: - if (curDoorLockUser.UserName != "") - { - btnDoorlockUser.Text = curDoorLockUser.UserName; - } - else - { - btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.IcCard) + "ID" + curDoorLockUser.UserID; - } - break; - case 15: - if (curDoorLockUser.UserName != "") - { - btnDoorlockUser.Text = curDoorLockUser.UserName; - } - else - { - btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "ID" + +curDoorLockUser.UserID; - } - break; - } - - if (curAccountObj.UserName == "") - { - btnMember.Text = curAccountObj.Account; - } - else - { - btnMember.Text = curAccountObj.UserName; - } - - Action<Shared.View> action = async (obj) => - { - var refreshDoorLockData = new ZigBee.Device.DoorLock.RefreshDoorLockData(); - refreshDoorLockData.CloudAccountId = curAccountObj.SubAccountDistributedMark; - if (doorLock.DeviceAddr != null) + var curDoorLockUser = curAccountDoorLockUserList[curUserId]; + if (curDoorLockUser.UnlockType != unlockMethod) { - refreshDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint; + continue; } - refreshDoorLockData.OpenLockMode = curDoorLockUser.UnlockType; - refreshDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString(); - refreshDoorLockData.PrimaryId = curDoorLockUser.PrimaryId; - refreshDoorLockData.UserIdRemarks = btnDoorlockUser.Text; - var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("App/UpdateDoorLock", refreshDoorLockData); - if (result.StateCode == "Success") + #region UI + var rowFrameLayout = new RowLayout() { - 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(); - } + Height = Application.GetRealHeight(127 + 23), + X = Application.GetRealWidth(58), + Y = i * Application.GetRealHeight(150), + Width = Application.GetRealWidth(965), + LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine, + }; + frameLayoutRow.AddChidren(rowFrameLayout); + + var btnPicFrameLayout = new FrameLayout() + { + Width = Application.GetRealWidth(81), + Height = Application.GetRealHeight(81), + X = Application.GetRealWidth(40), + Y = Application.GetRealHeight(49), + }; + rowFrameLayout.AddChidren(btnPicFrameLayout); + + var btnPic = new Button() + { + Width = Application.GetRealWidth(84), + Height = Application.GetRealHeight(84), + UnSelectedImagePath = "DoorLock/DoorLockUserPic.png", + }; + btnPicFrameLayout.AddChidren(btnPic); + + var btnDoorlockUser = new EditText() + { + Width = Application.GetRealWidth(1080 - 173), + Height = Application.GetRealHeight(60), + X = Application.GetRealWidth(173), + Y = Application.GetRealHeight(35), + TextSize = 14, + PlaceholderTextColor = Shared.Common.ZigbeeColor.Current.XMGray3, + TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, + TextAlignment = TextAlignment.CenterLeft, + }; + rowFrameLayout.AddChidren(btnDoorlockUser); + + var btnMember = new Button() + { + Width = Application.GetRealWidth(1080 - 173), + Height = Application.GetRealHeight(49), + X = Application.GetRealWidth(173), + Y = Application.GetRealHeight(95), + TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, + TextSize = 14, + TextAlignment = TextAlignment.CenterLeft, + }; + rowFrameLayout.AddChidren(btnMember); + + var btnDel = new Button() + { + Width = Application.GetRealWidth(1080 - 173), + Height = Application.GetRealHeight(49), + X = Application.GetRealWidth(173), + Y = Application.GetRealHeight(95), + Text = Language.StringByID(R.MyInternationalizationString.DelBindDevice), + TextColor = Shared.Common.ZigbeeColor.Current.XMWhite, + TextSize = 12, + TextAlignment = TextAlignment.Center, + BackgroundColor = Shared.Common.ZigbeeColor.Current.XMDel, + }; + rowFrameLayout.AddRightView(btnDel); + #endregion + #region 鏁版嵁澶勭悊 + int currentIndex = i; + if (currentIndex == curAccountDoorLockUserList.Keys.Count - 1) + { + rowFrameLayout.LineColor = Shared.Common.ZigbeeColor.Current.XMWhite; + } + switch (curDoorLockUser.UnlockType) + { + case 0: + if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) + { + btnDoorlockUser.Text = curDoorLockUser.UserName; + } + else + { + btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Password) + "ID" + curDoorLockUser.UserID; + } + break; + case 3: + if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) + { + btnDoorlockUser.Text = curDoorLockUser.UserName; + } + else + { + btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.IcCard) + "ID" + curDoorLockUser.UserID; + } + break; + case 15: + if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) + { + btnDoorlockUser.Text = curDoorLockUser.UserName; + } + else + { + btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "ID" + +curDoorLockUser.UserID; + } + break; + } + + if (curAccountObj.UserName == "" || curAccountObj.UserName == null) + { + btnMember.Text = curAccountObj.Account; } else { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ModigfyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); + btnMember.Text = curAccountObj.UserName; } - }; - btnDoorlockUser.EditorEnterAction += action; - btnDel.MouseUpEventHandler += (sender, e) => - { - var alert = new Alert(Language.StringByID(R.MyInternationalizationString.Tip), Language.StringByID(R.MyInternationalizationString.SureToDelUnlockMethod), - Language.StringByID(R.MyInternationalizationString.Cancel), Language.StringByID(R.MyInternationalizationString.Confrim)); - alert.Show(); - alert.ResultEventHandler += async (sender1, e1) => + Action<Shared.View> action = async (obj) => { - if (e1) + var refreshDoorLockData = new ZigBee.Device.DoorLock.RefreshDoorLockData(); + if (UserCenterResourse.UserInfo.AuthorityNo != 1) { - var passData = doorLock.SetUserAccessData(curDoorLockUser.UserID, ZigBee.Device.DoorLock.AccessType.DelCurrentUser); - var resultData = await doorLock.DefaultControlAsync(passData); - if (resultData != null && resultData.defaultControlResponseData != null) + refreshDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); + refreshDoorLockData.IsOtherAccountCtrl = true; + } + if (doorLock.DeviceAddr != null) + { + refreshDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint; + } + refreshDoorLockData.OpenLockMode = curDoorLockUser.UnlockType; + refreshDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString(); + refreshDoorLockData.PrimaryId = curDoorLockUser.PrimaryId; + refreshDoorLockData.UserIdRemarks = btnDoorlockUser.Text; + var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/UpdateDoorLock", refreshDoorLockData); + if (result != null) + { + if (result.StateCode == "Success") { - if (resultData.defaultControlResponseData.status == 0) + if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID)) { - var deleteDoorLockData = new ZigBee.Device.DoorLock.DeleteDoorLockData(); - if (doorLock.DeviceAddr != null) - { - deleteDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint; - } - deleteDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString(); - deleteDoorLockData.PrimaryId = curDoorLockUser.PrimaryId; - deleteDoorLockData.DelDoorLockDelType = 2; - var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("App/DelDoorLock", deleteDoorLockData); - 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; + 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.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser); + } + }; + btnDoorlockUser.EditorEnterAction += action; - //new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveSuccess), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel); - doorLock.localDoorLockUserList.Remove(curUserId); - RefreshList(); + btnDel.MouseUpEventHandler += (sender, e) => + { + var alert = new Alert(Language.StringByID(R.MyInternationalizationString.Tip), Language.StringByID(R.MyInternationalizationString.SureToDelUnlockMethod), + Language.StringByID(R.MyInternationalizationString.Cancel), Language.StringByID(R.MyInternationalizationString.Confrim)); + alert.Show(); + alert.ResultEventHandler += async (sender1, e1) => + { + if (e1) + { + var passData = doorLock.SetUserAccessData(curDoorLockUser.UserID, ZigBee.Device.DoorLock.AccessType.DelCurrentUser); + var resultData = await doorLock.DefaultControlAsync(passData); + if (resultData != null && resultData.defaultControlResponseData != null) + { + if (resultData.defaultControlResponseData.status == 0) + { + 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.UserID.ToString(); + deleteDoorLockData.PrimaryId = curDoorLockUser.PrimaryId; + deleteDoorLockData.DelDoorLockDelType = 2; + var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/DelDoorLock", deleteDoorLockData); + 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; + 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 + { + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), 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.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel); } + } 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); } - } - else - { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel); - } - } + }; }; - }; - #endregion + #endregion + i++; + } + frameLayoutRow.Height = i * Application.GetRealHeight(127 + 23); } } + /// <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