Skip to content
Roger Castaldo edited this page Sep 12, 2024 · 26 revisions

Welcome to BPMEngine a library designed to execute BPMN 2.0 compliant diagrams (XML Documents) and execute them in software. The execution of a business process can be extended by creating xml elements inside of the bpmn:extensionElements item inside BPMN (which is the compliant method). When executing a process and intercepting the tasks and elements, you can write code to access the elements inside of the item to perform appropriate steps based on the extension that has been written.

Contents

ActiveStepsException type

Namespace

BPMNEngine

Summary

This Exception is thrown when a Process Instance is being disposed but still has active steps

BasicEvents type

Namespace

BPMNEngine.DelegateContainers.Events

Summary

Base class used to define the properties (event types) for a given element types events

Completed property

Summary

This delegate is called when a particular element completes

public void OnEventCompleted(IStepElement Event, IReadonlyVariables variables){
    Console.WriteLine("Event {0} inside process {1} has completed with the following variables:",Event.id,Event.Process.id);
    foreach (string key in variables.FullKeys){
        Console.WriteLine("\t{0}:{1}",key,variables[key]);
    }
}

Error property

Summary

This delegate is called when a particular element has an error

    public void OnEventError(IStepElement Event, IReadonlyVariables variables){
        Console.WriteLine("Event {0} inside process {1} had the error {2} occur with the following variables:",new object[]{Event.id,Event.Process.id,variables.Error.Message});
        foreach (string key in variables.FullKeys){
            Console.WriteLine("\t{0}:{1}",key,variables[key]);
        }
    }

Started property

Summary

This is the delegate called when a particular element starts

public void OnEventStarted(IStepElement Event, IReadonlyVariables variables);{
    Console.WriteLine("Event {0} inside process {1} has been started with the following variables:",Event.id,Event.Process.id);
    foreach (string key in variables.FullKeys){
        Console.WriteLine("\t{0}:{1}",key,variables[key]);
    }
}

BusinessProcess type

Namespace

BPMNEngine

Summary

This class is the primary class for the library. It implements a Business Process by constructing the object using a BPMN 2.0 compliant definition. This is followed by assigning delegates for handling the specific process events and then starting the process. A process can also be suspended and the suspended state loaded and resumed. It can also be cloned, including the current state and delegates in order to have more than once instance of the given process executing.

#ctor(doc,constants,events,validations,tasks,logging) constructor

Summary

Creates a new instance of the BusinessProcess passing it the definition, StateLogLevel, runtime constants and LogLine delegate

Parameters
Name Type Description
doc System.Xml.XmlDocument The Xml Document containing the BPMN 2.0 definition
constants System.Collections.Generic.IEnumerable{BPMNEngine.SProcessRuntimeConstant} An array of runtime constants that are set for this particular instance of the process
events BPMNEngine.DelegateContainers.ProcessEvents The Process Events delegates container
validations BPMNEngine.DelegateContainers.StepValidations The Process Validations delegates container
tasks BPMNEngine.DelegateContainers.ProcessTasks The Process Tasks delegates container
logging BPMNEngine.DelegateContainers.ProcessLogging The Process Logging delegates container

Document property

Summary

The XML Document that was supplied to the constructor containing the BPMN 2.0 definition

Item property

Summary

This is used to access the values of the process runtime and definition constants

Returns

The value of the variable

Parameters
Name Type Description
name System.String The name of the variable

BeginProcess(pars,events,validations,tasks,logging,stateLogLevel) method

Summary

Called to start and instance of the defined BusinessProcess

Returns

a process instance if the process was successfully started

Parameters
Name Type Description
pars System.Collections.Generic.Dictionary{System.String,System.Object} The variables to start the process with
events BPMNEngine.DelegateContainers.ProcessEvents The Process Events delegates container
validations BPMNEngine.DelegateContainers.StepValidations The Process Validations delegates container
tasks BPMNEngine.DelegateContainers.ProcessTasks The Process Tasks delegates container
logging BPMNEngine.DelegateContainers.ProcessLogging The Process Logging delegates container
stateLogLevel Microsoft.Extensions.Logging.LogLevel Used to set the logging level for the process state document

Diagram(type) method

Summary

Called to render a PNG image of the process

Returns

A Bitmap containing a rendered image of the process

Parameters
Name Type Description
type Microsoft.Maui.Graphics.ImageFormat The output image format to generate, this being jpeg,png or bmp

Dispose() method

Summary

Called to Dispose of the given process instance.

Parameters

This method has no parameters.

Equals(obj) method

Summary

Compares a given process instance to this instance to see if they are the same.

Returns

true if they are the same, false if they are not.

Parameters
Name Type Description
obj System.Object The Business Process instance to compare this one to.

ExtractProcessLog(doc) method

Summary

A Utility call used to extract the log from a Business Process State Document

Returns

The log from the Process State Document

Parameters
Name Type Description
doc System.Xml.XmlDocument The State XML Document file to extract the values from

ExtractProcessLog(reader) method

Summary

A Utility call used to extract the log from a Business Process State Document

Returns

The log from the Process State Document

Parameters
Name Type Description
reader System.Text.Json.Utf8JsonReader The State Json Document file to extract the values from

ExtractProcessSteps(doc) method

Summary

A Utility call used to extract the steps from a Business Process State Document

Returns

The steps from the Process State Document

Parameters
Name Type Description
doc System.Xml.XmlDocument The State XML Document file to extract the values from

ExtractProcessSteps(reader) method

Summary

A Utility call used to extract the steps from a Business Process State Document

Returns

The steps from the Process State Document

Parameters
Name Type Description
reader System.Text.Json.Utf8JsonReader The State Json Document file to extract the values from

ExtractProcessVariablesFromStateDocument(doc) method

Summary

