using Elsa.Workflows.Runtime; using Elsa.Workflows.Runtime.Messages; using Microsoft.Extensions.DependencyInjection; namespace Elsa.Scheduling.Tasks; /// /// A task that resumes a workflow. /// public class ResumeWorkflowTask : ITask { private readonly ScheduleExistingWorkflowInstanceRequest _request; /// /// Initializes a new instance of the class. /// /// The dispatch workflow instance request. public ResumeWorkflowTask(ScheduleExistingWorkflowInstanceRequest request) { _request = request; } /// public async ValueTask ExecuteAsync(TaskExecutionContext context) { var cancellationToken = context.CancellationToken; var workflowRuntime = context.ServiceProvider.GetRequiredService(); var workflowClient = await workflowRuntime.CreateClientAsync(_request.WorkflowInstanceId, cancellationToken); var request = new RunWorkflowInstanceRequest { Input = _request.Input, Properties = _request.Properties, ActivityHandle = _request.ActivityHandle, BookmarkId = _request.BookmarkId }; await workflowClient.RunInstanceAsync(request, cancellationToken); } }