TX Text Control .NET Server

DataSourceManager Class

Class|Introduced in 24.0
Namespace
TXTextControl.DocumentServer.DataSources
Package
TXTextControl.TextControl.Core.SDK from the private NuGet feed or Text Control Offline Packages
Assembly
TXDocumentServer.Core.dll
Install
dotnet add package TXTextControl.TextControl.Core.SDK .NET 8 and later. For .NET Framework, reference TXDocumentServer.dll from the setup.
Also in
TXTextControl.TextControl.ASP.SDK as TXDocumentServer.dll

Description

The DataSourceManager class is designed for handling all existing kinds of data sources which can be used together with the MailMerge class. Use this class to determine which data tables, column names and data relations a data source contains and to insert merge block templates into documents.

Syntax

public class DataSourceManager

Examples

The following example creates a Data Source Manager instance and configures its max merge results setting for a document workflow.

TXTextControl.DocumentServer.DataSources.DataSourceManager dataSourceManager = new();
dataSourceManager.MaxMergeResults = 10;

Members

Constructors

ConstructorDescription
DataSourceManagerInitializes a new instance of the DataSourceManager class.

Properties

PropertyDescription
ConnectionStringGets the connection string of the connection selected with the DatabaseConnectionDialog. If no data connection was selected, this property returns an empty string.
DataProviderNameGets the name of the data provider selected with the DatabaseConnectionDialog. If no data connection was selected, this property returns an empty string.
DataRelationsGets a DataRelationInfoCollection of DataRelationInfo objects which represent the data relations in the data source.
DataSourceCultureSpecifies the culture with which numerical and date / time values coming from the data source are parsed. The default value for this property is the current thread culture.
DataTablesGets a DataTableInfoCollection of DataTableInfo objects which represent the data tables in the data source.
IsMergingPossibleGets a value indicating whether all requirements are met and the method Merge can be called.
MasterDataTableInfoGets or sets a DataTableInfo object representing the table which is used as a master table when merging data into the document. Changing the master table with this property influences the return values of the PossibleMergeBlockTables and the PossibleMergeFieldColumns properties.
MaxMergeResultsSpecifies the Upper merge result count. The default value for this property is int.MaxValue.
MergeCultureSpecifies the culture with which numerical and date / time values are formatted when merged into the target document. The default value for this property is the current thread culture.
PossibleMergeBlockTablesGets a DataTableInfoCollection of DataTableInfo objects representing the tables which can be used as merge blocks using the currently selected master table.
PossibleMergeFieldColumnsGets a DataColumnInfoCollection of DataColumnInfo objects representing the table columns which can be used as merge fields using the currently selected master table.

Methods

MethodDescription
InsertMergeBlockInserts a repeating merge block into a TextControl instance, a WPF.TextControl instance or a ServerTextControl instance at the current input position.
IsMergeBlockChecks if a given SubTextPart is a merge block.
LoadAssemblyLoads an assembly file as a data source. Automatically deduces table and column names as well as data relations from the public properties of all public classes found in the assembly.
LoadDataSetLoads a System.Data.DataSet object as a data source.
LoadDataSourceConfigLoads an XML string or a file containing "report data source configuration" data. Data Source Configuration Files can only be used in Windows Forms applications. When calling this method from a WPF Application, an exception is thrown. For more information about data source configuration files see method SaveDataSourceConfig.
LoadDataTableLoads a System.Data.DataTable object as a data source.
LoadJsonLoads a JSON string containing an array of objects or a single object as a data source. Automatically deduces table and column names as well as data relations from property names and nested objects in the given single object or, in case of an array, the first object.
LoadObjectsLoads a collection implementing the interface IEnumerable as a data source and deduces the data tables, column names and data relations from the public properties and used classes of the first contained object using .NET reflection or, in case of the first contained object being a Dictionary with string keys, from the key names and value types.
LoadSingleObjectLoads a single object which is either a Dictionary with string keys or an object of an arbitrary type as a data source. The data tables, column names are deduced either from the key names or the public property names and types using .NET reflection.
LoadXmlFileLoads the contents of an XML file as a data source.
LoadXmlStringLoads XML data, given as a string, as a data source.
MergeMerges a binary TX internal unicode format document with the currently loaded data source.
SaveDataSourceConfigSaves an XML string or a file containing "report data source config" data. Can only be called when a data provider based data source was loaded via the DatabaseConnectionDialog. The XML string contains information about the data provider, the connection string, the selected master table and existing data relations. Data Source Configuration Files can only be used in Windows Forms applications. When calling this method from a WPF Application, an exception is thrown.

Events

EventDescription
ConnectionStringChangedIs fired when the contents of the ConnectionString property change.
DataProviderNameChangedIs fired when the contents of the DataProviderName property change.
DataRelationsChangedIs fired when the contents of the DataRelations property change.
DataRowMergedOccurs when a data row has been merged successfully. The event handler receives an argument of type DataRowMergedEventArgs containing data related to this event.
DataTablesChangedIs fired when the contents of the DataTables property change.
FieldMergedOccurs when a field has been merged. The event handler receives an argument of type FieldMergedEventArgs containing data related to this event. This event can be used to change the field text and to determine whether the field has been merged successfully.
IsMergingPossibleChangedIs fired when the value of the IsMergingPossible property changes.
MasterDataTableInfoChangedIs fired when the contents of the MasterDataTableInfo property change.
PossibleMergeBlockTablesChangedIs fired when the contents of the PossibleMergeBlockTables property change.
PossibleMergeFieldColumnsChangedIs fired when the contents of the PossibleMergeFieldColumns property change.

Further Reading

  • Adding Sorting and Filter Instructions to Existing MergeBlocks –
  • Using the Reporting RibbonTab –
  • Using the DataSourceManager to Merge Templates –