TFORMer SDK - NET 8
Public Member Functions | Properties | List of all members
DataSource Class Reference

Abstract class for a DataSource. More...

Public Member Functions

ComputedField AddComputedField (string name)
 Creates and adds a ComputedField to the DataSource. More...
 
DSFieldMapping AddFieldMapping (string name)
 Creates and adds a DSFieldMapping to the DataSource. More...
 
DataSourceParameter AddParameter (string name)
 Creates and adds a DataSourceParameter to the DataSource. More...
 
void Dispose ()
 Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. More...
 
ComputedField GetComputedField (string name)
 Gets a ComputedField defined in the DataSource. More...
 
DSFieldMapping GetFieldMapping (string name)
 Gets a DSFieldMapping defined in the DataSource. More...
 
DataSourceParameter GetParameter (string name)
 Gets a DataSourceParameter defined in the DataSource. More...
 
void RemoveComputedField (ComputedField computedField)
 Removes the ComputedField from the DataSource. More...
 
void RemoveComputedField (string name)
 Removes the ComputedField from the DataSource. More...
 
void RemoveFieldMapping (DSFieldMapping fieldMapping)
 Removes the DSFieldMapping from the DataSource. More...
 
void RemoveFieldMapping (string name)
 Removes the DSFieldMapping from the DataSource. More...
 
void RemoveParameter (DataSourceParameter datasourceParameter)
 Removes the DataSourceParameter from the DataSource. More...
 
void RemoveParameter (string name)
 Removes the DataSourceParameter from the DataSource. More...
 
override string ToString ()
 Returns a string representation of the instance. More...
 

Properties

string Comment [get, set]
 Gets/Sets the comment for the DataSource. More...
 
string CopyColumnName [get, set]
 Gets/Sets the CopyColumnName of the DataSource. More...
 
string Description [get, set]
 Gets/Sets the description of the DataSource. More...
 
ComputedField FirstComputedField [get]
 Gets the first ComputedField defined in the DataSource. More...
 
DSFieldMapping FirstFieldMapping [get]
 Gets the first DSFieldMapping defined in the DataSource. More...
 
DataSourceParameter FirstParameter [get]
 Gets the first DataSourceParameter defined in the DataSource. More...
 
bool HandleEscapeSequences [get, set]
 Gets/Sets if escape sequences should be translated on data retrieval or not. More...
 
bool IsDefault [get]
 Gets a value indicating whether this object stores the default DataSource. More...
 
string Name [get, set]
 Gets/Sets the name of the DataSource. More...
 
DataSource Next [get]
 Gets the next DataSource instance defined in the Project. More...
 
int NumberOfComputedFields [get]
 Gets the number of ComputedFields defined in the DataSource. More...
 
int NumberOfFieldMappings [get]
 Gets the number of DSFieldMappings defined in the DataSource. More...
 
int NumberOfParameters [get]
 Gets the number of DataSourceParameters defined in the DataSource. More...
 
DataSourceType Type [get]
 Gets the type of the DataSource. More...
 

