Developer Reference - Creating Plugins

You can easily extend ActiveDataTools with your own plugins. This powerful feature enables you to create import and export connectors to your own systems, quickly and easily.

This guide will take you step-by-step through the process.

Requirements

To develop extensions, you will need .NET Framework 4.0, either C# or VB.NET and ideally Visual Studio 2010/2012/2013.

Background

Extensions in ActiveDataTools use the Managed Extensibility Framework. Once you have created your importer or exporter DLL, all you need to do is to drop it in to the plugins subfolder of ActiveDataTools and the system will pick it up next time you run the application.

Creating the Project

  1. Create a new class library in Visual Studio. Make sure you set the target framework version to .NET 4.0
  2. Add a reference to DigitalActive.DataTools.Plugins.Interfaces.dll (download below) and System.ComponentModel.Composition.
  3. Create a new class for each importer or exporter required (see below).
  4. Compile the project to a library DLL.
  5. Copy the DLL (and any associated files) to the \plugins subfolder. This is usually located at %Program Files%\ActiveDataTools\ActiveDataTools 2014\plugins.

Running your Extension

If you have created an importer, to run your extension, go to the Open menu and then select Other Sources. This will display a list of available importer extensions. If you have created an exporter, first create or open a worksheet in ActiveDataTools, click the Save As button and then choose Other Sources to display a list of available exporters.

Creating an Importer

To create an importer, you need to create a class that implements the IActiveDataToolsImporter interface. This interface currently exposes the following members:

DataSet GetData(IActiveDataTools host);
string DisplayName { get; }

ActiveDataTools calls the GetData method (passing in a host interface) when it needs to retrieve data from your extension. Your extension should return either a valid DataSet object or null, which represents 'no data'.

Your DataSet can contain one or more tables. Each table will be converted in to a worksheet in the ActiveDataTools UI. If your DataSet does not contain any tables, ActiveDataTools will do nothing.

Example extension:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DigitalActive.DataTools.Plugins.Interfaces;
using System.Data;
using System.ComponentModel.Composition;

namespace TestPlugin
{
    [Export(typeof(IActiveDataToolsImporter))]
    public class MyFirstPlugin : IActiveDataToolsImporter
    {
        #region IActiveDataToolsImporter Members
        public System.Data.DataSet GetData(IActiveDataTools host)
        {
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();

            dt.Columns.Add("X");
            dt.Columns.Add("Y");
            dt.Columns.Add("Z");

            dt.Rows.Add("a", "b", "c");
            dt.Rows.Add("d", "e", "f");

            ds.Tables.Add(dt);
            return ds;
        }

        public string DisplayName
        {
            get
            {
                return "My First Plugin";
            }
        }
        #endregion
    }
}

Important: Remember to decorate your class with the MEF [Export] attribute.

Creating an Exporter

To create an exporter, you need to create a class that implements the IActiveDataToolsExporter interface. This interface currently exposes the following members:

void SaveData(IActiveDataTools host, DataSet dataSet);
string DisplayName { get; }
bool MultiTable { get; }

ActiveDataTools calls the SaveData method when it needs to save data using your extension. The DataSet parameter will contain one or more tables, depending on the value of MultiTable. If your exporter's MultiTable property returns 'false', the user can only select one table to send to your exporter. If the property returns 'true' the user is able to select one or more tables.

Example extension:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DigitalActive.DataTools.Plugins.Interfaces;
using System.Data;
using System.ComponentModel.Composition;

namespace TestPlugin
{
    [Export(typeof(IActiveDataToolsExporter))]
    public class MyFirstExporter : IActiveDataToolsExporter
    {
        #region IActiveDataToolsExporter Members
        public void SaveData(IActiveDataTools host, DataSet dataSet)
        {
            dataSet.WriteXml(@"c:\output.xml", XmlWriteMode.WriteSchema);
        }

        public string DisplayName
        {
            get
            {
                return "My First Exporter";
            }
        }

        public bool MultiTable
        {
            get
            {
                return true;
            }
        }
        #endregion
    }
}

Important: Remember to decorate your class with the MEF [Export] attribute.

Deploying Your Solution

Deploying your solution is easy - just copy your DLL and required files in to the plugins subfolder of ActiveDataTools. The extension will be picked up next time you run ActiveDataTools.

More Help...

If you need more help or advice regarding the development of extension, please contact us.

AttachmentSize
DigitalActive.DataTools.Plugins.Interfaces.dll5.5 KB

Products