public override void Start() { _selectedUser = GetUserForStaff(_staffDetail); _userLookupHandler = new UserLookupHandler(this.Host.DesktopWindow); this.Validation.Add(new ValidationRule("SelectedUser", delegate { bool userNoLongerExist = !string.IsNullOrEmpty(_userNameNoLongerExist) && (_selectedUser != null && _selectedUser.UserName == _userNameNoLongerExist); return(new ValidationResult(!userNoLongerExist, string.Format(SR.MessageAssociatedUserNoLongerExist, _userNameNoLongerExist))); })); base.Start(); }
bool ILookupHandler.Resolve(string query, bool interactive, out object result) { result = null; var userComponent = new UserSummaryComponent(true); var exitCode = ApplicationComponent.LaunchAsDialog( _desktopWindow, userComponent, SR.TitleUser); if (exitCode == ApplicationComponentExitCode.Accepted) { var summary = (UserSummary) userComponent.SummarySelection.Item; result = new UserLookupData(summary.UserName); } return (result != null); }
bool ILookupHandler.Resolve(string query, bool interactive, out object result) { result = null; var userComponent = new UserSummaryComponent(true); var exitCode = ApplicationComponent.LaunchAsDialog( _desktopWindow, userComponent, SR.TitleUser); if (exitCode == ApplicationComponentExitCode.Accepted) { var summary = (UserSummary)userComponent.SummarySelection.Item; result = new UserLookupData(summary.UserName); } return(result != null); }
private UserLookupData GetUserForStaff(StaffDetail staff) { UserLookupData user = null; if (!string.IsNullOrEmpty(staff.UserName)) { // If this staff is associated with an user, get the most updated user using IUserAdminService if (this.IsUserAdmin) { Platform.GetService <IUserAdminService>( delegate(IUserAdminService service) { ListUsersRequest request = new ListUsersRequest(); request.UserName = staff.UserName; request.ExactMatchOnly = true; ListUsersResponse response = service.ListUsers(request); UserSummary summary = CollectionUtils.FirstElement(response.Users); // If there is no return user, it means that the user was deleted without updating staff. user = summary == null ? null : new UserLookupData(summary.UserName); }); if (user == null) { _userNameNoLongerExist = staff.UserName; // The user no longer exist, delete user name. staff.UserName = null; // Nevertheless, display this info. user = new UserLookupData(_userNameNoLongerExist); } } else { // if user is not a UserAdmin, don't hit the server, use the data we already have. // unfortunately, we cannot detect the case where user is deleted without staff updated. user = new UserLookupData(staff.UserName); } } return(user); }
private static string FormatItem(UserLookupData user) { return user.UserName; }
private static string FormatItem(UserLookupData user) { return(user.UserName); }