Abstract class for a DataSource.
Overview
TFORMer Designer allows to define a DataSource as part of a FormLayout. Such an user-defined DataSource can be used for printing directly from within TFORmer Designer or may be re-used by TFORmer SDK for providing JobData (see JobDataDataSource).
A DataSource defines how data is retrieved (e.g. from an ODBC database), the field-mappings (see DSFieldMapping), computed fields (see ComputedField) and optional data source parameters (see DataSourceParameter). Each DataSource is identified by its unique name. Optional DataSourceParameters can be defined to control certain aspects (like filenames, SQL statement or an ODBC-DSN) during runtime.
By default TFORMer Designer creates a DataSource named Default
. This DataSource is used for printing as long as neither a DataSource is specified for JobData nor the FormLayout has an active DataSource set in design. This DataSource retrieves the data from the file that is stored along with the FormLayout file (extension .xml) and contains the DataField values entered during the last TFORMer Designer session.
The available DataSource-classes are DataSourceCsv, DataSourceOdbc and DataSourceXml.
Escape Sequences
It depends on HandleEscapeSequences whether possible escape sequences in the values are translated into their corresponding binary representation. See Escape Sequences for details.
Each Record of a DataSource is usually considered exactly once for generating output. Use DataSource.CopyColumnName to instruct TFORMer SDK to use a specific field of the DataSource which contains the copy counter. This feature is helpful whenever a single Record of a DataSource should be printed multiple times (e.g. if a certain number of identical labels should be printed).
Computed Fields
Computations can be centralized in the DataSource instead of performing the computations in the FormLayout. The result of a ComputedField is available in the DataSource like any other source-field.
Example
Sample code that iterates all DataSource of a given Repository:
void IterateDataSourcesProject (
Project project)
{
{
Console.WriteLine (ds.ToString ());
Console.WriteLine (dsParam.ToString ());
for (
ComputedField dsComp = ds.FirstComputedField; dsComp !=
null; dsComp = dsComp.
Next)
Console.WriteLine (dsComp.ToString ());
for (
DSFieldMapping dsFieldmap = ds.FirstFieldMapping; dsFieldmap !=
null; dsFieldmap = dsFieldmap.
Next)
Console.WriteLine (dsFieldmap.ToString ());
}
}
Provides access to a ComputedField which is referenced by a DataSource.
Definition: ComputedField.cs:54
ComputedField Next
Gets the next ComputedField defined in the DataSource.
Definition: ComputedField.cs:315
DSFieldMapping defines the field-mappings between a DataSource and the DataFields used in a Formlayou...
Definition: DSFieldMapping.cs:20
DSFieldMapping Next
Gets the next DSFieldMapping in the DataSource.
Definition: DSFieldMapping.cs:137
Abstract class for a DataSource.
Definition: DataSource.cs:56
DataSource Next
Gets the next DataSource instance defined in the Project.
Definition: DataSource.cs:370
Provides access to properties of a DataSourceParameter.
Definition: DataSourceParameter.cs:17
DataSourceParameter Next
Gets the next DataSourceParameter defined in the DataSource.
Definition: DataSourceParameter.cs:245
Provides access to Project information of a Repository or a stand-alone link FormLayout.
Definition: Project.cs:22
DataSource FirstDataSource
Gets the first DataSource defined in the Project.
Definition: Project.cs:255
Repository repository =
new Repository(
@"C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/8/Examples/Demo Repository/Demos.tfr",
false,
true);
Opens or creates a Repository, opens a stand-alone FormLayout.
Definition: Repository.cs:24
Console.WriteLine ("Global project");
{
Console.WriteLine (project.ToString ());
IterateDataSourcesProject (project);
}
Project Next
Gets the next Project defined in the Repository.
Definition: Project.cs:193
Project GlobalProject
Gets the global Project of the Repository.
Definition: Repository.cs:478
Project FirstProject
Gets the first Project stored in the Repository.
Definition: Repository.cs:456
Sample code that iterates all DataSource-objects of a given stand-alone FormLayout:
void IterateDataSourcesProject (
Project project)
{
{
Console.WriteLine (ds.ToString ());
Console.WriteLine (dsParam.ToString ());
for (
ComputedField dsComp = ds.FirstComputedField; dsComp !=
null; dsComp = dsComp.
Next)
Console.WriteLine (dsComp.ToString ());
for (
DSFieldMapping dsFieldmap = ds.FirstFieldMapping; dsFieldmap !=
null; dsFieldmap = dsFieldmap.
Next)
Console.WriteLine (dsFieldmap.ToString ());
}
}
Repository repository =
new Repository(
@"C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/8/Examples/Command Line/ODBCReportPDF/ODBCReportPDF.tff",
false,
true);
Console.WriteLine ("Global project");
More Information
- See also
- ComputedField
Related documentation:
- Note
- Thread-safety: A single instance of this class must not be used by different threads.
- See also
- DataSourceCsv, DataSourceOdbc, DataSourceXml