Datapolis Process System SDK


Home > Activities > Activity Code

Activity Code



Below you will find basic information about coding activity in Datapolis Process System. 




For coding function you need to have in your project references to:

  • Datapolis.WorkBox.Common - for useful methods (i.e. logger)
  • Datapolis.WorkBox.Activities- for base class you need to inherit while creating activity


​​Coding an activity requires developing a class that inherits from base activity class supplied by Datapolis Process System: WBActivityBase.


public class WBCreateListActivity : WBActivityBase



Parameters Registration

An activity can have some number of properties. Each parameter is defined in xml and it should be registered in code. The following pattern is used for parameter registration:

DependencyProperty property = DependencyProperty.Register([Name], [PropertyType], [OwnerType]);
  • Name - the value of the name attribute (parameter node) in the activity xml
  • PropertyType - the type of a property.

    The Datapolis Process System activity supports (from Workbox 1.5) the property types like below:

    1. string
    2. int?
    3. bool?
    4. double?
    5. datetime?
    6. Guid?
    7. Hashtable
    8. object
Note that all of the parameters types are nullable. This was provided in Workbox 1.5. Workflows that use activities with non-nullable types of parameters can't be deployed. You have to change non-nullable types to nullable types.

In the parameter definition there is used OwnerType (createListType in the provided example) - it is just type of an activity.

A few examples displaying parameters registration is shown as follow:


private static readonly Type createListType = typeof(WBCreateListActivity);
public static DependencyProperty ParentWebUrlProperty = DependencyProperty.Register("ParentWebUrl", typeof(string), createListType);
public static DependencyProperty IsQuickLuanchProperty = DependencyProperty.Register("IsQuickLuanch", typeof(bool?), createListType);


Define the Activity Properties

The implementation of activity property is a bit different from the implementation of regular class property. The dependency property accessors methods: get and set use the base class methods: GetValue and SetValue appropriately. Such as implementation is necessary from Datapolis Process System Designer point of view.

The additional aspect of coding the activity properties is to indicate which property should be required and which one not. By settings the proper ValidationOption attribute impacts on Datapolis Process System Designer behaviour and rendering related to the activity property. It is a way to manage if the given activity property should be required or not.

This example shows the activity properties coding in practice:


public string ParentWebUrl
    get { return (string)base.GetValue(ParentWebUrlProperty); }
    set { base.SetValue(ParentWebUrlProperty, value); }
public bool IsQuickLuanch
        bool? quickLaunch = (bool?)base.GetValue(IsQuickLuanchProperty);
        if (quickLaunch != null && quickLaunch.HasValue)
            return quickLaunch.Value;
        return false;
    set { base.SetValue(IsQuickLuanchProperty, value); }


Verify Activity Properties and Parameter Registration

After finishing above two points verify that all parameters names are correct and same in every place. Please see below example:


public static DependencyProperty SomeNameProperty = DependencyProperty.Register("SomeName", typeof(string), createListType);
public string SomeName
    get { return (string)base.GetValue(SomeNameProperty); }
    set { base.SetValue(SomeNameProperty, value); }


Parameters must be also specified in XML, see next step for more details.


    <Parameter Name="SomeName">

Coding the Activity Business Logic

In order to develop the activity business logic it is needed to override the ExecuteBody method. Now, Datapolis Process System workflow system requires activity to always return the ActivityExecutionStatus.Closed activity execution status. The developer who builds an activity determines whether the activity execution breaks the workflow process or not. Additionally, any data occurred during the activity execution could be traced by WBLogger. For more details see Trace Logging


This example creates a list during the activity execution. When this process is broken (e.g. the list with the same name already exists) the appropriate message will be logged and the workflow process is being continued.


protected override ActivityExecutionStatus ExecuteBody(ActivityExecutionContext c)
    this.Logger.Verbose("Starting ExecuteBody function of the create list activity");
    catch (Exception e)
        this.ErrorStatus = e.Message;
        this.ReturnListUrl = string.Empty;
        this.Logger.Unexpected("An error occured during creation a new list", e);
    this.Logger.Verbose("Ending ExecuteBody function of the create list activity");
    return ActivityExecutionStatus.Closed;


When code part is done you can move to the next step, i.e. preparing Activity XMLs which will determine what the activity looks like and how it behaves in Datapolis Designer.