Datapolis Process System SDK
Creating Function Tutorial
This walkthrough will guide you through creating a custom function. The function takes date as argument and returns hour.
Prerequisites
Before creating a custom activity, be sure you have installed all of the necessary components.
ResGen.exe Datapolis.WorkBox.Sdk.Samples.Functions.resx Datapolis.WorkBox.Sdk.Samples.Functions.resources
ResGen.exe Datapolis.WorkBox.Sdk.Samples.Functions.pl-PL.resx Datapolis.WorkBox.Sdk.Samples.Functions.pl-PL.resources
Note: If you encounter errors when building your project please see "Environment Variables" section in Visual Studio Integration. Errors are probably caused by unspecified path to building tools. Also they may be related to problems with find 15th folder - check its path.
Prepare xml files
Define the function category. Open Datapolis.WorkBox.Sdk.Samples.Functions.Categories.xml and insert definition of the 'Date' function category.
<
FunctionCategories
xmlns
=
"http://www.datapolis.com.pl/WorkBox/FunctionCategories.xsd"
>
FunctionCategory
Name
"SDK.Date"
Title
"$Resources:Datapolis.WorkBox.Sdk.Samples.Functions,FunctionCategoryDate;"
></
</
Define the function. Open Datapolis.WorkBox.Sdk.Samples.Functions.xml and insert the below function definition
Functions
"http://www.datapolis.com.pl/WorkBox/Functions.xsd"
Function
"Datapolis.WorkBox.Sdk.Samples.Functions.WBHour"
"$Resources:Datapolis.WorkBox.Sdk.Samples.Functions,WBHour_FunctionTitle;"
Description
"$Resources:Datapolis.WorkBox.Sdk.Samples.Functions,WBHour_FunctionDescription;"
Assembly
"Datapolis.WorkBox.Sdk.Samples, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0a68baededa28155"
Category
Parameter
"Value"
"$Resources:Datapolis.WorkBox.Sdk.Samples.Functions,WBHour_Value_Title;"
"$Resources:Datapolis.WorkBox.Sdk.Samples.Functions,WBHour_Value_Description;"
Type
"String"
Develop code
When the both function category and function are defined, open WBHour.cs file and insert code implementation of the function:
using
System;
Datapolis.WorkBox.Common;
Datapolis.WorkBox.Functions;
namespace
Datapolis.WorkBox.Sdk.Samples.Functions
{
public
class
WBHour :IWBFunctionBase
DateTime? Value {
get
;
set
; }
object
Execute(WBFunctionExecutionContext functionExecutionContext)
if
(
this
.Value ==
null
)
return
.Value.Value.Hour;
}
Prepare multilanguage (optional)
Set the activity translation. Right click on the resource file Datapolis.WorkBox.Sdk.Samples.Functions.resx and select Open With... context menu. Pick XML Editor and click OK button. Just before the node: </root> insert the following xml translation
data
name
"FunctionCategoryDate"
xml:space
"preserve"
value
>SDK Date</
"WBHour_FunctionDescription"
>Returns the hour of a time value. The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.).</
"WBHour_FunctionTitle"
>Hour</
"WBHour_Value_Description"
>Enter the date that contains the hour you want to find.</
"WBHour_Value_Title"
>Date</
For Polish version use the below translations:
>SDK Funkcje daty</
>Zwraca godzinę w postaci numeru seryjnego. Godzina jest określona liczbą całkowitą z zakresu od 0 do 23.</
>Godzina</
>Określa datę, z której chcesz uzyskać godzinę.</
>Data</
Build project
Finally build your project and check how it works in Workflow Designer.
Remember that if you change some important parts of xml (like assembly, function name, parameter name) you have to remove function form your workflow, reopen designer and add your function again - otherwise it may not work.
Next Steps
Optionally, after reading this walkthrough you can see the same function code attached in SDK Samples in Download section.