CreateAndSetAttachmentsStorage(Database: IDatabase);
CreateAndSetAttachmentsStorage(Database: Prognoz.Platform.Interop.Db.IDatabase);
Database. Database where table for table MDM dictionary will be created.
The CreateAndSetAttachmentsStorage method creates and sets dictionary to store attachments.
The method creates the table MDM dictionary with predefined structure. Dictionary structure is described in the Cube Facts Binding subsection. Created dictionary is selected as storage location for attachments, its description will be available in the AttachmentsStorage property.
Executing the example requires that the repository contains a standard cube with the STD_CUBE identifier. The cube is set up for work with the source in which structure there is the ATTACHMENT integer field.
Add links to the Cubes, Db, Dimensions and Metabase system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
Cube: IStandardCube;
Dest: IStandardCubeDestination;
DataSet: IStandardCubeDataset;
FactDimInst: IDimInstance;
KeyAttribute: IDimAttributeInstance;
Binding: IStandardCubeFactBinding;
Begin
Mb := MetabaseClass.Active;
Cube := Mb.ItemById("STD_CUBE").Edit As IStandardCube;
Dest := Cube.Destinations.Item(0);
DataSet := Dest.Datasets.Item(0);
//Create dictionary to store attachments
Dest.CreateAndSetAttachmentsStorage(DataSet.Dataset.Database);
//Set up facts binding
FactDimInst := Dest.FactDimension.OpenDimension;
KeyAttribute := FactDimInst.Attributes.FindById("KEY");
Binding := Dest.FactBindings(DataSet).BindingWithRole(KeyAttribute.Value(0), CubeFactBindingRole.Attachment);
Binding.Formula.AsString := (DataSet.Dataset As IMetabaseObject).Id + ".ATTACHMENT";
//Save cube
(Cube As IMetabaseObject).Save;
End Sub UserProc;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Db;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Metabase;
Public Shared Sub Main(Params: StartParams);
Var
Mb: IMetabase;
Cube: IStandardCube;
Dest: IStandardCubeDestination;
DataSet: IStandardCubeDataset;
FactDimInst: IDimInstance;
KeyAttribute: IDimAttributeInstance;
Binding: IStandardCubeFactBinding;
Begin
Mb := Params.Metabase;
Cube := Mb.ItemById["STD_CUBE"].Edit() As IStandardCube;
Dest := Cube.Destinations.Item[0];
DataSet := Dest.Datasets.Item[0];
//Create dictionary to store attachments
Dest.CreateAndSetAttachmentsStorage(DataSet.Dataset.Database);
//Set up facts binding
FactDimInst := Dest.FactDimension.OpenDimension;
KeyAttribute := FactDimInst.Attributes.FindById("KEY");
Binding := Dest.FactBindings[DataSet].BindingWithRole[KeyAttribute.Value[0], CubeFactBindingRole.cfbrAttachment];
Binding.Formula.AsString := (DataSet.Dataset As IMetabaseObject).Id + ".ATTACHMENT";
//Save cube
(Cube As IMetabaseObject).Save();
End Sub;
On executing the example, table MDM dictionary to store attachments will be created for cube. For the first fact the binding with the source filed by which elements keys in dictionary of attachments will be stored will be set up.
See also: