コード例 #1
0
        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();
        }
コード例 #2
0
ファイル: UserLookupHandler.cs プロジェクト: nhannd/Xian
		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);
		}
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: UserLookupHandler.cs プロジェクト: nhannd/Xian
		private static string FormatItem(UserLookupData user)
		{
			return user.UserName;
		}
コード例 #6
0
 private static string FormatItem(UserLookupData user)
 {
     return(user.UserName);
 }