UserData: IXmlDomElement;
UserData: Prognoz.Platform.Interop.MsXml2.IXmlDomElement;
The UserData property determines additional settings in the XML format for custom data consumer.
Advanced settings are set in the IDtRecordsetUserData interface of the class which implements this interface and the IDtRecordsetConsumer interface.
Features of work with the XML files are presented on theExample of Working with XML Files page.
Executing the example requires that the repository have:
ETL task with the ETL identifier
Module with the MYCONSUMER identifier. The module contains class implementing the IDtRecordsetConsumer, IDtRecordsetUserData interfaces. The example of the IDtRecordsetUserData interface use is given in description of IDtRecordsetUserData.UserData.
Add links to the Andy, Dal, Drawing, Dt, Etl, Metabase, Xml system assemblies.
Sub UserProc;
Var
MB: IMetabase;
EtlTask: IEtlTask;
EtlConsumer: IEtlPlainDataConsumer;
UserConsumer: IDtUserConsumer;
WxConsumer: IWxRectangle;
WxETLConsumer: IWxETLObject;
Fields: IDtFieldDefinitions;
Field: IDtFieldDefinition;
Begin
// Get repository
MB := MetabaseClass.Active;
// Get ETL task
EtlTask := MB.ItemById("ETL").Edit As IEtlTask;
//Create the User Consumer object in the ETL task
EtlConsumer := EtlTask.Create(EtlObjectType.PlainDataUserConsumer) As IEtlPlainDataConsumer;
EtlConsumer := EtlConsumer.Edit;
EtlConsumer.Id := "User_Consumer";
EtlConsumer.Name := "User consumer";
EtlConsumer.Description := "User consumer";
//Setup data consumer
UserConsumer := EtlConsumer.Consumer As IDtUserConsumer;
UserConsumer.ForeModule := MB.ItemById("MYCONSUMER").Bind;
UserConsumer.ForeClass := "MyConsumer";
Debug.WriteLine("Custom data in the XML format" + UserConsumer.UserData.xml);
Fields := UserConsumer.Fields;
Field := Fields.Add;
Field.DataType := DbDataType.String;
Field.Name := "Name";
Field := Fields.Add;
Field.DataType := DbDataType.Float;
Field.Name := "Value";
EtlConsumer.FillDefault;
//Save settings of data consumer
EtlConsumer.Save;
// Create visual view of the object in the ETL task
WxConsumer := EtlTask.Workspace.CreateRectangle;
WxETLConsumer := New WxETLObject.Create;
WxETLConsumer.ETLObject := EtlConsumer;
WxConsumer.Style.TextPosition := WxTextPosition.Bottom;
WxConsumer.Style.PictureMarginTop := -10;
WxConsumer.PinPosition := New GxPointF.Create(50, 50);
WxConsumer.Extension := WxETLConsumer As IWxShapeExtension;
//Save changes
(EtlTask As IMEtabaseObject).Save;
End Sub UserProc;
After executing the example, custom data consumer basing on specified class is created in the ETL task. The console displays custom data in the XML format.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
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;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
EtlTask: IEtlTask;
EtlConsumer: IEtlPlainDataConsumer;
UserConsumer: IDtUserConsumer;
WxConsumer: IWxRectangle;
WxETLConsumer: WxETLObject = New WxETLObjectClass();
PointF: GxPointF = New GxPointFClass();
Fields: IDtFieldDefinitions;
Field: IDtFieldDefinition;
Begin
// Get repository
MB := Params.Metabase;
// Get ETL task
EtlTask := MB.ItemById["ETL"].Edit() As IEtlTask;
//Create the User Consumer object in the ETL task
EtlConsumer := EtlTask.Create(EtlObjectType.eotPlainDataUserConsumer) As IEtlPlainDataConsumer;
EtlConsumer := EtlConsumer.Edit();
EtlConsumer.Id := "User_Consumer";
EtlConsumer.Name := "User consumer";
EtlConsumer.Description := "User consumer";
//Setup data consumer
UserConsumer := EtlConsumer.Consumer As IDtUserConsumer;
UserConsumer.ForeModule := MB.ItemById["MYCONSUMER"].Bind();
UserConsumer.ForeClass := "MyConsumer";
System.Diagnostics.Debug.WriteLine("Custom data in the XML format" + UserConsumer.UserData.xml);
Fields := UserConsumer.Fields;
Field := Fields.Add();
Field.DataType := DbDataType.ddtString;
Field.Name := "Name";
Field := Fields.Add();
Field.DataType := DbDataType.ddtFloat;
Field.Name := "Value";
EtlConsumer.FillDefault();
//Save settings of data consumer
EtlConsumer.Save();
// Create visual view of the object in the ETL task
WxConsumer := EtlTask.Workspace.CreateRectangle();
//WxETLConsumer := New WxETLObject.Create;
WxETLConsumer.ETLObject := EtlConsumer;
WxConsumer.Style.TextPosition := WxTextPosition.wtpBottom;
WxConsumer.Style.PictureMarginTop := -10;
PointF.Create(50, 50);
WxConsumer.PinPosition := PointF;
WxConsumer.Extension := WxETLConsumer As IWxShapeExtension;
//Save changes
(EtlTask As IMEtabaseObject).Save();
End Sub;
See also: