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.
See also: