feat(sitecallaudit): query, KPI and detail backend for the Site Calls page
This commit is contained in:
@@ -2,6 +2,7 @@ using Akka.Actor;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ScadaLink.Commons.Messages.Artifacts;
|
||||
using ScadaLink.Commons.Messages.Audit;
|
||||
using ScadaLink.Commons.Messages.DebugView;
|
||||
using ScadaLink.Commons.Messages.Deployment;
|
||||
using ScadaLink.Commons.Messages.Health;
|
||||
@@ -25,6 +26,7 @@ public class CommunicationService
|
||||
private readonly ILogger<CommunicationService> _logger;
|
||||
private IActorRef? _centralCommunicationActor;
|
||||
private IActorRef? _notificationOutboxProxy;
|
||||
private IActorRef? _siteCallAuditProxy;
|
||||
|
||||
public CommunicationService(
|
||||
IOptions<CommunicationOptions> options,
|
||||
@@ -52,6 +54,17 @@ public class CommunicationService
|
||||
_notificationOutboxProxy = notificationOutboxProxy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the Site Call Audit (#22) singleton proxy reference. Called during
|
||||
/// actor system startup. The Site Call Audit actor is central-local, so Site
|
||||
/// Calls read calls Ask this proxy directly (no SiteEnvelope routing), the
|
||||
/// same pattern as <see cref="SetNotificationOutbox"/>.
|
||||
/// </summary>
|
||||
public void SetSiteCallAudit(IActorRef siteCallAuditProxy)
|
||||
{
|
||||
_siteCallAuditProxy = siteCallAuditProxy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggers an immediate refresh of the site address cache from the database.
|
||||
/// </summary>
|
||||
@@ -80,6 +93,15 @@ public class CommunicationService
|
||||
?? throw new InvalidOperationException("CommunicationService not initialized. NotificationOutbox proxy not set.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Site Call Audit proxy reference. Throws if not yet initialized.
|
||||
/// </summary>
|
||||
private IActorRef GetSiteCallAudit()
|
||||
{
|
||||
return _siteCallAuditProxy
|
||||
?? throw new InvalidOperationException("CommunicationService not initialized. SiteCallAudit proxy not set.");
|
||||
}
|
||||
|
||||
// ── Pattern 1: Instance Deployment ──
|
||||
|
||||
public async Task<DeploymentStatusResponse> DeployInstanceAsync(
|
||||
@@ -295,6 +317,36 @@ public class CommunicationService
|
||||
return await GetNotificationOutbox().Ask<PerSiteNotificationKpiResponse>(
|
||||
request, _options.QueryTimeout, cancellationToken);
|
||||
}
|
||||
|
||||
// ── Site Call Audit (central-local actor — Asked directly, no SiteEnvelope) ──
|
||||
|
||||
public async Task<SiteCallQueryResponse> QuerySiteCallsAsync(
|
||||
SiteCallQueryRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetSiteCallAudit().Ask<SiteCallQueryResponse>(
|
||||
request, _options.QueryTimeout, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<SiteCallDetailResponse> GetSiteCallDetailAsync(
|
||||
SiteCallDetailRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetSiteCallAudit().Ask<SiteCallDetailResponse>(
|
||||
request, _options.QueryTimeout, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<SiteCallKpiResponse> GetSiteCallKpisAsync(
|
||||
SiteCallKpiRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetSiteCallAudit().Ask<SiteCallKpiResponse>(
|
||||
request, _options.QueryTimeout, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<PerSiteSiteCallKpiResponse> GetPerSiteSiteCallKpisAsync(
|
||||
PerSiteSiteCallKpiRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetSiteCallAudit().Ask<PerSiteSiteCallKpiResponse>(
|
||||
request, _options.QueryTimeout, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user