mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2024-11-24 22:42:53 +01:00
42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Text.Json;
|
|
using Phantom.Server.Database.Enums;
|
|
|
|
namespace Phantom.Server.Database.Entities;
|
|
|
|
[Table("EventLog", Schema = "system")]
|
|
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Global")]
|
|
[SuppressMessage("ReSharper", "ClassWithVirtualMembersNeverInherited.Global")]
|
|
public sealed class EventLogEntity : IDisposable {
|
|
[Key]
|
|
public Guid EventGuid { get; set; }
|
|
|
|
public DateTime UtcTime { get; set; } // Note: Converting to UTC is not best practice, but for historical records it's good enough.
|
|
public Guid? AgentGuid { get; set; }
|
|
public EventLogEventType EventType { get; set; }
|
|
public EventLogSubjectType SubjectType { get; set; }
|
|
public string SubjectId { get; set; }
|
|
public JsonDocument? Data { get; set; }
|
|
|
|
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
|
internal EventLogEntity() {
|
|
SubjectId = string.Empty;
|
|
}
|
|
|
|
public EventLogEntity(Guid eventGuid, DateTime utcTime, Guid? agentGuid, EventLogEventType eventType, string subjectId, Dictionary<string, object?>? data) {
|
|
EventGuid = eventGuid;
|
|
UtcTime = utcTime;
|
|
AgentGuid = agentGuid;
|
|
EventType = eventType;
|
|
SubjectType = eventType.GetSubjectType();
|
|
SubjectId = subjectId;
|
|
Data = data == null ? null : JsonSerializer.SerializeToDocument(data);
|
|
}
|
|
|
|
public void Dispose() {
|
|
Data?.Dispose();
|
|
}
|
|
}
|