NTP_V2/src/NTP.Application/Abstractions/IEventLogger.cs

33 lines
1.4 KiB
C#

namespace NTP.Application.Abstractions;
/// <summary>
/// One row of the legacy EVENTS audit table (port of services.cfc addEvent).
/// <c>RefColumn</c> is the id column to fill: PERMITID, CRID, ORDERID, WAYBILLID (any identifier ^[A-Z][A-Z0-9_]{0,29}$).
/// </summary>
public sealed record EventEntry(
string RefColumn,
long RefId,
string? PrevStatus,
string? CurrentStatus,
string? DoneBy,
string EventType,
string? Domain,
string? LocationId,
string UpdatedType = "NTP",
string? Weight = null,
IReadOnlyDictionary<string, object?>? ExtraColumns = null);
public interface IEventLogger
{
/// <summary>
/// Inserts into EVENTS using SEQ_EVENTS.nextval and bind variables. Participates in the active
/// unit-of-work transaction. DONEBY is upper-cased (legacy). Extra column names are validated as plain Oracle
/// identifiers and must not collide with the fixed columns; they must exist on EVENTS (e.g. REMARKS).
/// </summary>
Task AddAsync(EventEntry entry, CancellationToken ct = default);
/// <summary>Same, taking DoneBy/Domain/LocationId from <see cref="ICurrentUser"/> (legacy session.userid/domain/locationid).</summary>
Task AddForCurrentUserAsync(string refColumn, long refId, string? prevStatus, string? currentStatus,
string eventType, string? remarks = null, string? weight = null, CancellationToken ct = default);
}