NewElementsOrderSetup: IDimElementsOrderSetup;
NewElementsOrderSetup(): Prognoz.Platform.Interop.Dimensions.IDimElementsOrderSetup;
The NewElementsOrderSetup method returns settings of dictionary elements custom sorting.
Executing the example requires that repository contains MDM table dictionary with the DIM identifier.
Add links to the Dimensions and Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
OrderSetup: IDimElementsOrderSetup;
Attribute : IDimAttribute;
AttrInst: IDimAttributeInstance;
Iterator: IDimTreeIterator;
DimInst: IDimInstance;
Begin
MB := MetabaseClass.Active;
DimInst := MB.ItemById("DIM").Open(Null) As IDimInstance;
OrderSetup := DimInst.NewElementsOrderSetup;
AttrInst := DimInst.Attributes.Item(1);
Attribute := AttrInst.Attribute;
// Add attribute to the sorting list
OrderSetup.Add(Attribute, False);
Debug.WriteLine("Number of sorting attributes: " + OrderSetup.Count.ToString);
Debug.WriteLine("Sorting by attribute " + Attribute.Name + ", attribute key: "
+ OrderSetup.AttributeKey(0).ToString);
// Get iterator for a tree built with taking sorting into account
Iterator := DimInst.ElementsByOrder(OrderSetup);
// Determine sorting order
If OrderSetup.ReverseOrder(0) Then
Debug.WriteLine("Sort descending");
Else
Debug.WriteLine("Sort ascending");
End If;
// Display dictionary elements taking sorting into account
While Iterator.HasNext >= 0 Do
Debug.WriteLine(DimInst.Elements.AttributeValueO(Iterator.GetElement, AttrInst));
// If element has owner, display owner index
If Iterator.GetParent >= 0 Then
Debug.WriteLine("Element owner index: " + Iterator.GetParent.ToString);
End If;
End While;
// Move to the iterator beginning
Iterator.ResetIterator;
End Sub UserProc;
After executing the example dictionary elements sorting will be set up, after it iterator will be obtained for built tree. The console displays information about sorting parameters and sorted dictionary elements.
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.Dimensions;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
OrderSetup: IDimElementsOrderSetup;
Attribute : IDimAttribute;
AttrInst: IDimAttributeInstance;
Iterator: IDimTreeIterator;
DimInst: IDimInstance;
Begin
MB := Params.Metabase;
DimInst := MB.ItemById["DIM"].Open(Null) As IDimInstance;
OrderSetup := DimInst.NewElementsOrderSetup();
AttrInst := DimInst.Attributes.Item[1];
Attribute := AttrInst.Attribute;
// Add attribute to the sorting list
OrderSetup.Add(Attribute, False);
System.Diagnostics.Debug.WriteLine("Number of sorting attributes: " + OrderSetup.Count);
System.Diagnostics.Debug.WriteLine("Sorting by attribute " + Attribute.Name + ", attribute key: "
+ OrderSetup.AttributeKey(0));
// Get iterator for a tree built with taking sorting into account
Iterator := DimInst.ElementsByOrder[OrderSetup];
// Determine sorting order
If OrderSetup.ReverseOrder[0] Then
System.Diagnostics.Debug.WriteLine("Descending sorting");
Else
System.Diagnostics.Debug.WriteLine("Ascending sorting");
End If;
// Display dictionary elements taking sorting into account
While Iterator.HasNext() >= 0 Do
System.Diagnostics.Debug.WriteLine(DimInst.Elements.AttributeValueO[Iterator.GetElement(), AttrInst]);
// If element has owner, display owner index
If Iterator.GetParent() >= 0 Then
System.Diagnostics.Debug.WriteLine("Element owner index: " + Iterator.GetParent());
End If;
End While;
// Move to the iterator beginning
Iterator.ResetIterator();
End Sub;
See also: