About plugins

It is possible to tune the behavior of certain processes using activities with support for plugins. In this release, the only process using plugins is the ExternalCommunication package with the SmartPost process.

The SimpleMergeDocumentsToPdf activity tests for the availability of a function with the signature:

/// <summary>
/// Update the record.
/// </summary>
/// <param name="updateRecord">The Pdf record to update</param>
/// <param name="inputRecords">The records used when merging the Pdf record.</param>
/// <returns></returns>
bool UpdateRecord(string updateRecord, List<String> inputRecords);
 

Currently, this is the only activity that uses functions in a plugin but in the future other activities may support other functions that must also be defined in the plugin.

To create a plugin, you must create a C# class library project and define the interface. For example:

using System;
using System.Collections.Generic;

namespace WorkZone.<package>.Plugin
{
    /// <summary>
    /// Plugin to do updated to recently merged Pdf records.
    /// </summary>
    public interface IPostPdfMerge
    {
        /// <summary>
        /// Update the record.
        /// </summary>
        /// <param name="updateRecord">The Pdf record to update</param>
        /// <param name="inputRecords">The records used when merging the Pdf record.</param>
        /// <returns></returns>
        bool UpdateRecord(string updateRecord, List<String> inputRecords);
    }
}
 

The interface name is defined in the package where the process is defined. The class library assembly name is defined in the extension package.

The implementation must implement a constructor with the signature shown below and the function defined in the interface:

using System;
using System.Collections.Generic;
using System.Net;

namespace WorkZone.<package>.Plugin
{
    /// <summary>
    /// Implements Plugin for SimpleMergeDocumentsToPdf.
    /// </summary>
   public class PostPdfMerge : PluginBase, IPostPdfMerge
   {
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="oDataUri">The oData Uri.</param>
        /// <param name="credentials">The credentials used for oData.</param>
        public PostPdfMerge(Uri oDataUri, ICredentials credentials) : base(oDataUri, credentials)
        {
        }

        /// <summary>
        /// Update newly created Pdf document with additional metadata.
        /// </summary>
        /// <param name="updateRecord">The newly generated PDF document</param>
        /// <param name="inputRecords">The documents contained in the PDF</param>
        /// <returns>true if the update succeds.</returns>
        public bool UpdateRecord(string updateRecord, List<string> inputRecords)
        {
        }
    }
}
 

The base interface exposes two methods, which allows the function to get an OData client context and a simple OData client.

ODataService GetOdataContext();

SimpleODataClient GetSimpleODataClient();

If the plugin needs to update custom properties that are not known to the OData context the SimpleODataCLient must be used.