Bindings: ICubeMetaExporterBindings;
Bindings: Prognoz.Platform.Interop.Cubes.ICubeMetaExporterBindings;
The Bindings property determines bindings of attributes of the time series database with data consumer fields.
To determine the exported time series database, use the IExportRequestParams.Rubricator property.
Executing the example requires a time series database with the TSDB identifier. This database must contain an attribute of the time series with the COUNTRY identifier that refers to a dictionary.
Add links to the Cubes, Dal, Dimensions, Dt, Metabase system assemblies.
Sub UserProc;
Var
TextConsumer: IDtTextConsumer;
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
ObjDesc: IMetabaseObjectDescriptor;
Obj: IMetabaseObject;
ExportRequestDef: IExportRequestDefinition;
Params: IExportRequestParams;
Binding: ICubeMetaExporterBinding;
Filter: ICubeMetaExporterFilter;
FilterValues: Array;
ExportRequestInst: IExportRequestInstance;
Begin
// Data successor to export to the textual format
TextConsumer := New DtTextConsumer.Create;
TextConsumer.File := "C:\result.txt";
TextConsumer.FormatType := DtTextFormatType.Delimited;
TextConsumer.DelimitedColumnDelimiter := ";";
TextConsumer.DelimitedTextQualifier := """";
TextConsumer.Encoding := "WIN";
TextConsumer.WriteHeader := True;
// Export object
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_EXPORTREQUEST;
CrInfo.Id := MB.GenerateId("OBJ_EXPORTREQUEST");
CrInfo.Permanent := True;
CrInfo.Parent := MB.ItemById("TSDB").Bind;
ObjDesc := MB.CreateObject(CrInfo);
Obj := ObjDesc.Edit;
ExportRequestDef := Obj As IExportRequestDefinition;
// Export parameters
Params := ExportRequestDef.Exporter;
Params.Rubricator := MB.ItemById("TSDB").Bind As IRubricator;
Params.Consumer := TextConsumer As IDtConsumer;
Params.ClearBeforeExport := True;
// Binding of COUNTRY attribute
Binding := Params.Bindings.Add;
Binding.FieldName := "CountryNm";
Binding.DataType := DbDataType.String;
Binding.BindingType := CubeMetaExporterBindingType.Attribute;
Binding.Attribute := "COUNTRY";
Binding.KeyField := "NAME";
// Calendar binding
Binding := Params.Bindings.Add;
Binding.FieldName := "Year";
Binding.DataType := DbDataType.String;
Binding.BindingType := CubeMetaExporterBindingType.Calendar;
Binding.DateFormat := "$Year$";
Binding.ValueFieldName := "Value";
Binding.ValueDataType := DbDataType.Float;
// Filtration parameters
Params.ByColumns := True;
Params.PeriodStart := DateTime.Parse("01.01.2000");
Params.PeriodEnd := DateTime.Parse("01.01.2008");
Params.CalendarLevel := DimCalendarLevel.Year;
Params.RowCount := 1000;
Filter := Params.Filters.Add;
Filter.Attribute := "COUNTRY";
FilterValues := New Variant[2];
FilterValues[0] := 512;
FilterValues[1] := 914;
Filter.ValuesList := FilterValues;
Obj.Save;
// Export
ExportRequestInst := (ExportRequestDef As IMetabaseObjectDescriptor).OpenWithParam(Null) As IExportRequestInstance;
ExportRequestInst.Export;
End Sub UserProc;
After executing the example the data of the time series will be exported to the C:\result.txt file by the following parameters:
The data of the time series is exported if the value of the COUNTRY attribute is equal to 512 or 914.
Export period: from 2000 to 2008 year.
Not more than 1000 strings will be exported.
The file consumer is cleared before the export.
The requirements and result of Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Dt;
…
Public Shared Sub Main(Params: StartParams);
Var
TextConsumer: IDtTextConsumer;
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
ObjDesc: IMetabaseObjectDescriptor;
Obj: IMetabaseObject;
ExportRequestDef: IExportRequestDefinition;
ExpParams: IExportRequestParams;
Binding: ICubeMetaExporterBinding;
Filter: ICubeMetaExporterFilter;
FilterValues: Array;
ExportRequestInst: IExportRequestInstance;
Begin
// Data successor to export to the textual format
TextConsumer := New DtTextConsumer.Create();
TextConsumer.File := "C:\result.txt";
TextConsumer.FormatType := DtTextFormatType.tftDelimited;
TextConsumer.DelimitedColumnDelimiter := ";";
TextConsumer.DelimitedTextQualifier := """";
TextConsumer.Encoding := "WIN";
TextConsumer.WriteHeader := True;
// Export object
MB := Params.Metabase;
CrInfo := MB.CreateCreateInfo();
CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_EXPORTREQUEST As integer;
CrInfo.Parent := MB.ItemById["TSDB"].Bind();
CrInfo.Id := MB.GenerateId("OBJ_EXPORTREQUEST", CrInfo.Parent.Key);
CrInfo.Permanent := True;
ObjDesc := MB.CreateObject(CrInfo);
Obj := ObjDesc.Edit();
ExportRequestDef := Obj As IExportRequestDefinition;
// Export parameters
ExpParams := ExportRequestDef.Exporter;
ExpParams.Rubricator := MB.ItemById["TSDB"].Bind() As IRubricator;
ExpParams.Consumer := TextConsumer As IDtConsumer;
ExpParams.ClearBeforeExport := True;
// Binding of COUNTRY attribute
Binding := ExpParams.Bindings.Add();
Binding.FieldName := "CountryNm";
Binding.DataType := DbDataType.ddtString;
Binding.BindingType := CubeMetaExporterBindingType.cmebtAttribute;
Binding.Attribute := "COUNTRY";
Binding.KeyField := "NAME";
// Calendar binding
Binding := ExpParams.Bindings.Add();
Binding.FieldName := "Year";
Binding.DataType := DbDataType.ddtString;
Binding.BindingType := CubeMetaExporterBindingType.cmebtCalendar;
Binding.DateFormat := "$Year$";
Binding.ValueFieldName := "Value";
Binding.ValueDataType := DbDataType.ddtFloat;
// Filtration parameters
ExpParams.ByColumns := True;
ExpParams.PeriodStart := DateTime.Parse("01.01.2000");
ExpParams.PeriodEnd := DateTime.Parse("01.01.2008");
ExpParams.CalendarLevel := DimCalendarLevel.dclYear;
ExpParams.RowCount := 1000;
Filter := ExpParams.Filters.Add();
Filter.Attribute := "COUNTRY";
FilterValues := New object[2];
FilterValues[0] := 512;
FilterValues[1] := 914;
Filter.ValuesList := FilterValues;
Obj.Save();
// Export
ExportRequestInst := (ExportRequestDef As IMetabaseObjectDescriptor).OpenWithParam(Null) As IExportRequestInstance;
ExportRequestInst.Export();
End Sub;
See also: