Browse Source

Audit log remove sync api

pull/2464/head
Halil İbrahim Kalkan 7 years ago
parent
commit
f0ae994848
  1. 15
      framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingManager.cs
  2. 2
      framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditLogSaveHandle.cs
  3. 2
      framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingStore.cs
  4. 7
      framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/SimpleLogAuditingStore.cs
  5. 27
      modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditingStore.cs
  6. 6
      modules/audit-logging/test/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests/Volo/Abp/AuditLogging/EntityFrameworkCore/AuditLogRepository_Tests.cs
  7. 12
      modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditLogRepository_Tests.cs
  8. 2
      modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditStore_Basic_Tests.cs

15
framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingManager.cs

@ -120,16 +120,6 @@ namespace Volo.Abp.Auditing
}
}
protected virtual void Save(DisposableSaveHandle saveHandle)
{
BeforeSave(saveHandle);
if (ShouldSave(saveHandle.AuditLog))
{
_auditingStore.Save(saveHandle.AuditLog);
}
}
protected bool ShouldSave(AuditLogInfo auditLog)
{
if (!auditLog.Actions.Any() && !auditLog.EntityChanges.Any())
@ -165,11 +155,6 @@ namespace Volo.Abp.Auditing
await _auditingManager.SaveAsync(this);
}
public void Save()
{
_auditingManager.Save(this);
}
public void Dispose()
{
_scope.Dispose();

2
framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditLogSaveHandle.cs

@ -5,8 +5,6 @@ namespace Volo.Abp.Auditing
{
public interface IAuditLogSaveHandle : IDisposable
{
void Save();
Task SaveAsync();
}
}

2
framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingStore.cs

@ -4,8 +4,6 @@ namespace Volo.Abp.Auditing
{
public interface IAuditingStore
{
void Save(AuditLogInfo auditInfo);
Task SaveAsync(AuditLogInfo auditInfo);
}
}

7
framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/SimpleLogAuditingStore.cs

@ -15,14 +15,9 @@ namespace Volo.Abp.Auditing
Logger = NullLogger<SimpleLogAuditingStore>.Instance;
}
public void Save(AuditLogInfo auditInfo)
{
Logger.LogInformation(auditInfo.ToString());
}
public Task SaveAsync(AuditLogInfo auditInfo)
{
Save(auditInfo);
Logger.LogInformation(auditInfo.ToString());
return Task.FromResult(0);
}
}

27
modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditingStore.cs

@ -33,33 +33,6 @@ namespace Volo.Abp.AuditLogging
Logger = NullLogger<AuditingStore>.Instance;
}
public void Save(AuditLogInfo auditInfo)
{
if (!Options.HideErrors)
{
SaveLog(auditInfo);
return;
}
try
{
SaveLog(auditInfo);
}
catch (Exception ex)
{
Logger.LogException(ex, LogLevel.Error);
}
}
protected virtual void SaveLog(AuditLogInfo auditInfo)
{
using (var uow = _unitOfWorkManager.Begin(true))
{
_auditLogRepository.Insert(new AuditLog(_guidGenerator, auditInfo));
uow.SaveChanges();
}
}
public async Task SaveAsync(AuditLogInfo auditInfo)
{
if (!Options.HideErrors)

6
modules/audit-logging/test/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests/Volo/Abp/AuditLogging/EntityFrameworkCore/AuditLogRepository_Tests.cs

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Volo.Abp.AuditLogging.EntityFrameworkCore
namespace Volo.Abp.AuditLogging.EntityFrameworkCore
{
public class AuditLogRepository_Tests : AuditLogRepository_Tests<AbpAuditLoggingEntityFrameworkCoreTestModule>
{

12
modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditLogRepository_Tests.cs

@ -119,8 +119,8 @@ namespace Volo.Abp.AuditLogging
}
};
AuditLogRepository.Insert(new AuditLog(GuidGenerator, log1));
AuditLogRepository.Insert(new AuditLog(GuidGenerator, log2));
await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log1));
await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log2));
//Assert
var logs = await AuditLogRepository.GetListAsync();
@ -223,8 +223,8 @@ namespace Volo.Abp.AuditLogging
}
};
AuditLogRepository.Insert(new AuditLog(GuidGenerator, log1));
AuditLogRepository.Insert(new AuditLog(GuidGenerator, log2));
await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log1));
await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log2));
//Assert
var logs = await AuditLogRepository.GetCountAsync();
@ -325,8 +325,8 @@ namespace Volo.Abp.AuditLogging
}
};
AuditLogRepository.Insert(new AuditLog(GuidGenerator, log1));
AuditLogRepository.Insert(new AuditLog(GuidGenerator, log2));
await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log1));
await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log2));
//Assert
var date = DateTime.Parse("2020-01-01");

2
modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditStore_Basic_Tests.cs

@ -68,7 +68,7 @@ namespace Volo.Abp.AuditLogging
//Assert
var insertedLog = _auditLogRepository.GetList(true)
var insertedLog = (await _auditLogRepository.GetListAsync(true))
.FirstOrDefault(al => al.UserId == userId);
insertedLog.ShouldNotBeNull();

Loading…
Cancel
Save