Added JobKeyProvider to centralize job key and group name handling, simplifying Quartz job scheduling. Refactored QuartzWorkflowScheduler to use the new provider, improving maintainability. Updated QuartzSchedulerFeature to register the new provider and a startup task for job registration.
19 lines
484 B
C#
19 lines
484 B
C#
using Elsa.Common.Multitenancy;
|
|
using Elsa.Quartz.Contracts;
|
|
using Quartz;
|
|
|
|
namespace Elsa.Quartz.Services;
|
|
|
|
internal class JobKeyProvider(ITenantAccessor tenantAccessor) : IJobKeyProvider
|
|
{
|
|
public JobKey GetJobKey<TJob>() where TJob : IJob
|
|
{
|
|
return new(typeof(TJob).Name, GetGroupName());
|
|
}
|
|
|
|
public string GetGroupName()
|
|
{
|
|
var tenantId = tenantAccessor.Tenant?.Id;
|
|
return string.IsNullOrWhiteSpace(tenantId) ? "Default" : tenantId;
|
|
}
|
|
} |