A Utility call used to extract the variable values from a Business Process State Document.

Returns

The variables extracted from the Process State Document

Parameters
Name Type Description
doc System.Xml.XmlDocument The State XML Document file to extract the values from

ExtractProcessVariablesFromStateDocument(doc,stepIndex) method

Summary

A Utility call used to extract the variable values from a Business Process State Document at a given step index.

Returns

The variables extracted from the Process State Document

Parameters
Name Type Description
doc System.Xml.XmlDocument The State XML Document file to extract the values from
stepIndex System.Int32 The step index to extract the values at

ExtractProcessVariablesFromStateDocument(reader) method

Summary

A Utility call used to extract the variable values from a Business Process State Document.

Returns

The variables extracted from the Process State Document

Parameters
Name Type Description
reader System.Text.Json.Utf8JsonReader The State Json Document file to extract the values from

ExtractProcessVariablesFromStateDocument(reader,stepIndex) method

Summary

A Utility call used to extract the variable values from a Business Process State Document at a given step index.

Returns

The variables extracted from the Process State Document

Parameters
Name Type Description
reader System.Text.Json.Utf8JsonReader The State Json Document file to extract the values from
stepIndex System.Int32 The step index to extract the values at

GetHashCode() method

Summary

Returns the HashCode of the Business Process instance.

Returns
Parameters

This method has no parameters.

LoadState(doc,autoResume,events,validations,tasks,logging,stateLogLevel) method

Summary

Called to load a Process Instance from a stored State Document

Returns

an instance of IProcessInstance if successful or null it failed

Parameters
Name Type Description
doc System.Xml.XmlDocument The process state document
autoResume System.Boolean set true if the process was suspended and needs to resume once loaded
events BPMNEngine.DelegateContainers.ProcessEvents The Process Events delegates container
validations BPMNEngine.DelegateContainers.StepValidations The Process Validations delegates container
tasks BPMNEngine.DelegateContainers.ProcessTasks The Process Tasks delegates container
logging BPMNEngine.DelegateContainers.ProcessLogging The Process Logging delegates container
stateLogLevel Microsoft.Extensions.Logging.LogLevel Used to set the logging level for the process state document

LoadState(reader,autoResume,events,validations,tasks,logging,stateLogLevel) method

Summary

Called to load a Process Instance from a stored State Document

Returns

an instance of IProcessInstance if successful or null it failed

Parameters
Name Type Description
reader System.Text.Json.Utf8JsonReader The json based process state
autoResume System.Boolean set true if the process was suspended and needs to resume once loaded
events BPMNEngine.DelegateContainers.ProcessEvents The Process Events delegates container
validations BPMNEngine.DelegateContainers.StepValidations The Process Validations delegates container
tasks BPMNEngine.DelegateContainers.ProcessTasks The Process Tasks delegates container
logging BPMNEngine.DelegateContainers.ProcessLogging The Process Logging delegates container
stateLogLevel Microsoft.Extensions.Logging.LogLevel Used to set the logging level for the process state document

DateString type

Namespace

BPMNEngine

Summary

This class is used to convert a date string into a datetime value, uses the similar concepts as the strtotime found in php

#ctor(value) constructor

Summary

creates an instance

Parameters
Name Type Description
value System.String the date string that is meant to be converted

GetTime(variables) method

Summary

Converts the date string into an actual datetime object

Returns

A DateTime build from the string

Parameters
Name Type Description
variables BPMNEngine.Interfaces.Variables.IReadonlyVariables The process variables currently avaialbe (this is used when variables exist in the string e.g. ${variablename})
Exceptions
Name Description
System.Exception Occurs when the string is determined unparsable

DiagramException type

Namespace

BPMNEngine

Summary

This Exception is thrown when an error occurs generating a Process Diagram Image

ElementProcessEvents type

Namespace

BPMNEngine.DelegateContainers.Events

Summary

Class used to define the properties (event types) for a Process

Completed property

Summary

This delegate is called when a particular element completes

public void OnEventCompleted(IStepElement Event, IReadonlyVariables variables){
    Console.WriteLine("Event {0} inside process {1} has completed with the following variables:",Event.id,Event.Process.id);
    foreach (string key in variables.FullKeys){
        Console.WriteLine("\t{0}:{1}",key,variables[key]);
    }
}

Error property

Summary

This delegate is called when a particular element has an error

    public void OnEventError(IStepElement process,IStepElement Event, IReadonlyVariables variables){
        Console.WriteLine("Event {0} inside process {1} had the error {2} occur with the following variables:",new object[]{Event.id,Event.Process.id,variables.Error.Message});
        foreach (string key in variables.FullKeys){
            Console.WriteLine("\t{0}:{1}",key,variables[key]);
        }
    }

Started property

Summary

This is the delegate called when a particular element starts

public void OnEventStarted(IStepElement Event, IReadonlyVariables variables);{
    Console.WriteLine("Event {0} inside process {1} has been started with the following variables:",Event.id,Event.Process.id);
    foreach (string key in variables.FullKeys){
        Console.WriteLine("\t{0}:{1}",key,variables[key]);
    }
}

FlowEvents type

Namespace

BPMNEngine.DelegateContainers.Events

Summary

Class used to define all Flow Events that can complete

AssociationFlow property

Summary

Called when an Association Flow completes

public void onAssociationFlowCompleted(IFlowElement flow, IReadonlyVariables variables){
        Console.WriteLine("Association Flow {0} has been completed with the following variables:",flow.id);
        foreach (string key in variables.FullKeys){
            Console.WriteLine("\t{0}:{1}",key,variables[key]);
        }
    }

MessageFlow property

Summary

Called when a Message Flow completes

SequenceFlow property

Summary

Called when a Sequence Flow completes

public void OnSequenceFlowCompleted(IFlowElement flow, IReadonlyVariables variables){
        Console.WriteLine("Sequence Flow {0} has been completed with the following variables:",flow.id);
        foreach (string key in variables.FullKeys){
            Console.WriteLine("\t{0}:{1}",key,variables[key]);
        }
    }

IElement type

Namespace

BPMNEngine.Interfaces.Elements

Summary

This interface is the parent interface for ALL process elements (which are XML nodes)

ExtensionElement property

Summary

The extensions element if it exists. This element is what is used in BPMN 2.0 to house additional components outside of the definition that woudl allow you to extend the definition beyond the business process diagraming and into more of a realm for building it. Such as Script and Condition elements that this library implements.

ID property

Summary

The unique ID of the element from the process

Item property

Summary

This is called to get an attribute value from the process element

Returns
Parameters
Name Type Description
attributeName System.String The name of the attribute

SubNodes property

Summary

The child XMLNodes from the process element

IFlowElement type

Namespace

BPMNEngine.Interfaces.Elements

Summary

An interface for a flow element which can be message, sequence, or in some cases association

SourceRef property

Summary

The id for the source element

TargetRef property

Summary

the id for the destination element

IManualTask type

Namespace

BPMNEngine.Interfaces.Tasks

Summary

This interface is used to define an externally accessible manual task

MarkComplete() method

Summary

Called to mark that the manual task has been completed

Parameters

This method has no parameters.

IParentElement type

Namespace

BPMNEngine.Interfaces.Elements

Summary

This interface is the interface for all process elements with children

Children property

Summary

The child elements of the given process element

IProcessInstance type

Namespace

BPMNEngine.Interfaces

Summary

This interface defines a running instance of a Business Process and will have its own Unique ID. It contains its own state defining the state of this instance.

CurrentState property

Summary

The Process State of this instance

CurrentVariables property

Summary

Used to get the current variable values for this process instance

Document property

Summary

The XML Document that was supplied to the constructor containing the BPMN 2.0 definition

Item property

Summary

This is used to access the values of the process runtime and definition constants

Returns

The value of the variable

Parameters
Name Type Description
name System.String The name of the variable

Keys property

Summary

Called to obtain the names of all process runtime and definition constants

StateLogLevel property

Summary

The log level to use inside the state document for logging

Animate(outputVariables) method

Summary

Called to render an animated version of the process (output in GIF format). This will animate each step of the process using the current state.

Returns

a binary array of data containing the animated GIF

Parameters
Name Type Description
outputVariables System.Boolean Set true to output the variables into the diagram

Diagram(outputVariables,type) method

Summary

Called to render a PNG image of the process at its current state

Returns

A Bitmap containing a rendered image of the process at its current state

Parameters
Name Type Description
outputVariables System.Boolean Set true to include outputting variables into the image
type Microsoft.Maui.Graphics.ImageFormat The image format to encode the diagram in

GetManualTask(taskID) method

Summary

Used to get an Active Manual Task by supplying the task ID

Returns

The User task specified from the business process. If it cannot be found or the Task is not waiting it will return null.

Parameters
Name Type Description
taskID System.String The id of the task to load

GetUserTask(taskID) method

Summary

Used to get an Active User Task by supplying the task ID

Returns

The User task specified from the business process. If it cannot be found or the Task is not waiting it will return null.

Parameters
Name Type Description
taskID System.String The id of the task to load

Resume() method

Summary

Called to Resume a suspended process. Will fail if the process is not currently suspended.

Parameters

This method has no parameters.

Suspend() method

Summary

Called to suspend this instance

Parameters

This method has no parameters.

WaitForCompletion() method

Summary

Used to lock a Thread into waiting for the process to complete

Returns

the result of calling WaitOne on the Process Complete manual reset event

Parameters

This method has no parameters.

WaitForCompletion(millisecondsTimeout) method

Summary

Used to lock a Thread into waiting for the process to complete including a timeout

Returns

the result of calling WaitOne(millisecondsTimeout) on the Process Complete manual reset event

Parameters
Name Type Description
millisecondsTimeout System.Int32 The timeout for the process to complete

WaitForCompletion(timeout) method

Summary

Used to lock a Thread into waiting for the process to complete including a timeout

Returns

the result of calling WaitOne(timeout) on the Process Complete manual reset event

Parameters
Name Type Description
timeout System.TimeSpan The timeout for the process to complete

WaitForManualTask(taskID,task) method

Summary

Used to lock a Thread into waiting for a Manual task to be ready

Returns

the result of calling WaitOne on the Manual Task manual reset event

Parameters
Name Type Description
taskID System.String The id of the task to wait for
task BPMNEngine.Interfaces.Tasks.IManualTask@ The Manual task specified if the task was successfully started

WaitForManualTask(millisecondsTimeout,taskID,task) method

Summary

Used to lock a Thread into waiting for a Manual task to be ready

Returns

the result of calling WaitOne(millisecondsTimeout) on the Manual Task manual reset event

Parameters
Name Type Description
millisecondsTimeout System.Int32 The timeout for the Manual task to start
taskID System.String The id of the task to wait for
task BPMNEngine.Interfaces.Tasks.IManualTask@ The Manual task specified if the task was successfully started

WaitForManualTask(timeout,taskID,task) method

Summary

Used to lock a Thread into waiting for a Manual task to be ready

Returns

the result of calling WaitOne(timeout) on the Manual Task manual reset event

Parameters
Name Type Description
timeout System.TimeSpan The timeout for the Manual task to start
taskID System.String The id of the task to wait for
task BPMNEngine.Interfaces.Tasks.IManualTask@ The Manual task specified if the task was successfully started

WaitForUserTask(taskID,task) method

Summary

Used to lock a Thread into waiting for a user task to be ready

