Developing .NET Components
Process Suite v23 allows you to extend its functionality by integrating custom .NET components. These components can be class libraries (DLL) called from scripts, custom actions, or specific services.
Creating a Class Library
To create a component compatible with APS v23:
- Create a Class Library project (.NET Framework) in Visual Studio.
- Target .NET Framework 4.8.
- Add references to the necessary APS DLLs (available in the server's
Bindirectory):Avanteam.Kernel.dllAvanteam.Documents.dllAvanteam.Workflow.dll
Utility Class Example
using System;
using Avanteam.Kernel;
namespace MonExtension.Utils
{
public class CalculateurService
{
public double CalculerRemise(double montant, string codeClient)
{
// Custom logic
if (codeClient == "VIP") return montant * 0.2;
return 0;
}
}
}
Usage in APS
Once your DLL is compiled and placed in the Bin directory of the APS web site, you can use it in several ways:
Script Library
In Process Studio, you can register your class in the Script Library. This makes your class methods available in the formula editor or workflow scripts as predefined functions.
Workflow C# Scripts
The workflow engine can dynamically load your assemblies to execute complex processes.
// Example of dynamic loading in a workflow script
var assembly = AppDomain.CurrentDomain.Load("MonExtension");
var service = assembly.CreateInstance("MonExtension.Utils.CalculateurService");
// Method call by reflection...
Best Practices
- Error Handling: Always wrap your calls in
try-catchblocks and useAvanteam.Kernel.Log.LogManagerto trace errors. - Performance: Avoid keeping connections open too long. Use the data managers provided by APS (see Data Model and ORM section).
- Versioning: Use clear assembly versions to facilitate production updates.