DataSourceManager Class
- Namespace
TXTextControl.DocumentServer. DataSources
- Package
TXTextControl.from the private NuGet feed or Text Control Offline PackagesTextControl. WinForms. SDK
- Assembly
TXDocumentServer.dll
- Install
dotnet add package TXTextControl..NET 8 and later. For .NET Framework, referenceTextControl. WinForms. SDK TXDocumentServer.from the setup.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 DataSourceManagerPublic Class DataSourceManagerExamples
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;Dim dataSourceManager As New TXTextControl.DocumentServer.DataSources.DataSourceManager()
dataSourceManager.MaxMergeResults = 10Members
Constructors
| Constructor | Description |
|---|---|
| DataSourceManager | Initializes a new instance of the DataSourceManager class. |
Properties
| Property | Description |
|---|---|
| ConnectionString | Gets the connection string of the connection selected with the DatabaseConnectionDialog. If no data connection was selected, this property returns an empty string. |
| DataProviderName | Gets the name of the data provider selected with the DatabaseConnectionDialog. If no data connection was selected, this property returns an empty string. |
| DataRelations | Gets a DataRelationInfoCollection of DataRelationInfo objects which represent the data relations in the data source. |
| DataSourceCulture | Specifies 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. |
| DataTables | Gets a DataTableInfoCollection of DataTableInfo objects which represent the data tables in the data source. |
| IsMergingPossible | Gets a value indicating whether all requirements are met and the method Merge can be called. |
| MasterDataTableInfo | Gets 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. |
| MaxMergeResults | Specifies the Upper merge result count. The default value for this property is int.MaxValue. |
| MergeCulture | Specifies 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. |
| PossibleMergeBlockTables | Gets a DataTableInfoCollection of DataTableInfo objects representing the tables which can be used as merge blocks using the currently selected master table. |
| PossibleMergeFieldColumns | Gets a DataColumnInfoCollection of DataColumnInfo objects representing the table columns which can be used as merge fields using the currently selected master table. |
Methods
| Method | Description |
|---|---|
| InsertMergeBlock | Inserts a repeating merge block into a TextControl instance, a WPF.TextControl instance or a ServerTextControl instance at the current input position. |
| IsMergeBlock | Checks if a given SubTextPart is a merge block. |
| LoadAssembly | Loads 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. |
| LoadDataSet | Loads a System.Data.DataSet object as a data source. |
| LoadDataSourceConfig | Loads 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. |
| LoadDataTable | Loads a System.Data.DataTable object as a data source. |
| LoadJson | Loads 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. |
| LoadObjects | Loads 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. |
| LoadSingleObject | Loads 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. |
| LoadXmlFile | Loads the contents of an XML file as a data source. |
| LoadXmlString | Loads XML data, given as a string, as a data source. |
| Merge | Merges a binary TX internal unicode format document with the currently loaded data source. |
| SaveDataSourceConfig | Saves 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
| Event | Description |
|---|---|
| ConnectionStringChanged | Is fired when the contents of the ConnectionString property change. |
| DataProviderNameChanged | Is fired when the contents of the DataProviderName property change. |
| DataRelationsChanged | Is fired when the contents of the DataRelations property change. |
| DataRowMerged | Occurs when a data row has been merged successfully. The event handler receives an argument of type DataRowMergedEventArgs containing data related to this event. |
| DataTablesChanged | Is fired when the contents of the DataTables property change. |
| FieldMerged | Occurs 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. |
| IsMergingPossibleChanged | Is fired when the value of the IsMergingPossible property changes. |
| MasterDataTableInfoChanged | Is fired when the contents of the MasterDataTableInfo property change. |
| PossibleMergeBlockTablesChanged | Is fired when the contents of the PossibleMergeBlockTables property change. |
| PossibleMergeFieldColumnsChanged | Is fired when the contents of the PossibleMergeFieldColumns property change. |