ICubeMetaExporterBinding.DateFormatEx

Fore Syntax

DateFormatEx(Level: DimCalendarLevel): String;

Fore.NET Syntax

DateFormatEx[Level: Prognoz.Platform.Interop.Dimensions.DimCalendarLevel]: String;

Parameters

Level. The calendar level, for which format is set.

Description

The DateFormatEx property determines date format for several calendar dimension levels.

Comments

To specify date format for several levels, consequently specify them using this property. For example, the code for specifying annual and quarterly frequency format:

Sub UserProc;
Var

    Binding: ICubeMetaExporterBinding;
Begin

    Binding.CalendarDateFormatEx(DimCalendarLevel.Year) := "$Year$";
    Binding.CalendarDateFormatEx(DimCalendarLevel.Quarter) := "$Year$Q$Quarter$";

End Sub UserProc;

Fore Example

Executing the example requires that the repository contains a time series database with the TSDB identifier. This time series database must have annual and quarterly frequencies and a custom time series attribute with the INDICATOR identifier.

Add links to the Cubes, Dal, Dimensions, Dt, Metabase system assemblies.

Sub UserProc;
Var
    TextConsumer: IDtTextConsumer;
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    RubDescr: IMetabaseObjectDescriptor;
    ObjDesc: IMetabaseObjectDescriptor;
    Obj: IMetabaseObject;
    ExportRequestDef: IExportRequestDefinition;
    RequestParams: IExportRequestParams;
    Rubr: IRubricator;
    Binding: ICubeMetaExporterBinding;
    ExportRequestInst: IExportRequestInstance;
