32 lines
931 B
C#
32 lines
931 B
C#
using BimAI.Infrastructure.Sync;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace BimAI.Infrastructure.Jobs;
|
|
|
|
public class InvoiceSyncJob
|
|
{
|
|
private readonly InvoiceSyncService _invoiceSyncService;
|
|
private readonly ILogger<InvoiceSyncJob> _logger;
|
|
|
|
public InvoiceSyncJob(InvoiceSyncService invoiceSyncService, ILogger<InvoiceSyncJob> logger)
|
|
{
|
|
_invoiceSyncService = invoiceSyncService;
|
|
_logger = logger;
|
|
}
|
|
|
|
public async Task ExecuteAsync()
|
|
{
|
|
_logger.LogInformation("Starting invoice sync...");
|
|
|
|
try
|
|
{
|
|
await _invoiceSyncService.RunAsync();
|
|
_logger.LogInformation("Invoice sync finished.");
|
|
} catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Error during invoice sync.");
|
|
throw;
|
|
}
|
|
}
|
|
}
|