Custom data source providers

Applies to v8.0 or later.

 
Custom data source providers are a means of developing customised code to retrieve data from a third party system where the collection of built-in data source providers are not an option.
 
A data source provider not only needs to retrieve the data at runtime but also needs to return a list of input and outputs (referred to as filter fields and display fields) so that they can be mapped to and from the right locations during the design and testing of the actual Infiniti form.
 
For example: a ‘username’ might be passed to a HR system and the response containing their personal details and role information might pre-populate a form and/or be included as content within a generated document. Some design of what operations the data source will support and how the input and output fields will be maintained is an important investment.

How to develop a data source provider

 
For this example, we will load a list of staff members from a CSV file located on the server. In this example, some of the inputs and outputs are hardwired, but a more dynamic approach should be considered if changes are likely to be made to the data in the future.
 
Note: there are already two built-in data source providers capable of doing this in the product and this is a cut-down version as an example only. Open Visual Studio and create a new Class Library Project and give it a meaningful name. For this example, we will use ‘HelloWorldDataSourceProvider’.
 
 
 
 
 
 
 
Add the following references to the project
 
.NET References:
  • System.Configuration
Infiniti References (usually located C:\inetpub\wwwroot\Infiniti\Produce\bin)
  • Intelledox.DataSource
  • Intelledox.InfinitiProviderBase.dll
  • Intelledox.Model.dll
Inherit the Intelledox.Datasource.DatasourceProvider and override necessary methods, as described in the table below and demonstrated in the samples below
 
Method Response Description
TestConnection Boolean All data sources require a connection string. The value of the connection string depends on the type of data being retrieved for example, it could be the location of a data file or a traditional database connection string.
To test the connection string’s integrity a test connection button is available in the UI. The click event runs whatever is coded within this Method.
The outcome of the test connection button in Manage when a data source is installed. For example, if the data source was to call a database
ObjectTypes Array of ‘ObjectType’
Data sources are divided into object types to allow separation of how to handle them in the code. For example, the in-built SQL server source providers separates Stored Procedures from Tables and Views, as they need to be handled differently when determining the input (filter) fields and what fields will be returned.
Whilst many data source providers only support one type the list of types is displayed in the Object Type drop down in Manage.
 
ObjectList Array of String
A list of possible values for the above Object Type. For example, an if an object type was database tables in a database the object list would return all the actual tables present in a database. The list can be filtered at run time if needed as depicted below.
 
GetAvailableKeyFields DataTable Returns a data table where the column names are the identified key fields. (Referred to as filter fields in the UI). For example, the key fields might be the input parameters for a web service or stored procedure.
For consistency this method returns a data table, though as only the column headings are used the data table usually contains no rows.
GetSchema DataTable A data table once again where the column names represent the fields retuned by the data source.
GetData DataTable The method called at run time where an end user is requesting data, the call will contain a collection of filter fields with real values that can be used to make an actual call to the third party system.
The response should be the have the same columns as the equivalent call to get Schema but this time have one or more rows as part of the response.
GetDataReader IDataReader Similar to GetData above but returns an IDataReader object rather than a DataTable.
Although it is called by different areas of the product at runtime the method is usually calls the above GerData method and coverts its DataTable response to an IDataReader.
 
using System;
using System.Data;

namespace HelloWorldDataSourceProvider
{
    public class HelloWorldDataSource : Intelledox.Datasource.DatasourceProvider
    {
        public override DataTable GetAvailableKeyFields(string connectionString, string query, Guid objectType, Intelledox.Model.DataFilter criteria, string username, string password, bool windowsAuthentication)
        {
            throw new NotImplementedException();
        }

        public override DataTable GetData(string connectionString, string query, Guid objectType, Intelledox.Model.DataFilter criteria, string username, string password, bool windowsAuthentication)
        {
            throw new NotImplementedException();
        }

        public override IDataReader GetDataReader(string connectionString, string query, Guid objectType, Intelledox.Model.DataFilter criteria, string username, string password, bool windowsAuthentication)
        {
            throw new NotImplementedException();
        }

        public override DataTable GetSchema(string connectionString, string query, Guid objectType, Intelledox.Model.DataFilter criteria, string username, string password, bool windowsAuthentication)
        {
            throw new NotImplementedException();
        }

        public override string[] ObjectList(string connectionString, Guid objectType, string username, string password, bool windowsAuthentication, string prefixText)
        {
            throw new NotImplementedException();
        }

        public override ObjectType[] ObjectTypes()
        {
            throw new NotImplementedException();
        }

        public override bool TestConnection(string connectionString, string userName, string password, bool windowsAuthentication)
        {
            throw new NotImplementedException();
        }
    }
}
 
To connect to our CSV file the following sample code has been provided with explanation provided in the comments.
 
This code is coming soon. If you need it now, please use the feedback section at the bottom of this page.
 

Deploying a data source provider

Data Source Providers are deployed to an Infiniti environment by copying the Data Source Provider’s .dll file to the Produce and Manage bin folders and referencing it within Manage and Produce web.config files.
 
Note: [Infiniti Produce Path] refers to the installation path on the web server running Infiniti, where the Produce site has been installed. By default, this is c:\inetpub\wwwroot\infiniti\produce however may vary from environment to environment. Equally, [Infiniti Manage Path] refers to where the Manage site has been installed.
 
1. Locate your ‘HelloWorldStateProvider.dll’ file and copy it to the Produce bin directory
[Infiniti Produce Path]\bin
 
2. Using a text editor such as Notepad, open the following file:
[Infiniti Produce Path]\web.config
 
Note: Ensure you have elevated privileges when opening the web.config file, otherwise you may not be able to save in the current folder.
 
3. Locate the <datasource> section of the web.config file. It should appear similar to the following, and may include reference to different Datasource providers:
<datasource>
<providers>
</providers>
</datasource>
4. Within this block, after the last ‘add’ line and before the ‘’ end tag, add the following line:
<add name="Hello World" type="HelloWorldDataSourceProvider.HelloWorldDataSource,HelloWorldDataSourceProvider">
</add>
5. Save and close the web.config file.
 
6. Using a text editor such as Notepad, open the following file:
[Infiniti Manage Path]\web.config
 
Note: Ensure you have elevated privileges when opening the web.config file, otherwise you may not be able to save in the current folder.
 
7. Locate the <datasource> section of the web.config file. It should appear similar to the following, and may include reference to different action providers:
<datasource>
<providers>
</providers>
</datasource>
8. Within this block, after the last ‘add’ line and before the ‘’ end tag, add the following line:
<add name="DocuShare" type=" HelloWorldDataSourceProvider. HelloWorldDataSource, HelloWorldDataSourceProvider">
</add>
9. Save and close the web.config file.
 
10. Using a web browser, navigate to the Infiniti Manage and Produce application to allow the system to register the new data source.
 

Testing and configuring datasource Providers.

Once a datasource provider has been deployed it can be configured for use in Infiniti. The various methods of the dataSource provider are called as they are needed so they can be tested individually.
 

Related Articles

 

Keywords

repeat page variable