CheckExecute(CheckType: Integer): Boolean;
CheckExecute(CheckType: Integer): Boolean;
CheckType - type of conflict that should be checked.
The CheckExecute method implements event that occurs when the Execute method is executed, if a conflict occurs.
This event occurs if any conflicts that should be resolved arise during execution. If custom function returns True, the conflict is resolved. If the function returns False, execution stops.
Executing the example requires an MDM repository with the RDS identifier. The MDM dictionary with the Country identifier is created in this repository. Tracking links to elements is enabled for a dictionary.
Sub UserProc;
Var
MB: IMetabase;
Dict: IRdsDictionary;
DictInst: IRdsDictionaryInstance;
DictBatch: IRdsDictionaryBatch;
DelBatch: IRdsDictionaryBatchDelete;
BatchFilters: IRdsDictionaryFilterConditions;
Filter: IRdsDictionaryFilterCondition;
Attr: IRdsAttribute;
Begin
MB := MetabaseClass.Active;
Dict := MB.ItemByIdNamespace("Country", MB.GetObjectKeyById("RDS")).Bind As IRdsDictionary;
DictInst := Dict.Open(Null) As IRdsDictionaryInstance;
DictBatch := DictInst.CreateBatch(RdsDictionaryBatchType.Delete);
DelBatch := DictBatch As IRdsDictionaryBatchDelete;
BatchFilters := DelBatch.Filter;
Attr := Dict.Attributes.FindById("ACTUAL");
Filter := BatchFilters.Add(Attr);
Filter.Value := False;
DelBatch.Callback := New MyCallback.Create;
DelBatch.Execute;
End Sub UserProc;
Class MyCallback: Object, IRdsBatchCallback
Function OnError(Element: Integer; ErrorType: integer; Error: IException): RdsBatchCallbackContinue;
Begin
Debug.WriteLine(Error!);
Debug.WriteLine( element: + Element.ToString);
Debug.WriteLine( error type: + ErrorType.ToString);
Debug.WriteLine( error text: + Error.Message);
Return RdsBatchCallbackContinue.Continue_;
End function OnError;
Function CheckExecute(CheckType: Integer): Boolean;
Begin
If CheckType = RdsCheckExecuteDeleteBatch.DeleteDepends Then
Return False;
End If;
End Function CheckExecute;
End Class MyCallback;
On executing the example, a batch used to remove elements with a handler of exception cases and to resolve conflicts is created. The batch is executed. All errors, occurred during the execution, are displayed in the console window. If conflict, connected with the removal of objects on which repository objects depend, arises, batch execution is cancelled.
The specified procedure is an entry point for .NET assembly. Executing the example requires an MDM repository with the RDS identifier. The MDM dictionary with the Country identifier is created in this repository. Tracking links to elements is enabled for a dictionary.
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Dict: IRdsDictionary;
DictInst: IRdsDictionaryInstance;
DictBatch: IRdsDictionaryBatch;
DelBatch: IRdsDictionaryBatchDelete;
BatchFilters: IRdsDictionaryFilterConditions;
Filter: IRdsDictionaryFilterCondition;
Attr: IRdsAttribute;
Begin
MB := Params.Metabase;
Dict := MB.ItemByIdNamespace["Country", MB.GetObjectKeyById("RDS")].Bind() As IRdsDictionary;
DictInst := Dict.Open(Null) As IRdsDictionaryInstance;
DictBatch := DictInst.CreateBatch(RdsDictionaryBatchType.rdbtDelete);
DelBatch := DictBatch As IRdsDictionaryBatchDelete;
BatchFilters := DelBatch.Filter;
Attr := Dict.Attributes.FindById("ACTUAL");
Filter := BatchFilters.Add(Attr);
Filter.Value := False;
DelBatch.Callback := New MyCallback();
DelBatch.Execute();
End Sub;
Class MyCallback: IRdsBatchCallback
Public Function OnError(Element: uinteger; ErrorType: integer; Error: Prognoz.Platform.Interop.ForeSystem.Exception): RdsBatchCallbackContinue;
Begin
Return RdsBatchCallbackContinue.rbacacoContinue;
End Function OnError;
Public Function CheckExecute(CheckType: Integer): Boolean;
Begin
If CheckType = (RdsCheckExecuteDeleteBatch.rcedbDeleteDepends As integer) Then
Return False;
Else
Return True;
End If;
End Function CheckExecute;
End Class MyCallback;
On executing the example, a batch used to remove elements with a handler of exception cases and to resolve conflicts is created. The batch is executed. If errors occur, the execution continues. If conflict, connected with the removal of objects on which repository objects depend, arises, batch execution is cancelled.
See also: