Example of Custom Data Loading Algorithm

The section describes the custom data extraction algorithm implemented as the MyDtCustomConsumer class in the Fore language.

The data is uploaded to the C:\Data_Out.txt file.

Add links to the Dt and Xml system assemblies.

Public Class MyDtCustomConsumer: Object, IDtCustomConsumer
    _mb: IMetabase;
    c: IDtTextConsumer;
    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;
        c.Close;
    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;

See also:

IDtUserConsumerEx