UpdateUsers_ShowErrorsDialog Command

Purpose

It opens a dialog box with user update errors.

Parameters of Use

Command parameters are passed in the Data property. Executing the command requires to specify the following values in this property:

Parameter Description
IMetabaseUsersUpdateErrors Information about the errors that could happen on users update. The information can be obtained in the IMetabaseUsersUpdate.Errors property.

Application Features

The command is available to be used after users update. Users can be updated using the IMetabaseSecurity.UpdateUsers method.

Example

To execute the example, add links to the Metabase and Ui system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MBSec: IMetabaseSecurity;
    Users: IMetabaseUsers;
    User: IMetabaseUser;
    UserUpdate: IMetabaseUsersUpdate;
    Result: IMetabaseUsersUpdateErrors;
    Target: IUiCommandTarget;
    Context: IUiCommandExecutionContext;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    
// Get license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    MBSec := MB.Security;
    Users := MBSec.Users;
    UserUpdate := MBSec.CreateUsersUpdate;
    UserUpdate.Callback := 
New UsersUpdateCallback.Create;
    
For Each User In Users Do
        UserUpdate.Add(User);
    
End For;
    
// Update all users added in security manager
    MBSec.UpdateUsers(UserUpdate);
    
// Get list of errors that may occur on update
    Result := UserUpdate.Errors;
    Target := WinApplication.Instance.GetPluginTarget(
"Adm");
    Context := Target.CreateExecutionContext;
    Context.Data := Result;
    Target.Execute(
"UpdateUsers_ShowErrorsDialog", Context);
    
// Check in license
    Lic := Null;
End Sub Main;

Class UsersUpdateCallback: Object, IMetabaseUsersUpdateCallback
    UpdateResult: MetabaseUsersUpdateCallbackResult;

    
Function RequestAction(ErrorInfo: IMetabaseUsersUpdateError): MetabaseUsersUpdateCallbackResult;
    
Begin
        
Return MetabaseUsersUpdateCallbackResult.SilentContinue;
    
End Function RequestAction;
    
    
Sub Process(Subject: ISecuritySubject);
    
Begin
        Debug.WriteLine(
"Update user: " + Subject.Name);
    
End Sub Process;
    
    
Function get_CallbackResult: MetabaseUsersUpdateCallbackResult;
    
Begin
        
Return UpdateResult;
    
End Function get_CallbackResult;

    
Sub set_CallbackResult(Value: MetabaseUsersUpdateCallbackResult);
    
Begin
        UpdateResult := Value;
    
End Sub set_CallbackResult;
End Class UsersUpdateCallback;

After executing the example, all the users added in the security manager of the current repository are updated. Update will be continued regardless of any errors occurred on updating a user. After all the users are updated, the window with the information about all occurred errors is displayed.

See also:

IUiCommandTarget.Execute