TFORMer SDK - NET 8
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.

Record Copies

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)
{
// Iterate all DataSources of the Project
for (DataSource ds = project.FirstDataSource; ds != null; ds = ds.Next)
{
Console.WriteLine (ds.ToString ());
// Print information for the DataSourceParameters of the DataSource
for (DataSourceParameter dsParam = ds.FirstParameter; dsParam != null; dsParam = dsParam.Next)
Console.WriteLine (dsParam.ToString ());
// Print information for the ComputedFields of the DataSource
for (ComputedField dsComp = ds.FirstComputedField; dsComp != null; dsComp = dsComp.Next)
Console.WriteLine (dsComp.ToString ());
// Print the mapping between source fields and DataFields
for (DSFieldMapping dsFieldmap = ds.FirstFieldMapping; dsFieldmap != null; dsFieldmap = dsFieldmap.Next)
Console.WriteLine (dsFieldmap.ToString ());
}
}
// Create a new Repository instance using a Repository (extension *.tfr)
// Examples are usually installed in
// - Windows Vista: C:/Program Data/TEC-IT/TFORMer/8/Examples
// - Older Microsoft Windows versions: C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/8/Examples
Repository repository = new Repository(@"C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/8/Examples/Demo Repository/Demos.tfr", false, true);
// Iterate the DataSources of the global Project
// If a Repository is used, the global Project and additional user-defined Projects may exist
Console.WriteLine ("Global project");
IterateDataSourcesProject (repository.GlobalProject);
// Iterate additional Projects
// Additional Projects are only possible when using a Repository
for (Project project = repository.FirstProject; project != null; project = project.Next)
{
Console.WriteLine (project.ToString ());
// Iterate the DataSources of the Project
IterateDataSourcesProject (project);
}

Sample code that iterates all DataSource-objects of a given stand-alone FormLayout:

void IterateDataSourcesProject (Project project)
{
// Iterate all DataSources of the Project
for (DataSource ds = project.FirstDataSource; ds != null; ds = ds.Next)
{
Console.WriteLine (ds.ToString ());
// Print information for the DataSourceParameters of the DataSource
for (DataSourceParameter dsParam = ds.FirstParameter; dsParam != null; dsParam = dsParam.Next)
Console.WriteLine (dsParam.ToString ());
// Print information for the ComputedFields of the DataSource
for (ComputedField dsComp = ds.FirstComputedField; dsComp != null; dsComp = dsComp.Next)
Console.WriteLine (dsComp.ToString ());
// Print the mapping between source fields and DataFields
for (DSFieldMapping dsFieldmap = ds.FirstFieldMapping; dsFieldmap != null; dsFieldmap = dsFieldmap.Next)
Console.WriteLine (dsFieldmap.ToString ());
}
}
// Create a new Repository instance using a stand-alone FormLayout (extension *.tff)
// Examples are usually installed in
// - Windows Vista or later: C:/Program Data/TEC-IT/TFORMer/8/Examples
// - Older Microsoft Windows versions: C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/8/Examples
Repository repository = new Repository(@"C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/8/Examples/Command Line/ODBCReportPDF/ODBCReportPDF.tff", false, true);
// Iterate the DataSources of the global Project
// If a stand-alone FormLayout is used, the global Project is the only Project
Console.WriteLine ("Global project");
IterateDataSourcesProject (repository.GlobalProject);

More Information

See also
ComputedField

Related documentation:


© 2006-2023 - all rights reserved by TEC-IT Datenverarbeitung GmbH
Generated on Thu Dec 28 2023 18:45:19 for TFORMer SDK - NET with doxygen 1.9.4