Table of Contents

Class Runtime

Namespace
DCR.Workflow
Assembly
DCR.Workflow.dll

DCR Workflow Runtime

public class Runtime
Inheritance
Runtime
Inherited Members
Extension Methods

Remarks

The runtime takes care of executing activities, with necessary side-effects such as executing effects, running effect continuation activities, and running robot activities. Depending on configuration, model may be persisted back to the database.

Constructors

Runtime(IRuntimeConfigurationService, IServiceProvider, ILogger<Runtime>, RuntimeScheduler?, IRuntimeContextService?)

Multi-configuration runtime constructor

public Runtime(IRuntimeConfigurationService configService, IServiceProvider sp, ILogger<Runtime> logger, RuntimeScheduler? scheduler = null, IRuntimeContextService? context = null)

Parameters

configService IRuntimeConfigurationService

Service providing current runtime configuration. NB! The service will be consulted at construction time, after which the configuration is fixed. If the service subsequentely changes state, that new state will not be reflected in the constructed runtime.

sp IServiceProvider
logger ILogger<Runtime>
scheduler RuntimeScheduler
context IRuntimeContextService

Remarks

This constructor is intended for multi-tenant settings, where the service environment contains an IRuntimeConfigurationService appropriate for the current tenant.

Runtime(RuntimeConfiguration, IServiceProvider, ILogger<Runtime>, RuntimeScheduler?, IRuntimeContextService?)

Canonical runtime constructor

public Runtime(RuntimeConfiguration config, IServiceProvider sp, ILogger<Runtime> logger, RuntimeScheduler? scheduler = null, IRuntimeContextService? context = null)

Parameters

config RuntimeConfiguration

Static configuration

sp IServiceProvider

Used to construct effects

logger ILogger<Runtime>
scheduler RuntimeScheduler

Optional scheduler (for scheduling robots for automatic execution in the future)

context IRuntimeContextService

Optional service providing last-minute context such as current case or user id. Execute(Model, Activity, value?, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?).

Remarks

Note that all actual configuration of the runtime is given by ; remaining parameters are services.

Properties

Effects

public IEnumerable<string> Effects { get; }

Property Value

IEnumerable<string>

Methods

CommitTransactionAsync(Model, TransactionLogEntry, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)

public Task<Model> CommitTransactionAsync(Model model, TransactionLogEntry transaction, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)

Parameters

model Model
transaction TransactionLogEntry
context Dictionary<string, string>
secrets Dictionary<string, string>
trace List<LogEntry>
cts CancellationToken?
persistor ICasePersistor

Returns

Task<Model>

Create(Action<IRuntimeBuilder>?)

public static Runtime Create(Action<IRuntimeBuilder>? configure = null)

Parameters

configure Action<IRuntimeBuilder>

Returns

Runtime

Execute(Model, Activity, value?, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)

Execute an activity including follow-up actions such as running robots and executing effects

public Task<Model> Execute(Model model, Activity activity0, value? value0 = null, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)

Parameters

model Model

The DCR model to update. This model will be mutated.

activity0 Activity

The activity of the model to execute. The activity must be enabled in the model.

value0 value

The value to assign to he activity as part of the execution

context Dictionary<string, string>

Key-value pairs from the host system to be used in parameters

secrets Dictionary<string, string>

Key-value pairs from the host system to be used for authentication

trace List<LogEntry>

If supplied, a record of activites executed will be added to this list

cts CancellationToken?

A cancellation token

persistor ICasePersistor

Returns

Task<Model>

The updated model. NB! In case of concurrency conflicts, the returned model may have been reloaded from persistent store. It is important that calling code replaces any reference it might have to the model argument with the returned reference.

Exceptions

KeyNotFoundException
InvalidOperationException
RuntimeException

Execute(Model, Request, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)

public Task<Model> Execute(Model model, Request request, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)

Parameters

model Model
request Request
context Dictionary<string, string>
secrets Dictionary<string, string>
trace List<LogEntry>
cts CancellationToken?
persistor ICasePersistor

