Merge pull request #6388 from elsa-workflows/bug/hangfire-job-compat
Add obsolete ExecuteAsync overloads for job classes
This commit is contained in:
commit
0dcc15cbec
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue