# Class ActivityDefinition OptimaJet.Workflow.Core.Model.ActivityDefinition Defines an activity in a process scheme. Namespace: [OptimaJet.Workflow.Core.Model](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/) ```csharp public class ActivityDefinition : BaseDefinition, IInlineActivity, IOrdinaryActivity ``` ## Type Hierarchy - [BaseDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/BaseDefinition/) - ActivityDefinition Current type - Implemented interfaces - [IInlineActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/IInlineActivity/) - [IOrdinaryActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/IOrdinaryActivity/) ## Properties `public string OriginalName { get; set; }` Gets or sets the activity name before the activity was first inlined into another scheme. `public string OriginalSchemeCode { get; set; }` Gets or sets the code of the scheme from which the activity was originally inlined. `public string LastTimeInlineName { get; set; }` Gets or sets the name of the inline activity used when this activity was last copied into a parent process scheme. `public string FirstTimeInlineName { get; set; }` Gets or sets the name of the first inline activity through which this activity was inlined. `public bool WasInlined { get; set; }` Gets or sets a value indicating whether this activity was copied into another process scheme during scheme inlining. `[JsonConverter(typeof(StringEnumConverter))] [JsonConverter(typeof(SystemStringEnumConverter))] public ActivityType ActivityType { get; set; }` Gets or sets the kind of activity represented by this definition. `public string SchemeCode { get; set; }` Gets or sets the code of the process scheme referenced by this inline activity. `public string State { get; set; }` Gets or sets the business state name associated with this activity. ### Remarks Multiple activities can have the same [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) value. `public bool IsInitial { get; set; }` Gets or sets a value indicating whether this activity is the process entry point. ### Remarks Every scheme has exactly one initial activity. `public bool IsFinal { get; set; }` Gets or sets a value indicating whether this activity is marked as final. ### Remarks The process status becomes [ProcessStatus.Finalized](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/ProcessStatus/) when execution stops at a final activity. `public bool IsForSetState { get; set; }` Gets or sets a value indicating whether this activity is eligible to be selected by state-setting operations. ### Remarks An activity is selected by state only when this property and [ActivityDefinition.IsState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) are [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) and the requested state matches [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). `public bool IsAutoSchemeUpdate { get; set; }` Gets or sets a value indicating whether Workflow Engine may automatically update an obsolete process scheme while this activity is current. `public bool DisablePersistState { get; set; }` Gets or sets a value indicating whether entering this activity skips updating the stored current activity and business state. `public bool DisablePersistTransitionHistory { get; set; }` Gets or sets a value indicating whether entering this activity skips writing the transition to process history. `public bool DisablePersistParameters { get; set; }` Gets or sets a value indicating whether entering this activity skips saving persistent process parameters. `public string UserComment { get; set; }` Gets or sets a user-defined comment for the activity. `public bool HaveImplementation { get; }` Gets a value indicating whether [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) contains at least one [ActionDefinitionReference](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActionDefinitionReference/). `public bool HavePreExecutionImplementation { get; }` Gets a value indicating whether [ActivityDefinition.PreExecutionImplementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) contains at least one [ActionDefinitionReference](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActionDefinitionReference/). `public List Implementation { get; set; }` Gets or sets the actions executed when a process instance enters this activity during normal execution. ### Remarks Actions are invoked in ascending [ActionDefinitionReference.Order](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActionDefinitionReference/) order. `public List PreExecutionImplementation { get; set; }` Gets or sets the [ActionDefinitionReference](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActionDefinitionReference/) instances for actions executed during pre-execution simulation. ### Remarks Actions are invoked in ascending [ActionDefinitionReference.Order](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActionDefinitionReference/) order. `public List Annotations { get; set; }` Gets or sets the [Annotation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/Annotation/) instances attached to this activity. `public ActivityTimeout ExecutionTimeout { get; set; }` Gets or sets the timeout that requests cancellation when normal activity execution exceeds its interval and defines how Workflow Engine responds. `public ActivityTimeout IdleTimeout { get; set; }` Gets or sets the timeout that limits how long a process instance can wait at this activity without a transition firing and defines how Workflow Engine responds. `public List ExceptionsHandlers { get; set; }` Gets or sets the [ActivityExceptionsHandler](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityExceptionsHandler/) configurations used during normal activity execution. ### Remarks Handlers are evaluated in ascending [ActivityExceptionsHandler.Order](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityExceptionsHandler/) order, and the first matching handler is used. `public bool IsState { get; }` Gets a value indicating whether [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) is neither [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) nor empty. `public int? NestingLevel { get; set; }` Gets or sets the subprocess nesting level assigned to this activity. `[JsonIgnore] [JsonIgnore] public string CustomType { get; set; }` Gets or sets the custom activity type identifier stored in [ActivityDefinition.Annotations](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). ### Remarks The getter reads the first matching [Annotation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/Annotation/). The setter appends an [Annotation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/Annotation/) whose [Annotation.Name](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/Annotation/) is [FormBase.CustomTypeAnnotationName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core/FormBase/). ## Methods `public static ActivityDefinition CreateInlineActivity(string name, string schemeCode)` Creates an inline activity that references another process scheme. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The name assigned to the created activity. | | `schemeCode` | `String` | The process scheme code assigned to [ActivityDefinition.SchemeCode](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). | ### Returns | Type | Description | | --- | --- | | `ActivityDefinition` | An [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) whose [ActivityDefinition.ActivityType](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) is [ActivityType.Inline](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityType/). | `public void AddAction(ActionDefinitionReference action)` Adds `action` to [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `action` | `ActionDefinitionReference` | The [ActionDefinitionReference](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActionDefinitionReference/) to add. | `public void AddPreExecutionAction(ActionDefinitionReference action)` Adds `action` to [ActivityDefinition.PreExecutionImplementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `action` | `ActionDefinitionReference` | The [ActionDefinitionReference](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActionDefinitionReference/) to add. | `public ActivityDefinition Clone()` Creates a copy of this [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). ### Returns | Type | Description | | --- | --- | | `ActivityDefinition` | The copied [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). | ### Exceptions | Type | Description | | --- | --- | | `Exception` | Thrown when [BaseDefinition.Clone()](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/BaseDefinition/) does not produce an [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). | ### Remarks [BaseDefinition.Clone()](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/BaseDefinition/) supplies the initial copy. This method then creates new [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/), [ActivityDefinition.PreExecutionImplementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/), and [ActivityDefinition.Annotations](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) collections and clones their elements. The copied [ActivityDefinition.ExecutionTimeout](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/), [ActivityDefinition.IdleTimeout](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/), and [ActivityDefinition.ExceptionsHandlers](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) references are retained. `public T GetAnnotation(string name)` Gets an [Annotation.JsonValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/Annotation/) and deserializes it to `T`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The annotation name to match against [Annotation.Name](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/Annotation/). | ### Returns | Type | Description | | --- | --- | | `{T}` | The annotation value deserialized as `T`. | `public string GetAnnotation(string name)` Gets the stored string value for an annotation. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The annotation name to match against [Annotation.Name](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/Annotation/). | ### Returns | Type | Description | | --- | --- | | `String` | The [Annotation.JsonValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/Annotation/) of the first annotation whose [Annotation.Name](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/Annotation/) matches `name`; otherwise, [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | ## Remarks An [ActivityType.Ordinary](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityType/) activity is a stable point where a process instance waits between transitions and can run actions on entry. An [ActivityType.Inline](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityType/) activity marks where another process scheme is embedded during scheme building. [Previous ActionDefinitionReference](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActionDefinitionReference/) [Next ActivityExceptionsHandler](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityExceptionsHandler/)