CreateDimInstance: IDimInstance;
CreateDimInstance: Prognoz.Platform.Interop.Dimensions.IDimInstance;
The CreateDimInstance method returns dictionary data on the base of the current set of elements of the MDM dictionary.
This method returns values of system attributes, or all attributes of the MDM dictionary, depending on the value defined for the IRdsDictionaryInstance.FetchAll property.
NOTE. This method does not get values of imported attributes.
If you directly cast the IRdsDictionaryInstance interface to IDimInstance, cached data is returned. When you use the CreateDimInstance method, it returns data based on actual set of elements. Use CreateDimInstance to get current data.
Executing the example requires a form with the Button1 button, the RdsDictionaryBox component named RdsDictionaryBox1, and the UiRdsDictionary component that is a data source for RdsDictionaryBox1. An MDM dictionary is loaded to RdsDictionaryBox1.
This example is a handler of the OnClick event for the Button1 button.
Add a link to the Dimensions system assembly.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
DictInst: IRdsDictionaryInstance;
Inst: IDimInstance;
Elems: IDimElements;
ElemArr: IDimElementArray;
Iter: IDimIterator;
Ats: IDimAttributesInstance;
Atr: IDimAttributeInstance;
i: Integer;
s: String;
Begin
DictInst := RdsDictionaryBox1.Source.Instance;
// Load values of system and custom attributes to cache
DictInst.FetchAll := True;
// Get dictionary data
Inst := DictInst As IDimInstance;
// Get dictionary elements
Elems := Inst.Elements;
ElemArr := Inst.RootElements;
Iter := ElemArr.Iterator;
// Get dictionary attributes
Ats := Inst.Attributes;
// Output attribute values
Debug.WriteLine("Values of attributes for root elements:");
While Iter.Next Do
Debug.WriteLine("Element " + Iter.Position.ToString);
Debug.Indent;
For i := 0 To Ats.Count - 1 Do
s := "";
Atr := Ats.Item(i);
s := Atr.Attribute.Name + ": ";
s := s + Atr.Value(Iter.Element);
Debug.WriteLine(s);
End For;
Debug.Unindent;
If Iter.Position = 9 Then
Break;
End If;
End While;
End Sub Button1OnClick;
Example execution result: the console window displays attribute values for the first ten root elements of the MDM dictionary loaded to RdsDictionaryBox1.
Executing the example requires a form with a button with the button1 identifier, the RdsDictionaryBoxNet component with the rdsDictionaryBoxNet1 identifier, and the UiRdsDictionaryNet component used as a data source for rdsDictionaryBoxNet1. An MDM dictionary is loaded to rdsDictionaryBoxNet1.
This example is a handler of the Click event for the button1 button.
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Rds;
…
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
DictInst: IRdsDictionaryInstance;
Inst: IDimInstance;
Elems: IDimElements;
ElemArr: IDimElementArray;
Iter: IDimIterator;
Ats: IDimAttributesInstance;
Atr: IDimAttributeInstance;
i: Integer;
s: String;
Begin
DictInst := rdsDictionaryBoxNet1.Source.Instance;
// Load values of system and custom attributes to cache
DictInst.FetchAll := True;
// Get dictionary data
Inst := DictInst As IDimInstance;
// Get dictionary elements
Elems := Inst.Elements;
ElemArr := Inst.RootElements;
Iter := ElemArr.Iterator();
// Get dictionary attributes
Ats := Inst.Attributes;
// Output attribute values
System.Diagnostics.Debug.WriteLine("Values of attributes for root elements:");
While Iter.Next() Do
System.Diagnostics.Debug.WriteLine("Element " + Iter.Position.ToString());
System.Diagnostics.Debug.Indent();
For i := 0 To Ats.Count - 1 Do
s := "";
Atr := Ats.Item[i];
s := Atr.Attribute.Name + ": ";
s := s + Atr.Value[Iter.Element];
System.Diagnostics.Debug.WriteLine(s);
End For;
System.Diagnostics.Debug.Unindent();
If Iter.Position = 9 Then
Break;
End If;
End While;
End Sub;
Example execution result: the console window shows attribute values for the first ten root elements of the MDM dictionary loaded to rdsDictionaryBoxNet1.
See also: