ReadAttachments(Iterator: IMatrixModelIterator): ICubeAttachments;
Iterator. Iterator of matrix with attachments.
The ReadAttachments method returns the collection of attachments saved in cube.
The method returns the values that are available for the current iterator position. Obtained attachments will be read-only. To edit attachments, use the EditAttachments method.
Executing the example requires that the repository contains a standard cube with the STD_CUBE identifier. Facts binding is set up in cube to store attachments. Attachments are saved by any cube coordinates.
Add links to the Cubes, Dal, Dimensions, Matrix, and Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
CubeInst: ICubeInstance;
Dest: ICubeInstanceDestination;
Sels: IDimSelectionSet;
Sel: IDimSelection;
Exec: ICubeInstanceDestinationExecutor;
Mat: IMatrix;
MatEx: IMatrixEx;
Ite: IMatrixIterator;
ExecResult: ICubeExecuteResult;
Manager: ICubeAttachmentManager;
Ats: ICubeAttachments;
At: ICubeAttachment;
NameAttributeKey: Integer;
i: integer;
Begin
MB := MetabaseClass.Active;
CubeInst := MB.ItemById("STD_CUBE").Open(Null) As ICubeInstance;
Dest := CubeInst.Destinations.DefaultDestination;
//Cube selection
Sels := Dest.CreateDimSelectionSet;
For Each Sel In Sels Do
Sel.SelectAll;
End For;
Exec := Dest.CreateExecutor;
Exec.IncludeAttachments := True;
Exec.PrepareExecute(Sels);
Exec.PerformExecute;
Mat := Exec.Matrix;
//Resulting cube matrix
MatEx := Mat As IMatrixEx;
If MatEx.AttachmentValueIndex < 0 Then
Debug.WriteLine("AttachmentValueIndex <0. Aborted ");
Return;
End If;
ExecResult := CubeClass.ExecuteResult(Mat);
//Manager to work with cube attachments
Manager := ExecResult.CreateAttachmentManager;
//Matrix iterator
Ite := Mat.CreateIterator;
Ite.Move(IteratorDirection.First);
While Ite.Valid Do
//Attachments by the current coordinate
Ats := Manager.ReadAttachments(Ite);
If Ats <> Null Then
Debug.WriteLine("There is attachment. The number = " + Ats.Count.ToString);
NameAttributeKey := Ats.Attributes.FindById("Name").Key;
For i := 0 To Ats.Count - 1 Do
At := Ats.Item(i);
Debug.WriteLine("Key= " + At.Key.ToString + " Name = " + At.AttributeValueByKey(NameAttributeKey) + " Type = " + At.Type.ToString);
End For;
Else
Debug.WriteLine("No attachments");
End If;
Debug.WriteLine(" ");
Ite.Move(IteratorDirection.Next);
End While;
End Sub UserProc;
On executing the example the resulting cube matrix will be calculated and manager to work with attachments will be obtained. Iterator will be created and traversal of all matrix coordinates will be executed. If attachments are stored by coordinate, information about them (key, name and type) will be displayed in the development environment console.
See also: