View All Blog Posts

Integrate Data Sync with 3rd Party Systems

We now have an alternative way for you to integrate other systems that we do not have providers for with Data Sync. This could be used with virtually anything and support 2 way synchronisations.

The process involves a Data Sync provider that connects to a Web Service and you would place your code in the web service. We have abstracted all the schema mapping code that you needed to contend with when writing providers directly so you simply detail with connectivity to the system your connecting to. Also as it's a separate Visual Studio project you can easily debug the Web Service end in Visual Studio.

Overview

Overview

Web Service

The Web Service exposes a few methods that the Data Sync provider will interact with we are supplying a template Visual Studio Project that you can use to build your project.

  • GetSchemas - Return a List of DataSources/Schemas from the Service
  • GetDefaultSchema - Returns Schema Information for a Schema/DataSource
  • GetData - Returns the Data from the DataSource
  • AddItem - Add's an Item
  • UpdateItem - Update's an Item
  • DeleteItem - Deletes an Item

DataService

Really Simple Connector

Below is some sample source code for a really simple read-only connector that is also supplied in the sample project. You can see there are just a few simple methods that you need to implement to get it working.

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;

namespace DataSyncService.DataSources
{
    public class DefaultDataSource : IDataSource
    {
        private readonly DataTable _dataTable = new DataTable();

        public DefaultDataSource()
        {
            //Setup Schema
            _dataTable.Columns.Add("ID", typeof (int));
            _dataTable.Columns.Add("FirstName", typeof (string));
            _dataTable.Columns.Add("LastName", typeof(string));
            _dataTable.Columns.Add("Email", typeof(string));
            _dataTable.Columns.Add("Phone", typeof(string));

            _dataTable.Columns["ID"].Unique = true;

            //Add Rows
            _dataTable.Rows.Add(new object[] { 1, "Sean", "Cleaver", "sean@simego.com", "555-1234" });
            _dataTable.Rows.Add(new object[] { 2, "Trem", "Christ", "trem@simego.com", "555-1235" });

        }

        public List<SchemaItem> GetDefaultSchema()
        {
            return (from DataColumn column in _dataTable.Columns select new SchemaItem {ColumnName = column.ColumnName, DataType = column.DataType.ToString(), Unique = column.Unique}).ToList();
        }

        public List<object[]> GetData(List<SchemaItem> detail)
        {
            var data = new List<object[]>();

            foreach(DataRow row in _dataTable.Rows)
            {
                var rowData = new object[detail.Count];
                for (var i = 0; i < detail.Count; i++)
                    rowData[i] = row[detail[i].ColumnName];
                data.Add(rowData);
            }
            
            return data;
        }

        public void AddItem(object key, DataItem[] values)
        {

        }

        public void UpdateItem(object key, DataItem[] values)
        {

        }

        public void DeleteItem(object key)
        {

        }
    }
}

Connecting to the Web Service

To Connect to the Web Service you need to install the Data Sync Integration Web Service Connector and then it's a matter of entering the URL to the Service and choosing a Data Source from the Drop down.

Connect

Once you connect to the Web service everything just works like any other Data Source in Data Sync. You can change the Data Source, Refresh the Schema etc all from within Data Sync.

Data Sync

Download the necessary connector and sample web service code.

| Tuesday, August 16, 2011 |