Returns

the result of calling WaitOne on the User Task manual reset event

Parameters
Name Type Description
taskID System.String The id of the task to wait for
task BPMNEngine.Interfaces.Tasks.IUserTask@ The User task specified if the task was successfully started

WaitForUserTask(millisecondsTimeout,taskID,task) method

Summary

Used to lock a Thread into waiting for a user task to be ready

Returns

the result of calling WaitOne(millisecondsTimeout) on the User Task manual reset event

Parameters
Name Type Description
millisecondsTimeout System.Int32 The timeout for the user task to start
taskID System.String The id of the task to wait for
task BPMNEngine.Interfaces.Tasks.IUserTask@ The User task specified if the task was successfully started

WaitForUserTask(timeout,taskID,task) method

Summary

Used to lock a Thread into waiting for a user task to be ready

Returns

the result of calling WaitOne(timeout) on the User Task manual reset event

Parameters
Name Type Description
timeout System.TimeSpan The timeout for the user task to start
taskID System.String The id of the task to wait for
task BPMNEngine.Interfaces.Tasks.IUserTask@ The User task specified if the task was successfully started

IReadonlyVariables type

Namespace

BPMNEngine.Interfaces.Variables

Summary

This interface defines a Read Only version of the process variables container. These are using in event delegates as the process variables cannot be changed by events.

Error property

Summary

The error that occured, assuming this was passed to an error event delgate this will have a value

ISequenceFlow type

Namespace

BPMNEngine.Interfaces.Elements

Summary

This interface is the extended interface for a sequence flow to provide additional properties that are beyond an IElement

ConditionExpression property

Summary

The Condition Expression that was attached to the sequence flow, this may be an attribute or a sub element

IState type

Namespace

BPMNEngine.Interfaces.State

Summary

Houses the current state of a process, this will have current variables (including the Keys to know all variables contained) as well as the ability to output a string version (XML/JSON) of the state

ActiveElements property

Summary

Called to obtain a list of all elements that are active (Started or Waiting)

AsJSONDocument property

Summary

Called to convert the state into a loadable json document

AsXMLDocument property

Summary

Called to convert the state into a loadable xml document

Item property

Summary

Called to get the value of a process variable

Returns

The value of the variable or null if not found

Parameters
Name Type Description
name System.String The name of the process variable

Keys property

Summary

Called to get a list of all process variable names available

Log property

Summary

Called to obtain a copy of the current log content found within the state

Steps property

Summary

Called to obtain a readonly list of the step state information

Variables property

Summary

Called to obtain a readonly dictionary of the current variables in the state

IStateStep type

Namespace

BPMNEngine.Interfaces.State

Summary

Houses the step information from a state to indicate statuses and timestamps for given elements during the execution of the procesas

CompletedBy property

Summary

When a user task is completed and the CompletedBy is set, it is housed here

ElementID property

Summary

The ID of the element for this step

EndTime property

Summary

When the element is completed this will had a value or used to house the suspension timestamp

IncomingID property

Summary

The ID of the element that led to this step

OutgoingID property

Summary

The list of outgoing elements to be executed next from the completion of this element

StartTime property

Summary

The timestamp for the start of the step

Status property

Summary

The status at the point of logging

IStepElement type

Namespace

BPMNEngine.Interfaces.Elements

Summary

This interface implements Step Elements in a process. These are elements that are containg both within a Process and a Lane and have properties to access those objects.

Lane property

Summary

The Lane within the process containing this element

Process property

Summary

The process containing this element

SubProcess property

Summary

The SubProcess containing this element, if the element is within a subprocess

ITask type

Namespace

BPMNEngine.Interfaces.Tasks

Summary

This interface is used to define an externall accessible task that can have extension items to allow for processing beyond the basic BPMN notation. All emissions from this Task if caught by a brounday event that is flagged to cancelActivity will cause this task to abort and no longer be usable.
In doing so it will not submit the variable changes into the process.

Variables property

Summary

The variables container for this task which allows you to both obtain and modify process variables.

Debug(message) method

Summary

Called to log a debug level message

Parameters
Name Type Description
message System.String The string message

Debug(message,pars) method

Summary

Called to log a debug level message

Parameters
Name Type Description
message System.String The string formatted message
pars System.Object[] The arguments to be fed into a string format call agains the message

EmitError(error,isAborted) method

Summary

Called to issue an exception fromn the task (this should be caught somewhere within the process by an Exception Recieving Element with a matching exception definition)

Parameters
Name Type Description
error System.Exception
isAborted System.Boolean@ returns true if emitting this signal causes the task to abort

EmitMessage(message,isAborted) method

Summary

Called to issue a message from the task (this should be caught somewhere within the process by a Message Recieving Element with a matching message defined)

Parameters
Name Type Description
message System.String The message to emit into the process
isAborted System.Boolean@ returns true if emitting this signal causes the task to abort

Error(message) method

Summary

Called to log an error level message

Parameters
Name Type Description
message System.String The string message

Error(message,pars) method

Summary

Called to log an error level message

Parameters
Name Type Description
message System.String The string formatted message
pars System.Object[] The arguments to be fed into a string format call agains the message

Escalate(isAborted) method

Summary

Called to issue an escalation from the task (this should be caught somewhere within the process by an Escalation Reciving Element)

Parameters
Name Type Description
isAborted System.Boolean@ returns true if emitting this signal causes the task to abort

Exception(exception) method

Summary

Called to log an exception

Returns

The exception that was passed as an arguement to allow for throwing

Parameters
Name Type Description
exception System.Exception The Exception that occured

Fatal(message) method

Summary

Called to log a fatal level message

Parameters
Name Type Description
message System.String The string message

Fatal(message,pars) method

Summary

Called to log a fatal level message

