Datapolis Process System SDK
Function Code
Below you will find basic information about coding functions in Datapolis Process System.
Requirements
For coding function you need to have in your project references to:
to create class that implements IWBFunctionBase interface. This interface is available in Datapolis.WorkBox.Functions assembly which you need to reference in your project. This assembly is installed with Datapolis Process System and is uploaded to GAC. This interface requires to implement Execute() method.
Implementation
Function which you create should implement interface Datapolis.WorkBox.Functions.IWBFunctionBase
public
class
WBHour : IWBFunctionBase
The main entry point where a function can implement its business logic is overriding the method: Execute():
object
Execute(WBFunctionExecutionContext functionExecutionContext)
{
//Some code
return
"Some value"
;
}
Function Properties
Function can have properties that can be set by workflow. They should be declared as simple types (string, int, double, bool, DateTime).
Example property definition:
DateTime? Value {
get
set
; }
Function Context
As a parameter in Execute method is provided WBFunctionExecutionContext. It contains data about actual context:
Example 1: If you open Action Launch Form on which you have used your function two times (e.g. in footer), both runs of Execute method will gather the same CorrelationId
Example 2: If you open Action Launch Form two times (e.g. by refreshing window in browser) and you have already used your function on this form then each request to your function will get different CorrelationId
Please note that there is no SPWeb object where workflow runs in WBFunctionExecutionContext and accessing it by SPContext.Current.Web is highly not recommended due to possibility of running your function in SharePoint Timer Service where SPContext is null. Below you will find example of Execute method where Locale is used.
logger.Verbose(
"Function start"
);
if
(
string
.IsNullOrEmpty(
this
.Value))
logger.Medium(
"Value = [NULL] or Empty"
"Output: [NULL]"
"Function end"
null
"Value = "
+ Value.ToString());
result = WBVariableTypeHelper.ParseMathExpression(
.Value, functionExecutionContext.Locale);
(result ==
) logger.Monitorable(
else
"Output: "
+ result.ToString());
result =
.Format(functionExecutionContext.Locale,
"{0}"
, result);
result;