| | |
| | | VerticalScrolViewLayout contentView; |
| | | FrameLayout userPermissionsView; |
| | | |
| | | Button btnUserName; |
| | | //Button btnUserName; |
| | | |
| | | Function device; |
| | | VideoDoorlockUser doorlockUser; |
| | | public Action delCallBackAction; |
| | | |
| | | public Action<string> updataUserNameAction; |
| | | Loading waitPage; |
| | | |
| | | |
| | | public VideoDoorlockUserManagerPage(Function function,VideoDoorlockUser user) |
| | | { |
| | |
| | | doorlockUser = user; |
| | | BackgroundColor = CSS_Color.BackgroundColor; |
| | | waitPage = new Loading(); |
| | | bodyView.AddChidren(waitPage); |
| | | waitPage.Hide(); |
| | | |
| | | } |
| | | |
| | | public override void RemoveFromParent() |
| | | { |
| | | base.RemoveFromParent(); |
| | | bodyView = null; |
| | | if (waitPage != null) |
| | | { |
| | | waitPage.RemoveFromParent(); |
| | | waitPage = null; |
| | | } |
| | | } |
| | | |
| | | public void LoadPage() |
| | | { |
| | | bodyView.AddChidren(waitPage); |
| | | new TopViewDiv(bodyView, Language.StringByID(StringId.UserManagement)).LoadTopView(); |
| | | |
| | | contentView = new VerticalScrolViewLayout() |
| | |
| | | Height = Application.GetRealHeight(667 - 70), |
| | | }; |
| | | bodyView.AddChidren(contentView); |
| | | |
| | | |
| | | |
| | | #region 用户名称 |
| | | var userNameView = new FrameLayout() |
| | |
| | | }; |
| | | userNameView.AddChidren(btnEditUserNameIcon); |
| | | |
| | | btnUserName = new Button() |
| | | var btnUserName = new Button() |
| | | { |
| | | X = Application.GetRealWidth(100), |
| | | Width = Application.GetRealWidth(230), |
| | |
| | | contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8) }); |
| | | |
| | | initOptionView(false); |
| | | |
| | | EventHandler<MouseEventArgs> eventHandler = (sender, e) => |
| | | { |
| | | Action<string> callBack = (str) => |
| | | { |
| | | if (string.IsNullOrEmpty(str)) |
| | | { |
| | | new Tip() |
| | | { |
| | | CloseTime = 1, |
| | | Text = Language.StringByID(StringId.UesrNameCannotBeEmpty), |
| | | Direction = AMPopTipDirection.None, |
| | | }.Show(bodyView); |
| | | return; |
| | | } |
| | | if (str == UserInfo.Current.userName) |
| | | { |
| | | return; |
| | | } |
| | | if (System.Text.Encoding.Unicode.GetBytes(str).Length > 20) |
| | | { |
| | | new Tip() |
| | | { |
| | | CloseTime = 1, |
| | | Text = Language.StringByID(StringId.LengthOutOfRange), |
| | | Direction = AMPopTipDirection.None, |
| | | }.Show(bodyView); |
| | | return; |
| | | } |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | Application.RunOnMainThread(() => { |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | }); |
| | | var pack = ApiUtlis.Ins.HttpRequest.EditDoorlockUserName(device.deviceId, doorlockUser.extUserId, str); |
| | | if (pack.Code == StateCode.SUCCESS) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnUserName.Text = str; |
| | | updataUserNameAction?.Invoke(str); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | //失败提示 |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (string.IsNullOrEmpty(pack.message)) |
| | | { |
| | | pack.message = Language.StringByID(StringId.OperationFailed); |
| | | } |
| | | { |
| | | var tip = new Tip() |
| | | { |
| | | MaxWidth = Application.GetRealWidth(300), |
| | | Text = $"{pack.message}({pack.Code})", |
| | | CloseTime = 3, |
| | | Direction = AMPopTipDirection.None |
| | | }; |
| | | tip.Show(MainPage.BaseView); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"update user name error : {ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | waitPage.Hide(); |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }; |
| | | var pa = new PublicAssmebly(); |
| | | pa.entryMaxLength = 20; |
| | | pa.LoadDialog_EditParater(StringId.ChangeName, "", callBack, StringId.UesrNameCannotBeEmpty, 0, new List<string>()); |
| | | }; |
| | | btnUserName.MouseUpEventHandler = eventHandler; |
| | | btnEditUserNameIcon.MouseUpEventHandler = eventHandler; |
| | | userNameView.MouseUpEventHandler = eventHandler; |
| | | |
| | | } |
| | | |
| | | void initOptionView(bool isEdit) |
| | | { |
| | | if(doorlockUser.faceCount == 0&& |
| | | doorlockUser.faceCount == 0 && |
| | | doorlockUser.fingerCount == 0 && |
| | | doorlockUser.pwdCount == 0 && |
| | | doorlockUser.cardCount == 0) |
| | | { |
| | |
| | | |
| | | |
| | | int childrenViewHeight = Application.GetRealWidth(116); |
| | | int permissionsViewHeight = Application.GetRealHeight(291 + 92); |
| | | int permissionsViewHeight = Application.GetRealHeight(291 + 92 + 100); |
| | | if (userPermissionsView!= null) |
| | | { |
| | | userPermissionsView.RemoveAll(); |
| | | |
| | | if (isEdit) |
| | | { |
| | | permissionsViewHeight = Application.GetRealHeight(391 + 50); |
| | | permissionsViewHeight = Application.GetRealHeight(391 + 50 + 100); |
| | | childrenViewHeight = Application.GetRealWidth(156); |
| | | } |
| | | userPermissionsView.Height = permissionsViewHeight; |
| | | userPermissionsView.Height = permissionsViewHeight ; |
| | | } |
| | | else |
| | | { |
| | |
| | | fingerprintView.AddChidren(btnClearFingerprints); |
| | | btnClearFingerprints.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | Application.RunOnMainThread(() => { |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | }); |
| | | var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUserFingerPassword(device.deviceId, doorlockUser.lockUserIndex); |
| | | if (pack != null && pack.Code == StateCode.SUCCESS) |
| | | { |
| | |
| | | digitalPasswordView.AddChidren(btnClearDigitalPassword); |
| | | btnClearDigitalPassword.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | Application.RunOnMainThread(() => { |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | }); |
| | | var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUserNumberPassword(device.deviceId, doorlockUser.lockUserIndex); |
| | | if (pack != null && pack.Code == StateCode.SUCCESS) |
| | | { |
| | |
| | | }; |
| | | nfcView.AddChidren(btnClearNfc); |
| | | btnClearNfc.MouseUpEventHandler = (sender, e) => { |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | Application.RunOnMainThread(() => { |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | }); |
| | | var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUserCardPassword(device.deviceId, doorlockUser.lockUserIndex); |
| | | if (pack != null && pack.Code == StateCode.SUCCESS) |
| | | { |
| | |
| | | }; |
| | | faceView.AddChidren(btnClearFace); |
| | | btnClearFace.MouseUpEventHandler = (sender, e) => { |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | Application.RunOnMainThread(() => { |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | }); |
| | | var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUserFacePassword(device.deviceId, doorlockUser.lockUserIndex); |
| | | if (pack != null && pack.Code == StateCode.SUCCESS) |
| | | { |
| | |
| | | var delUserView = new FrameLayout() |
| | | { |
| | | Y = unlockOptionView.Bottom, |
| | | Height = Application.GetRealHeight(110), |
| | | Height = Application.GetRealHeight(310), |
| | | BackgroundColor = CSS_Color.BackgroundColor, |
| | | }; |
| | | userPermissionsView.AddChidren(delUserView); |
| | |
| | | { |
| | | new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.DeleteDoorlockUserTip, () => |
| | | { |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | Application.RunOnMainThread(() => { |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | }); |
| | | var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUser(device.deviceId, doorlockUser.lockUserIndex); |
| | | if (pack != null && pack.Code == StateCode.SUCCESS) |
| | | { |
| | |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (string.IsNullOrEmpty(pack.message)) { |
| | | pack.message = Language.StringByID(StringId.OperationFailed); |
| | | } |
| | | //失败提示 |
| | | var tip = new Tip() |
| | | { |
| | |
| | | /// </summary> |
| | | void LoadEvent_EditUserName() |
| | | { |
| | | EventHandler<MouseEventArgs> eventHandler = (sender, e) => |
| | | { |
| | | Action<string> callBack = (str) => |
| | | { |
| | | if (string.IsNullOrEmpty(str)) |
| | | { |
| | | new Tip() |
| | | { |
| | | CloseTime = 1, |
| | | Text = Language.StringByID(StringId.UesrNameCannotBeEmpty), |
| | | Direction = AMPopTipDirection.None, |
| | | }.Show(bodyView); |
| | | return; |
| | | } |
| | | if (str == UserInfo.Current.userName) |
| | | { |
| | | return; |
| | | } |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | var resultObj = ApiUtlis.Ins.HttpRequest.EditDoorlockUserName(device.deviceId, doorlockUser.extUserId,str); |
| | | if (resultObj.Code == StateCode.SUCCESS) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnUserName.Text = str; |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | //失败提示 |
| | | IMessageCommon.Current.ShowErrorInfoAlter(resultObj.Code); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"update user name error : {ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | waitPage.Hide(); |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }; |
| | | new PublicAssmebly().LoadDialog_EditParater(StringId.ChangeName, doorlockUser.lockUserName, callBack, StringId.UesrNameCannotBeEmpty, 0, new System.Collections.Generic.List<string>()); |
| | | }; |
| | | btnUserName.MouseUpEventHandler = eventHandler; |
| | | //btnUserName.MouseUpEventHandler = eventHandler; |
| | | } |
| | | |
| | | |