Returns

Task<Model>

ExecuteAsync(Activity, value?, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)

public Task<Model> ExecuteAsync(Activity act, value? value = null, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)

Parameters

act Activity
value value
context Dictionary<string, string>
secrets Dictionary<string, string>
trace List<LogEntry>
cts CancellationToken?
persistor ICasePersistor

Returns

Task<Model>

ExecuteAsync(Model, Request, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)

Execute an activity including follow-up actions such as running robots and executing effects

public Task<Model> ExecuteAsync(Model model, Request request, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)

Parameters

model Model

The DCR model to update. This model will be mutated.

request Request
context Dictionary<string, string>

Key-value pairs from the host system to be used in parameters

secrets Dictionary<string, string>

Key-value pairs from the host system to be used for authentication

trace List<LogEntry>

If supplied, a record of activites executed will be added to this list

cts CancellationToken?

A cancellation token

persistor ICasePersistor

Returns

Task<Model>

The updated model. NB! In case of concurrency conflicts, the returned model may have been reloaded from persistent store. It is important that calling code replaces any reference it might have to the model argument with the returned reference.

Exceptions

KeyNotFoundException
InvalidOperationException
RuntimeException

ExecuteAsync(Model, string, value?, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)

public Task<Model> ExecuteAsync(Model m, string activityId, value? value = null, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)

Parameters

m Model
activityId string
value value
context Dictionary<string, string>
secrets Dictionary<string, string>
trace List<LogEntry>
cts CancellationToken?
persistor ICasePersistor

Returns

Task<Model>

ExecuteClientEffectAsync(Model, Activity, value?, Dictionary<string, string>?, Dictionary<string, string>?, CancellationToken?, object?)

public Task<object?> ExecuteClientEffectAsync(Model model, Activity activity0, value? value0 = null, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, CancellationToken? cts = null, object? clientState = null)

Parameters

model Model
activity0 Activity
value0 value
context Dictionary<string, string>
secrets Dictionary<string, string>
cts CancellationToken?
clientState object

Returns

Task<object>

GetSpeculative()

public Runtime GetSpeculative()

Returns

Runtime

Initialize(Model, Dictionary<string, string>?, Dictionary<string, string>?, ICasePersistor?)

public Task Initialize(Model model, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, ICasePersistor? persistor = null)

Parameters

model Model
context Dictionary<string, string>
secrets Dictionary<string, string>
persistor ICasePersistor

Returns

Task

Load(string)

Load model from file

public Model Load(string filename)

Parameters

filename string

Returns

Model

Remarks

File will be assumed to contain an XML-serialized model, unless the filename ends with .dcr.

Parse(string, string?)

public Model Parse(string str, string? title = null)

Parameters

str string
title string

Returns

Model

Parse(XDocument)

Deserialize an XML-serialized model

public Model Parse(XDocument xml)

Parameters

xml XDocument

Returns

Model

ParseDcr(string, string?)

Deserialize model from .dcr source format

public Model ParseDcr(string str, string? title = null)

Parameters

str string
title string

Returns

Model

RunOnlyRobots(Model, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)

public Task<Model> RunOnlyRobots(Model model, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)

Parameters

model Model
context Dictionary<string, string>
secrets Dictionary<string, string>
trace List<LogEntry>
cts CancellationToken?
persistor ICasePersistor

Returns

Task<Model>

ValidateEffects(Model)

Statically verify that effects in model m are defined under current runtime

public IEnumerable<Runtime.EffectValidationError> ValidateEffects(Model m)

Parameters

m Model

Returns

IEnumerable<Runtime.EffectValidationError>

An empty sequence if all effects are defined or ignored, otherwise the sequence of errors detected

Remarks

Validation proceeds by instantiating effects for each activity one at a time. Validation respects ignore options for the Runtime; no validation errors will be reported for ignored effects, and if unknown effects are ignored, no errors will be reported at all.

See Also