| | |
| | | using ZigBee.Device; |
| | | namespace Shared.Phone.UserCenter.DoorLock |
| | | { |
| | | public class UndistributeDoorlockUserPage : DoorLockCommonLayout, ZigBee.Common.IStatus |
| | | public class UndistributeDoorlockUserPage : DoorLockCommonLayout |
| | | { |
| | | /// <summary> |
| | | /// 构造函数 |
| | |
| | | BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor; |
| | | } |
| | | |
| | | #region ◆ 变量申明__________________________ |
| | | #region 变量申明 |
| | | /// <summary> |
| | | /// 当前门锁 |
| | | /// </summary> |
| | | ZigBee.Device.DoorLock doorLock; |
| | | /// <summary> |
| | | /// 底部白色布局 |
| | | /// </summary> |
| | | FrameLayout bottomFrameLayout; |
| | | /// <summary> |
| | | /// 当前类型 |
| | | /// </summary> |
| | | string currentType = string.Empty; |
| | | /// <summary> |
| | | /// 本地账户列表 |
| | | /// </summary> |
| | | List<Shared.Phone.UserCenter.MemberInfoRes> localAccountList; |
| | | VerticalScrolViewLayout bodyView; |
| | | /// <summary> |
| | | /// 滑动布局View |
| | | /// </summary> |
| | | VerticalRefreshLayout bodyView; |
| | | /// <summary> |
| | | /// 保存之前搜索到本地门锁用户列表 |
| | | /// </summary> |
| | | Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj> oldLocalDoorLockUserList = new Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj>(); |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 获取所有账户的门锁用户列表 |
| | | /// </summary> |
| | | 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(); |
| | | bodyView.EndHeaderRefreshing(); |
| | | }); |
| | | } |
| | | }); |
| | |
| | | /// </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(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 中部布局 |
| | | /// </summary> |
| | | public void MidFrameLayoutContent() |
| | | { |
| | | var midTopFrameLayout = new FrameLayout() |
| | |
| | | Y = Application.GetRealHeight(35), |
| | | X = Application.GetRealWidth(812 - 100), |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | Text = Language.StringByID(R.MyInternationalizationString.AllMethod), |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText, |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, |
| | | TextSize = 12, |
| | | IsBold = true, |
| | | }; |
| | | 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() |
| | | { |
| | |
| | | SelectedImagePath = "DoorLock/UnLockSideslipIcon.png", |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnNext); |
| | | btnNext.MouseUpEventHandler += (sender, e) => |
| | | EventHandler<MouseEventArgs> handerSideLip = (sender, e) => |
| | | { |
| | | SideslipFramelayout(); |
| | | }; |
| | | |
| | | btnNext.MouseUpEventHandler += handerSideLip; |
| | | btnAllMethod.MouseUpEventHandler += handerSideLip; |
| | | var btnLine = new Button |
| | | { |
| | | Y = midTopFrameLayout.Bottom, |
| | |
| | | }; |
| | | 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(); |
| | | }; |
| | | } |
| | | |
| | | void RefreshList() |
| | | /// <summary> |
| | | /// 刷新列表 |
| | | /// </summary> |
| | | void RefreshList(int unlockMethod = -1) |
| | | { |
| | | this.midFrameLayout.RemoveAll(); |
| | | MidFrameLayoutContent(); |
| | | bodyView.RemoveAll(); |
| | | var curLocalDoorLockUserList = new Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj>(); |
| | | |
| | | foreach (var curUserId in doorLock.localDoorLockUserList.Keys) |
| | | { |
| | | var curDoorLockUser = doorLock.localDoorLockUserList[curUserId]; |
| | | if (curDoorLockUser.ConnectedAccount != "") |
| | | if (!string.IsNullOrEmpty(curDoorLockUser.ConnectedAccount)) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | 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), |
| | |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, |
| | | Gravity = Gravity.CenterVertical, |
| | | TextSize = 15, |
| | | }; |
| | | rowFrameLayout.AddChidren(btnText); |
| | | |
| | | var line2 = new Button() |
| | | { |
| | | Y = rowFrameLayout.Height - 1, |
| | | X = Application.GetRealWidth(58), |
| | | Width = Application.GetRealWidth(965), |
| | | X = Application.GetRealWidth(176), |
| | | Width = Application.GetRealWidth(847), |
| | | Height = 1, |
| | | BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine, |
| | | }; |
| | |
| | | switch (curDoorLockUser.UnlockType) |
| | | { |
| | | case 0: |
| | | if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) |
| | | if (!string.IsNullOrEmpty(curDoorLockUser.UserName)) |
| | | { |
| | | btnText.Text = curDoorLockUser.UserName; |
| | | } |
| | |
| | | } |
| | | break; |
| | | case 3: |
| | | if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) |
| | | if (!string.IsNullOrEmpty(curDoorLockUser.UserName)) |
| | | { |
| | | btnText.Text = curDoorLockUser.UserName; |
| | | } |
| | |
| | | } |
| | | break; |
| | | case 15: |
| | | if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) |
| | | if (!string.IsNullOrEmpty(curDoorLockUser.UserName)) |
| | | { |
| | | btnText.Text = curDoorLockUser.UserName; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | //本地账户 |
| | | /// <summary> |
| | | /// 分配本地账户 |
| | | /// </summary> |
| | | void MatchUsersFrameLayout(ZigBee.Device.DoorLock.LocaDoorLockObj curDoorLockUser) |
| | | { |
| | | #region UI |
| | | FrameLayout flMain = new FrameLayout { BackgroundColor = 0x0f000000 }; |
| | | this.midFrameLayout.AddChidren(flMain); |
| | | this.AddChidren(flMain); |
| | | flMain.MouseUpEventHandler += (sender11, e11) => |
| | | { |
| | | flMain.RemoveFromParent(); |
| | |
| | | bottomFrameLayout = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(100), |
| | | Y = Application.GetRealHeight(930), |
| | | Radius = 17, |
| | | Y = Application.GetRealHeight(1253), |
| | | Radius = (uint)Application.GetRealHeight(100 / 2), |
| | | BackgroundColor = ZigbeeColor.Current.XMWhite, |
| | | }; |
| | | flMain.AddChidren(bottomFrameLayout); |
| | | |
| | | var bottomFrameLayout1 = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(806 - 50), |
| | | Y = Application.GetRealHeight(930 + 48), |
| | | Height = Application.GetRealHeight(668 - 60), |
| | | Y = Application.GetRealHeight(1253 + 58), |
| | | BackgroundColor = ZigbeeColor.Current.XMWhite, |
| | | }; |
| | | flMain.AddChidren(bottomFrameLayout1); |
| | | |
| | | var bottomFrameLayout2 = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(806), |
| | | Y = Application.GetRealHeight(930), |
| | | Height = Application.GetRealHeight(668), |
| | | Y = Application.GetRealHeight(1253), |
| | | }; |
| | | flMain.AddChidren(bottomFrameLayout2); |
| | | |
| | |
| | | |
| | | var btnMatchUser = new Button |
| | | { |
| | | X = Application.GetRealWidth(446), |
| | | X = Application.GetRealWidth(159), |
| | | Y = Application.GetRealHeight(35), |
| | | Height = Application.GetRealHeight(63), |
| | | Width = Application.GetRealWidth(284), |
| | | Text = Language.StringByID(R.MyInternationalizationString.MatchPerson), |
| | | Width = Application.GetRealWidth(762), |
| | | Text = Language.StringByID(R.MyInternationalizationString.MatchUser), |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, |
| | | TextSize = 16, |
| | | TextAlignment = TextAlignment.Center, |
| | | }; |
| | | matchUsersFrameLayout.AddChidren(btnMatchUser); |
| | | |
| | | var btnFinish = new Button |
| | | { |
| | | X = Application.GetRealWidth(919), |
| | | X = Application.GetRealWidth(921), |
| | | Y = Application.GetRealHeight(40), |
| | | Height = Application.GetRealHeight(58), |
| | | Width = Application.GetRealWidth(101), |
| | | Width = Application.GetRealWidth(101 + 81), |
| | | Text = Language.StringByID(R.MyInternationalizationString.Complete), |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMOrange, |
| | | TextSize = 14, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | matchUsersFrameLayout.AddChidren(btnFinish); |
| | | |
| | | var btnTopLine = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(5), |
| | | Height = 1, |
| | | Y = Application.GetRealHeight(138), |
| | | BackgroundColor = Shared.Common.ZigbeeColor.Current.XMGray3, |
| | | BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine, |
| | | }; |
| | | bottomFrameLayout2.AddChidren(btnTopLine); |
| | | |
| | |
| | | |
| | | var btnChoose = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(60), |
| | | Height = Application.GetRealHeight(60), |
| | | Width = Application.GetMinRealAverage(60), |
| | | Height = Application.GetMinRealAverage(60), |
| | | X = Application.GetRealWidth(861 + 81), |
| | | Y = Application.GetRealHeight(35), |
| | | SelectedImagePath = "DoorLock/SelectedIcon.png", |
| | |
| | | btnLine.Visible = false; |
| | | } |
| | | |
| | | if (currentAccount.UserName != "" && currentAccount.UserName != null) |
| | | if (!string.IsNullOrEmpty(currentAccount.UserName)) |
| | | { |
| | | btnUserName.Text = currentAccount.UserName; |
| | | } |
| | |
| | | { |
| | | if (doorLock.IsFreezeAccount[currentAccount.SubAccountDistributedMark] == true) |
| | | { |
| | | |
| | | new Tip() { MaxWidth = 150, Text = btnUserName.Text + Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | new Tip() { MaxWidth = 150, Text = btnUserName.Text + Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); |
| | | }); |
| | | return; |
| | | } |
| | | |
| | |
| | | bottomFrameLayout.RemoveAll(); |
| | | }; |
| | | |
| | | btnFinish.MouseUpEventHandler += async (sender, e) => |
| | | { |
| | | if (curAccountId == "") |
| | | { |
| | | flMain.RemoveFromParent(); |
| | | bottomFrameLayout.RemoveAll(); |
| | | } |
| | | else |
| | | { |
| | | var addLockInfo = new ZigBee.Device.DoorLock.AddDoorLockData(); |
| | | if (UserCenterResourse.UserInfo.AuthorityNo != 1) |
| | | { |
| | | addLockInfo.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); |
| | | addLockInfo.IsOtherAccountCtrl = true; |
| | | } |
| | | addLockInfo.CloudAccountId = curAccountId; |
| | | if (doorLock.DeviceAddr != null) |
| | | { |
| | | addLockInfo.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint; |
| | | } |
| | | addLockInfo.OpenLockMode = curDoorLockUser.UnlockType; |
| | | addLockInfo.DoorLockLocalUserId = curDoorLockUser.UserID.ToString(); |
| | | |
| | | switch (curDoorLockUser.UnlockType) |
| | | { |
| | | case 0: |
| | | if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) |
| | | { |
| | | addLockInfo.UserIdRemarks = curDoorLockUser.UserName; |
| | | } |
| | | else |
| | | { |
| | | addLockInfo.UserIdRemarks = Language.StringByID(R.MyInternationalizationString.Password) + "ID" + curDoorLockUser.UserID; |
| | | } |
| | | break; |
| | | case 3: |
| | | if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) |
| | | { |
| | | addLockInfo.UserIdRemarks = curDoorLockUser.UserName; |
| | | } |
| | | else |
| | | { |
| | | addLockInfo.UserIdRemarks = Language.StringByID(R.MyInternationalizationString.IcCard) + "ID" + curDoorLockUser.UserID; |
| | | } |
| | | break; |
| | | case 15: |
| | | if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null) |
| | | { |
| | | addLockInfo.UserIdRemarks = curDoorLockUser.UserName; |
| | | } |
| | | else |
| | | { |
| | | addLockInfo.UserIdRemarks = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "ID" + +curDoorLockUser.UserID; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | addLockInfo.EntryTime = curDoorLockUser.EntryTime; |
| | | var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/AddDoorLock", addLockInfo); |
| | | if (result != null) |
| | | { |
| | | if (result.StateCode == "Success") |
| | | { |
| | | //存门锁信息 |
| | | var resultList = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetCloudLocalDoorLocklist(doorLock, curAccountId); |
| | | var uList = new List<int> { }; |
| | | if (resultList != null) |
| | | { |
| | | foreach (var a in resultList.Keys) |
| | | { |
| | | uList.Add(a); |
| | | } |
| | | } |
| | | var d = uList.Find((value) => { return value == curDoorLockUser.UserID; }); |
| | | if (d != null) |
| | | { |
| | | RefreshList(); |
| | | flMain.RemoveFromParent(); |
| | | bottomFrameLayout.RemoveAll(); |
| | | } |
| | | else |
| | | { |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance); |
| | | flMain.RemoveFromParent(); |
| | | bottomFrameLayout.RemoveAll(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish); |
| | | flMain.RemoveFromParent(); |
| | | bottomFrameLayout.RemoveAll(); |
| | | } |
| | | } |
| | | }; |
| | | btnFinish.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | try |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | CommonPage.Loading.Start(""); |
| | | }); |
| | | if (curAccountId == "") |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | flMain.RemoveFromParent(); |
| | | bottomFrameLayout.RemoveAll(); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | var addLockInfo = new ZigBee.Device.DoorLock.AddDoorLockData(); |
| | | if (UserCenterResourse.UserInfo.AuthorityNo != 1) |
| | | { |
| | | addLockInfo.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); |
| | | addLockInfo.IsOtherAccountCtrl = true; |
| | | } |
| | | addLockInfo.CloudAccountId = curAccountId; |
| | | if (doorLock.DeviceAddr != null) |
| | | { |
| | | addLockInfo.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint; |
| | | } |
| | | addLockInfo.OpenLockMode = curDoorLockUser.UnlockType; |
| | | addLockInfo.DoorLockLocalUserId = curDoorLockUser.UserID.ToString(); |
| | | switch (curDoorLockUser.UnlockType) |
| | | { |
| | | case 0: |
| | | if (!string.IsNullOrEmpty(curDoorLockUser.UserName)) |
| | | { |
| | | addLockInfo.UserIdRemarks = curDoorLockUser.UserName; |
| | | } |
| | | else |
| | | { |
| | | addLockInfo.UserIdRemarks = Language.StringByID(R.MyInternationalizationString.Password) + "ID" + curDoorLockUser.UserID; |
| | | } |
| | | break; |
| | | case 3: |
| | | if (!string.IsNullOrEmpty(curDoorLockUser.UserName)) |
| | | { |
| | | addLockInfo.UserIdRemarks = curDoorLockUser.UserName; |
| | | } |
| | | else |
| | | { |
| | | addLockInfo.UserIdRemarks = Language.StringByID(R.MyInternationalizationString.IcCard) + "ID" + curDoorLockUser.UserID; |
| | | } |
| | | break; |
| | | case 15: |
| | | if (!string.IsNullOrEmpty(curDoorLockUser.UserName)) |
| | | { |
| | | addLockInfo.UserIdRemarks = curDoorLockUser.UserName; |
| | | } |
| | | else |
| | | { |
| | | addLockInfo.UserIdRemarks = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "ID" + +curDoorLockUser.UserID; |
| | | } |
| | | break; |
| | | } |
| | | addLockInfo.EntryTime = curDoorLockUser.EntryTime; |
| | | var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/AddDoorLock", addLockInfo); |
| | | if (result != null) |
| | | { |
| | | if (result.StateCode == "Success") |
| | | { |
| | | //存门锁信息 |
| | | var resultList = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetCloudLocalDoorLocklist(doorLock, curAccountId); |
| | | var uList = new List<int> { }; |
| | | if (resultList != null) |
| | | { |
| | | foreach (var a in resultList.Keys) |
| | | { |
| | | uList.Add(a); |
| | | } |
| | | } |
| | | var d = uList.Find((value) => { return value == curDoorLockUser.UserID; }); |
| | | if (d != null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.DistributeSuccess), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); |
| | | TypeRefresh(); |
| | | CommonPage.Loading.Hide(); |
| | | flMain.RemoveFromParent(); |
| | | bottomFrameLayout.RemoveAll(); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance); |
| | | }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance); |
| | | }); |
| | | return; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(btnFinish); |
| | | }); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | catch { } |
| | | }); |
| | | }; |
| | | } |
| | | |
| | | // 侧边导航栏 |
| | | /// <summary> |
| | | /// 侧边导航栏搜索 |
| | | /// </summary> |
| | | void SideslipFramelayout() |
| | | { |
| | | #region sidelipFrameLayout UI |
| | | var dialog = new Dialog |
| | | { |
| | | }; |
| | |
| | | Y = Application.GetRealHeight(28), |
| | | }; |
| | | sidelipFrameLayout.AddChidren(sidelipVerticalScrolViewLayout); |
| | | #endregion |
| | | |
| | | Button oldbutton = null; |
| | | Button oldbuttonText = null; |
| | | for (var i = 0; i < 4; i++) |
| | | { |
| | | #region rowFrameLayout UI |
| | | var rowFrameLayout = new RowLayout() |
| | | { |
| | | Height = Application.GetRealHeight(150), |
| | | LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine, |
| | | X = Application.GetRealWidth(81), |
| | | }; |
| | | sidelipVerticalScrolViewLayout.AddChidren(rowFrameLayout); |
| | | |
| | |
| | | { |
| | | Width = Application.GetRealWidth(81), |
| | | Height = Application.GetRealHeight(81), |
| | | X = Application.GetRealWidth(81), |
| | | Y = Application.GetRealHeight(55), |
| | | Y = Application.GetRealHeight(35), |
| | | }; |
| | | rowFrameLayout.AddChidren(btnAllMethod); |
| | | |
| | |
| | | { |
| | | Width = Application.GetRealWidth(311), |
| | | Height = Application.GetRealHeight(58), |
| | | X = Application.GetRealWidth(173), |
| | | Y = Application.GetRealHeight(69), |
| | | X = Application.GetRealWidth(92), |
| | | Y = Application.GetRealHeight(49), |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, |
| | | TextSize = 14, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | rowFrameLayout.AddChidren(btnMethodText); |
| | | #endregion |
| | | |
| | | #region 数据处理 |
| | | EventHandler<MouseEventArgs> hander = (sender, e) => |
| | | { |
| | | if (!btnAllMethod.IsSelected) |
| | |
| | | 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); |
| | | } |
| | | oldbuttonText.IsBold = true; |
| | | TypeRefresh(); |
| | | } |
| | | dialog.Close(); |
| | | }; |
| | | rowFrameLayout.MouseUpEventHandler += hander; |
| | | btnAllMethod.MouseUpEventHandler += hander; |
| | | btnMethodText.MouseUpEventHandler += hander; |
| | | DisplayAllUnlockMethod(i, btnAllMethod, btnMethodText); |
| | | |
| | | switch (i) |
| | | if (string.IsNullOrEmpty(doorLock.currentUserDisplayMethod) && i == 0) |
| | | { |
| | | case 0: |
| | | btnAllMethod.UnSelectedImagePath = "DoorLock/AllMethod.png"; |
| | | btnAllMethod.SelectedImagePath = "DoorLock/AllMethodOn.png"; |
| | | btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.AllMethod); |
| | | break; |
| | | case 1: |
| | | btnAllMethod.UnSelectedImagePath = "DoorLock/Password.png"; |
| | | btnAllMethod.SelectedImagePath = "DoorLock/PasswordOn.png"; |
| | | btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.PasswordUnlock); |
| | | break; |
| | | case 2: |
| | | btnAllMethod.UnSelectedImagePath = "DoorLock/Fingerprint.png"; |
| | | btnAllMethod.SelectedImagePath = "DoorLock/FingerprintOn.png"; |
| | | btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.FingerprintUnlock); |
| | | break; |
| | | case 3: |
| | | btnAllMethod.UnSelectedImagePath = "DoorLock/proximityCard.png"; |
| | | btnAllMethod.SelectedImagePath = "DoorLock/proximityCardOn.png"; |
| | | btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock); |
| | | break; |
| | | CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText); |
| | | } |
| | | |
| | | if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.AllMethod) && i == 0) |
| | | { |
| | | btnAllMethod.IsSelected = true; |
| | | btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | oldbutton = btnAllMethod; |
| | | oldbuttonText = btnMethodText; |
| | | CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText); |
| | | } |
| | | if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock) && i == 1) |
| | | { |
| | | btnAllMethod.IsSelected = true; |
| | | btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | oldbutton = btnAllMethod; |
| | | oldbuttonText = btnMethodText; |
| | | CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText); |
| | | } |
| | | if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FingerprintUnlock) && i == 2) |
| | | { |
| | | btnAllMethod.IsSelected = true; |
| | | btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | oldbutton = btnAllMethod; |
| | | oldbuttonText = btnMethodText; |
| | | CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText); |
| | | } |
| | | if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock) && i == 3) |
| | | { |
| | | btnAllMethod.IsSelected = true; |
| | | btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | oldbutton = btnAllMethod; |
| | | oldbuttonText = btnMethodText; |
| | | CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 通过类型筛选显示 |
| | | void DisplayByType(int unlockMethod) |
| | | { |
| | | bodyView.RemoveAll(); |
| | | |
| | | var curLocalDoorLockUserList = new Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj>(); |
| | | |
| | | foreach (var curUserId in doorLock.localDoorLockUserList.Keys) |
| | | { |
| | | var curDoorLockUser = doorLock.localDoorLockUserList[curUserId]; |
| | | if (curDoorLockUser.ConnectedAccount != "" || curDoorLockUser.UnlockType != unlockMethod) |
| | | { |
| | | continue; |
| | | } |
| | | curLocalDoorLockUserList.Add(curUserId, curDoorLockUser); |
| | | } |
| | | |
| | | int i = 0; |
| | | foreach (var curUserId in curLocalDoorLockUserList.Keys) |
| | | { |
| | | 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++; |
| | | } |
| | | } |
| | | #region ◆ 接口实现__________________________ |
| | | /// <summary> |
| | | /// 处理变化事件 --将弃用 改用DeviceInfoChange() |
| | | /// </summary> |
| | | /// <returns>The changed.</returns> |
| | | /// <param name="common">Common.</param> |
| | | public void Changed(CommonDevice common) |
| | | { |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 处理变化事件 |
| | | /// 类型区分 |
| | | /// </summary> |
| | | /// <param name="common"></param> |
| | | /// <param name="typeTag"></param> |
| | | public void DeviceInfoChange(CommonDevice common, string typeTag) |
| | | void TypeRefresh() |
| | | { |
| | | if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock)) |
| | | { |
| | | RefreshList(0); |
| | | } |
| | | else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FingerprintUnlock)) |
| | | { |
| | | RefreshList(15); |
| | | } |
| | | else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock)) |
| | | { |
| | | RefreshList(3); |
| | | } |
| | | else |
| | | { |
| | | RefreshList(); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// Changeds the IL ogic status. |
| | | /// </summary> |
| | | /// <param name="logic">Logic.</param> |
| | | public void ChangedILogicStatus(ZigBee.Device.Logic logic) |
| | | { |
| | | } |
| | | /// <summary> |
| | | /// Changeds the IS cene status. |
| | | /// </summary> |
| | | /// <param name="scene">Scene.</param> |
| | | public void ChangedISceneStatus(Scene scene) |
| | | { |
| | | } |
| | | #endregion |
| | | } |
| | | } |