| | 1 | | using Audit.Core; |
| | 2 | | using System.Text.Json; |
| | 3 | | using Audit.EntityFramework; |
| | 4 | |
|
| | 5 | | namespace Syki.Back.Audit; |
| | 6 | |
|
| | 7 | | /// <summary> |
| | 8 | | /// Tabela de logs de auditoria. |
| | 9 | | /// </summary> |
| | 10 | | public class AuditLog |
| | 11 | | { |
| 7608 | 12 | | public Guid Id { get; set; } |
| 7608 | 13 | | public Guid EntityId { get; set; } |
| 7610 | 14 | | public string EntityType { get; set; } |
| 7610 | 15 | | public string Action { get; set; } |
| 7608 | 16 | | public DateTime CreatedAt { get; set; } |
| 7608 | 17 | | public Guid UserId { get; set; } |
| 7608 | 18 | | public Guid InstitutionId { get; set; } |
| 7607 | 19 | | public JsonDocument Data { get; set; } |
| | 20 | |
|
| | 21 | | public bool Fill(AuditEvent evt, EventEntry entry) |
| | 22 | | { |
| 8581 | 23 | | if (evt.CustomFields.Count == 0 || evt.CustomFields.ContainsKey("Skip")) |
| 974 | 24 | | return false; |
| | 25 | |
|
| 7607 | 26 | | Id = Guid.NewGuid(); |
| 7607 | 27 | | EntityId = Guid.Parse(entry.PrimaryKey.First().Value.ToString()!); |
| 7607 | 28 | | EntityType = entry.EntityType.Name; |
| 7607 | 29 | | Action = entry.Action; |
| 7607 | 30 | | CreatedAt = DateTime.Now; |
| 7607 | 31 | | UserId = Guid.Parse(evt.CustomFields["UserId"].ToString()!); |
| 7607 | 32 | | InstitutionId = Guid.Parse(evt.CustomFields["InstitutionId"].ToString()!); |
| 7607 | 33 | | Data = AuditData.NewAsJson(entry); |
| | 34 | |
|
| 7607 | 35 | | return true; |
| | 36 | | } |
| | 37 | | } |