Callback: IMetabaseUsersUpdateCallback;
Callback: Prognoz.Platform.Interop.Metabase.IMetabaseUsersUpdateCallback;
The Callback property determines the object, performing the handling of errors that may occur on updating users.
As the value of the property it is necessary to specify the instance of the custom class, realizing properties and methods of the IMetabaseUsersUpdateCallback interfaces.
Sub UserProc;
Var
MB: IMetabase;
Sec: IMetabaseSecurity;
Users: IMetabaseUsers;
User: IMetabaseUser;
UsUpdate: IMetabaseUsersUpdate;
UpdateCallback: IMetabaseUsersUpdateCallback;
Results: IMetabaseUsersUpdateErrors;
Error: IMetabaseUsersUpdateError;
Begin
MB := MetabaseClass.Active;
Sec := MB.Security;
Users := Sec.Users;
UsUpdate := Sec.CreateUsersUpdate;
For Each User In Users Do
UsUpdate.Add(User);
End For;
UpdateCallback := New UserUpdateClb.Create;
UpdateCallback.CallbackResult := MetabaseUsersUpdateCallbackResult.SilentContinue;
UsUpdate.Callback := UpdateCallback;
Sec.UpdateUsers(UsUpdate);
Results := UsUpdate.Errors;
If Results.Count <> 0 Then
Results.SaveToFile("c:\UpdateUsersResult.txt", True);
End If;
For Each Error In Results Do
If Error.Type = MetabaseUsersUpdateErrorType.Error Then
Debug.WriteLine("Error: " + Error.Message + ". Details: " + Error.DetailText);
Else
Debug.WriteLine("Warning: " + Error.Message + ". Details: " + Error.DetailText);
End If;
End For;
End Sub UserProc;
Class UserUpdateClb: Object, IMetabaseUsersUpdateCallback
_ClbResult: MetabaseUsersUpdateCallbackResult;
Sub Process(Subject: ISecuritySubject);
Begin
Debug.WriteLine("Updating user: " + Subject.Name);
End Sub Process;
Function RequestAction(Error: IMetabaseUsersUpdateError): MetabaseUsersUpdateCallbackResult;
Begin
Select Case Error.Type
Case MetabaseUsersUpdateErrorType.Warning:
Debug.WriteLine("Warning: " + Error.Message);
Case MetabaseUsersUpdateErrorType.Error:
Debug.WriteLine("Error: " + Error.Message);
End Select;
Return _ClbResult;
End Function RequestAction;
Function get_CallbackResult: MetabaseUsersUpdateCallbackResult;
Begin
Return _ClbResult;
End Function get_CallbackResult;
Sub set_CallbackResult(Result: MetabaseUsersUpdateCallbackResult);
Begin
_ClbResult := Result;
End Sub set_CallbackResult;
End Class UserUpdateClb;
On executing the example all users created in the security manager of the repository are updated. To track the process of updating the object of the UserUpdateClb custom class is created. On occurring any problems the update process will be resumed. When finished, if during the update any errors/warnings appeared then the information on them would be displayed in the development environment console and saved to the file.
The specified procedure is an entry point for the .NET assembly.
Imports Prognoz.Platform.Interop.Metabase;
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Sec: IMetabaseSecurity;
Users: IMetabaseUsers;
User: IMetabaseUser;
UsUpdate: IMetabaseUsersUpdate;
UpdateCallback: IMetabaseUsersUpdateCallback = New UserUpdateClb();
Results: IMetabaseUsersUpdateErrors;
Error: IMetabaseUsersUpdateError;
Begin
MB := Params.Metabase;
Sec := MB.Security;
Users := Sec.Users;
UsUpdate := Sec.CreateUsersUpdate();
For Each User In Users Do
UsUpdate.Add(User);
End For;
UpdateCallback.CallbackResult := MetabaseUsersUpdateCallbackResult.muucrSilentContinue;
UsUpdate.Callback := UpdateCallback;
Sec.UpdateUsers(UsUpdate);
Results := UsUpdate.Errors;
If Results.Count <> 0 Then
Results.SaveToFile("c:\\UpdateUsersResult.txt", True);
End If;
For Each Error In Results Do
If Error.Type = MetabaseUsersUpdateErrorType.muuetError Then
System.Diagnostics.Debug.WriteLine("Error: " + Error.Message + ". Details: " + Error.DetailText);
Else
System.Diagnostics.Debug.WriteLine("Warning: " + Error.Message + ". Details: " + Error.DetailText);
End If;
End For;
End Sub;
Class UserUpdateClb: IMetabaseUsersUpdateCallback
_ClbResult: MetabaseUsersUpdateCallbackResult;
Public Sub Process(Subject: ISecuritySubject);
Begin
System.Diagnostics.Debug.WriteLine("Updating users: " + Subject.Name);
End Sub;
Public Function RequestAction(Error: IMetabaseUsersUpdateError): MetabaseUsersUpdateCallbackResult;
Begin
Select Case Error.Type
Case MetabaseUsersUpdateErrorType.muuetWarning:
System.Diagnostics.Debug.WriteLine("Warning: " + Error.Message);
Case MetabaseUsersUpdateErrorType.muuetError:
System.Diagnostics.Debug.WriteLine("Error: " + Error.Message);
End Select;
Return _ClbResult;
End Function;
Public Property CallbackResult: MetabaseUsersUpdateCallbackResult
Get
Begin
Return _ClbResult;
End Get
Set
Begin
_ClbResult := Value;
End Set
End Property;
End Class;
On executing the example all users created in the security manager of the repository are updated. To track the process of updating the object of the UserUpdateClb custom class is created. On occurring any problems the update process will be resumed. When finished, if during the update any errors/warnings appeared then the information on them would be displayed in the development environment console and saved to the file.
See also: