UsePredefinedDateFormats: Boolean;
UsePredefinedDateFormats: Boolean;
The UsePredefinedDateFormats property determines the use of the field date format predefinition according to the specified format using the IDtFieldDefinition.DateFormat property.
Available values of the property:
False (by default). Predefinition of field date format is not used.
True. Use the field date format predefinition.
Executing the example requires that the repository contains an ETL task with the ETL identifier. There is also the Data_Import.txt text file located in the C:\Temp\Data_Import folder.
Add links to the Andy, Dal, Drawing, Dt, Etl, Forms and Metabase system assemblies.
<font color="#008080">Sub</font><font color="#000000"> UserProc;<br /> </font><font color="#008080">Var</font><font color="#000000"><br /> MB: IMetabase;<br /> EtlTask: IEtlTask;<br /> EtlProvider: IEtlPlainDataProvider;<br /> TextProvider: IDtTextProvider;<br /> DateFormat: IDtObjectDataFormat;<br /> WxProvider: IWxRectangle;<br /> WxETLProvider: IWxETLObject;<br /> </font><font color="#008080">Begin</font><font color="#000000"><br /> MB := MetabaseClass.Active;<br /> EtlTask := MB.ItemById(</font><font color="#800000">"ETL"</font><font color="#000000">).Edit </font><font color="#008080">As</font><font color="#000000"> IEtlTask;<br /> </font><font color="#008000">//Create object "Import from text"<br /> </font><font color="#000000"> EtlProvider := EtlTask.Create(EtlObjectType.PlainDataTextProvider) </font><font color="#008080">As</font><font color="#000000"> IEtlPlainDataProvider;<br /> EtlProvider := EtlProvider.Edit;<br /> EtlProvider.Id := </font><font color="#800000">"Data_Import"</font><font color="#000000">;<br /> EtlProvider.Name := </font><font color="#800000">"Data_Import"</font><font color="#000000">;<br /> EtlProvider.Description := </font><font color="#800000">"Data_Import"</font><font color="#000000">;<br /> </font><font color="#008000">//Set up data provider<br /> </font><font color="#000000"> TextProvider := EtlProvider.Provider </font><font color="#008080">As</font><font color="#000000"> IDtTextProvider;<br /> TextProvider.File := </font><font color="#800000">"C:\Temp\Data_Import.txt"</font><font color="#000000">;<br /> DateFormat := TextProvider.StringDataFormat;<br /> DateFormat.UsePredefinedDateFormats := </font><font color="#008080">True</font><font color="#000000">;</font><font color="#008000"><br /> </font><font color="#000000"> TextProvider.FieldsFromFile;<br /> TextProvider.Fields.item(</font><font color="#008000">0</font><font color="#000000">).DateFormat := </font><font color="#800000">"$Year$A$Quarter$"</font><font color="#000000">;<br /> TextProvider.Fields.item(</font><font color="#008000">0</font><font color="#000000">).DataType := dbdatatype.Date;<br /> TextProvider.Fields.item(</font><font color="#008000">1</font><font color="#000000">).DateFormat := </font><font color="#800000">"$Year$M$Quarter$"</font><font color="#000000">;<br /> TextProvider.Fields.item(</font><font color="#008000">1</font><font color="#000000">).DataType := dbdatatype.Date;<br /> TextProvider.Fields.item(</font><font color="#008000">2</font><font color="#000000">).DateFormat := </font><font color="#800000">"$Year$$Month$$Day$"</font><font color="#000000">;<br /> TextProvider.Fields.item(</font><font color="#008000">2</font><font color="#000000">).DataType := dbdatatype.Date;<br /> EtlProvider.FillDefault;<br /> </font><font color="#008000">//Save provider<br /> </font><font color="#000000"> EtlProvider.Save;<br /> </font><font color="#008000">//Create visual object<br /> </font><font color="#000000"> WxProvider := EtlTask.Workspace.CreateRectangle;<br /> WxETLProvider := </font><font color="#008080">New</font><font color="#000000"> WxETLObject.Create;<br /> WxETLProvider.ETLObject := EtlProvider;<br /> WxProvider.Style.TextPosition := WxTextPosition.Bottom;<br /> WxProvider.Style.PictureMarginTop := -</font><font color="#008000">10</font><font color="#000000">;<br /> WxProvider.PinPosition := </font><font color="#008080">New</font><font color="#000000"> GxPointF.Create(</font><font color="#008000">50</font><font color="#000000">, </font><font color="#008000">50</font><font color="#000000">);<br /> WxProvider.Extension := WxETLProvider </font><font color="#008080">As</font><font color="#000000"> IWxShapeExtension;<br /> </font><font color="#008000">//Save task Etl<br /> </font><font color="#000000"> (EtlTask </font><font color="#008080">As</font><font color="#000000"> IMetabaseObject).Save;<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000"> UserProc;</font>
Imports Prognoz.Platform.Interop.Andy;
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Dt;
Imports Prognoz.Platform.Interop.Etl;
Imports Prognoz.Platform.Interop.Forms;
Imports Prognoz.Platform.Interop.Metabase;
<font color="#008080">Public</font><font color="#000000"> </font><font color="#008080">Shared</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000"> Main(Params: StartParams);<br /> </font><font color="#008080">Var</font><font color="#000000"><br /> MB: IMetabase;<br /> EtlTask: IEtlTask;<br /> EtlProvider: IEtlPlainDataProvider;<br /> TextProvider: IDtTextProvider;<br /> DateFormat: IDtObjectDataFormat;<br /> WxProvider: IWxRectangle;<br /> WxETLProvider: IWxETLObject;<br /> OutPoint: GxPointF = </font><font color="#008080">New</font><font color="#000000"> GxPointFClass();<br /> </font><font color="#008080">Begin</font><font color="#000000"><br /> MB := Params.Metabase;<br /> EtlTask := MB.ItemById[</font><font color="#800000">"ETL"</font><font color="#000000">].Edit() </font><font color="#008080">As</font><font color="#000000"> IEtlTask;<br /> </font><font color="#008000">//Create an object "Import from Text"<br /> </font><font color="#000000"> EtlProvider := EtlTask.Create(EtlObjectType.eotPlainDataTextProvider) </font><font color="#008080">As</font><font color="#000000"> IEtlPlainDataProvider;<br /> EtlProvider := EtlProvider.Edit();<br /> EtlProvider.Id := </font><font color="#800000">"Data_Import"</font><font color="#000000">;<br /> EtlProvider.Name := </font><font color="#800000">"Data_Import"</font><font color="#000000">;<br /> EtlProvider.Description := </font><font color="#800000">"Data_Import"</font><font color="#000000">;<br /> </font><font color="#008000">//Set up data provider<br /> </font><font color="#000000"> TextProvider := EtlProvider.Provider </font><font color="#008080">As</font><font color="#000000"> IDtTextProvider;<br /> TextProvider.File := </font><span><font color="#800000">"C:\Temp\Data_Import.txt"</font></span><font color="#000000">;<br /> DateFormat := TextProvider.StringDataFormat;<br /> DateFormat.UsePredefinedDateFormats := </font><font color="#008080">True</font><font color="#000000">;<br /> </font><font color="#008000">//DateFormat.DateFormat := "$Day$M$Month$Q$Year$";<br /> </font><font color="#000000"> TextProvider.FieldsFromFile();<br /> TextProvider.Fields.item[</font><font color="#008000">0</font><font color="#000000">].DateFormat := </font><font color="#800000">"$Year$A$Quarter$"</font><font color="#000000">;<br /> TextProvider.Fields.item[</font><font color="#008000">0</font><font color="#000000">].DataType := dbdatatype.ddtDate;<br /> TextProvider.Fields.item[</font><font color="#008000">1</font><font color="#000000">].DateFormat := </font><font color="#800000">"$Year$M$Quarter$"</font><font color="#000000">;<br /> TextProvider.Fields.item[</font><font color="#008000">1</font><font color="#000000">].DataType := dbdatatype.ddtDate;<br /> TextProvider.Fields.item[</font><font color="#008000">2</font><font color="#000000">].DateFormat := </font><font color="#800000">"$Year$Month$Day$"</font><font color="#000000">;<br /> TextProvider.Fields.item[</font><font color="#008000">2</font><font color="#000000">].DataType := dbdatatype.ddtDate;<br /> EtlProvider.FillDefault();<br /> </font><font color="#008000">//Save provider<br /> </font><font color="#000000"> EtlProvider.Save();<br /> </font><font color="#008000">//Create a visual object<br /> </font><font color="#000000"> WxProvider := EtlTask.Workspace.CreateRectangle();<br /> WxETLProvider := </font><font color="#008080">New</font><font color="#000000"> WxETLObject.Create();<br /> WxETLProvider.ETLObject := EtlProvider;<br /> WxProvider.Style.TextPosition := WxTextPosition.wtpBottom;<br /> WxProvider.Style.PictureMarginTop := -</font><font color="#008000">10</font><font color="#000000">;<br /> OutPoint := WxProvider.PinPosition;<br /> OutPoint.Create(</font><font color="#008000">50</font><font color="#000000">, </font><font color="#008000">50</font><font color="#000000">);<br /> WxProvider.Extension := WxETLProvider </font><font color="#008080">As</font><font color="#000000"> IWxShapeExtension;<br /> </font><font color="#008000">//Save Etl task<br /> </font><font color="#000000"> (EtlTask </font><font color="#008080">As</font><font color="#000000"> IMetabaseObject).Save();<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000">;</font>
On executing the example a new data provider will be created in ETL task - Import from text. The provider will be linked to the specified text file, various formats will be preconfigured to parse dates in various fields. As a result of import, the following values will be obtained:
See also: