| | |
| | | /// <param name="common">Common.</param> |
| | | public void Changed(CommonDevice common) |
| | | { |
| | | //if (common.Type != ZigBee.Device.DeviceType.OnOffSwitch) |
| | | //{ |
| | | // return; |
| | | //} |
| | | |
| | | Shared.Application.RunOnMainThread(() => |
| | | { |
| | | //var dev = common as Panel; |
| | | }); |
| | | } |
| | | |
| | | |
| | | /// 构造函数 |
| | | /// </summary> |
| | | /// <param name="doorLock"></param> |
| | | public UserManagement(ZigBee.Device.DoorLock doorLock) |
| | | { |
| | | this.doorLock = doorLock; |
| | | localAllAccountListTemp = doorLock.localAllAccountList; |
| | | localDoorLockUserListTemp = doorLock.localDoorLockUserList; |
| | | } |
| | | |
| | | #region ◆ 变量申明__________________________ |
| | | ZigBee.Device.DoorLock doorLock; |
| | | List<Shared.Phone.UserCenter.MemberInfoRes> localAccountList = new List<Shared.Phone.UserCenter.MemberInfoRes> { }; |
| | | VerticalRefreshLayout midVerticalScrolViewLayout; |
| | | public List<Shared.Phone.UserCenter.MemberInfoRes> localAllAccountListTemp = new List<Shared.Phone.UserCenter.MemberInfoRes> { }; |
| | | public Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj> localDoorLockUserListTemp = new Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj>(); |
| | | |
| | | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 数据刷新 |
| | | /// </summary> |
| | | void ReadAccountDoorLockInfoList() |
| | | { |
| | | System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | try |
| | | { |
| | | var localAccountListTemp = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.LocalAccountList(); |
| | | if (localAccountListTemp != null) |
| | | { |
| | | doorLock.localAllAccountList.Clear(); |
| | | doorLock.localAllAccountList = localAccountListTemp; |
| | | localAllAccountListTemp = doorLock.localAllAccountList; |
| | | |
| | | //初始化权限信息 |
| | | foreach (var sub in localAccountListTemp) |
| | | { |
| | | if (doorLock.IsFreezeAccount.ContainsKey(sub.SubAccountDistributedMark) == false) |
| | | { |
| | | doorLock.IsFreezeAccount.Add(sub.SubAccountDistributedMark, false); |
| | | } |
| | | if (doorLock.HasRemoteUnlockAccess.ContainsKey(sub.SubAccountDistributedMark) == false) |
| | | { |
| | | doorLock.HasRemoteUnlockAccess.Add(sub.SubAccountDistributedMark, false); |
| | | } |
| | | if (doorLock.IsFailedToGetDoorLockInfo.ContainsKey(sub.SubAccountDistributedMark) == false) |
| | | { |
| | | doorLock.IsFailedToGetDoorLockInfo.Add(sub.SubAccountDistributedMark, false); |
| | | } |
| | | } |
| | | |
| | | //获取本地门锁列表 |
| | | if (localDoorLockUserListTemp.Count == 0) |
| | | { |
| | | var list = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockAllAcountUserlist(doorLock); |
| | | localDoorLockUserListTemp = doorLock.localDoorLockUserList; |
| | | } |
| | | doorLock.ReSave(); |
| | | } |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance); |
| | | }); |
| | | } |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | MidFrameLayoutContent(); |
| | | CommonPage.Loading.Hide(); |
| | | midVerticalScrolViewLayout.EndHeaderRefreshing(); |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 显示界面 |
| | | /// </summary> |
| | | public void Show() |
| | | { |
| | | this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.UserManagement)); |
| | |
| | | |
| | | var btnAddFrameLayout = new FrameLayout |
| | | { |
| | | X = Application.GetRealWidth(829), |
| | | X = Application.GetRealWidth(829 - 116), |
| | | Height = Application.GetRealHeight(72), |
| | | Width = Application.GetRealWidth(190), |
| | | }; |
| | |
| | | var btnUndistributeText = new Button |
| | | { |
| | | Height = Application.GetRealHeight(72), |
| | | Width = Application.GetRealWidth(121), |
| | | Width = Application.GetRealWidth(150), |
| | | TextID = R.MyInternationalizationString.Undistributed, |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText, |
| | | X = btnUndistributeIcon.Right, |
| | | IsBold = true, |
| | | TextSize = 13, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | btnAddFrameLayout.AddChidren(btnUndistributeText); |
| | | |
| | | if (UserCenterResourse.UserInfo.AuthorityNo != 1) |
| | | { |
| | | btnUndistributeIcon.Width = 0; |
| | | btnUndistributeText.Width = 0; |
| | | } |
| | | EventHandler<MouseEventArgs> eHandler = (sender, e) => |
| | | { |
| | | var undistributeDoorlockUserPage = new Shared.Phone.UserCenter.DoorLock.UndistributeDoorlockUserPage(doorLock, localAccountList); |
| | | var undistributeDoorlockUserPage = new Shared.Phone.UserCenter.DoorLock.UndistributeDoorlockUserPage(doorLock, doorLock.localAllAccountList); |
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(undistributeDoorlockUserPage); |
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; |
| | | undistributeDoorlockUserPage.Show(); |
| | |
| | | btnAddFrameLayout.MouseDownEventHandler += eHandler; |
| | | btnUndistributeText.MouseDownEventHandler += eHandler; |
| | | btnUndistributeIcon.MouseDownEventHandler += eHandler; |
| | | |
| | | MidFrameLayoutContent(); |
| | | } |
| | | |
| | | async void MidFrameLayoutContent() |
| | | { |
| | | var SubAccounList = await ZigBee.Device.DoorLock.GetSubAccountByDistributedMark(); |
| | | |
| | | var masterAccount = new Shared.Phone.UserCenter.MemberInfoRes(); |
| | | masterAccount.Account = Shared.Common.Config.Instance.Account; |
| | | masterAccount.AccountType = Shared.Common.Config.Instance.AccountType; |
| | | masterAccount.SubAccountDistributedMark = Shared.Common.Config.Instance.Guid; |
| | | masterAccount.UserName = UserCenterResourse.UserInfo.UserName; |
| | | localAccountList.Add(masterAccount); |
| | | localAccountList.AddRange(SubAccounList); |
| | | |
| | | var bodyView = new VerticalScrolViewLayout() |
| | | midVerticalScrolViewLayout = new VerticalRefreshLayout() |
| | | { |
| | | }; |
| | | this.midFrameLayout.AddChidren(bodyView); |
| | | this.midFrameLayout.AddChidren(midVerticalScrolViewLayout); |
| | | |
| | | doorLock.localAllAccountList = localAccountList; |
| | | for (int i = 0; i < localAccountList.Count; i++) |
| | | if (localAllAccountListTemp.Count == 0) |
| | | { |
| | | var currentAccount = localAccountList[i]; |
| | | CommonPage.Loading.Start("Loading..."); |
| | | ReadAccountDoorLockInfoList(); |
| | | } |
| | | else |
| | | { |
| | | MidFrameLayoutContent(); |
| | | } |
| | | |
| | | midVerticalScrolViewLayout.BeginHeaderRefreshingAction += () => |
| | | { |
| | | midVerticalScrolViewLayout.BeginHeaderRefreshing(); |
| | | ReadAccountDoorLockInfoList(); |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 中部布局显示 |
| | | /// </summary> |
| | | async void MidFrameLayoutContent() |
| | | { |
| | | midVerticalScrolViewLayout.RemoveAll(); |
| | | for (int i = 0; i < doorLock.localAllAccountList.Count; i++) |
| | | { |
| | | var currentAccount = doorLock.localAllAccountList[i]; |
| | | var RowView = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(161), |
| | | BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTopFrameLayout, |
| | | Height = Application.GetRealHeight(127 + 23), |
| | | BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite, |
| | | }; |
| | | bodyView.AddChidren(RowView); |
| | | midVerticalScrolViewLayout.AddChidren(RowView); |
| | | |
| | | var btnText = new Button() |
| | | { |
| | | X = Application.GetRealWidth(58), |
| | | Width = Application.GetRealWidth(300), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText, |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, |
| | | Gravity = Gravity.CenterVertical, |
| | | TextSize = 14, |
| | | }; |
| | |
| | | }; |
| | | RowView.AddChidren(line2); |
| | | int currentIndex = i; |
| | | if (currentIndex == localAccountList.Count - 1) |
| | | if (currentIndex == doorLock.localAllAccountList.Count - 1) |
| | | { |
| | | line2.Visible = false; |
| | | } |
| | | |
| | | if (currentAccount.UserName != null) |
| | | if (!string.IsNullOrEmpty(currentAccount.UserName)) |
| | | { |
| | | btnText.Text = currentAccount.UserName; |
| | | } |
| | |
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(masterManagementPage); |
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; |
| | | masterManagementPage.Show(); |
| | | } |
| | | else if (currentIndex == 3) |
| | | { |
| | | var userDoorLockPage = new UserDoorLockPage(doorLock, currentAccount); |
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(userDoorLockPage); |
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; |
| | | userDoorLockPage.Show(); |
| | | } |
| | | else |
| | | { |