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.
Executing the example requires a form and a button named Button1 on the form.
Class TESTForm: Form
Button1: Button;
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
MB: IMetabase;
MBSec: IMetabaseSecurity;
Users: IMetabaseUsers;
User: IMetabaseUser;
UserUpdate: IMetabaseUsersUpdate;
Result: IMetabaseUsersUpdateErrors;
Target: IUiCommandTarget;
Context: IUiCommandExecutionContext;
Begin
MB := MetabaseClass.Active;
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;
//Updating of all users added in security manager
MBSec.UpdateUsers(UserUpdate);
//Viewing the list of errors which could occur on updating
Result := UserUpdate.Errors;
Target := WinApplication.Instance.GetPluginTarget("Adm");
Context := Target.CreateExecutionContext;
Context.Data := Result;
Target.Execute("UpdateUsers_ShowErrorsDialog", Context);
End Sub Button1OnClick;
End Class TESTForm;
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("User updating: " + 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;
Clicking the button updates all the users added in the security manager of the current repository. Update will be continued regardless of any errors occurred on updating a user. After all users are updated, the window is displayed with the information on all occurred errors.
Executing the example requires a .NET form and the Button1 button on the form.
Imports Prognoz.Platform.Forms.Net;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Ui;
Public Partial Class TESTForm: Prognoz.Platform.Forms.Net.ForeNetForm
Public Constructor TESTForm();
Begin
InitializeComponent();
End Constructor;
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
MB: IMetabase;
MBSec: IMetabaseSecurity;
Users: IMetabaseUsers;
User: IMetabaseUser;
UserUpdate: IMetabaseUsersUpdate;
Result: IMetabaseUsersUpdateErrors;
Target: IUiCommandTarget;
Context: IUiCommandExecutionContext;
WinAppCls: WinApplicationClass = New WinApplicationClassClass();
Begin
MB := Self.Metabase;
MBSec := MB.Security;
Users := MBSec.Users;
UserUpdate := MBSec.CreateUsersUpdate();
UserUpdate.Callback := New UsersUpdateCallback();
For Each User In Users Do
UserUpdate.Add(User);
End For;
//Updating of all users added in security manager
MBSec.UpdateUsers(UserUpdate);
//Viewing the list of errors which could occur on updating
Result := UserUpdate.Errors;
Target := WinAppCls.Instance[Null].GetPluginTarget("Adm");
Context := Target.CreateExecutionContext();
Context.Data := Result;
Target.Execute("UpdateUsers_ShowErrorsDialog", Context, 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("User updating: " + 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;
Clicking the button updates all the users added in the security manager of the current repository. Update will be continued regardless of any errors occurred on updating a user. After all users are updated, the window is displayed with the information on all occurred errors.
See also: