elsa-core/src/modules/Elsa.Hangfire/Jobs/ResumeWorkflowJob.cs
Ray 3aafcddb02
Fix hangfire resume workflow (#6097)
There was a bug in the hangfire implementation where it would always generate a random workflowinstanceid because it was not passed into the createclient. Because of this hangfire was unable to resume instances.

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-11-08 21:43:52 +01:00

31 lines
1.1 KiB
C#

using Elsa.Scheduling;
using Elsa.Workflows.Runtime;
using Elsa.Workflows.Runtime.Messages;
namespace Elsa.Hangfire.Jobs;
/// <summary>
/// A job that resumes a workflow.
/// </summary>
public class ResumeWorkflowJob(IWorkflowRuntime workflowRuntime)
{
/// <summary>
/// Executes the job.
/// </summary>
/// <param name="name">The name of the job.</param>
/// <param name="request">The workflow request.</param>
/// <param name="cancellationToken">The cancellation token.</param>
public async Task ExecuteAsync(string name, ScheduleExistingWorkflowInstanceRequest request, CancellationToken cancellationToken)
{
var client = await workflowRuntime.CreateClientAsync(request.WorkflowInstanceId, cancellationToken);
var runRequest = new RunWorkflowInstanceRequest
{
BookmarkId = request.BookmarkId,
ActivityHandle = request.ActivityHandle,
Input = request.Input,
Properties = request.Properties
};
await client.RunInstanceAsync(runRequest, cancellationToken);
}
}