mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-08-16 03:31:43 +02:00
.config
.run
.workdir
Agent
Common
Controller
Phantom.Controller
Phantom.Controller.Database
Converters
Entities
AgentEntity.cs
AuditLogEntity.cs
EventLogEntity.cs
InstanceEntity.cs
PermissionEntity.cs
RoleEntity.cs
RolePermissionEntity.cs
UserAgentAccessEntity.cs
UserEntity.cs
UserPermissionEntity.cs
UserRoleEntity.cs
Factories
Repositories
ApplicationDbContext.cs
DatabaseMigrator.cs
IDbContextProvider.cs
ILazyDbContext.cs
Phantom.Controller.Database.csproj
Phantom.Controller.Database.Postgres
Phantom.Controller.Minecraft
Phantom.Controller.Services
Docker
Utils
Web
.dockerignore
.gitattributes
.gitignore
AddMigration.bat
AddMigration.sh
Directory.Build.props
Directory.Build.targets
Dockerfile
LICENSE
Packages.props
PhantomPanel.sln
README.md
global.json
45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Text.Json;
|
|
using Phantom.Common.Data.Web.AuditLog;
|
|
|
|
namespace Phantom.Controller.Database.Entities;
|
|
|
|
[Table("AuditLog", Schema = "system")]
|
|
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Global")]
|
|
[SuppressMessage("ReSharper", "ClassWithVirtualMembersNeverInherited.Global")]
|
|
public class AuditLogEntity : IDisposable {
|
|
[Key]
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
|
public long Id { get; init; }
|
|
|
|
public Guid? UserGuid { get; init; }
|
|
public DateTime UtcTime { get; init; } // Note: Converting to UTC is not best practice, but for historical records it's good enough.
|
|
public AuditLogEventType EventType { get; init; }
|
|
public AuditLogSubjectType SubjectType { get; init; }
|
|
public string SubjectId { get; init; }
|
|
public JsonDocument? Data { get; init; }
|
|
|
|
public virtual UserEntity? User { get; init; }
|
|
|
|
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
|
internal AuditLogEntity() {
|
|
SubjectId = string.Empty;
|
|
}
|
|
|
|
public AuditLogEntity(Guid? userGuid, AuditLogEventType eventType, string subjectId, Dictionary<string, object?>? data) {
|
|
UserGuid = userGuid;
|
|
UtcTime = DateTime.UtcNow;
|
|
EventType = eventType;
|
|
SubjectType = eventType.GetSubjectType();
|
|
SubjectId = subjectId;
|
|
Data = data == null ? null : JsonSerializer.SerializeToDocument(data);
|
|
}
|
|
|
|
public void Dispose() {
|
|
Data?.Dispose();
|
|
}
|
|
}
|