* Introduce new AuditEntryService - Moved logic related to the IAuditEntryRepository from the AuditService to the new service - Introduced new Async methods - Using ids (for easier transition from the previous Write method) - Using keys - Moved and updated integration tests related to the audit entries to a new test class `AuditEntryServiceTests` - Added unit tests class `AuditEntryServiceTests` and added a few unit tests - Added migration to add columns for `performingUserKey` and `affectedUserKey` and convert existing user ids - Adjusted usages of the old AuditService.Write method to use the new one (mostly notification handlers) * Apply suggestions from code review * Small improvement * Some adjustments following code review. Removed UnknownUserKey and used null instead. * Small adjustments * Better handle audits performed during the migration state * Update TODO comment
93 lines
2.5 KiB
C#
93 lines
2.5 KiB
C#
using System.Runtime.Serialization;
|
|
using Umbraco.Cms.Core.Models.Entities;
|
|
|
|
namespace Umbraco.Cms.Core.Models;
|
|
|
|
/// <summary>
|
|
/// Represents an audited event.
|
|
/// </summary>
|
|
[Serializable]
|
|
[DataContract(IsReference = true)]
|
|
public class AuditEntry : EntityBase, IAuditEntry
|
|
{
|
|
private string? _affectedDetails;
|
|
private int _affectedUserId;
|
|
private Guid? _affectedUserKey;
|
|
private string? _eventDetails;
|
|
private string? _eventType;
|
|
private string? _performingDetails;
|
|
private string? _performingIp;
|
|
private int _performingUserId;
|
|
private Guid? _performingUserKey;
|
|
|
|
/// <inheritdoc />
|
|
public int PerformingUserId
|
|
{
|
|
get => _performingUserId;
|
|
set => SetPropertyValueAndDetectChanges(value, ref _performingUserId, nameof(PerformingUserId));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public Guid? PerformingUserKey
|
|
{
|
|
get => _performingUserKey;
|
|
set => SetPropertyValueAndDetectChanges(value, ref _performingUserKey, nameof(PerformingUserKey));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public string? PerformingDetails
|
|
{
|
|
get => _performingDetails;
|
|
set => SetPropertyValueAndDetectChanges(value, ref _performingDetails, nameof(PerformingDetails));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public string? PerformingIp
|
|
{
|
|
get => _performingIp;
|
|
set => SetPropertyValueAndDetectChanges(value, ref _performingIp, nameof(PerformingIp));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public DateTime EventDateUtc
|
|
{
|
|
get => CreateDate;
|
|
set => CreateDate = value;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public int AffectedUserId
|
|
{
|
|
get => _affectedUserId;
|
|
set => SetPropertyValueAndDetectChanges(value, ref _affectedUserId, nameof(AffectedUserId));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public Guid? AffectedUserKey
|
|
{
|
|
get => _affectedUserKey;
|
|
set => SetPropertyValueAndDetectChanges(value, ref _affectedUserKey, nameof(AffectedUserKey));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public string? AffectedDetails
|
|
{
|
|
get => _affectedDetails;
|
|
set => SetPropertyValueAndDetectChanges(value, ref _affectedDetails, nameof(AffectedDetails));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public string? EventType
|
|
{
|
|
get => _eventType;
|
|
set => SetPropertyValueAndDetectChanges(value, ref _eventType, nameof(EventType));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public string? EventDetails
|
|
{
|
|
get => _eventDetails;
|
|
set => SetPropertyValueAndDetectChanges(value, ref _eventDetails, nameof(EventDetails));
|
|
}
|
|
}
|