Connectors

Empty Data Source

The Empty Data Source provides a container that can be used as a dummy target or used for a custom data source when combined with .NET C# code in project automation.

Connect to Empty Data Source

Columns

The Schema Column collection for this Data Source.

Since the Empty Data Source does not define any Schema you need to specify the schema columns.

Empty Data Source Column 1 Empty Data Source Column 2

Properties

A list of user defined properties that can be accessed via project automation or dynamic columns.

Empty Data Source Property 1 Empty Data Source Property 2

UseDefaultJsonRequestFeature

This is a feature where this provider can provide read-only access to a basic JSON-REST type service.

Configuration

The Properties collection is used to control the service endpoint and other basic parameters.

Property Description Example
URL The url to the JSON service https://jsonplaceholder.typicode.com/users
Username Username to use with BASIC AUTH username
Password Password for Username password123
AuthorizationToken Set a Bearer HTTP Header for OAuth authentication AaaaBBccc444566
DataTokenName The Json Token that returns an Array of items to read Required if the items array is a child of the json document data

Download Json Demo Project

Project Automation

The Empty Data Source can be loaded with data via project automation code, this is if you need to quickly create a Data source from a service that is not supported in Data Sync.

class ProjectAutomationOverride : Simego.DataSync.Automation.ProjectAutomationShim //Do Not Change This Line
{    	
    // Http Request Helper to call Json Service
    private HttpWebRequestHelper helper = new HttpWebRequestHelper() { UseDefaultCredentials = true };
    
    public override void Start()
    {        
        // Set callback function implementation.
        DataSourceA.GetDataTableCallback = GetDataTableSource;    		
    }    

    public DataTableStore GetDataTableSource(DataTableStoreCallbackInfo info)
    {            
        // Convert Datasource Properties to a Dictionary.
        var prop = DataSourceA.Properties.ToDictionary(k => k.Name);
		
        // Get a response from the Json Service
        var jsonResponse = helper.GetRequestAsJson(prop["url"].Value);
                                
        //Enumerate the result json array (use jsonResponse["xxx'] if required)
        foreach(var item_json in jsonResponse)
        {            
            // Add the columns to the Data Row
            info.Store.Rows.Add(info, 
	            (o, columnName) => 
	            {
		            // Get the requested column from the Json Document
		            var value = item_json[columnName];
					
		            //Return the value.
		            return value != null ? value.ToObject(typeof(object)) : null;				
	            });
        }
        
        return info.Store;
    }
}

Download Json Demo Project Automation Project

Dynamic Columns

Another way of achieving the same result as by using Project Automation is to use Dynamic Columns. Override the loading of the data table with your own code.

partial class DataSourceRowOverride : Simego.DataSync.DynamicColumns.DataSourceRowInternal //Do Not Change This Line
{
    //Every time DS3 calculates a row is runs this BeginRow method.
    //You can use this to decide whether to include the row in the results
    //Return true to process the row
    //Return false to skip the row
    public override bool BeginRow()
    {
        return true; // return false to skip row from results.
    }    
	
	public override DataTableStore GetDataTable(DataTableStore dt, IDataSourceReader reader) 
    {   				  		
		// Create a Callback Info Object to be used later during the data load.
		var info = new DataTableStoreCallbackInfo() 
		{
			Mapping = new DataSchemaMapping(reader.SchemaMap, reader.Side),
			IncludedColumns = reader.SchemaMap.GetIncludedColumns()
		};
				
		// Convert Datasource Properties to a Dictionary to get the Endpoint URL
		var prop = GetDataSourceA().Properties.ToDictionary(k => k.Name, v => v.Value, StringComparer.OrdinalIgnoreCase);
		
		// Get a WebRequest Helper to call the Json API
		var helper = new HttpWebRequestHelper() { UseDefaultCredentials = true, TraceEnabled = true };
		
		// Get a response from the Json Service
        var jsonResponse = helper.GetRequestAsJson(prop["url"]);
        
		//Enumerate the result json array (use jsonResponse["xxx'] if required)
        foreach(var item_json in jsonResponse)
        {            
			// Add the columns to the Data Row
            dt.Rows.Add(info, 
				(o, columnName) => 
				{
					// Get the requested column from the Json Document
					var value = item_json[columnName];
					
					//Return the value.
					return value != null ? value.ToObject(typeof(object)) : null;				
				});
        }
        
        return dt;
    }

Download Json Demo Dynamic Columns Project

Target

When used as a target the normal scenario is that is returns zero rows so all operations are actually ADD operations. These operations do not actually do anything however you can still override the action in project automation item events.

This scenario might be used simply for testing or for targeting a data source that is not currently supported by Data Sync.

Setup the Empty Data Source as a Target automatically from the Schema Map via Tools->Create Null\Empty Data Source

Create Empty Target