elsa-core/src/modules/Elsa.Quartz/Services/JobKeyProvider.cs
Sipke Schoorstra 96bf791668 Introduce JobKeyProvider for managing Quartz job keys
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.
2024-12-11 14:35:49 +01:00

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;
}
}