Custom Import/Export

Adding custom functionality when publishing or importing data

This guide will step through the process of coding a custom integration step. If you are just getting started, you can learn about getting started with customizations

This is an Import and Publish Option that can be used for integration to other systems.

When a Publish is initiated with this option checked,  APS Extra Services does the following:

  1. Attempts to load a Microsoft .Net dll called "CustomInterface.dll" in the Extra Services Working Directory. This dll must implement IPTCustomInterface as described below.
  2. A memory-resident copy of the Publish DataSet is created. This matches the DataSet shown by the Browse Publish Data function.
  3. Calls the PerformExport method on the custom interface, passing the working directory path and the DataSet. At this point, the custom logic can be used to update third party applications using the data in the Publish DataSet.

When an Import is initiated with this option checked,  APS Interface Service does the following:

  1. Attempts to load a Microsoft .Net dll called "CustomInterface.dll" in the Interface Service Working Directory. This dll must implement IPTCustomInterface as described below.
  2. Calls the PerformImport method on the custom interface passing in the working directory.
  3. Listens for the SendTransmissionEvent.
  4. If RunStandardImport is true, the import process continues once the PerformImport method returns.

Once the custom data is imported in this function, an ImportT transmission can be created and the SentTransmissionEvent can be raised to send the transmission and refresh the APS data.

Enable the Customization

The enable this customization, a setting in the Import Mappings must be enabled. On the welcome page, enable the Use a Custom Interface... option.

CustomInterfaceOptionEnable

IPTCustomInterface

These are the elements of the Interface:

///<summary>
/// Trigger sending of transmissions to APS.
///</summary>
void PerformImport(string workingDirectory);

/// <summary>
/// Whether to run the standard import after this import.
/// </summary>
bool RunStandardImport { get; }

///<summary>
/// Fire this event to submit a Transmission to APS.
///</summary>
event InterfaceDelegate.SendTransmissionHandler SendTransmissionEvent;

///<summary>
/// Export the data.
///</summary>
void PerformExport(string workingDirectory, PT.Database.PtDbDataSet dataset);

Example:

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

using PT.Transmissions;
using PT.ERPTransmissions;

namespace PT.CustomInterface
{
public class CustomInterfaceExample : PT.CustomInterface.IPTCustomInterface
{

public void PerformImport(string workingDirectory)
{
//Custom integration can be done here.

//Single transmission example
PT.ERPTransmissions.PlantT plantT = new PT.ERPTransmissions.PlantT();
//TODO: Need to create a sql adapter and open connection
System.Data.IDbCommand command = new System.Data.SqlClient.SqlCommand("Select * from APS_Plants");
plantT.Fill(command);

//A standard import transmission can be sent as well
PT.ERPTransmissions.ImportT importT = new PT.ERPTransmissions.ImportT();
SendTransmissionEvent?.Invoke(this, imporT);

//Once this function returns, the import process will continue
}

public bool RunStandardImport => false;

public event InterfaceDelegate.SendTransmissionHandler SendTransmissionEvent;

public void PerformExport(string workingDirectory, PT.Database.PtDbDataSet dataset)
{
//Custom integration can be done here.
}
}
}

Other Uses

This customization point can also be used to run custom logic before each import and then allow the standard import to continue. For example, instead of sending an ImportT from the customization, a ScenarioDetailClockAdvanceT could be sent to advance the clock to the current time.

Next Steps

Take a look at some other Customization Points