In a real production GN4 environment, the code workflows are called by menu, toolbar, script, etc… receiving input data (name-value parameters, list of GN4 objects ids, list of files, etc…).
In GN4 there is an .aspx test page (http://localhost/GN4/test/wftestForm.aspx), where you can specify the input parameters and run a workflow (both WindowWorkflow and CodeWorkflow) for testing (note that the workflow must already exist into the GN4 database).
In the testing environment of the code workflows, we can specify the input data of the workflow modifying the RunSequential call in the Program.vb file:
' Sequential workflow test call
hasLogError = WFTest.RunSequential(
GetType(SequentialWorkflow),
WFTest.Ids(),
WFTest.DataFiles(),
WFTest.Pars(),
executionLog
)
The RunSequential method accepts:
-a list of ids (integers). For example:
' Sequential workflow test call
hasLogError = WFTest.RunSequential(
GetType(SequentialWorkflow),
WFTest.Ids(12345, 12346),
WFTest.DataFiles(),
WFTest.Pars(),
executionLog
)
List of ids
This list of ids is copied into the Context.ObjectIds property of the ExecutionContext object.
So, the following lines:
Dim loadImgAct As LoadObjects = New LoadObjects(Context) With {.Name = "load picture", .Description = "loading image..."}
loadImgAct.ObjectIds = Context.ObjectIds
Dim loadImgRes As LoadObjectsResult = loadImgAct.Do()
are equivalent to:
<LoadObjects
x:Name="loadImgAct"
Description="loading image..."
ObjectIds="{wf:ActivityBind mainWorkflow, Path=ObjectIds}" />
of the old WindowsWorkflow.
List of files
For example:
' Sequential workflow test call
hasLogError = WFTest.RunSequential(
GetType(SequentialWorkflow),
WFTest.Ids(),
WFTest.DataFiles("c:\temp\myPicture.jpg", "c:\temp\myDocument.xml"),
WFTest.Pars(),
executionLog
)
This list of files is copied into the Context.Data property of the ExecutionContext object.
So, the following lines:
Dim callImportDocumentsAct As ExecuteSequentialWorkflow = New ExecuteSequentialWorkflow(Context) _
With {.Name = "execute workflow", .Description = "Call the documents import workflow"}
callImportDocumentsAct.WorkflowName = "ImportDocuments"
callImportDocumentsAct.Data = Context.Data
Dim callImportDocumentsRes As ExecuteSequentialWorkflowResult = callImportDocumentsAct.Do()
are equivalent to:
<ExecuteSequentialWorkflow
x:Name="callImportDocumentsAct"
Description="Call the documents import workflow"
WorkflowName="ImportDocuments"
Data='{wf:ActivityBind mainWorkflow, Path=Data}'>
of the old WindowsWorkflow.
List of name-value parameters
' Sequential workflow test call
hasLogError = WFTest.RunSequential(
GetType(SequentialWorkflow),
WFTest.Ids(),
WFTest.DataFiles(),
WFTest.Pars("destPath", "c:\temp", "maxSize", "250"),
executionLog
)
This list of parameters is copied into the ExecutionContext object.
Read parameter value
To read the parameter value from the CodeWorkflow, you can use the Context.ParValue() method.
Dim destPath As String = Context.ParValue("destPath")
If String.IsNullOrEmpty(destPath) Then
Throw New TeraDP.GN4.Common.WorkflowException(TeraDP.GN4.Common.ErrorCode.WFInvalidParam, "destPath")
End If
Dim maxSizeValue As String = Context.ParValue("maxSize")
If String.IsNullOrEmpty(maxSizeValue) Then
Throw New TeraDP.GN4.Common.WorkflowException(TeraDP.GN4.Common.ErrorCode.WFInvalidParam, "maxSize")
End If
Dim maxSize As Integer = CInt(maxSizeValue)
See the ‘Error management’ section for more info about WorkflowException.