Implement an Activity that Calculates a Logarithm
Implementing a custom activity allows you to build a reusable, completely custom behavior to augment the existing activities that come with Geocortex Workflow.
In this article, you will learn how to create a custom activity that calculates the logarithm of a number with a given base.
Prerequisites
important
Extending Geocortex Workflow with server side components requires an on-premises installation of Geocortex Workflow. You will need administrative access to this installation.
Follow the instructions in the Geocortex Workflow Server page to set up your development environment and Geocortex Workflow Server extension project.
note
A working knowledge of C# and the .NET platform is recommended before extending Geocortex Workflow Server
Set up the Activity Skeleton
- Create a new file
CalculateLog.cs
in the project. - Add a new skeleton workflow activity that implements
IActivityHandler
.
tip
Use a unique prefix on the Action
property to avoid it conflicting with someone else's custom activities.
Register the Activity with an Assembly Attribute
- Create a new file,
Properties\AssemblyInfo.cs
- Add the custom Geocortex Workflow attribute to
AssemblyInfo.cs
:
This registers the assembly to a namespace that Geocortex Workflow Server can discover.
note
By convention, assembly attributes are typically added to a file called "Properties\AssemblyInfo.cs"
, but they can be added to any code file.
Implement the Custom Activity
We now have a empty activity that Geocortex Workflow Server can use that takes no inputs and produces no outputs. By changing the inputs, outputs, and execute logic, you can create your own custom activity that calculates the logarithm of a number.
First, let's change the execute logic to parse inputs that make sense for a logarithm activity.
Next, modify the Execute
method of the activity to calculate the logarithm of a number given an optional base
Deploy the Activity
Follow the instructions to deploy Geocortex Workflow Server activities.
Test your Activity
Server workflows that run on your Geocortex Workflow Server deployment can now run this custom activity.
tip
Registering .NET activity stubs provides a user friendly interface for your custom activities in Geocortex Workflow Designer.
You can run the custom activity by referencing it by action with the RunActivity
activity.
note
You can download this demo server workflow that runs the custom activity and import it into the Geocortex Workflow Designer.