It opens a dialog box with user update errors.
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. |
The command is available to be used after users update. Users can be updated using the IMetabaseSecurity.UpdateUsers method.
To execute the example, add links to the Metabase, Ui, ForeSystem (for Fore.NET example) 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;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Ui;
Imports Prognoz.Platform.Interop.ForeSystem;
…
Public Class Program
[STAThread]
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MBSec: IMetabaseSecurity;
Users: IMetabaseUsers;
User: IMetabaseUser;
UserUpdate: IMetabaseUsersUpdate;
Result: IMetabaseUsersUpdateErrors;
Target: IUiCommandTarget;
Context: IUiCommandExecutionContext;
WinAppCls: WinApplicationClass = New WinApplicationClassClass();
Lic: Object;
Begin
MB := Params.Metabase;
// Get license to work with security manager
Lic := Mb.RequestLicense(UiLicenseFeatureType.lftAdm);
MBSec := MB.Security;
Users := MBSec.Users;
UserUpdate := MBSec.CreateUsersUpdate();
UserUpdate.Callback := New UsersUpdateCallback();
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 := WinAppCls.Instance[Null].GetPluginTarget("Adm");
Context := Target.CreateExecutionContext();
Context.Data := Result;
Target.Execute("UpdateUsers_ShowErrorsDialog", Context, Null);
// Check in license
Lic := Null;
End Sub;
End Class;
Class UsersUpdateCallback: Object, IMetabaseUsersUpdateCallback
UpdateResult: MetabaseUsersUpdateCallbackResult;
Public Function RequestAction(ErrorInfo: IMetabaseUsersUpdateError): MetabaseUsersUpdateCallbackResult;
Begin
Return MetabaseUsersUpdateCallbackResult.muucrSilentContinue;
End Function RequestAction;
Public Sub Process(Subject: ISecuritySubject);
Begin
System.Diagnostics.Debug.WriteLine("Update user: " + Subject.Name);
End Sub Process;
Public Property CallbackResult: MetabaseUsersUpdateCallbackResult
Get
Begin
Return UpdateResult;
End Get
Set
Begin
UpdateResult := Value;
End Set
End Property CallbackResult;
End Class;
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: