/// <summary> /// Add a RequestId so the audit events can be grouped per request /// </summary> public static void UseAuditCorrelationId(this IApplicationBuilder app, IHttpContextAccessor ctxAccesor) { Configuration.AddCustomAction(ActionType.OnScopeCreated, scope => { HttpContext httpContext = ctxAccesor.HttpContext; scope.Event.CustomFields[CorrelationIdField] = httpContext.TraceIdentifier; }); }
public static IServiceCollection AddPersistenceLayer(this IServiceCollection services, string databaseConnection) { services .AddDbContext <AIDungeonPromptsDbContext>(options => options.UseNpgsql(databaseConnection, builder => { // See: https://docs.microsoft.com/en-us/ef/core/querying/single-split-queries builder.UseQuerySplittingBehavior(QuerySplittingBehavior.SingleQuery); })) .AddScoped <IAIDungeonPromptsDbContext>(provider => provider.GetService <AIDungeonPromptsDbContext>() !); Configuration.AddCustomAction(ActionType.OnScopeCreated, scope => { scope.SetCustomField(AuditScopeId, Guid.NewGuid()); }); _ = Configuration.Setup() .UseEntityFramework(ef => ef .AuditTypeExplicitMapper(m => m .Map <Prompt, AuditPrompt>((prompt, auditEntity) => { auditEntity.PromptId = prompt.Id; }) .Map <PromptTag, AuditPrompt>((tag, auditEntity) => { auditEntity.PromptId = tag.PromptId; }) .Map <WorldInfo, AuditPrompt>((wi, auditEntity) => { auditEntity.PromptId = wi.PromptId; }) .AuditEntityAction <AuditPrompt>((evt, entry, auditEntity) => { auditEntity.DateCreated = DateTime.UtcNow; auditEntity.Entry = entry.ToJson(); auditEntity.AuditScopeId = (Guid)evt.CustomFields[AuditScopeId]; }) ).IgnoreMatchedProperties() ); return(services); }
public void OnEventSaved(Action <AuditScope> action) { Configuration.AddCustomAction(ActionType.OnEventSaved, action); }
public void OnScopeCreated(Func <AuditScope, Task> action) { //TODO: FDCG: Pending test Configuration.AddCustomAction(ActionType.OnScopeCreated, action); }
public void OnScopeCreated(Action <AuditScope> action) { Configuration.AddCustomAction(ActionType.OnScopeCreated, action); }
public void OnEventSaving(Func <AuditScope, Task> action) { //TODO: FDCG: Pending test Configuration.AddCustomAction(ActionType.OnEventSaving, action); }
public void OnEventSaving(Func <AuditScope, Task> action) { Configuration.AddCustomAction(ActionType.OnEventSaving, action); }