diff --git a/src/modules/Elsa.Workflows.Core/Builders/WorkflowBuilder.cs b/src/modules/Elsa.Workflows.Core/Builders/WorkflowBuilder.cs index b3e78b665..d3b390dd4 100644 --- a/src/modules/Elsa.Workflows.Core/Builders/WorkflowBuilder.cs +++ b/src/modules/Elsa.Workflows.Core/Builders/WorkflowBuilder.cs @@ -38,6 +38,9 @@ public class WorkflowBuilder : IWorkflowBuilder /// public string? Description { get; set; } + /// + public bool IsReadonly { get; set; } + /// public IActivity? Root { get; set; } @@ -135,7 +138,7 @@ public class WorkflowBuilder : IWorkflowBuilder var identity = new WorkflowIdentity(definitionId, Version, id); var publication = WorkflowPublication.LatestAndPublished; var workflowMetadata = new WorkflowMetadata(Name, Description); - var workflow = new Workflow(identity, publication, workflowMetadata, WorkflowOptions, root, Variables, Inputs, Outputs, Outcomes, CustomProperties); + var workflow = new Workflow(identity, publication, workflowMetadata, WorkflowOptions, root, Variables, Inputs, Outputs, Outcomes, CustomProperties, IsReadonly); // If a Result variable is defined, install it into the workflow so we can capture the output into it. if (Result != null) diff --git a/src/modules/Elsa.Workflows.Core/Contracts/IWorkflowBuilder.cs b/src/modules/Elsa.Workflows.Core/Contracts/IWorkflowBuilder.cs index 71c8d9fd3..8280ad733 100644 --- a/src/modules/Elsa.Workflows.Core/Contracts/IWorkflowBuilder.cs +++ b/src/modules/Elsa.Workflows.Core/Contracts/IWorkflowBuilder.cs @@ -31,7 +31,13 @@ public interface IWorkflowBuilder /// A description of the workflow. /// string? Description { get; set; } - + + + /// + /// WorkflowDefinition is readonly. + /// + bool IsReadonly { get; set; } + /// /// Options for the workflow being built. /// diff --git a/src/modules/Elsa.Workflows.Core/Models/Workflow.cs b/src/modules/Elsa.Workflows.Core/Models/Workflow.cs index a3cbd2ca6..93672d8d6 100644 --- a/src/modules/Elsa.Workflows.Core/Models/Workflow.cs +++ b/src/modules/Elsa.Workflows.Core/Models/Workflow.cs @@ -28,7 +28,8 @@ public class Workflow : Composite, ICloneable ICollection inputs, ICollection outputs, ICollection outcomes, - IDictionary customProperties) + IDictionary customProperties, + bool isReadonly) { Identity = identity; Publication = publication; @@ -40,6 +41,7 @@ public class Workflow : Composite, ICloneable Variables = variables; CustomProperties = customProperties; Root = root; + IsReadonly = isReadonly; } /// @@ -91,7 +93,14 @@ public class Workflow : Composite, ICloneable /// Gets or sets options for the workflow. /// public WorkflowOptions Options { get; set; } = new(); - + + + /// + /// Make workflow definition readonly. + /// + public bool IsReadonly { get; set; } + + /// /// Constructs a new from the specified . /// diff --git a/src/modules/Elsa.Workflows.Management/Mappers/WorkflowDefinitionMapper.cs b/src/modules/Elsa.Workflows.Management/Mappers/WorkflowDefinitionMapper.cs index e883e02e3..1081a0d23 100644 --- a/src/modules/Elsa.Workflows.Management/Mappers/WorkflowDefinitionMapper.cs +++ b/src/modules/Elsa.Workflows.Management/Mappers/WorkflowDefinitionMapper.cs @@ -44,7 +44,8 @@ public class WorkflowDefinitionMapper source.Inputs, source.Outputs, source.Outcomes, - source.CustomProperties); + source.CustomProperties, + source.IsReadonly); } /// @@ -71,7 +72,8 @@ public class WorkflowDefinitionMapper source.Inputs ?? new List(), source.Outputs ?? new List(), source.Outcomes ?? new List(), - source.CustomProperties ?? new Dictionary()); + source.CustomProperties ?? new Dictionary(), + source.IsReadonly); } ///