Create an Activity
This article will walk you through creating a new workflow activity for VertiGIS Studio Workflow Server.
Prerequisites
Extending VertiGIS Studio Workflow with server side components requires an on-premises installation of VertiGIS Studio Workflow. You will need administrative access to this installation.
Follow the instructions in the VertiGIS Studio Workflow Server page to set up your development environment and VertiGIS Studio Workflow Server extension project.
A working knowledge of C# and .NET Standard is recommended before extending VertiGIS Studio Workflow Server
Create the Activity
- Create a new file
CustomActivity.cs
in the root of your VertiGIS Studio Workflow Server extension project. - Add a new skeleton workflow activity that implements
IActivityHandler
.
using VertiGIS.Workflow.Runtime;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace App1.Workflow
{
public class CustomActivity : IActivityHandler
{
public static string Action { get; } = "uuid:<uuid>::CustomActivity";
public Task<IDictionary<string, object?>> Execute(IDictionary<string, object?> inputs, IActivityContext context)
{
return Task.FromResult((IDictionary<string, object?>)new Dictionary<string, object?>(){
["test"] = "value"
});
}
}
}
Register the Activity with an Assembly Attribute
- Create a new file,
Properties\AssemblyInfo.cs
- Add the custom VertiGIS Studio Workflow attribute to
AssemblyInfo.cs
:
[assembly: VertiGIS.Workflow.Runtime.WorkflowActivities]
This registers the assembly to a namespace that VertiGIS Studio Workflow Server can discover.
By convention, assembly attributes are typically added to a file called "Properties\AssemblyInfo.cs"
, but they can be added to any code file.
Deploy the Activity
Follow the instructions to deploy VertiGIS Studio Workflow Server activities.
Use the Activity in a Workflow
Server workflows that run on your VertiGIS Studio Workflow Server deployment can now run this custom activity.
Registering stubs for .NET activities provides a user friendly interface for your custom activities in VertiGIS Studio Workflow Designer.
You can run the custom activity by referencing it by action with the RunActivity
activity. The custom activity created in this article takes no inputs but produces an output with the property "test".
You can
download this demo server workflow
that runs the custom activity and
import it into the VertiGIS Studio Workflow Designer.