|
|
@ -14,44 +14,34 @@ namespace LINGYUN.Abp.AuditLogging.EntityFrameworkCore; |
|
|
public class EfCoreSecurityLogWriter : ISecurityLogWriter, ITransientDependency |
|
|
public class EfCoreSecurityLogWriter : ISecurityLogWriter, ITransientDependency |
|
|
{ |
|
|
{ |
|
|
protected IIdentitySecurityLogRepository IdentitySecurityLogRepository { get; } |
|
|
protected IIdentitySecurityLogRepository IdentitySecurityLogRepository { get; } |
|
|
protected IUnitOfWorkManager UnitOfWorkManager { get; } |
|
|
|
|
|
protected IGuidGenerator GuidGenerator { get; } |
|
|
protected IGuidGenerator GuidGenerator { get; } |
|
|
|
|
|
|
|
|
public EfCoreSecurityLogWriter( |
|
|
public EfCoreSecurityLogWriter( |
|
|
IIdentitySecurityLogRepository identitySecurityLogRepository, |
|
|
IIdentitySecurityLogRepository identitySecurityLogRepository, |
|
|
IUnitOfWorkManager unitOfWorkManager, |
|
|
|
|
|
IGuidGenerator guidGenerator) |
|
|
IGuidGenerator guidGenerator) |
|
|
{ |
|
|
{ |
|
|
IdentitySecurityLogRepository = identitySecurityLogRepository; |
|
|
IdentitySecurityLogRepository = identitySecurityLogRepository; |
|
|
UnitOfWorkManager = unitOfWorkManager; |
|
|
|
|
|
GuidGenerator = guidGenerator; |
|
|
GuidGenerator = guidGenerator; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[UnitOfWork] |
|
|
public async virtual Task BulkWriteAsync(IEnumerable<SecurityLogInfo> securityLogInfos, CancellationToken cancellationToken = default) |
|
|
public async virtual Task BulkWriteAsync(IEnumerable<SecurityLogInfo> securityLogInfos, CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
using (var uow = UnitOfWorkManager.Begin(requiresNew: true)) |
|
|
var securityLogs = securityLogInfos.Select(securityLogInfo => |
|
|
{ |
|
|
|
|
|
var securityLogs = securityLogInfos.Select(securityLogInfo => |
|
|
|
|
|
new IdentitySecurityLog(GuidGenerator, securityLogInfo)); |
|
|
new IdentitySecurityLog(GuidGenerator, securityLogInfo)); |
|
|
|
|
|
|
|
|
await IdentitySecurityLogRepository.InsertManyAsync( |
|
|
await IdentitySecurityLogRepository.InsertManyAsync( |
|
|
securityLogs, |
|
|
securityLogs, |
|
|
false, |
|
|
false, |
|
|
cancellationToken); |
|
|
cancellationToken); |
|
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[UnitOfWork] |
|
|
public async virtual Task WriteAsync(SecurityLogInfo securityLogInfo, CancellationToken cancellationToken = default) |
|
|
public async virtual Task WriteAsync(SecurityLogInfo securityLogInfo, CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
using (var uow = UnitOfWorkManager.Begin(requiresNew: true)) |
|
|
await IdentitySecurityLogRepository.InsertAsync( |
|
|
{ |
|
|
new IdentitySecurityLog(GuidGenerator, securityLogInfo), |
|
|
await IdentitySecurityLogRepository.InsertAsync( |
|
|
false, |
|
|
new IdentitySecurityLog(GuidGenerator, securityLogInfo), |
|
|
cancellationToken); |
|
|
false, |
|
|
|
|
|
cancellationToken); |
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|