private void GetUserIdButton_Click(object sender, EventArgs e) { UserId delegateUserId = null; if (UserIdDialog.ShowDialog(this.CurrentService, ref delegateUserId) != DialogResult.OK) { // If the UserIdDialog does not return OK then do nothing DebugLog.WriteVerbose("UserIdDialog did not return OK"); return; } if (delegateUserId == null) { // If delegateUserId is NULL then do nothing DebugLog.WriteVerbose("UserIdDialog return a NULL UserId"); return; } // If the UserIdDialog returns OK then reset the DelegateUser using the new UserId if (!String.IsNullOrEmpty(delegateUserId.PrimarySmtpAddress)) { this.DelegateUser = new DelegateUser(delegateUserId.PrimarySmtpAddress); } else if (delegateUserId.StandardUser.HasValue) { this.DelegateUser = new DelegateUser(delegateUserId.StandardUser.Value); } else { // Treat an invalid delegateUserId as if the UserIdDialog did not return OK DebugLog.WriteVerbose("UserIdDialog returned OK but UserId returned didn't have StandardUser or PrimarySmtpAddress"); } }
public static DialogResult ShowDialog(ExchangeService service, ref UserId user) { UserIdDialog dialog = new UserIdDialog(); dialog.CurrentService = service; dialog.UserId = user; DialogResult res = dialog.ShowDialog(); if (res == DialogResult.OK) { user = dialog.UserId; } return(res); }
/// <summary> /// Display the UserIdDialog to get a UserId of the user to /// remove. Prepopulate UserIdDialog if a delegate is selected /// in the delegate list. After getting a UserId, call RemoveDelegate /// </summary> private void btnRemove_Click(object sender, EventArgs e) { UserId removeUser = null; if (GetSelectedDelegateUser() != null) { removeUser = GetSelectedDelegateUser().UserId; } if (UserIdDialog.ShowDialog(this.CurrentService, ref removeUser) == DialogResult.OK && removeUser != null) { ICollection <DelegateUserResponse> results; try { this.Cursor = Cursors.WaitCursor; results = this.CurrentService.RemoveDelegates(this.PrincipalMailbox, new UserId[] { removeUser }); } 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 remove delegate. {0}, {1}", result.ErrorCode.ToString(), result.ErrorMessage)); } } GetDelegateInformation(); } }