Authoring Workflows
A workflow can be created programmatically in code, but normally it is defined via a XAML file, which defines the entire workflow via an industry-standard XML-based file format. The XAML file is a text file, which facilitates version and change control using industry-standard tools such as Git.
The XAML namespace used for workflow activities in Acuit Pinpoint is:
http://schemas.acuit.com/pinpoint/2020/xaml/workflows
Simple Example
A XAML file that defines a very simple workflow that simply delays for five seconds, while allowing the duration to be configurable via a parameter, could look like this:
Workflow.xaml
<Sequence xmlns="http://schemas.acuit.com/pinpoint/2020/xaml/workflows">
<Sequence.Parameters>
<Parameter Name="DelayTime" Type="TimeSpan" DefaultValue="0:00:05" Description="How long to delay." />
</Sequence.Parameters>
<Delay Duration="[param.DelayTime]" />
</Sequence>
Type Converters
Parameter and variable values are specified
in a XAML file as text. The .NET type converter infrastructure will automatically attempt to convert
these text values to the appropriate type for the parameter or variable. For example, in the simple
example workflow above, the "DelayTime" parameter's default value was specified as 0:00:05
, which
is automatically converted to a TimeSpan of 5 seconds.
The invariant culture will always be used when performing this conversion. For example, the floating-point value for 1-1/2 must be specified as "1.5", even if the computer running the workflow is configured with culture settings that would normally cause that value to display as "1,5".
Some custom type converters are automatically registered to make authoring workflows in XAML easier. The following types can be converted from strings as follows:
- Arrays of the various integer types (i.e.,
byte[]
,sbyte[]
,int[]
,uint[]
,long[]
,ulong[]
,short[]
, orushort[]
):- Array literals are specified as comma-separated lists of values or value ranges. For example:
1
= the single value 11,4,3
= the three values 1, 4, and 310-15
= the six values 10, 11, 12, 13, 14, and 1599,1-3,-14
= the five values 99, 1, 2, 3, and -14
- Array literals are specified as comma-separated lists of values or value ranges. For example:
- Arrays of other primitive value types (
bool[]
,decimal[]
,double[]
, orfloat[]
):- Array literals are specified as comma-separated lists of values. For example:
1.5
= the single value 1.51,4.2,-3
= the three values 1, 4.2, and -3
- Array literals are specified as comma-separated lists of values. For example:
Any custom types added for use by workflows as parameters or variables must have type converters registered that can convert from string values to the custom type.
Using Custom Activities
A custom activity can be used in a workflow XAML file by doing the following:
- Create the custom activity by creating a public class that derives from Activity, implementing the custom execution logic.
- Reference the custom activity in your workflow XAML file just like you would any other activity, being sure to properly specify the activity's namespace.
- Ensure the assembly containing the custom activity is loaded into the process before attempting to load the workflow from the XAML file. With Test Workflows,this can be accomplished by placing the custom activity in an Acuit Pinpoint Workstation plug-in that is configured for the station type using the workflow.
For example, the following custom activity could be defined:
namespace MyCompany.Workflows
{
public class MyCustomActivity : Activity
{
protected override Task OnExecuteAsync(ActivityContext context, CancellationToken cancellationToken)
{
// TODO: Implement the logic here...
}
}
}
It could then be added to the simple workflow example from above like this:
<Sequence xmlns="http://schemas.acuit.com/pinpoint/2020/xaml/workflows"
xmlns:my="clr-namespace:MyCompany.Workflows">
<Sequence.Parameters>
<Parameter Name="DelayTime" Type="TimeSpan" DefaultValue="0:00:05" Description="How long to delay." />
</Sequence.Parameters>
<Delay Duration="[param.DelayTime]" />
<my:MyCustomActivity />
</Sequence>