Detailed Description

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.

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 ());
}
}
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
// 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);
Opens or creates a Repository, opens a stand-alone FormLayout.
Definition: Repository.cs:24
// 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);
}
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)
{
// 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:

Note
Thread-safety: A single instance of this class must not be used by different threads.
See also
DataSourceCsv, DataSourceOdbc, DataSourceXml

Member Function Documentation

◆ AddComputedField()

ComputedField AddComputedField ( string  name)

Creates and adds a ComputedField to the DataSource.

Parameters
nameThe name of the ComputedField
Returns
A new ComputedField
See also
ComputedField

◆ AddFieldMapping()

DSFieldMapping AddFieldMapping ( string  name)

Creates and adds a DSFieldMapping to the DataSource.

Parameters
nameThe name of the DataField for which a DSFieldMapping should be created.
Returns
A new DSFieldMapping

◆ AddParameter()

DataSourceParameter AddParameter ( string  name)

Creates and adds a DataSourceParameter to the DataSource.

Parameters
nameThe name of the DataSourceParameter
Returns
A new DataSourceParameter
See also
DataSourceParameter

◆ Dispose()

void Dispose ( )

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

◆ GetComputedField()

ComputedField GetComputedField ( string  name)

Gets a ComputedField defined in the DataSource.

Parameters
nameThe name of the ComputedField
Returns
A valid object instance or null
See also
ComputedField

◆ GetFieldMapping()

DSFieldMapping GetFieldMapping ( string  name)

Gets a DSFieldMapping defined in the DataSource.

Retrieves the DSFieldMapping for a given DataField name from the DataSource

Parameters
nameThe name of a DataField
Returns
A valid object instance or null

◆ GetParameter()

DataSourceParameter GetParameter ( string  name)

Gets a DataSourceParameter defined in the DataSource.

Parameters
nameThe name of the DataSourceParameter
Returns
A valid object instance or null
See also
DataSourceParameter

◆ RemoveComputedField() [1/2]

void RemoveComputedField ( ComputedField  computedField)

Removes the ComputedField from the DataSource.

Parameters
computedFieldThe ComputedField
See also
ComputedField

◆ RemoveComputedField() [2/2]

void RemoveComputedField ( string  name)

Removes the ComputedField from the DataSource.

Parameters
nameThe name of the ComputedField
See also
ComputedField

◆ RemoveFieldMapping() [1/2]

void RemoveFieldMapping ( DSFieldMapping  fieldMapping)

Removes the DSFieldMapping from the DataSource.

Parameters
fieldMappingThe DSFieldMapping

◆ RemoveFieldMapping() [2/2]

void RemoveFieldMapping ( string  name)

Removes the DSFieldMapping from the DataSource.

Parameters
nameThe name of the DataField for which the mapping should be deleted

◆ RemoveParameter() [1/2]

void RemoveParameter ( DataSourceParameter  datasourceParameter)

Removes the DataSourceParameter from the DataSource.

Parameters
datasourceParameterThe DataSourceParameter
See also
DataSourceParameter

◆ RemoveParameter() [2/2]

void RemoveParameter ( string  name)

Removes the DataSourceParameter from the DataSource.

Parameters
nameThe name of the DataSourceParameter
See also
DataSourceParameter

◆ ToString()

override string ToString ( )

Returns a string representation of the instance.

Returns
A string representation of the instance

Property Documentation

◆ Comment

string Comment
getset

Gets/Sets the comment for the DataSource.

Returns
The comment for the DataSource

◆ CopyColumnName

string CopyColumnName
getset

Gets/Sets the CopyColumnName of the DataSource.

Returns
The CopyColumnName of the DataSource
See also
DataSource

◆ Description

string Description
getset

Gets/Sets the description of the DataSource.

Returns
The description of the DataSource

◆ FirstComputedField

ComputedField FirstComputedField
get

Gets the first ComputedField defined in the DataSource.

Returns
The first ComputedField object in the list or null
See also
ComputedField

◆ FirstFieldMapping

DSFieldMapping FirstFieldMapping
get

Gets the first DSFieldMapping defined in the DataSource.

Returns
The first DSFieldMapping in the list or null

◆ FirstParameter

DataSourceParameter FirstParameter
get

Gets the first DataSourceParameter defined in the DataSource.

Returns
The first DataSourceParameter defined in the DataSource or null
See also
DataSourceParameter

◆ HandleEscapeSequences

bool HandleEscapeSequences
getset

Gets/Sets if escape sequences should be translated on data retrieval or not.

Returns
true if escape sequences should be translated.
See also
Escape Sequences, DataSource

◆ IsDefault

bool IsDefault
get

Gets a value indicating whether this object stores the default DataSource.

Returns
true if this DataSource is the default DataSource.
See also
DataSource

◆ Name

string Name
getset

Gets/Sets the name of the DataSource.

Returns
The name of the DataSource

◆ Next

DataSource Next
get

Gets the next DataSource instance defined in the Project.

A Project stores a list of DataSource objects. To retrieve the first DataSource in the Project see Project.FirstDataSource.

Returns
null if there aren't other instances in the Project, otherwise a valid instance of this class (DataSourceCsv, DataSourceOdbc or DataSourceXml)
See also
Project

◆ NumberOfComputedFields

int NumberOfComputedFields
get

Gets the number of ComputedFields defined in the DataSource.

Returns
The number of ComputedFields defined in the DataSource
See also
ComputedField

◆ NumberOfFieldMappings

int NumberOfFieldMappings
get

Gets the number of DSFieldMappings defined in the DataSource.

Returns
The number of DSFieldMappings defined in the DataSource

◆ NumberOfParameters

int NumberOfParameters
get

Gets the number of DataSourceParameters defined in the DataSource.

Returns
The number of DataSourceParameters defined in the DataSource
See also
DataSourceParameter

◆ Type

DataSourceType Type
get

Gets the type of the DataSource.

The DataSourceType is read-only, and is set on creation. It specifies the type of a DataSource (e.g. DataSourceOdbc, DataSourceCsv, DataSourceXml).

Returns
The DataSourceType of the DataSource

© 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