From 33f7b3979d85048716692da9390e4b2005f9734f Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sun, 24 May 2026 03:49:26 -0400 Subject: [PATCH] feat(transport): add IAuditCorrelationContext scoped service --- .../ServiceCollectionExtensions.cs | 2 ++ .../Services/AuditCorrelationContext.cs | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/ScadaLink.ConfigurationDatabase/Services/AuditCorrelationContext.cs diff --git a/src/ScadaLink.ConfigurationDatabase/ServiceCollectionExtensions.cs b/src/ScadaLink.ConfigurationDatabase/ServiceCollectionExtensions.cs index d926f1e..62266ec 100644 --- a/src/ScadaLink.ConfigurationDatabase/ServiceCollectionExtensions.cs +++ b/src/ScadaLink.ConfigurationDatabase/ServiceCollectionExtensions.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using ScadaLink.Commons.Interfaces; using ScadaLink.Commons.Interfaces.Repositories; using ScadaLink.Commons.Interfaces.Services; +using ScadaLink.Commons.Interfaces.Transport; using ScadaLink.ConfigurationDatabase.Maintenance; using ScadaLink.ConfigurationDatabase.Repositories; using ScadaLink.ConfigurationDatabase.Services; @@ -51,6 +52,7 @@ public static class ServiceCollectionExtensions services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/src/ScadaLink.ConfigurationDatabase/Services/AuditCorrelationContext.cs b/src/ScadaLink.ConfigurationDatabase/Services/AuditCorrelationContext.cs new file mode 100644 index 0000000..180cdb3 --- /dev/null +++ b/src/ScadaLink.ConfigurationDatabase/Services/AuditCorrelationContext.cs @@ -0,0 +1,14 @@ +using ScadaLink.Commons.Interfaces.Transport; + +namespace ScadaLink.ConfigurationDatabase.Services; + +/// +/// Per-scope mutable holder for the active bundle import id. AuditService reads it +/// while writing AuditLogEntry rows. Registered as Scoped so each Blazor circuit / +/// request gets its own value; ApplyAsync explicitly creates a service scope and +/// sets the id at the top of the transaction. +/// +public sealed class AuditCorrelationContext : IAuditCorrelationContext +{ + public Guid? BundleImportId { get; set; } +}