This commit is contained in:
parent
8f84bd3d09
commit
313879e52b
@ -15,11 +15,12 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services
|
||||||
{
|
{
|
||||||
public class IntegrationEventLogService : IIntegrationEventLogService
|
public class IntegrationEventLogService : IIntegrationEventLogService,IDisposable
|
||||||
{
|
{
|
||||||
private readonly IntegrationEventLogContext _integrationEventLogContext;
|
private readonly IntegrationEventLogContext _integrationEventLogContext;
|
||||||
private readonly DbConnection _dbConnection;
|
private readonly DbConnection _dbConnection;
|
||||||
private readonly List<Type> _eventTypes;
|
private readonly List<Type> _eventTypes;
|
||||||
|
private volatile bool disposedValue;
|
||||||
|
|
||||||
public IntegrationEventLogService(DbConnection dbConnection)
|
public IntegrationEventLogService(DbConnection dbConnection)
|
||||||
{
|
{
|
||||||
@ -89,5 +90,25 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Servi
|
|||||||
|
|
||||||
return _integrationEventLogContext.SaveChangesAsync();
|
return _integrationEventLogContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (!disposedValue)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
_integrationEventLogContext?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
disposedValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(disposing: true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,14 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Catalog.API.IntegrationEvents
|
namespace Catalog.API.IntegrationEvents
|
||||||
{
|
{
|
||||||
public class CatalogIntegrationEventService : ICatalogIntegrationEventService
|
public class CatalogIntegrationEventService : ICatalogIntegrationEventService,IDisposable
|
||||||
{
|
{
|
||||||
private readonly Func<DbConnection, IIntegrationEventLogService> _integrationEventLogServiceFactory;
|
private readonly Func<DbConnection, IIntegrationEventLogService> _integrationEventLogServiceFactory;
|
||||||
private readonly IEventBus _eventBus;
|
private readonly IEventBus _eventBus;
|
||||||
private readonly CatalogContext _catalogContext;
|
private readonly CatalogContext _catalogContext;
|
||||||
private readonly IIntegrationEventLogService _eventLogService;
|
private readonly IIntegrationEventLogService _eventLogService;
|
||||||
private readonly ILogger<CatalogIntegrationEventService> _logger;
|
private readonly ILogger<CatalogIntegrationEventService> _logger;
|
||||||
|
private volatile bool disposedValue;
|
||||||
|
|
||||||
public CatalogIntegrationEventService(
|
public CatalogIntegrationEventService(
|
||||||
ILogger<CatalogIntegrationEventService> logger,
|
ILogger<CatalogIntegrationEventService> logger,
|
||||||
@ -65,5 +66,24 @@ namespace Catalog.API.IntegrationEvents
|
|||||||
await _eventLogService.SaveEventAsync(evt, _catalogContext.Database.CurrentTransaction);
|
await _eventLogService.SaveEventAsync(evt, _catalogContext.Database.CurrentTransaction);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (!disposedValue)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
(_eventLogService as IDisposable)?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
disposedValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(disposing: true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user