From 63ada68a2030cb01ec4f266492b199f0fde06f0a Mon Sep 17 00:00:00 2001
From: MariusVuscanNx <96233009+MariusVuscanNx@users.noreply.github.com>
Date: Thu, 25 May 2023 23:54:16 +0300
Subject: [PATCH] Added workflow execution context to the workflow executred
and workflow executing notifications (#4065)
---
.../Elsa.Workflows.Core/Notifications/WorkflowExecuted.cs | 2 +-
.../Elsa.Workflows.Core/Notifications/WorkflowExecuting.cs | 2 +-
src/modules/Elsa.Workflows.Core/Services/WorkflowRunner.cs | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/modules/Elsa.Workflows.Core/Notifications/WorkflowExecuted.cs b/src/modules/Elsa.Workflows.Core/Notifications/WorkflowExecuted.cs
index 8f7e9b39a..016a6784a 100644
--- a/src/modules/Elsa.Workflows.Core/Notifications/WorkflowExecuted.cs
+++ b/src/modules/Elsa.Workflows.Core/Notifications/WorkflowExecuted.cs
@@ -7,4 +7,4 @@ namespace Elsa.Workflows.Core.Notifications;
///
/// A domain event that is published everytime a burst of execution completes.
///
-public record WorkflowExecuted(Workflow Workflow, WorkflowState WorkflowState) : INotification;
\ No newline at end of file
+public record WorkflowExecuted(Workflow Workflow, WorkflowState WorkflowState, WorkflowExecutionContext WorkflowExecutionContext) : INotification;
\ No newline at end of file
diff --git a/src/modules/Elsa.Workflows.Core/Notifications/WorkflowExecuting.cs b/src/modules/Elsa.Workflows.Core/Notifications/WorkflowExecuting.cs
index 645b8c17e..ae3168508 100644
--- a/src/modules/Elsa.Workflows.Core/Notifications/WorkflowExecuting.cs
+++ b/src/modules/Elsa.Workflows.Core/Notifications/WorkflowExecuting.cs
@@ -6,4 +6,4 @@ namespace Elsa.Workflows.Core.Notifications;
///
/// A domain event that is published before a burst of execution begins.
///
-public record WorkflowExecuting(Workflow Workflow) : INotification;
\ No newline at end of file
+public record WorkflowExecuting(Workflow Workflow, WorkflowExecutionContext WorkflowExecutionContext) : INotification;
\ No newline at end of file
diff --git a/src/modules/Elsa.Workflows.Core/Services/WorkflowRunner.cs b/src/modules/Elsa.Workflows.Core/Services/WorkflowRunner.cs
index a8e4b1966..deaf4cb97 100644
--- a/src/modules/Elsa.Workflows.Core/Services/WorkflowRunner.cs
+++ b/src/modules/Elsa.Workflows.Core/Services/WorkflowRunner.cs
@@ -165,7 +165,7 @@ public class WorkflowRunner : IWorkflowRunner
var cancellationToken = workflowExecutionContext.CancellationToken;
// Publish domain event.
- await _eventPublisher.PublishAsync(new WorkflowExecuting(workflow), cancellationToken);
+ await _eventPublisher.PublishAsync(new WorkflowExecuting(workflow, workflowExecutionContext), cancellationToken);
// Transition into the Running state.
workflowExecutionContext.TransitionTo(WorkflowSubStatus.Executing);
@@ -182,7 +182,7 @@ public class WorkflowRunner : IWorkflowRunner
var result = workflow.ResultVariable?.Get(workflowExecutionContext.MemoryRegister);
// Publish domain event.
- await _eventPublisher.PublishAsync(new WorkflowExecuted(workflow, workflowState), cancellationToken);
+ await _eventPublisher.PublishAsync(new WorkflowExecuted(workflow, workflowState, workflowExecutionContext), cancellationToken);
// Return workflow execution result containing state + bookmarks.
return new RunWorkflowResult(workflowState, workflowExecutionContext.Workflow, result);