1
0
mirror of https://github.com/bitwarden/server synced 2026-01-03 09:03:44 +00:00

abstract quartz jobs sevrice out to core

This commit is contained in:
Kyle Spearrin
2018-08-10 11:05:45 -04:00
parent 06d5b4af29
commit 670f79a861
10 changed files with 127 additions and 80 deletions

31
src/Core/Jobs/BaseJob.cs Normal file
View File

@@ -0,0 +1,31 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Quartz;
namespace Bit.Core.Jobs
{
public abstract class BaseJob : IJob
{
protected readonly ILogger _logger;
public BaseJob(ILogger logger)
{
_logger = logger;
}
public async Task Execute(IJobExecutionContext context)
{
try
{
await ExecuteJobAsync(context);
}
catch(Exception e)
{
_logger.LogError(2, e, "Error performing {0}.", GetType().Name);
}
}
protected abstract Task ExecuteJobAsync(IJobExecutionContext context);
}
}