Table of Contents

Working with models

The Model class represents a DCR model.

Obtaining a model

Models are created by domain-experts in the DCR Designer on-line tool. DCR.Workflow does not provide functionality for programmatically constructing models.

You have the following options for obtaining a model:

  1. Load a model directly from an XML file.
  2. Load a model from the DCR Repository.

Deserialize a model from XML

Assume you have an XML-serialized DCR model saved in a file model.xml on disk. To load this file and deserialize the model:

Warning

It looks like the sample you are looking for does not exist.

If serialized model is more conveniently available as an XDocument use the DCR.Workflow.Model.#ctor(System.Xml.Linq.XDocument) constructor.

Tip

In the DCR Designer, on the model editing page, use File -> Export as XML to obtain an XML file. (However, availability of this feature dependes on your subscription.)

Serialize a model to XML

Serialize to an XDocument using ToXDocument.

Find enabled activities

A DCR Model contains some number of activites, each of which has a state. The most important state for end-users is whether the activity is enabled, that is, whether it is currently allowed to be executed. For instance, the DCR Model might require that the activity "Pay out" cannot happen without the activity "Approve" happening first.

In general, to find sets of activities, use Linq-queries on the Activities property. E.g., to find enabled activities:

Warning

It looks like the sample you are looking for does not exist.

Activites that are marked "pending" are required to be executed before the workflow can be considered complete. It is often helpful to present these to end-users in isolation. To find events that are enabled and pending:

Warning

It looks like the sample you are looking for does not exist.

Read more about DCR Activities and their states, or about the rules which causes state to change.

Query properties of a particular activity

Activities are identified by modellers using a string id. To find a particular id use either:

Both calls return an object of type Activity. Query the state of the activity by inspecting the properties of this object. E.g., to find the current deadline of the activity, if any, use the Deadline property:

Warning

It looks like the sample you are looking for does not exist.

Tip

In the DCR Designer, the id of an activity is available under the "Advanced" tab in the right-hand--side edit panel.

Read more about deadlines.

Update the workflow by executing an activity

To update the state of a model by executing an activity:

Warning

It looks like the sample you are looking for does not exist.

This method does not return anything; the state of the Model is updated in-place.

An Activity object returned from a model will always return up-to-date information, even across calls to Execute. E.g.:

Warning

It looks like the sample you are looking for does not exist.

Note how the Deadline property changed value after the call to DCR.Workflow.Model.Execute(DCR.Workflow.Activity,DCR.Core.Data.value).

Caution
DCR.Workflow.Model.Execute(DCR.Workflow.Activity,DCR.Core.Data.value) does not check that the supplied Activity is enabled. It is your responsibility to ensure that enabledness _before_ calling Execute. Refer to DCR.Workflow.Model.Execute(DCR.Workflow.Activity,DCR.Core.Data.value) documentation for more details.
Tip
DCR.Workflow.Model.Execute(DCR.Workflow.Activity,DCR.Core.Data.value) does not implement side-effects or automatic execution of follow-up events ("robots"). If you need any of these features, you need to perform execution via DCR Workflow middleware.

Working with values

Activities in a DCR Model may carry a data value, represented programmatically as a @DCR.Core.Data.value.

Read more about data values in modelling.