Begin
    // Get current repository
    MB := MetabaseClass.Active;
    // Create a text data consumer
    TextConsumer := New DtTextConsumer.Create;
    TextConsumer.File := "C:\result.txt";
    TextConsumer.FormatType := DtTextFormatType.Delimited;
    TextConsumer.DelimitedColumnDelimiter := ";";
    TextConsumer.DelimitedTextQualifier := """";
    TextConsumer.Encoding := "WIN";
    TextConsumer.WriteHeader := True;
    TextConsumer.Metabase := MB;
    // Get time series database
    RubDescr := MB.ItemById("TSDB");
    // Create an export object
    CrInfo := MB.CreateCreateInfo;
    CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_EXPORTREQUEST;
    CrInfo.Id := MB.GenerateId("OBJ_EXPORTREQUEST", RubDescr.Key);
    CrInfo.Permanent := True;
    CrInfo.Parent := RubDescr;
    ObjDesc := MB.CreateObject(CrInfo);
    Obj := ObjDesc.Edit;
    // Set export parameters
    ExportRequestDef := Obj As IExportRequestDefinition;
    RequestParams := ExportRequestDef.Exporter;
    // Specify time series database, which data will be exported
    Rubr := RubDescr.Bind As IRubricator;
    RequestParams.Rubricator := Rubr;
    // Specify data consumer
    RequestParams.Consumer := TextConsumer As IDtConsumer;
    // Specify that consumer must be cleared before export
    RequestParams.ClearBeforeExport := True;
    // Set export parameters for the INDICATOR attribute
    Binding := RequestParams.Bindings.Add;
    Binding.FieldName := "IndicatorKey";
    Binding.DataType := DbDataType.Integer;
    Binding.BindingType := CubeMetaExporterBindingType.Attribute;
    Binding.Attribute := "INDICATOR";
    Binding.KeyField := "KEY";
    // Set date export parameters
    Binding := RequestParams.Bindings.Add;
    Binding.FieldName := "Date";
    Binding.DataType := DbDataType.String;
    Binding.BindingType := CubeMetaExporterBindingType.Calendar;
    Binding.ValueFieldName := "Value";
    Binding.ValueDataType := DbDataType.Float;
    // Set date export format
    Binding.DateFormatEx(DimCalendarLevel.Year) := "$Year$";
    Binding.DateFormatEx(DimCalendarLevel.Quarter) := "$Year$Q$Quarter$";
    // Set exported calendar levels
    RequestParams.CalendarLevelSet := DimCalendarLevelSet.Year Or DimCalendarLevelSet.Quarter;
    // Create a calculated field for export
    Binding := RequestParams.Bindings.Add;
    Binding.FieldName := "CalcField";
    Binding.DataType := DbDataType.Float;
    Binding.BindingType := CubeMetaExporterBindingType.Calculated;
    Binding.Expression := "Value * 1.25";
    // Save export object
    Obj.Save;
    // Execute export
    ExportRequestInst := ObjDesc.OpenWithParam(NullAs IExportRequestInstance;
    ExportRequestInst.Export;
End Sub UserProc;

After executing the example, annual and quarterly values and values of the INDICATOR attribute are loaded from time series database to the C:\result.txt file. The CalcField calculated field is also created that contains annual and quarterly values 1.25 times increased.

Fore.NET Example

The requirements and result of the 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;
    RubDescr: IMetabaseObjectDescriptor;
    ObjDesc: IMetabaseObjectDescriptor;
    Obj: IMetabaseObject;
    ExportRequestDef: IExportRequestDefinition;
    RequestParams: IExportRequestParams;
    Rubr: IRubricator;
    Binding: ICubeMetaExporterBinding;
    ExportRequestInst: IExportRequestInstance;
Begin
    // Get current repository
    MB := Params.Metabase;
    // Create a text data consumer
    TextConsumer := New DtTextConsumer.Create();
    TextConsumer.File := "C:\result.txt";
    TextConsumer.FormatType := DtTextFormatType.tftDelimited;
    TextConsumer.DelimitedColumnDelimiter := ";";
    TextConsumer.DelimitedTextQualifier := """";
    TextConsumer.Encoding := "WIN";
    TextConsumer.WriteHeader := True;
    TextConsumer.Metabase := MB;
    // Get time series database
    RubDescr := MB.ItemById["TSDB"];
    // Create an export object
    CrInfo := MB.CreateCreateInfo();
    CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_EXPORTREQUEST As integer;
    CrInfo.Id := MB.GenerateId("OBJ_EXPORTREQUEST", RubDescr.Key);
    CrInfo.Permanent := True;
    CrInfo.Parent := RubDescr;
    ObjDesc := MB.CreateObject(CrInfo);
    Obj := ObjDesc.Edit();
    // Set export parameters
    ExportRequestDef := Obj As IExportRequestDefinition;
    RequestParams := ExportRequestDef.Exporter;
    // Specify time series database, which data will be exported
    Rubr := RubDescr.Bind() As IRubricator;
    RequestParams.Rubricator := Rubr;
    // Specify data consumer
    RequestParams.Consumer := TextConsumer As IDtConsumer;
    // Specify that data consumer must be cleared before export
    RequestParams.ClearBeforeExport := True;
    // Set export parameters for the INDICATOR attribute
    Binding := RequestParams.Bindings.Add();
    Binding.FieldName := "IndicatorKey";
    Binding.DataType := DbDataType.ddtInteger;
    Binding.BindingType := CubeMetaExporterBindingType.cmebtAttribute;
    Binding.Attribute := "INDICATOR";
    Binding.KeyField := "KEY";
    // Set date export parameters
    Binding := RequestParams.Bindings.Add();
    Binding.FieldName := "Date";
    Binding.DataType := DbDataType.ddtString;
    Binding.BindingType := CubeMetaExporterBindingType.cmebtCalendar;
    Binding.ValueFieldName := "Value";
    Binding.ValueDataType := DbDataType.ddtFloat;
    // Set date export format
    Binding.DateFormatEx[DimCalendarLevel.dclYear] := "$Year$";
    Binding.DateFormatEx[DimCalendarLevel.dclQuarter] := "$Year$Q$Quarter$";
    // Set exported calendar levels
    RequestParams.CalendarLevelSet := DimCalendarLevelSet.dclsYear Or DimCalendarLevelSet.dclsQuarter;
    // Create a calculated field for export
    Binding := RequestParams.Bindings.Add();
    Binding.FieldName := "CalcField";
    Binding.DataType := DbDataType.ddtFloat;
    Binding.BindingType := CubeMetaExporterBindingType.cmebtCalculated;
    Binding.Expression := "Value * 1.25";
    // Save export object
    Obj.Save();
    // Execute export
    ExportRequestInst := ObjDesc.OpenWithParam(NullAs IExportRequestInstance;
    ExportRequestInst.Export();
End Sub;

See also:

ICubeMetaExporterBinding