Parameters
Name Type Description
message System.String The string formatted message
pars System.Object[] The arguments to be fed into a string format call agains the message

Info(message) method

Summary

Called to log an info level message

Parameters
Name Type Description
message System.String The string message

Info(message,pars) method

Summary

Called to log an info level message

Parameters
Name Type Description
message System.String The string formatted message
pars System.Object[] The arguments to be fed into a string format call agains the message

Signal(signal,isAborted) method

Summary

Called to issue a signal from the task (this should be caught somewhere within the process by a Signal Recieving Element with a matching signal defined)

Parameters
Name Type Description
signal System.String The signal to emit into the process
isAborted System.Boolean@ returns true if emitting this signal causes the task to abort

IUserTask type

Namespace

BPMNEngine.Interfaces.Tasks

Summary

This interface is used to define an externally accessible User Task.

UserID property

Summary

The User ID of the user that completed the task. This should be set before calling MarkComplete() if there is a desire to log the user id of the individual completing the task.

IVariables type

Namespace

BPMNEngine.Interfaces.Variables

Summary

This interface defines a container to house the process variables and allows for editing of those variables.

Item property

Summary

Called to get or set the value of a process variable

Returns

The value of the process variable or null if not found

Parameters
Name Type Description
name System.String The name of the process variable

IVariablesContainer type

Namespace

BPMNEngine.Interfaces.Variables

Summary

This interface defines the base container to house the process variables

FullKeys property

Summary

Called to get a list of all process variable names available, including process definition constants and runtime constants

Item property

Summary

Called to get the value of a process variable

Returns

The value of the variable or null if not found

Parameters
Name Type Description
name System.String The name of the process variable

Keys property

Summary

Called to get a list of all process variable names available

IntermediateProcessExcepion type

Namespace

BPMNEngine

Summary

This Exception is thrown by an Intermediate Throw Event when an Error Message is defined

ProcessMessage property

Summary

Houses the error message string defined inside the ErrorMessage definition from within the process document

InvalidAttributeValueException type

Namespace

BPMNEngine

Summary

This Exception is thrown when an attribute value is not valid on an Element found within the definition

InvalidElementException type

Namespace

BPMNEngine

Summary

This Exception is thrown when an Element found within the definition is not valid

InvalidProcessDefinitionException type

Namespace

BPMNEngine

Summary

This Exception gets thrown on the loading of a Process Definition inside a BusinessProcess class when the definition is found to be invalid.

ProcessExceptions property

Summary

The Exception(s) thrown during the validation process.

IsEventStartValid type

Namespace

BPMNEngine

Summary

This delegate is implemented to get triggered when determining if an Event Start is valid (i.e. can this event start)

Returns
Parameters
Name Type Description
Event T:BPMNEngine.IsEventStartValid The Start Event that is being checked
Example

XML: <bpmn:startEvent id="StartEvent_0ikjhwl"> bpmn:extensionElements </bpmn:extensionElements> bpmn:outgoingSequenceFlow_1kh3jxa</bpmn:outgoing> </bpmn:startEvent>

public bool _EventStartValid(IStepElement Event, IVariables variables){
    if (Event.ExtensionElement != null){
        foreach (XmlNode xn in Event.ExtensionElement.SubNodes){
            if (xn.NodeType == XmlNodeType.Element)
            {
                if (xn.Name=="DateRange"){
                    return DateTime.Now.Ticks &gt;= DateTime.Parse(xn.Attributes["start"].Value) &amp;&amp; DateTime.Now.Ticks &lt;= DateTime.Parse(xn.Attributes["end"].Value);
                }
            }
        }
    }
    return true;
}
Remarks

This delegate is useful when adding additional elements through the extension element that are custom to your code. It will be called with the given starting element that can be checked against additional components to decide if the start event is valid for a process. If valid, return true to initiate the containing process.

IsFlowValid type

Namespace

BPMNEngine

Summary

This delegate is implemented to get triggered when determining if a Flow is a valid path

Returns
Parameters
Name Type Description
flow T:BPMNEngine.IsFlowValid The process Flow that is being checked
Example

XML: bpmn:outgoingSequenceFlow_1jma3bu bpmn:extensionElements </bpmn:extensionElements> </bpmn:outgoing>

public bool _FlowValid(ISequenceFlow flow, IVariables variables){
    if (flow.ExtensionElement != null){
        foreach (XmlNode xn in flow.ExtensionElement.SubNodes){
            if (xn.NodeType == XmlNodeType.Element)
            {
                if (xn.Name=="DateRange"){
                    return DateTime.Now.Ticks &gt;= DateTime.Parse(xn.Attributes["start"].Value) &amp;&amp; DateTime.Now.Ticks &lt;= DateTime.Parse(xn.Attributes["end"].Value);
                }
            }
        }
    }
    return true;
}
Remarks

This delegate is useful when adding additional elements through the extension element that are custom to your code.It will be called with the given flow element that can be checked against additional components to decide if the flow is a valid next step in the process. If valid, return true to allow the system to continue along the supplied flow.

IsProcessStartValid type

Namespace

BPMNEngine

Summary

This delegate is implemented to get triggered when determining if a Process is valid to Start

Returns
Parameters
Name Type Description
process T:BPMNEngine.IsProcessStartValid The Process that is being checked
Example

XML: <bpmn:process id="Process_1" isExecutable="false"> ... bpmn:extensionElements </bpmn:extensionElements> </bpmn:process>

public bool _ProcessStartValid(IElement process, IVariables variables){
    if (process.ExtensionElement != null){
        foreach (XmlNode xn in process.ExtensionElement.SubNodes){
            if (xn.NodeType == XmlNodeType.Element)
            {
                if (xn.Name=="DateRange"){
                    return DateTime.Now.Ticks &gt;= DateTime.Parse(xn.Attributes["start"].Value) &amp;&amp; DateTime.Now.Ticks &lt;= DateTime.Parse(xn.Attributes["end"].Value);
                }
            }
        }
    }
    return true;
}
Remarks

This delegate is useful when adding additional elements through the extension element that are custom to your code.It will be called with the given process element that can be checked against additional components to decide if the start is valid for a process. If valid, return true to allow the system to continue to locate a valid start event within that process.

JintAssemblyMissingException type

Namespace

BPMNEngine

Summary

Thrown when attempting to use Javascript without the Jint Assembly

#ctor() constructor

Summary

Thrown when attempting to use Javascript without the Jint Assembly

Parameters

This constructor has no parameters.

LogException type

Namespace

BPMNEngine

Summary

This delegate is implemented to be called when a Log Exception is made by a process. This can be used to log exceptions externally, to a file, database, or logging engine implemented outside of the library.

Parameters
Name Type Description
callingElement T:BPMNEngine.LogException The Process Element Calling the Log Exception (may be null)

LogLine type

Namespace

BPMNEngine

Summary

This delegate is implemented to be called when a Log Line Entry is made by a process. This can be used to log items externally, to a file, database, or logging engine implemented outside of the library.

Parameters
Name Type Description
callingElement T:BPMNEngine.LogLine The Process Element Calling the Log Line (may be null)

MissingAttributeException type

Namespace

BPMNEngine

Summary

This Exception is thrown when a required attribute is missing from an Element found within the definition

MultipleOutgoingPathsException type

Namespace

BPMNEngine

Summary

This Exception is thrown when an Exclusive Gateway evalutes to more than 1 outgoing path

NotSuspendedException type

Namespace

BPMNEngine

Summary

This Exception is thrown when a Business Process is told to Resume but is not Suspended

OnElementAborted type

Namespace

BPMNEngine

Summary

This delegate is implemented to get triggered when a process element has been aborted.

Parameters
Name Type Description
element T:BPMNEngine.OnElementAborted The process element that is being aborted.
Example
    public void _OnElementAborted(IElement element,IElement source,IReadonlyVariables variables){
        Console.WriteLine("Element {0} inside process {1} has been aborted by {2} with the following variables:",element.id,element.Process.id,source.id);
        foreach (string key in variables.FullKeys){
            Console.WriteLine("\t{0}:{1}",key,variables[key]);
        }
    }
Remarks

As it is an event driven delegate, the process will continue on without waiting for the delegate to finish.

OnElementEvent type

Namespace

BPMNEngine

Summary

This delegate is implemented to get triggered when a process element has been started, completed or errored.

Parameters
Name Type Description
element T:BPMNEngine.OnElementEvent The process element that is starting, has completed or has errored.
Example
    public void _OnElementStarted(IStepElement element,IReadonlyVariables variables){
        Console.WriteLine("Element {0} inside process {1} has been started with the following variables:",element.id,element.Process.id);
        foreach (string key in variables.FullKeys){
            Console.WriteLine("\t{0}:{1}",key,variables[key]);
        }
    }
Remarks

As it is an event driven delegate, the process will continue on without waiting for the delegate to finish.

OnFlowComplete type

Namespace

BPMNEngine

Summary

This delegate is implemented to get triggered when a process flow has been completed.

Parameters
Name Type Description
element T:BPMNEngine.OnFlowComplete The process flow that has been completed.
Example
    public void _OnFlowCompleted(IElement element,IReadonlyVariables variables){
        Console.WriteLine("Flow {0} inside process {1} has been started with the following variables:",element.id,element.Process.id);
        foreach (string key in variables.FullKeys){
            Console.WriteLine("\t{0}:{1}",key,variables[key]);
        }
    }
Remarks

As it is an event driven delegate, the process will continue on without waiting for the delegate to finish.

OnProcessErrorEvent type

Namespace

BPMNEngine

Summary

This delegate is implemented to get triggered when a Process has an Error

Parameters
Name Type Description
process T:BPMNEngine.OnProcessErrorEvent The process that the error is contained in
Example
    public void _ProcessError(IElement process,IElement sourceElement, IReadonlyVariables variables){
        Console.WriteLine("Element {0} inside process {1} had the error {2} occur with the following variables:",new object[]{sourceElement.id,process.id,variables.Error.Message});
        foreach (string key in variables.FullKeys){
            Console.WriteLine("\t{0}:{1}",key,variables[key]);
        }
    }
Remarks

As it is an event driven delegate, the process will continue on without waiting for the delegate to finish. As well as the variables container will have Error set to the Exception that occured.

OnProcessEvent type

Namespace

BPMNEngine

Summary

This delegate is implemented to get triggered when a Process has been started or completed.

Parameters
Name Type Description
process T:BPMNEngine.OnProcessEvent The Process being started or completed
Example
    public void _ProcessStarted(IElement process,IReadonlyVariables variables){
        Console.WriteLine("Process {0} has been started with the following variables:",process.id);
        foreach (string key in variables.FullKeys){
            Console.WriteLine("\t{0}:{1}",key,variables[key]);
        }
    }
Remarks

As it is an event driven delegate, the process will continue on without waiting for the delegate to finish.

OnStateChange type

Namespace

BPMNEngine

Summary

This delegate is implemented to get triggered when the Process State changes. The state may not be usable externally without understanding its structure, however, capturing these events allows for the storage of a process state externally to be brought back in on a process restart.

Parameters
Name Type Description
currentState T:BPMNEngine.OnStateChange The current state of the process
Example
    public void _StateChange(XmlDocument stateDocument){
        Console.WriteLine("Current Process State: \n{0}",stateDocument.OuterXML);
    }

ProcessEvents type

Namespace

BPMNEngine.DelegateContainers

Summary

This class is used to house all the event based delegates for a business process. This can be defined at either the BusinessProcess constructor level for defining it against all instances or at the BeginProcess level to defining it against a specific instance

Events property

Summary

Houses the delegates for Events related to a Business Process Event item

Flows property

Summary

Houses the delegates for Events related to a Business Process flow item

Gateways property

Summary

Houses the delegates for Events related to a Business Process Gateway item

OnStateChange property

Summary

A delegate called when the Business Process Instance state document has changed

public void OnStateChange(XmlDocument stateDocument){
        Console.WriteLine("Current Process State: \n{0}",stateDocument.OuterXML);
    }

OnStepAborted property

Summary

A delegate called when an element is aborted within the Business Process

public void OnStepAborted(IElement element, IElement source, IReadonlyVariables variables){
        Console.WriteLine("Element {0} inside process {1} has been aborted by {2} with the following variables:",element.id,element.Process.id,source.id);
        foreach (string key in variables.FullKeys){
            Console.WriteLine("\t{0}:{1}",key,variables[key]);
        }
    }

Processes property

Summary

Houses the delegates for Events related to a Business Process Process item

SubProcesses property

Summary

Houses the delegates for Events related to a Business Process SubProcess item

Tasks property

Summary

Houses the delegates for Events related to a Business Process Task item

ProcessLogging type

Namespace

BPMNEngine.DelegateContainers

Summary

This class is used to house all the Logging delegates for a business process. This can be defined at either the BusinessProcess constructor level for defining it against all instances or at the BeginProcess level to defining it against a specific instance

LogException property

Summary

A delegate called to append a logged exception from the process

LogLine property

Summary

A delegate called to append a log line entry from the process

ProcessTask type

Namespace

BPMNEngine

Summary

This delegate is implemented to process a Process Task (This can be a Business Rule, Script, Send, Service and Task)

Parameters
Name Type Description
task T:BPMNEngine.ProcessTask The Task being processed
Example

XML: <bpmn:businessRuleTask id="BusinessRule_0ikjhwl"> bpmn:extensionElements </bpmn:extensionElements> bpmn:outgoingSequenceFlow_1kh3jxa</bpmn:outgoing> </bpmn:startEvent>

public void _ProcessBusinessRuleTask(ITask task)
    if (task.ExtensionElement != null){
        foreach (XmlNode xn in task.ExtensionElement.SubNodes){
            if (xn.NodeType == XmlNodeType.Element)
            {
                if (xn.Name=="Analysis"){
                    switch(xn.Attributes["formula"].Value){
                        case "Average":
                            decimal avgSum=0;
                            decimal avgCount=0;
                            foreach (Hashtable item in task.Variables["Items"]){
                                if (item.ContainsKey(xn.Attributes["inputs"].Value)){
                                    avgSum+=(decimal)item[xn.Attributes["inputs"].Value];
                                    avgCount++;
                                }
                            }
                            task.Variables[xn.Attriubtes["outputVariable"].Value] = avgSum/avgCount;
                            break;
                        case "Sum":
                            decimal sum=0;
                            foreach (Hashtable item in task.Variables["Items"]){
                                if (item.ContainsKey(xn.Attributes["inputs"].Value)){
                                    sum+=(decimal)item[xn.Attributes["inputs"].Value];
                                }
                            }
                            task.Variables[xn.Attriubtes["outputVariable"].Value] = sum;
                            break;
                    }
                }
            }
        }
    }
}
Remarks

Use of the bpmn:extension element to add additional components to the Task is recommended in order to implement your own piece of functionality used in handling of a Task.

ProcessTasks type

Namespace

BPMNEngine.DelegateContainers

Summary

This class is used to house all the Tasks delegates for a business process. This can be defined at either the BusinessProcess constructor level for defining it against all instances or at the BeginProcess level to defining it against a specific instance

BeginManualTask property

Summary

A delegate called to start a Manual Task

<![CDATA[
            XML:
            <bpmn:manualTask id="ManualTask_0ikjhwl">
             <bpmn:extensionElements>
               <Question prompt="What is the answer to the life, universe and everything" answer_property="answer"/>
             </bpmn:extensionElements>
             <bpmn:outgoing>SequenceFlow_1kh3jxa</bpmn:outgoing>
            </bpmn:startEvent>
            ]]>

BeginUserTask property

Summary

A delegate called to start a User Task

<![CDATA[
            XML:
            <bpmn:userTask id="UserTask_0ikjhwl">
             <bpmn:extensionElements>
               <Question prompt="What is the answer to the life, universe and everything" answer_property="answer"/>
             </bpmn:extensionElements>
             <bpmn:outgoing>SequenceFlow_1kh3jxa</bpmn:outgoing>
            </bpmn:startEvent>
            ]]>

CallActivity property

Summary

A delegate called to execute a CallActivity

ProcessBusinessRuleTask property

Summary

A delegate called to execute a Business Rule Task

<![CDATA[
            XML:
            <bpmn:businessRuleTask id="BusinessRule_0ikjhwl">
             <bpmn:extensionElements>
               <Analysis outputVariable="averageCost" inputs="Cost" formula="Average"/>
               <Analysis outputVariable="totalQuantity" inputs="Quantity" formula="Sum"/>
             </bpmn:extensionElements>
             <bpmn:outgoing>SequenceFlow_1kh3jxa</bpmn:outgoing>
            </bpmn:startEvent>
            ]]>

ProcessReceiveTask property

Summary

A delegate called to execute a Receive Task

ProcessScriptTask property

Summary

A delegate called to execute a Script Task. This is called after any internal script extension elements have been processed.

ProcessSendTask property

Summary

A delegate called to exeucte a Send Task.

ProcessServiceTask property

Summary

A delegate called to execute a Service Task

ProcessTask property

Summary

A delegate called to execute a Task

SFile type

Namespace

BPMNEngine

Summary

This structure is used to house a File associated within a process instance. It is used to both store, encode, decode and retreive File variables inside the process state.

Content property

Summary

The binary content of the File.

ContentType property

Summary

The content type tag for the File. e.g. text/html

Extension property

Summary

The extension of the File.

Name property

Summary

The name of the File.

Equals(obj) method

Summary

Compares the object to this

Returns

true if obj is an sFile and is equal

Parameters
Name Type Description
obj System.Object the object to compare

op_Equality(left,right) method

Summary

Compares left and right files

Returns

true if are equal

Parameters
Name Type Description
left BPMNEngine.SFile left file for comparison
right BPMNEngine.SFile right file for comparison

op_Inequality(left,right) method

Summary

Compares left and right files

Returns

true if are not equal

Parameters
Name Type Description
left BPMNEngine.SFile left file for comparison
right BPMNEngine.SFile right file for comparison

SProcessRuntimeConstant type

Namespace

BPMNEngine

Summary

This structure is used to specify a Process Runtime Constant. These Constants are used as a Dynamic Constant, so a read only variable within the process that can be unique to the instance running, only a constant to that specific process instance.

Name property

Summary

The Name of the variable.

Value property

Summary

The Value of the variable.

StartManualTask type

Namespace

BPMNEngine

Summary

This delegate is implemented to start a Manual Task

Parameters
Name Type Description
task T:BPMNEngine.StartManualTask The Task being started
Example

XML: <bpmn:manualTask id="ManualTask_0ikjhwl"> bpmn:extensionElements </bpmn:extensionElements> bpmn:outgoingSequenceFlow_1kh3jxa</bpmn:outgoing> </bpmn:startEvent>

public void _ProcessManualTask(IManualTask task)
    if (task.ExtensionElement != null){
        foreach (XmlNode xn in task.ExtensionElement.SubNodes){
            if (xn.NodeType == XmlNodeType.Element)
            {
                if (xn.Name=="Question"){
                    Console.WriteLine(string.format("{0}?",xn.Attributes["prompt"].Value));
                    task.Variables[xn.Attributes["answer_property"].Value] = Console.ReadLine();
                }
            }
        }
    }
    task.MarkComplete();
}
Remarks

Use of the bpmn:extension element to add additional components to the Task is recommended in order to implement your own piece of functionality used in handling of a Task.

StartUserTask type

Namespace

BPMNEngine

Summary

This delegate is implemented to start a User Task

Parameters
Name Type Description
task T:BPMNEngine.StartUserTask The Task being started
Example

XML: <bpmn:userTask id="UserTask_0ikjhwl"> bpmn:extensionElements </bpmn:extensionElements> bpmn:outgoingSequenceFlow_1kh3jxa</bpmn:outgoing> </bpmn:startEvent>

public void _ProcessUserTask(IUserTask task)
    if (task.ExtensionElement != null){
        foreach (XmlNode xn in task.ExtensionElement.SubNodes){
            if (xn.NodeType == XmlNodeType.Element)
            {
                if (xn.Name=="Question"){
                    Console.WriteLine(string.format("{0}?",xn.Attributes["prompt"].Value));
                    task.Variables[xn.Attributes["answer_property"].Value] = Console.ReadLine();
                    Console.WriteLine("Who Are You?");
                    task.UserID = Console.ReadLine();
                }
            }
        }
    }
    task.MarkComplete();
}
Remarks

Use of the bpmn:extension element to add additional components to the Task is recommended in order to implement your own piece of functionality used in handling of a Task.

StepStatuses type

Namespace

BPMNEngine

Summary

Enumeration of the statuses used for each step of a process

Aborted constants

Summary

Aborted after being started or Suspended or Waiting on Start

Failed constants

Summary

Failed during execution

NotRun constants

Summary

Step not run (typically used for drawing only and not stored in the state)

Started constants

Summary

Started the satep

Succeeded constants

Summary

Completed successfully

Suspended constants

Summary

Suspended until a timeout has passed

Waiting constants

Summary

Waiting for input to complete execution

WaitingStart constants

Summary

Delayed start until a timeout has passed

StepValidations type

Namespace

BPMNEngine.DelegateContainers

Summary

This class is used to house all the validation delegates for a business process. This can be defined at either the BusinessProcess constructor level for defining it against all instances or at the BeginProcess level to defining it against a specific instance

IsEventStartValid property

Summary

A delegate called to validate if an event can start

<![CDATA[
            XML:
            <bpmn:startEvent id="StartEvent_0ikjhwl">
             <bpmn:extensionElements>
               <DateRange start="2020-01-01 00:00:00" end="2020-12-31 11:59:59"/>
             </bpmn:extensionElements>
             <bpmn:outgoing>SequenceFlow_1kh3jxa</bpmn:outgoing>
            </bpmn:startEvent>
            ]]>

IsFlowValid property

Summary

A delegate called to validate if a flow is valid to run

<![CDATA[
            XML:
            <bpmn:outgoing>SequenceFlow_1jma3bu
             <bpmn:extensionElements>
               <DateRange start="2020-01-01 00:00:00" end="2020-12-31 11:59:59"/>
             </bpmn:extensionElements>
            </bpmn:outgoing>
            ]]>

IsProcessStartValid property

Summary

A delegate called to validate if a process is valid to start

<![CDATA[
            XML:
            <bpmn:process id="Process_1" isExecutable="false">
             ...
             <bpmn:extensionElements>
               <DateRange start="2020-01-01 00:00:00" end="2020-12-31 11:59:59"/>
             </bpmn:extensionElements>
            </bpmn:process>
            ]]>
Clone this wiki locally