public void OnDeleteUser(UserRowData userRowData) { DeleteConfirmation.Message = string.Format(SR.AdminUser_DeleteDialog_AreYouSure, userRowData.DisplayName, userRowData.UserName); DeleteConfirmation.MessageType = MessageBox.MessageTypeEnum.YESNO; DeleteConfirmation.Data = userRowData; DeleteConfirmation.Show(); }
private void SaveData() { if (User == null) { User = new UserRowData(); } if (EditMode) { User.Enabled = UserEnabledCheckbox.Checked; } else { User.UserName = UserLoginId.Text; User.Enabled = true; } User.DisplayName = DisplayName.Text; User.EmailAddress = EmailAddressId.Text; User.UserGroups.Clear(); foreach (ListItem item in UserGroupListBox.Items) { if (item.Selected) { User.UserGroups.Add(new UserGroup( item.Value, item.Text)); } } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { using (var service = new AuthorityManagement()) { IList <AuthorityGroupSummary> list = service.ListAllAuthorityGroups(); IList <ListItem> items = CollectionUtils.Map( list, delegate(AuthorityGroupSummary summary) { return(new ListItem(summary.Name, summary.AuthorityGroupRef.Serialize())); } ); UserGroupListBox.Items.AddRange(CollectionUtils.ToArray(items)); }; } else { if (ViewState["EditMode"] != null) { _editMode = (bool)ViewState["EditMode"]; } if (ViewState["EditedUser"] != null) { _user = ViewState["EditedUser"] as UserRowData; } } }
protected void ResetPasswordButton_Click(object sender, ImageClickEventArgs e) { UserRowData user = UserGridPanel.SelectedUser; if (user != null) { ((Default)Page).OnResetPassword(user); } }
protected void DeleteUserButton_Click(object sender, ImageClickEventArgs e) { UserRowData user = UserGridPanel.SelectedUser; if (user != null) { ((Default)Page).OnDeleteUser(user); } }
private static void CustomizeUserGroupsColumn(GridViewRowEventArgs e) { TextBox textBox = ((TextBox)e.Row.FindControl("UserGroupTextBox")); UserRowData rowData = e.Row.DataItem as UserRowData; string groupList = string.Empty; foreach (UserGroup userGroup in rowData.UserGroups) { groupList += userGroup.Name + "\n"; } textBox.Text = groupList; }
public void OnResetPassword(UserRowData userRowData) { if (_controller.ResetPassword(userRowData)) { PasswordResetConfirmation.Message = string.Format(SR.AdminUser_PasswordReset, userRowData.UserName); } else { PasswordResetConfirmation.Message = ErrorMessages.PasswordResetFailed; } PasswordResetConfirmation.Title = Titles.AdminUser_PasswordResetDialogTitle; PasswordResetConfirmation.MessageType = MessageBox.MessageTypeEnum.INFORMATION; PasswordResetConfirmation.Show(); }
protected void UserGridView_SelectedIndexChanged(object sender, EventArgs e) { UserRowData userRow = SelectedUser; if (userRow != null) { if (OnUserSelectionChanged != null) { OnUserSelectionChanged(this, userRow); } } DataBind(); }
public List <UserRowData> GetAllUsers() { List <UserRowData> data; using (var service = new UserManagement()) { data = CollectionUtils.Map( service.FindUsers(new ListUsersRequest()), delegate(UserSummary summary) { var user = new UserRowData(summary, null); return(user); }); } return(data); }
/// <summary> /// Set up the event handlers for child controls. /// </summary> protected void SetupEventHandlers() { AddEditUserDialog.OKClicked += delegate(UserRowData user) { if (AddEditUserDialog.EditMode) { // Commit the change into database if (_controller.UpdateUser(user)) { UserPanel.UpdateUI(); return(true); } return(false); } else { try { if (_controller.AddUser(user)) { UserPanel.UpdateUI(); return(true); } return(false); } catch (Exception) { return(false); } } }; DeleteConfirmation.Confirmed += delegate(object data) { // delete the device and reload the affected partition. UserRowData user = data as UserRowData; _controller.DeleteUser(user); UserPanel.UpdateUI(); }; }
public bool DeleteUser(UserRowData user) { bool success = false; using (var service = new UserManagement()) { try { service.DeleteUser(user.UserName); success = true; } catch (Exception ex) { Platform.Log(LogLevel.Error, ex, "Unexpected exception deleting user: {0}", user.DisplayName); } } return(success); }
public bool ResetPassword(UserRowData user) { bool success = false; using (var service = new UserManagement()) { try { service.ResetPassword(user.UserName); success = true; } catch (Exception ex) { Platform.Log(LogLevel.Error, ex, "Unexpected exception resetting password for user: {0}", user.DisplayName); } } return(success); }
public bool AddUser(UserRowData user) { bool success = false; using (var service = new UserManagement()) { try { var newUser = new UserDetail { UserName = user.UserName, DisplayName = user.DisplayName, Enabled = user.Enabled, CreationTime = Platform.Time, PasswordExpiryTime = Platform.Time, EmailAddress = user.EmailAddress, ResetPassword = true // TODO: Why do we need to reset password here? }; var groups = new List <AuthorityGroupSummary>(); foreach (UserGroup userGroup in user.UserGroups) { groups.Add(new AuthorityGroupSummary(new EntityRef(userGroup.UserGroupRef), userGroup.Name, userGroup.Name, false, false)); } newUser.AuthorityGroups = groups; service.AddUser(newUser); success = true; } catch (Exception ex) { Platform.Log(LogLevel.Error, ex, "Unexpected exception adding user: {0}", user.DisplayName); } } return(success); }
public void UpdateUI() { UserRowData userRow = UserGridPanel.SelectedUser; if (userRow == null) { // no device being selected EditUserButton.Enabled = false; DeleteUserButton.Enabled = false; ResetPasswordButton.Enabled = false; } else { EditUserButton.Enabled = true; DeleteUserButton.Enabled = true; ResetPasswordButton.Enabled = true; } // UpdatePanel UpdateMode must be set to "conditional" // Calling UpdatePanel.Update() will force the client to refresh the screen UserGridPanel.RefreshCurrentPage(); SearchUpdatePanel.Update(); }
public bool UpdateUser(UserRowData user) { bool success = false; using (var service = new UserManagement()) { try { var updateUser = new UserDetail { UserName = user.UserName, DisplayName = user.DisplayName, EmailAddress = user.EmailAddress, Enabled = user.Enabled }; var groups = new List <AuthorityGroupSummary>(); foreach (UserGroup userGroup in user.UserGroups) { groups.Add(new AuthorityGroupSummary(new EntityRef(userGroup.UserGroupRef), userGroup.Name, userGroup.Name, false, false)); } updateUser.AuthorityGroups = groups; service.UpdateUserDetail(updateUser); success = true; } catch (Exception ex) { Platform.Log(LogLevel.Error, ex, "Unexpected exception updating user: {0}", user.DisplayName); } } return(success); }
public void OnEditUser(UserRowData userRowData) { AddEditUserDialog.EditMode = true; AddEditUserDialog.User = userRowData; AddEditUserDialog.Show(true); }