Writing a new CodeWorkflow

Build 1501 on 14/Nov/2017  This topic last edited on: 21/Mar/2016, at 18:52

Once the CodeWorkflowTestExpress VB.NET project has been successfully compiled, you are ready to write the code workflow.

The VB.NET project contains a file called Program.vb: double-click on it to open.

This file is a simple VB.NET module: when running the project, the __Do() method  of the SequentialWorkflow class is called.

You have to write your new sequential code workflow into that method, after the comment “Sequential workflow code goes here”.

  Public Class SequentialWorkflow

    '--------------------- Sequential workflow sub/functions/fields go here

    '--------------------- End of sequential workflows sub/functions/fields

    Private Sub __Do()

      '----------------------- Sequential workflow code goes here

 

write here your sequential code workflow

 

      '----------------------- End of sequential workflow code

    End Sub

  End Class

If the code workflow contains Sub() or Function() VB.NET methods, they must be written into the Program.vb file just after the “Sequential workflow sub/functions/fields go here” comment. For example:

 

  Public Class SequentialWorkflow

    '--------------------- Sequential workflow sub/functions/fields go here

Sub ClearTestObject(ids As IList(Of Integer))

  'clear test objects

  Dim spikeAct As Spike = New Spike(Context) With {.Name = "spike"}

  spikeAct.ObjectIds = ids

  Dim spikeRes As SpikeResult = spikeAct.Do()

End Sub

    '--------------------- End of sequential workflows sub/functions/fields

    Private Sub __Do()

      '----------------------- Sequential workflow code goes here

Dim imgId As Integer = 12345

Dim loadImgAct As LoadObjects = New LoadObjects(Context) With {.Name = "load picture", .Description = "loading image..."}

loadImgAct.ObjectIds.Add(imgId)

Dim loadImgRes As LoadObjectsResult = loadImgAct.Do()

Dim objectXml As XDocument = loadImgRes.XmlOut

ClearTestObject(New List(Of Integer)({imgId}))

      '----------------------- End of sequential workflow code

    End Sub

  End Class

Visual Studio Express supports you with IntelliSense while writing a code workflow. This means that if you write, in the above example, “loadImg.”, then Visual Studio Express shows you all the available methods and properties of the LoadObjects activity.

codewf3