В разделе приведено описание пользовательского алгоритма выгрузки данных, реализованного в виде класса MyDtCustomConsumer на языках Fore и Fore.NET.
Данные выгружаются в текстовый файл «C:\Data_Out.txt».
Класс MyDtCustomConsumer на языке Fore
Добавьте ссылки на системные сборки: Dt, Xml.
Public Class MyDtCustomConsumer: Object, IDtCustomConsumer
c: IDtTextConsumer;
_mb: IMetabase;
m_Active, keep: Boolean;
Public Constructor MyDtCustomConsumer;
Begin
m_Active := False;
End Constructor MyDtCustomConsumer;
Public Sub Open;
Begin
m_Active := True;
If c = Null Then
c := New DtTextConsumer.Create;
c.File := "C:\Data_Out.txt";
End If;
c.WriteHeader := True;
c.Open;
End Sub Open;
Public Sub Close;
Begin
m_Active := False;
End Sub Close;
Public Sub Save(Element: IXMLDOMElement);
Begin
c.Save(Element);
End Sub Save;
Public Sub Load(Element: IXMLDOMElement);
Begin
If c = Null Then
c := New DtTextConsumer.Create;
c.File := "C:\Data_Out.txt";
End If;
End Sub Load;
Public Sub FieldsFromFile;
Begin
c.FieldsFromFile;
End Sub FieldsFromFile;
Public Property GetType: DtObjectType
Get
Begin
Return DtObjectType.TDtExcelConsumer;
End Get
End Property GetType;
Public Sub ClearFields;
Begin
c.ClearFields;
End Sub ClearFields;
Public Sub Clear;
Begin
c.Clear;
End Sub Clear;
Public Sub Put(Values: Array);
Begin
c.Put(Values);
End Sub Put;
Public Sub PutRow(Values: Array);
Begin
c.PutRow(Values);
End Sub PutRow;
Public Sub PutData(Var Values: Object; RowCount: Integer; ColCount: Integer);
Begin
End Sub PutData;
Public Function WritingRowsCount: Integer;
Begin
Return c.WritingRowsCount;
End Function WritingRowsCount;
Public Function ImplementPut: Boolean;
Begin
Return True;
End Function ImplementPut;
Function get_Fields: IDtFieldDefinitions;
Begin
If c = Null Then
c := New DtTextConsumer.Create;
End If;
Return c.Fields;
End Function get_Fields;
Function get_Active: boolean;
Begin
Return m_Active;
End Function get_Active;
Function get_getType: dtobjecttype;
Begin
Return dtobjecttype.TDtUserConsumerEx
End Function get_getType;
Public Function get_Metabase: IMetabase;
Begin
Return _mb;
End Function get_Metabase;
Public Sub set_Metabase(metabase: IMetabase);
Begin
_mb := metabase;
End Sub set_Metabase;
Function get_KeepCalcFields: Boolean;
Begin
Return keep;
End Function get_KeepCalcFields;
Sub set_KeepCalcFields(Value: Boolean);
Begin
keep := Value;
End Sub set_KeepCalcFields;
End Class MyDtCustomConsumer;
Класс MyDtCustomConsumer на языке Fore.NET
Imports Prognoz.Platform.Interop.Dt;
Imports Prognoz.Platform.Interop.MsXml2;
Imports Prognoz.Platform.Interop.Metabase;
Public Class MyDtCustomConsumer: Object, IDtCustomConsumer
m_Active: Boolean;
c: IDtTextConsumer;
fsO: DtFieldDefinitions;
_mb: IMetabase;
keep: Boolean;
Public Constructor MyDtCustomConsumer();
Begin
m_Active := False;
End Constructor;
Public Property Fields: DtFieldDefinitions
Get
Begin
If c = Null Then
c := New DtTextConsumer.Create();
End If;
Return c.Fields;
End Get
End Property;
Public Property Active: Boolean
Get
Begin
Return m_Active;
End Get
End Property;
Public Sub Open();
Var
i: Integer;
Field: IDtFieldDefinition;
Begin
m_Active := True;
If c = Null Then
c := New DtTextConsumer.Create();
c.File := "C:\Data_Out.txt";
End If;
c.WriteHeader := True;
c.Open();
End Sub;
Public Sub Close();
Begin
m_Active := False;
End Sub;
Public Sub Save(Element: IXMLDOMElement);
Begin
c.Save(Element);
End Sub;
Public Sub Load(Element: IXMLDOMElement);
Begin
If c = Null Then
c := New DtTextConsumer.Create();
c.File := "C:\Data_Out.txt";
End If;
End Sub;
Public Sub FieldsFromFile();
Begin
c.FieldsFromFile();
End Sub;
Public Property GetType: DtObjectType
Get
Begin
Return DtObjectType.TDtExcelConsumer;
End Get
End Property;
Public Sub ClearFields();
Begin
c.ClearFields();
End Sub;
Public Sub Clear();
Begin
c.Clear();
End Sub;
Public Sub Put(Values: Array);
Begin
c.Put(Values);
End Sub;
Public Sub PutRow(Values: Array);
Begin
c.PutRow(Values);
End Sub;
Public Sub PutData(Var Values: Object; RowCount: Integer; ColCount: Integer);
Begin
End Sub;
Public Function WritingRowsCount(): Integer;
Begin
Return c.WritingRowsCount();
End Function;
Public Function ImplementPut(): Boolean;
Begin
Return True;
End Function;
Public Property Metabase: IMetabase
Get
Begin
Return _mb;
End Get
Set
Begin
_mb := Value;
End Set
End Property;
Public Property KeepCalcFields: Boolean
Get
Begin
Return keep;
End Get
Set
Begin
keep := Value;
End Set
End Property;
Public Sub SaveToSerializer(Serializer: Prognoz.Platform.Interop.Metabase.IMetabaseSerializer);
Begin
End Sub;
Public Sub LoadFromSerializer(Serializer: Prognoz.Platform.Interop.Metabase.IMetabaseSerializer);
Begin
End Sub;
Public Sub FieldsFromFileEx();
Begin
End Sub;
Public Sub OpenO(Options: integer);
Begin
End Sub;
Public Property FieldsO[Options: Integer]: Prognoz.Platform.Interop.Dt.DtFieldDefinitions
Get
Begin
Return fsO
End Get
End Property;
End Class;
См. также: