Executing the example requires that the repository contains time series database with the TSDB identifier.
After executing the example the console displays keys of time series attributes included in the time series database hierarchy.
Add links to the Cubes, Metabase, Orm, Rds system assemblies.
Sub MetaMembersKey;
Var
mb: IMetabase;
Rubricator: IRubricator;
Facts: IMetaDictionary;
pHierarchy: IMetaHierarchy;
pHierarchyAttributes: IMetaHierarchyAttributes;
pLevel: IMetaHierarchyLevel;
Members: IMetaMembers;
FactsInst: IMetaDictionaryInstance;
i, ind: Integer;
AtrSet: IMetaAttributesSet;
Attr: IMetaAttribute;
cur: IMetaMember;
id, name: String;
Tuple: IOrmRecord;
Begin
// Get repository
mb := MetabaseClass.Active;
// Get time series database
Rubricator := mb.ItemById("TSDB").Bind As IRubricator;
// Get time series dictionary
Facts := Rubricator.Facts;
// Get time series hierarchy
pHierarchy := Facts.DefaultHierarchy;
// Get attributes included in the hierarchy
pHierarchyAttributes := pHierarchy.Attributes;
// Get hierarchy sheet level
pLevel := pHierarchy.Levels.Leaf;
// Set that level does not include all elements
pLevel.IncludeAll := False;
// Move all hierarchy attributes to the sheet level
pHierarchyAttributes.MoveAllTo(pHierarchyAttributes, pLevel);
// Get instance of the rime series dictionary
FactsInst := (Facts As IMetabaseObject).Open(Null) As IMetaDictionaryInstance;
// Get root elements of time series hierarchy
Members := FactsInst.OpenHierarchy(pHierarchy).GetRootMembers;
If Members <> Null Then
// Reset current cursor position in the hierarchy
Members.Reset;
// Get current hierarchy element
Cur := Members.Current;
Debug.WriteLine("Values of time series attributes:");
// Look over all hierarchy elements
While Not Members.Eof Do
Debug.WriteLine("");
// Get hierarchy element attributes
AtrSet := Cur.Attributes;
// Look over hierarchy element attributes
For i := 0 To AtrSet.Count - 1 Do
// Get current attribute
Attr := AtrSet.Item(i);
// Get identifier and name of the attribute
id := Attr.Id;
name := Attr.Name;
// Get system record corresponding to current hierarchy element
Tuple := cur.Tuple;
// Get attribute index
ind := Tuple.FindAttribute(id);
// Get attribute value and display it to the console
Debug.WriteLine(name + " = " + Tuple.AttributeValue(ind));
End For;
// Go to the next hierarchy element
Members.Next;
End While;
End If;
End Sub MetaMembersKey;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Orm;
Imports Prognoz.Platform.Interop.Rds;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
Rubricator: IRubricator;
Facts: IMetaDictionary;
pHierarchy: IMetaHierarchy;
pHierarchyAttributes: IMetaHierarchyAttributes;
pLevel: IMetaHierarchyLevel;
Members: IMetaMembers;
FactsInst: IMetaDictionaryInstance;
i, ind: Integer;
AtrSet: IMetaAttributesSet;
Attr: IMetaAttribute;
cur: IMetaMember;
id, name: String;
Tuple: IOrmRecord;
Begin
// Get repository
mb := Params.Metabase;
// Get time series database
Rubricator := mb.ItemById["TSDB"].Bind() As IRubricator;
// Get time series dictionary
Facts := Rubricator.Facts;
// Get time series hierarchy
pHierarchy := Facts.DefaultHierarchy;
// Get attributes included in the hierarchy
pHierarchyAttributes := pHierarchy.Attributes;
// Get hierarchy sheet level
pLevel := pHierarchy.Levels.Leaf;
// Set that level does not include all elements
pLevel.IncludeAll := False;
// Move all hierarchy attributes to the sheet level
pHierarchyAttributes.MoveAllTo(pHierarchyAttributes, pLevel, -1, False);
// Get instance of the rime series dictionary
FactsInst := (Facts As IMetabaseObject).Open(Null) As IMetaDictionaryInstance;
// Get root elements of time series hierarchy
Members := FactsInst.OpenHierarchy(pHierarchy).GetRootMembers();
If Members <> Null Then
// Reset current cursor position in the hierarchy
Members.Reset();
// Get current hierarchy element
Cur := Members.Current();
System.Diagnostics.Debug.WriteLine("Time series attributes values:");
// Look over all hierarchy elements
While Not Members.Eof() Do
System.Diagnostics.Debug.WriteLine("");
// Get hierarchy element attributes
AtrSet := Cur.Attributes;
// Look over hierarchy element attributes
For i := 0 To AtrSet.Count - 1 Do
// Get current attribute
Attr := AtrSet.Item[i];
// Get identifier and name of the attribute
id := Attr.Id;
name := Attr.Name;
// Get system record corresponding to current hierarchy element
Tuple := cur.Tuple;
// Get attribute index
ind := Tuple.FindAttribute(id);
// Get attribute value and display it to the console
System.Diagnostics.Debug.WriteLine(name + " = " + Tuple.AttributeValue[ind]);
End For;
// Go to the next hierarchy element
Members.Next();
End While;
End If;
End Sub;
See also: