Table of Contents

Class Model

Namespace
DCR.Workflow
Assembly
DCR.Workflow.dll

DCR Model

public class Model
Inheritance
Model
Inherited Members
Extension Methods

Remarks

This class is the canonical C# representation of a DCR model.

Caution

If at all possible, work with DCR models through this class:

  • DO NOT manipulate the DCR XML format directly
  • DO NOT reference the underlying F# implementation directly
  • AVOID the older DCR.Engine.Graph representation.

Constructors

Model(Model)

public Model(Model other)

Parameters

other Model

Properties

Activities

Return material activities in the model

[NotMapped]
public IEnumerable<Activity> Activities { get; }

Property Value

IEnumerable<Activity>

AllActivities

Return all activities in the model

[NotMapped]
public IEnumerable<Activity> AllActivities { get; }

Property Value

IEnumerable<Activity>

CurrentPhase

[NotMapped]
public Phase? CurrentPhase { get; }

Property Value

Phase

CurrentPhaseTitle

[Column("Phase")]
public string? CurrentPhaseTitle { get; }

Property Value

string

Deadline

Return the earliest point in time at which a pending included activity has a deadline.

public DateTimeOffset? Deadline { get; }

Property Value

DateTimeOffset?

Groups

[NotMapped]
public Group[] Groups { get; }

Property Value

Group[]

Id

public int Id { get; set; }

Property Value

int

IsAccepting

public bool IsAccepting { get; }

Property Value

bool

IsBlocked

public bool IsBlocked { get; }

Property Value

bool

this[int]

public Activity this[int id] { get; }

Parameters

id int

Property Value

Activity

this[string]

public Activity this[string path] { get; }

Parameters

path string

Property Value

Activity

NextDeadline

Returns the earliest point in the future at which an including pending activity has a deadline or null if no such point exists.

[NotMapped]
public DateTimeOffset? NextDeadline { get; }

Property Value

DateTimeOffset?

Remarks

"The future" is relative to current graph time. This property is different from Deadline in that here we ignore deadlines in the past, that is, if current time is later than all deadlines, we return null.

NextDelay

public DateTimeOffset? NextDelay { get; }

Property Value

DateTimeOffset?

Phases

[NotMapped]
public Phase[] Phases { get; }

Property Value

Phase[]

Roles

[NotMapped]
public Role[] Roles { get; }

Property Value

Role[]

Time

public DateTimeOffset Time { get; set; }

Property Value

DateTimeOffset

Title

public string Title { get; }

Property Value

string

XmlString

[Column("Xml", TypeName = "xml")]
public string XmlString { get; set; }

Property Value

string

Methods

BlockContainer(Activity)

public void BlockContainer(Activity a)

Parameters

a Activity

Execute(Activity, value?, string?)

public void Execute(Activity a, value? v = null, string? user = null)

Parameters

a Activity
v value
user string

Find(string)

public Activity? Find(string path)

Parameters

path string

Returns

Activity

FindPhase(int)

public Phase? FindPhase(int index)

Parameters

index int

Returns

Phase

FindPhase(string)

public Phase? FindPhase(string title)

Parameters

title string

Returns

Phase

GetByteCode()

public VM.Process<Vm.Info> GetByteCode()

Returns

VM.Process<Vm.Info>

GetOrigin()

public Origin? GetOrigin()

Returns

Origin

ReplaceParameters(string)

Replace all occurrences of '$(<eid>)' with the value of the event eid.

public string ReplaceParameters(string s)

Parameters

s string

Returns

string

) The string s, with all occurrences of '<eid>' replaced with the value of 'eid'. If eid has no value, the empty string is returned.

Replay(Log)

public ReplayResult[] Replay(Log log)

Parameters

log Log

Returns

ReplayResult[]

Replay1(IEnumerable<LogEntry>, out Model, out List<Violation>, out int, Recover)

Replays the provided trace against this model. The replay continues as long as the log conforms to the model. This model is never updated.

public bool Replay1(IEnumerable<LogEntry> trace, out Model result, out List<LogModule.Violation> violations, out int index, LogModule.Recover recover = (LogModule.Recover)7)

Parameters

trace IEnumerable<LogEntry>

The trace to replay.

result Model

A copy of the input model advanced to the last successful replay step. The origin (GetOrigin()) of the input model will be copied to this result model.

violations List<LogModule.Violation>

If the replay was unsuccessful, the list of violations encountered at the first unsuccessful replay step; otherwise, an empty list.

index int

The index of the first unsuccessful replay step, or -1 if the replay was successful. If the underlying log contains index pointers, this index pointer is returned; otherwise, simply the index into trace of the unsuccessful step is returned.

recover LogModule.Recover

Flags for the replay engine indicating which violations to consider acceptable. See DCR.Core.LogModule.Recover.

Returns

bool

True if the replay was successful; otherwise, false.

Replay1(IEnumerable<LogEntry>, out List<Violation>, out int, Recover)

In-place replay

public bool Replay1(IEnumerable<LogEntry> trace, out List<LogModule.Violation> violations, out int index, LogModule.Recover recover = (LogModule.Recover)7)

Parameters

trace IEnumerable<LogEntry>
violations List<LogModule.Violation>
index int
recover LogModule.Recover

Returns

bool

Search(TraceSearchParameters)

Search through the graph looking for a path from start state to the designated end point of the search, if that is an activity or graph accepting. Search have to go through the activities in "hit" and avoid those in "excl".

public TraceSearchResult Search(TraceSearchParameters param)

Parameters

param TraceSearchParameters

Returns

TraceSearchResult

a tuple containing a bool saying if a trace was found or not. Int saying how many executions was done to complete the search, String xml representation of the trace (if any) that was found.

SetConfiguration(RuntimeConfiguration)

Set necessary configuration. You generally should not call this.

public void SetConfiguration(RuntimeConfiguration config)

Parameters

config RuntimeConfiguration

Remarks

Necessary configuration is set up by Runtime in its various Load and Parse methods. The one situation where you may need to set this manually is if you are deserializing models from DB using EF, in which case you need to manually add configuration.

As of 2024-08-13, the necessary configuration currently comprises only TimeOptions (timezone, holidays).

ToString()

public override string ToString()

Returns

string

ToXDocument()

public XDocument ToXDocument()

Returns

XDocument

TryEvaluateExpression(string, out value?, out typ?, out string?)

Attempt to parse and evaluate an expression in the context of the current graph

public bool TryEvaluateExpression(string expression, out value? result, out typ? t, out string? error)

Parameters

expression string

The expression to evaluate

result value

The value of the expression, or null if parsing or evaluation failed

t typ

The type of the value of the expression, or null if parsing or evaluation failed

error string

An error message or null if parsing and evaluation succeeded

Returns

bool

True if parsing and evaluation succeeded, otherweise false

Typecheck(string, out typ?, out string?)

public bool Typecheck(string input, out typ? typ, out string? err)

Parameters

input string
typ typ
err string

Returns

bool

UnblockContainer(Activity)

public void UnblockContainer(Activity a)

Parameters

a Activity

ValidateExpression(string)

Check that given expression is syntactically correct, and references only activities in the graph.

public string? ValidateExpression(string src)

Parameters

src string

Returns

string