Merge pull request #6388 from elsa-workflows/bug/hangfire-job-compat

Add obsolete ExecuteAsync overloads for job classes
This commit is contained in:
Sipke Schoorstra 2025-02-07 13:29:04 +01:00 committed by GitHub
commit 0dcc15cbec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 0 deletions

View file

@ -19,4 +19,14 @@ public class ExecuteBackgroundActivityJob(IBackgroundActivityInvoker backgroundA
using var scope = tenantAccessor.PushContext(tenant);
await backgroundActivityInvoker.ExecuteAsync(scheduledBackgroundActivity, cancellationToken);
}
/// <summary>
/// Executes the job.
/// </summary>
[Obsolete("Use the other overload.")]
[UsedImplicitly]
public async Task ExecuteAsync(ScheduledBackgroundActivity scheduledBackgroundActivity, CancellationToken cancellationToken = default)
{
await backgroundActivityInvoker.ExecuteAsync(scheduledBackgroundActivity, cancellationToken);
}
}

View file

@ -3,6 +3,7 @@ using Elsa.Scheduling;
using Elsa.Workflows.Runtime;
using Elsa.Workflows.Runtime.Messages;
using Hangfire;
using JetBrains.Annotations;
namespace Elsa.Hangfire.Jobs;
@ -34,4 +35,19 @@ public class ResumeWorkflowJob(IWorkflowRuntime workflowRuntime, ITenantFinder t
};
await client.RunInstanceAsync(runRequest, cancellationToken);
}
[Obsolete("Use the other overload.")]
[UsedImplicitly]
public async Task ExecuteAsync(string taskName, 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);
}
}

View file

@ -3,6 +3,7 @@ using Elsa.Scheduling;
using Elsa.Workflows.Runtime;
using Elsa.Workflows.Runtime.Messages;
using Hangfire;
using JetBrains.Annotations;
namespace Elsa.Hangfire.Jobs;
@ -36,4 +37,21 @@ public class RunWorkflowJob(IWorkflowRuntime workflowRuntime, ITenantFinder tena
};
await client.CreateAndRunInstanceAsync(createAndRunRequest, cancellationToken);
}
[Obsolete("Use the other overload.")]
[UsedImplicitly]
public async Task ExecuteAsync(string taskName, ScheduleNewWorkflowInstanceRequest request, CancellationToken cancellationToken)
{
var client = await workflowRuntime.CreateClientAsync(cancellationToken);
var createAndRunRequest = new CreateAndRunWorkflowInstanceRequest
{
WorkflowDefinitionHandle = request.WorkflowDefinitionHandle,
TriggerActivityId = request.TriggerActivityId,
CorrelationId = request.CorrelationId,
Input = request.Input,
Properties = request.Properties,
ParentId = request.ParentId
};
await client.CreateAndRunInstanceAsync(createAndRunRequest, cancellationToken);
}
}