Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public WorkflowState Extract(WorkflowExecutionContext workflowExecutionContext)
var state = new WorkflowState
{
Id = workflowExecutionContext.Id,
TenantId = workflowExecutionContext.Workflow?.Identity?.TenantId,
DefinitionId = workflowExecutionContext.Workflow.Identity.DefinitionId,
DefinitionVersionId = workflowExecutionContext.Workflow.Identity.Id,
DefinitionVersion = workflowExecutionContext.Workflow.Identity.Version,
Expand Down
5 changes: 5 additions & 0 deletions src/modules/Elsa.Workflows.Core/State/WorkflowState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public class WorkflowState
/// </summary>
public string Id { get; set; } = null!;

/// <summary>
/// Gets or sets the TenantId.
/// </summary>
public string TenantId { get; set; } = null!;

/// <summary>
/// The workflow definition ID.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class WorkflowStateMapper
public void Apply(WorkflowState source, WorkflowInstance target)
{
target.Id = source.Id;
target.TenantId = source.TenantId;
target.CreatedAt = source.CreatedAt;
target.DefinitionId = source.DefinitionId;
target.DefinitionVersionId = source.DefinitionVersionId;
Expand Down Expand Up @@ -66,6 +67,7 @@ public void Apply(WorkflowState source, WorkflowInstance target)

var workflowState = source.WorkflowState;
workflowState.Id = source.Id;
workflowState.TenantId = source.TenantId;
workflowState.CreatedAt = source.CreatedAt;
workflowState.DefinitionId = source.DefinitionId;
workflowState.DefinitionVersionId = source.DefinitionVersionId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public ActivityExecutionRecord Map(ActivityExecutionContext source)
return new()
{
Id = source.Id,
TenantId = source.WorkflowExecutionContext.Workflow?.Identity?.TenantId,
ActivityId = source.Activity.Id,
ActivityNodeId = source.NodeId,
WorkflowInstanceId = source.WorkflowExecutionContext.Id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public async Task<RunWorkflowResult> RunWorkflowAsync(RunWorkflowOptions? @param
var workflowResult = await workflowRunner.RunAsync(WorkflowGraph, WorkflowState, runOptions, linkedCancellationToken);

WorkflowState = workflowResult.WorkflowState;
WorkflowState.TenantId = WorkflowGraph.Workflow.Identity?.TenantId;
await PersistStateAsync(scope, cancellationToken);

_linkedTokenSource.Dispose();
Expand Down