Delete(Where: IMbElementDependentTemplate);
Delete(Where: Prognoz.Platform.Interop.Metabase.IMbElementDependentTemplate);
Where. Template, according to which delete is done.
The Delete method deletes dependencies corresponding to the specified template.
To check whether there are dependencies of MDM dictionary elements from repository objects, use the IMbElementDependentsDatabase.Exists method.
Executing the example requires MDM dictionaries with the DICT and DICT1 identifiers.
Add links to the Metabase, Rds and Ui system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Obj, Dictionary: IMetabaseObjectDescriptor;
RdsDictIns: IRdsDictionaryInstance;
Elements: IRdsDictionaryElements;
Template: IMbElementDependentTemplate;
ObjKeys: Array[2] Of Integer;
DictKey: Integer;
ElemDependDB: IMbElementDependentsDatabase;
b: Boolean;
Begin
MB := MetabaseClass.Active;
Obj := MB.ItemById("DICT1");
Dictionary := MB.ItemById("DICT");
RdsDictIns := Dictionary.Open(Null) As IRdsDictionaryInstance;
Elements := RdsDictIns.Elements;
// Object settings:
Obj := Obj.EditDescriptor;
Obj.ElementDependenciesTrackingType := MbElementDependenciesTrackingType.Dependecies;
Obj.SaveDescriptor;
// Template:
DictKey := Dictionary.Key;
Template := New MbElementDependentTemplateClass.CreateByDictionary(DictKey);
Template.ObjectKey := Dictionary.Key;
ObjKeys[0] := Elements.Element(1);
ObjKeys[1] := Elements.Element(2);
// Specify element keys
Template.ObjectKeys := ObjKeys;
// Working with dependencies:
ElemDependDB := Mb.ElementDependentsDatabase;
If ElemDependDB.Exists(Template) Then
WinApplication.YesNoCancelBox(font color="#800000">"Dependencies exist. Delete dependencies from element?", b); If b Then
ElemDependDB.Delete(Template);
End If;
End If;
Debug.WriteLine("Number of repository object keys: "
+ Template.ObjectKeysCount.ToString);
End Sub UserProc;
After executing the example the console window displays the information about the number of repository object keys. If there are dependencies that correspond to the specified template, it is prompted to delete them. If the user presses the OK button, dependencies will be deleted.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Rds;
Imports Prognoz.Platform.Interop.Ui;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Obj, Dictionary: IMetabaseObjectDescriptor;
RdsDictIns: IRdsDictionaryInstance;
Elements: IRdsDictionaryElements;
Template: MbElementDependentTemplateClass;
DependTemplClass: MbElementDependentTemplateClassClass = New MbElementDependentTemplateClassClass();
ObjKeys: Array[2] Of uinteger;
DictKey: uinteger;
ElemDependDB: IMbElementDependentsDatabase;
WinAppCls: WinApplicationClass = New WinApplicationClassClass();
b, b1: Boolean;
Begin
MB := Params.Metabase;
Obj := MB.ItemById["DICT1"];
Dictionary := MB.ItemById["DICT"];
RdsDictIns := Dictionary.Open(Null) As IRdsDictionaryInstance;
Elements := RdsDictIns.Elements;
// Object settings:
Obj := Obj.EditDescriptor();
Obj.ElementDependenciesTrackingType := MbElementDependenciesTrackingType.mbeledeptratypDependecies;
Obj.SaveDescriptor();
// Template:
DictKey := Dictionary.Key;
DependTemplClass.CreateByDictionary(DictKey);
Template := DependTemplClass As MbElementDependentTemplateClass;
Template.ObjectKey := Dictionary.Key;
ObjKeys[0] := Elements.Element[1];
ObjKeys[1] := Elements.Element[2];
// Specify element keys
Template.ObjectKeys := ObjKeys;
// Working with dependencies:
ElemDependDB := Mb.ElementDependentsDatabase;
If ElemDependDB.Exists(Template) Then
b := WinAppCls.YesNoCancelBox("Dependencies exist. Delete dependencies from element?",
b, Var b1, New IWin32WindowForeAdapter(Self));
If b Then
ElemDependDB.Delete(Template);
End If;
End If;
System.Diagnostics.Debug.WriteLine("Number of repository object keys: "
+ Template.ObjectKeysCount.ToString());
End Sub;
See also: