public static DialogResult ShowDialog(ExchangeService service, ref DelegateUser user) { DelegateUserDialog diag = new DelegateUserDialog(); diag.CurrentService = service; diag.DelegateUser = user; DialogResult res = diag.ShowDialog(); if (res == DialogResult.OK) { user = diag.DelegateUser; } return(res); }
/// <summary> /// Show the DelegatePermissionDialog for the selected user. /// </summary> private void btnUpdate_Click(object sender, EventArgs e) { // If the dialog result returned is actionable, change the edit // state. DelegateUser delegateUser = GetSelectedDelegateUser(); if (DelegateUserDialog.ShowDialog(this.CurrentService, ref delegateUser) == DialogResult.OK) { ICollection <DelegateUserResponse> results; try { this.Cursor = Cursors.WaitCursor; results = this.CurrentService.UpdateDelegates( this.PrincipalMailbox, GetScopeFromForm(), new DelegateUser[] { delegateUser }); } finally { this.Cursor = Cursors.Default; } foreach (DelegateUserResponse result in results) { if (result.Result == ServiceResult.Error) { ErrorDialog.ShowWarning(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Failed to update {0}. {1}, {2}", result.DelegateUser.UserId.StandardUser.HasValue ? result.DelegateUser.UserId.StandardUser.Value.ToString() : result.DelegateUser.UserId.PrimarySmtpAddress, result.ErrorCode.ToString(), result.ErrorMessage)); } } GetDelegateInformation(); } }
/// <summary> /// Display the DelegateUserDialog to get a new DelegateUser. After /// getting that call AddDelegate /// </summary> private void btnAdd_Click(object sender, EventArgs e) { DelegateUser newDelegate = null; if (DelegateUserDialog.ShowDialog(this.CurrentService, ref newDelegate) == DialogResult.OK && newDelegate != null) { ICollection <DelegateUserResponse> results; try { this.Cursor = Cursors.WaitCursor; results = this.CurrentService.AddDelegates( this.PrincipalMailbox, GetScopeFromForm(), new DelegateUser[] { newDelegate }); } finally { this.Cursor = Cursors.Default; } foreach (DelegateUserResponse result in results) { if (result.Result == ServiceResult.Error) { ErrorDialog.ShowWarning(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Failed to add {0}. {1}, {2}", result.DelegateUser.UserId.StandardUser.HasValue ? result.DelegateUser.UserId.StandardUser.Value.ToString() : result.DelegateUser.UserId.PrimarySmtpAddress, result.ErrorCode.ToString(), result.ErrorMessage)); } } GetDelegateInformation(); } }