All Classes Namespaces Functions Properties Pages
Custom dll

This page explains how to set up a custom dll that is used to import a package that is stored in a compressed (.zip) file.

Creating the custom dll

This section will explain how to create a custom dll that will be used to import and export TotalAgility processes. Please see ImportPackage3 for more details.

Create the dll

For details of how to create an assembly please see here except this project will need to be a Class Library instead of a Console Application:

Add the code

This dll is necessary for importing and exporting processes using the SDK as the relevant methods have a byte array as a parameter which is not supported directly by the Process Designer.

The code for the dll is as follows:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ImportExportPackage
public class ImportExportPackage
public Agility.Sdk.Model.Package.ImportPackageResult importPackageFromFile(string sessionID, string filename, Agility.Sdk.Model.Package.PackageImportOptions3 importOptions, Int16 importType)
FileInfo fileInfo = new FileInfo(filename);
if (fileInfo.Exists)
// open the file
FileStream fileStream = fileInfo.OpenRead();
// create a buffer in memory and set it to the correct length
MemoryStream memstream = new MemoryStream();
// copy from the file to the memory stream
fileStream.Read(memstream.ToArray(), 0, (int)fileStream.Length);
TotalAgility.Sdk.ServerService serverService = new TotalAgility.Sdk.ServerService();
return serverService.ImportPackage3(sessionID, memstream.ToArray(), importOptions, importType);
return null;
public bool exportPackageToFile(string sessionID, string filename, Agility.Sdk.Model.Package.PackageExportOptions2 exportOptions, bool overwrite)
// create a file object for the specfied file
FileInfo fileInfo = new FileInfo(filename);
// If the file already exists and overwrite hasn't been specifed then return an error
if (fileInfo.Exists && !overwrite)
return false;
// Setup the ServerService object
TotalAgility.Sdk.ServerService serverService = new TotalAgility.Sdk.ServerService();
// make the call to the ExportPackage and capture the byte array
byte[] package = serverService.ExportPackage2(sessionID, exportOptions);
// open the file to be saved
FileStream fileStream = fileInfo.OpenWrite();
// write the data to the file
fileStream.Write(package, 0, package.Length);
return true;

Setting up the reference to the dll

Once the dll is created a reference to it needs to be added to TotalAgility. Go to the Integration page, click .Net Assemblies and then the + button. The path to the dll will need to be entered by hand and then click Ok:


Using the dll in a process map

Next, a simple process map will be created that uses the custom dll. It has 2 nodes:


Configuring the nodes

Create a new process maps and add two nodes and an end point. Rename the process to something suitable such as 'Import Package'. Then add a string variable called SessionId.

The Get Session Id node

This node will make a call to GetSession to retrieve a session Id for a user and capture the returned sessionId in the variable created earlier:

The Import Package node

This node will call the ImportPackageFromFile method in the custom dll created earlier. Map in the SessionId variable and add a filename. The parameters, importOptions and importType, will be the same as those described in ImportPackage3: