mirror of
https://github.com/bitwarden/server
synced 2025-12-11 13:53:40 +00:00
abstract quartz jobs sevrice out to core
This commit is contained in:
@@ -1,34 +1,27 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Jobs;
|
||||
using Bit.Core.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Quartz;
|
||||
|
||||
namespace Bit.Api.Jobs
|
||||
{
|
||||
public class ValidateOrganizationsJob : IJob
|
||||
public class ValidateOrganizationsJob : BaseJob
|
||||
{
|
||||
private readonly ILicensingService _licensingService;
|
||||
private readonly ILogger<ValidateOrganizationsJob> _logger;
|
||||
|
||||
public ValidateOrganizationsJob(
|
||||
ILicensingService licensingService,
|
||||
ILogger<ValidateOrganizationsJob> logger)
|
||||
: base(logger)
|
||||
{
|
||||
_licensingService = licensingService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
protected async override Task ExecuteJobAsync(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _licensingService.ValidateOrganizationsAsync();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
_logger.LogError(2, e, "Error performing {0}.", nameof(ValidateOrganizationsJob));
|
||||
}
|
||||
await _licensingService.ValidateUsersAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user