Create(Type: EtlObjectType): IEtlObject;
Type. Type of ETL task object.
The Create method creates an ETL task object. Object type is passed by the Type parameter.
To execute the example, add links to the system assemblies:
Andy.
Drawing.
Dt.
Etl.
Metabase.
Executing the example requires that the repository contains a folder with the ETLTASKS identifier and the data.xls file on the local drive, from which data is imported. Create a new ETL task in the folder with the specified identifier. Add the task to the Import from Excel object.
Sub Main;
Var MB: IMetabase;
ci: IMetabaseObjectCreateInfo;
MbObj: IMetabaseObject;
EtlTask: IEtlTask;
EtlProvider: IEtlPlainDataProvider;
ExcelProvider: IDtExcelProvider;
WxConsumer: IWxRectangle;
WxETLConsumer: IWxEtlObject;
Begin
MB := MetabaseClass.Active;
//Create a new ETL task
ci := Mb.CreateCreateInfo;
ci.ClassId := MetabaseObjectClass.KE_CLASS_ETLTASK;
ci.Parent := MB.ItemById( "ETLTASKS" );
ci.Name := "ETL task" ;
ci.Id := "ETLTASK" ;
MbObj := Mb.CreateObject(ci).Edit;
EtlTask := MbObj As IEtlTask;
//Create the Import from Excel object
EtlProvider := EtlTask.Create(EtlObjectType.PlainDataExcelProvider) As IEtlPlainDataProvider;
EtlProvider := EtlProvider.Edit;
EtlProvider.Id := "File_XLS" ;
EtlProvider.Name := XLS data source ;
EtlProvider.Description := Data from the data.xls file ;
//Set up data source
ExcelProvider := EtlProvider.Provider As IDtExcelProvider;
ExcelProvider.File := "c:\data.xls" ;
ExcelProvider.DriverVersion := "Excel 8.0" ;
ExcelProvider.Query := select * from [Sheet1$] ;
ExcelProvider.HasHeader := False ;
EtlProvider.FillDefault;
//Save Excel source
EtlProvider.Save;
//Create a visual object
WxConsumer := EtlTask.Workspace.CreateRectangle;
WxETLConsumer := New WxEtlObject.Create;
WxETLConsumer.EtlObject := EtlProvider;
WxConsumer.Style.TextPosition := WxTextPosition.Bottom;
WxConsumer.Style.PictureMarginTop := - 10 ;
WxConsumer.PinPosition := New GxPointF.Create(50, 50 );
WxConsumer.Extension := WxETLConsumer As IWxShapeExtension;
//Save repository object
MbObj.Save;
End Sub Main;
After executing the example an ETL task named EYL Task is created in the folder with the ETLTASKS identifier. The Import from Excel object with the FILE_XLS identifier is added to this ETL task, data is taken from the c:\data.xls file.
The specified procedure is the Main entry point in the Program unit of the .NET assembly. The Andy, Drawing, Dt, Etl and Metabase system assemblies must be imported to this unit from the Prognoz.Platform.Interop system assembly.
Executing the example requires that the repository contains a folder with the ETLTASKS identifier and the data.xls file on the local drive, from which data is imported. Create a new ETL task in the folder with the specified identifier. Add the task to the Import from Excel object.
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
ci: IMetabaseObjectCreateInfo;
MbObj: IMetabaseObject;
EtlTask: IEtlTask;
EtlProvider: IEtlPlainDataProvider;
ExcelProvider: IDtExcelProvider;
WxConsumer: IWxRectangle;
WxETLConsumer: IWxEtlObject;
Point: GxPointFClass;
Begin
MB := Params.Metabase;
//Create a new ETL task
ci := Mb.CreateCreateInfo();
ci.ClassId := MetabaseObjectClass.KE_CLASS_ETLTASK As integer; ;
ci.Parent := MB.ItemById["ETLTASKS"];
ci.Name := ETL task;
ci.Id := "ETlTASK";
MbObj := Mb.CreateObject(ci).Edit();
EtlTask := MbObj As IEtlTask; //Create the Import from Excel object
EtlProvider := EtlTask.Create(EtlObjectType.eotPlainDataExcelProvider) As IEtlPlainDataProvider;
EtlProvider := EtlProvider.Edit();
EtlProvider.Id := "File_XLS";
EtlProvider.Name := XLS data source;
EtlProvider.Description := Data from the data.xls file;
//Set up data source
ExcelProvider := EtlProvider.Provider As IDtExcelProvider;
ExcelProvider.File := "c:\data.xls" ;
ExcelProvider.DriverVersion := "Excel 8.0";
ExcelProvider.Query := select * from [Sheet1$];
ExcelProvider.HasHeader := False;
EtlProvider.FillDefault();
//Save Excel source
EtlProvider.Save();
//Create a visual object
WxConsumer := EtlTask.Workspace.CreateRectangle();
WxETLConsumer := New WxEtlObject.Create();
WxETLConsumer.EtlObject := EtlProvider;
WxConsumer.Style.TextPosition := WxTextPosition.wtpBottom;
WxConsumer.Style.PictureMarginTop := -10;
Point := New GxPointFClass();
Point.Create(50, 50);
WxConsumer.PinPosition := Point;
WxConsumer.Extension := WxETLConsumer As IWxShapeExtension;
//Save repository object
MbObj.Save();
End Sub;
The result of example execution matches with that of the Fore Example.
See also: