В разделе приведено описание пользовательского алгоритма получения данных, реализованного в виде класса MyDtCustomProvider на языках Fore и Fore.NET.
Данные загружаются из текстового файла «C:\Data_Out.txt».
Класс MyDtCustomProvider на языке Fore
Добавьте ссылки на системные сборки: Dt, Xml.
Public Class MyDtCustomProvider: Object, IDtCustomProvider
p: IDtTextProvider;
fs: IDtFieldDefinitions;
_mb: IMetabase;
m_active, keep: Boolean;
Public Constructor MyDtCustomProvider;
Begin
m_Active := False;
End Constructor MyDtCustomProvider;
Public Sub Open;
Begin
m_Active := True;
If p = Null Then
p := New DtTextProvider.Create;
p.File := "C:\Data_Out.txt";
End If;
p.RangeHasHeader := True;
p.Open;
End Sub Open;
Public Sub Close;
Begin
m_Active := False;
End Sub Close;
Public Sub Save(Element: IXMLDOMElement);
Begin
p.Save(Element);
End Sub Save;
Public Sub Load(Element: IXMLDOMElement);
Begin
If p = Null Then
p := New DtTextProvider.Create;
p.File := "C:\Data_Out.txt";
End If;
End Sub Load;
Public Sub FieldsFromFile;
Begin
p.FieldsFromFile;
End Sub FieldsFromFile;
Public Property GetType: DtObjectType
Get
Begin
Return DtObjectType.TDtTextProvider;
End Get
End Property GetType;
Public Sub ClearFields;
Begin
p.ClearFields;
End Sub ClearFields;
Public Sub Fetch(Var Values: Array);
Begin
p.Fetch(Values);
End Sub Fetch;
Public Function FetchRows(Count: Integer; Var Values: Array): Integer;
Var
i: Integer;
Begin
i := p.FetchRows(Count, Values);
Return i;
End Function FetchRows;
Public Function ReadingRowsCount: Integer;
Begin
Return p.ReadingRowsCount;
End Function ReadingRowsCount;
Public Function ImplementFetchRows: Boolean;
Begin
Return True;
End Function ImplementFetchRows;
Function get_Eof: Boolean;
Begin
Return p.Eof;
End Function get_Eof;
Function get_Fields: IDtFieldDefinitions;
Begin
If fs = Null Then
fs := p.Fields;
End If;
Return fs;
End Function get_Fields;
Function get_Active: boolean;
Begin
Return m_Active;
End Function get_Active;
Function get_getType: dtobjecttype;
Begin
Return dtobjecttype.TDtUserProviderEx
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 MyDtCustomProvider;
Класс MyDtCustomProvider на языке Fore.NET
Imports Prognoz.Platform.Interop.Dt;
Imports Prognoz.Platform.Interop.MsXml2;
Imports Prognoz.Platform.Interop.Metabase;
Public Class MyDtCustomProvider: Object, IDtCustomProvider
m_Active: boolean;
p: IDtTextProvider;
fs: IDtFieldDefinitions;
fsO: DtFieldDefinitions;
_mb: IMetabase;
keep: boolean;
Public Constructor MyDtCustomProvider();
Begin
m_Active := False;
End Constructor;
Public Property Fields: DtFieldDefinitions
Get
Begin
If p = Null Then
p := New DtTextProviderClass();
End If;
Return p.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 p = Null Then
p := New DtTextProviderClass();
p.File := "p:\Data_Out.txt";
End If;
p.RangeHasHeader := True;
p.Open();
End Sub;
Public Sub Close();
Begin
m_Active := False;
End Sub;
Public Sub Save(Element: IXMLDOMElement);
Begin
p.Save(Element);
End Sub;
Public Sub Load(Element: IXMLDOMElement);
Begin
If p = Null Then
p := New DtTextProvider.Create();
p.File := "C:\Data_Out.txt";
End If;
End Sub;
Public Sub FieldsFromFile();
Begin
p.FieldsFromFile();
End Sub;
Public Property GetType: DtObjectType
Get
Begin
Return DtObjectType.TDtTextConsumer;
End Get
End Property;
Public Sub ClearFields();
Begin
p.ClearFields();
End Sub;
Public Sub Fetch(Var Values: Array);
Begin
p.Fetch(Var Values);
End Sub;
Public Function FetchRows(Count: Integer; Var Values: Array): Integer;
Var
i: Integer;
Begin
i := p.FetchRows(Count, Var Values);
Return i;
End Function;
Public Function ReadingRowsCount(): Integer;
Begin
Return p.ReadingRowsCount();
End Function;
Public Function ImplementFetchRows(): Boolean;
Begin
Return True;
End Function;
Public Sub PutData(Var Values: Object; RowCount: Integer; ColCount: Integer);
Begin
End Sub;
Public Function ImplementPut(): Boolean;
Begin
Return True;
End Function;
Public Property Eof: Boolean
Get
Begin
Return p.Eof
End Get
End Property;
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;
См. также: