| | |
| | | FrameLayout bottomFrameLayout; |
| | | string currentType = string.Empty; |
| | | List<Shared.Phone.UserCenter.MemberInfoRes> localAccountList; |
| | | VerticalScrolViewLayout bodyView; |
| | | VerticalRefreshLayout bodyView; |
| | | Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj> oldLocalDoorLockUserList = new Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj>(); |
| | | #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); |
| | | var list = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockAllAcountUserlist(doorLock); |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | if (oldLocalDoorLockUserList.Count != 0) |
| | | { |
| | | 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) |
| | | { |
| | | var dataList = getDoorLockInfo.doorLockUserDetailData.UserObjList; |
| | | foreach (var doorData in dataList) |
| | | if (list.Count == 0) |
| | | { |
| | | var localDoorLockObj1 = new ZigBee.Device.DoorLock.LocaDoorLockObj() |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | UserID = doorData.UserId, |
| | | UnlockType = doorData.UserType |
| | | }; |
| | | if ((doorLock.localDoorLockUserList.ContainsKey(localDoorLockObj1.UserID)) == false) |
| | | { |
| | | doorLock.localDoorLockUserList.Add(localDoorLockObj1.UserID, localDoorLockObj1); |
| | | } |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); |
| | | }); |
| | | } |
| | | |
| | | // 读取云端门锁设备中的信息 |
| | | var localDoorLockObj = new ZigBee.Device.DoorLock.GetDoorLockData() { }; |
| | | |
| | | foreach (var curAccountObj in doorLock.localAllAccountList) |
| | | { |
| | | if (UserCenterResourse.UserInfo.AuthorityNo != 1) |
| | | { |
| | | localDoorLockObj.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); |
| | | localDoorLockObj.IsOtherAccountCtrl = true; |
| | | } |
| | | localDoorLockObj.CloudAccountId = curAccountObj.SubAccountDistributedMark; |
| | | if (doorLock.DeviceAddr != null) |
| | | { |
| | | localDoorLockObj.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint; |
| | | } |
| | | var getDoorLockInfoList = await ZigBee.Device.DoorLock.GetDoorLockInfoFromServer("DoorLock/GetDoorLockPager", localDoorLockObj); |
| | | if (getDoorLockInfoList != null) |
| | | { |
| | | foreach (var curDoorLockUser in getDoorLockInfoList.PageData) |
| | | { |
| | | if (curDoorLockUser.DoorLockLocalUserId == null || curDoorLockUser.DoorLockLocalUserId == "") |
| | | { |
| | | continue; |
| | | } |
| | | if (doorLock.localDoorLockUserList.ContainsKey(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; |
| | | } |
| | | else |
| | | { |
| | | if (curDoorLockUser.DoorLockLocalUserId != null) |
| | | { |
| | | //门锁中没有,云端有用户ID,后台删除云端这些ID |
| | | 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.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); |
| | | return; |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //数据如果在门锁上面是空的时候,数据也是没有的 |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); |
| | | }); |
| | | } |
| | | } |
| | | catch { } |
| | |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | MidFrameLayoutContent(); |
| | | TypeRefresh(); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | } |
| | |
| | | /// </summary> |
| | | public void Show() |
| | | { |
| | | doorLock.currentUserDisplayMethod = ""; |
| | | this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.UndistributedUnlockMethod)); |
| | | this.btnTitleLine.Visible = false; |
| | | EventHandler<MouseEventArgs> eHandlerBack = (sender, e) => |
| | |
| | | MidFrameLayoutContent(); |
| | | if (doorLock.localDoorLockUserList.Count == 0) |
| | | { |
| | | CommonPage.Loading.Start("Loading..."); |
| | | ReadDoorLockUserInfo(); |
| | | } |
| | | RefreshList(); |
| | | else |
| | | { |
| | | RefreshList(); |
| | | } |
| | | } |
| | | |
| | | public void MidFrameLayoutContent() |
| | |
| | | Y = Application.GetRealHeight(35), |
| | | X = Application.GetRealWidth(812 - 100), |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | Text = Language.StringByID(R.MyInternationalizationString.AllMethod), |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText, |
| | | TextSize = 12, |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnAllMethod); |
| | | // 类型区分 |
| | | if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.AllMethod)) |
| | | { |
| | | btnAllMethod.Text = Language.StringByID(R.MyInternationalizationString.AllMethod); |
| | | } |
| | | else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock)) |
| | | { |
| | | btnAllMethod.Text = Language.StringByID(R.MyInternationalizationString.PasswordUnlock); |
| | | } |
| | | else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FingerprintUnlock)) |
| | | { |
| | | btnAllMethod.Text = Language.StringByID(R.MyInternationalizationString.FingerprintUnlock); |
| | | } |
| | | else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock)) |
| | | { |
| | | btnAllMethod.Text = Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock); |
| | | } |
| | | else |
| | | { |
| | | btnAllMethod.Text = Language.StringByID(R.MyInternationalizationString.AllMethod); |
| | | } |
| | | |
| | | var btnNext = new Button() |
| | | { |
| | |
| | | }; |
| | | this.midFrameLayout.AddChidren(btnLine); |
| | | |
| | | bodyView = new VerticalScrolViewLayout() |
| | | bodyView = new VerticalRefreshLayout() |
| | | { |
| | | Y = midTopFrameLayout.Bottom, |
| | | Y = btnLine.Bottom, |
| | | Height = Application.GetRealHeight(1921 - 184 - 115 - 1), |
| | | }; |
| | | this.midFrameLayout.AddChidren(bodyView); |
| | | bodyView.BeginHeaderRefreshingAction += () => |
| | | { |
| | | bodyView.BeginHeaderRefreshing(); |
| | | ReadDoorLockUserInfo(); |
| | | bodyView.EndHeaderRefreshing(); |
| | | }; |
| | | } |
| | | |
| | | void RefreshList() |
| | | void RefreshList(int unlockMethod = -1) |
| | | { |
| | | this.midFrameLayout.RemoveAll(); |
| | | MidFrameLayoutContent(); |
| | | bodyView.RemoveAll(); |
| | | var curLocalDoorLockUserList = new Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj>(); |
| | | |
| | |
| | | int i = 0; |
| | | foreach (var curUserId in curLocalDoorLockUserList.Keys) |
| | | { |
| | | oldLocalDoorLockUserList = curLocalDoorLockUserList; |
| | | var curDoorLockUser = curLocalDoorLockUserList[curUserId]; |
| | | switch (unlockMethod) |
| | | { |
| | | case 0: |
| | | if (curDoorLockUser.UnlockType != unlockMethod) |
| | | { |
| | | continue; |
| | | } |
| | | break; |
| | | case 3: |
| | | if (curDoorLockUser.UnlockType != unlockMethod) |
| | | { |
| | | continue; |
| | | } |
| | | break; |
| | | case 15: |
| | | if (curDoorLockUser.UnlockType != unlockMethod) |
| | | { |
| | | continue; |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | var rowFrameLayout = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(127 + 23), |
| | |
| | | var d = uList.Find((value) => { return value == curDoorLockUser.UserID; }); |
| | | if (d != null) |
| | | { |
| | | RefreshList(); |
| | | TypeRefresh(); |
| | | flMain.RemoveFromParent(); |
| | | bottomFrameLayout.RemoveAll(); |
| | | } |
| | |
| | | doorLock.currentUserDisplayMethod = btnMethodText.Text; |
| | | btnAllMethod.IsSelected = true; |
| | | oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | |
| | | // 类型区分 |
| | | if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.AllMethod)) |
| | | { |
| | | RefreshList(); |
| | | } |
| | | if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock)) |
| | | { |
| | | DisplayByType(0); |
| | | } |
| | | if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FingerprintUnlock)) |
| | | { |
| | | DisplayByType(15); |
| | | } |
| | | if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock)) |
| | | { |
| | | DisplayByType(3); |
| | | } |
| | | TypeRefresh(); |
| | | } |
| | | dialog.Close(); |
| | | }; |
| | |
| | | break; |
| | | } |
| | | |
| | | if (doorLock.currentUserDisplayMethod == "" && i == 0) |
| | | { |
| | | btnAllMethod.IsSelected = true; |
| | | btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | oldbutton = btnAllMethod; |
| | | oldbuttonText = btnMethodText; |
| | | } |
| | | if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.AllMethod) && i == 0) |
| | | { |
| | | btnAllMethod.IsSelected = true; |
| | |
| | | } |
| | | } |
| | | |
| | | // 通过类型筛选显示 |
| | | void DisplayByType(int unlockMethod) |
| | | //类型区分 |
| | | void TypeRefresh() |
| | | { |
| | | bodyView.RemoveAll(); |
| | | |
| | | var curLocalDoorLockUserList = new Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj>(); |
| | | |
| | | foreach (var curUserId in doorLock.localDoorLockUserList.Keys) |
| | | if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock)) |
| | | { |
| | | var curDoorLockUser = doorLock.localDoorLockUserList[curUserId]; |
| | | if (curDoorLockUser.ConnectedAccount != "" || curDoorLockUser.UnlockType != unlockMethod) |
| | | { |
| | | continue; |
| | | } |
| | | curLocalDoorLockUserList.Add(curUserId, curDoorLockUser); |
| | | RefreshList(0); |
| | | } |
| | | |
| | | int i = 0; |
| | | foreach (var curUserId in curLocalDoorLockUserList.Keys) |
| | | else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FingerprintUnlock)) |
| | | { |
| | | var curDoorLockUser = curLocalDoorLockUserList[curUserId]; |
| | | |
| | | var rowFrameLayout = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(150), |
| | | BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite, |
| | | }; |
| | | bodyView.AddChidren(rowFrameLayout); |
| | | |
| | | var btnDistributeUnlockIconFrameLayout = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(84), |
| | | Width = Application.GetRealWidth(84), |
| | | X = Application.GetRealWidth(58), |
| | | Y = Application.GetRealHeight(43), |
| | | }; |
| | | rowFrameLayout.AddChidren(btnDistributeUnlockIconFrameLayout); |
| | | |
| | | var btnDistributeUnlockIcon = new Button() |
| | | { |
| | | Height = Application.GetRealHeight(84), |
| | | Width = Application.GetRealWidth(84), |
| | | UnSelectedImagePath = "DoorLock/DistributeUnlockIcon.png", |
| | | }; |
| | | btnDistributeUnlockIconFrameLayout.AddChidren(btnDistributeUnlockIcon); |
| | | |
| | | var btnText = new Button() |
| | | { |
| | | X = Application.GetRealWidth(176), |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(300), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, |
| | | Gravity = Gravity.CenterVertical, |
| | | }; |
| | | rowFrameLayout.AddChidren(btnText); |
| | | |
| | | var line2 = new Button() |
| | | { |
| | | Y = rowFrameLayout.Height - 1, |
| | | X = Application.GetRealWidth(58), |
| | | Width = Application.GetRealWidth(965), |
| | | Height = 1, |
| | | BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine, |
| | | }; |
| | | rowFrameLayout.AddChidren(line2); |
| | | |
| | | #region 数据处理 |
| | | int currentIndex = i; |
| | | if (currentIndex == curLocalDoorLockUserList.Keys.Count - 1) |
| | | { |
| | | line2.Visible = false; |
| | | } |
| | | |
| | | switch (curDoorLockUser.UnlockType) |
| | | { |
| | | case 0: |
| | | if (curDoorLockUser.UserName != "") |
| | | { |
| | | btnText.Text = curDoorLockUser.UserName; |
| | | } |
| | | else |
| | | { |
| | | btnText.Text = Language.StringByID(R.MyInternationalizationString.Password) + "ID" + curDoorLockUser.UserID; |
| | | } |
| | | break; |
| | | case 3: |
| | | if (curDoorLockUser.UserName != "") |
| | | { |
| | | btnText.Text = curDoorLockUser.UserName; |
| | | } |
| | | else |
| | | { |
| | | btnText.Text = Language.StringByID(R.MyInternationalizationString.IcCard) + "ID" + curDoorLockUser.UserID; |
| | | } |
| | | break; |
| | | case 15: |
| | | if (curDoorLockUser.UserName != "") |
| | | { |
| | | btnText.Text = curDoorLockUser.UserName; |
| | | } |
| | | else |
| | | { |
| | | btnText.Text = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "ID" + +curDoorLockUser.UserID; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | EventHandler<MouseEventArgs> eHandler = (sender, e) => |
| | | { |
| | | MatchUsersFrameLayout(curDoorLockUser); |
| | | }; |
| | | btnDistributeUnlockIcon.MouseUpEventHandler += eHandler; |
| | | btnDistributeUnlockIconFrameLayout.MouseUpEventHandler += eHandler; |
| | | rowFrameLayout.MouseUpEventHandler += eHandler; |
| | | btnText.MouseUpEventHandler += eHandler; |
| | | #endregion |
| | | i++; |
| | | RefreshList(15); |
| | | } |
| | | else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock)) |
| | | { |
| | | RefreshList(3); |
| | | } |
| | | else |
| | | { |
| | | RefreshList(); |
| | | } |
| | | } |
| | | #region ◆ 接口实现__________________________ |