From 80a132db21ae97caf32c2b8efdc889e89f01cd6f Mon Sep 17 00:00:00 2001 From: Rogee Date: Tue, 22 Sep 2026 17:04:09 +0800 Subject: [PATCH] Load connection authorization for offline collection --- .../WxAgent.Service/RemoteAgentHostedService.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/node-agent/WxAgent.Service/RemoteAgentHostedService.cs b/node-agent/WxAgent.Service/RemoteAgentHostedService.cs index f995bae..9cdbbe8 100644 --- a/node-agent/WxAgent.Service/RemoteAgentHostedService.cs +++ b/node-agent/WxAgent.Service/RemoteAgentHostedService.cs @@ -52,7 +52,19 @@ public sealed class RemoteAgentHostedService( string? registeredActiveAccountId = null; bool? registeredActiveAccountVerified = null; long registeredReportingConfigVersion = -1; - ReportingConfig? activeReporting = ConnectionAuthorizedReporting(options.Reporting, null); + var initialReporting = options.Reporting; + if (!string.IsNullOrWhiteSpace(options.RemoteConfigurationFile)) + { + try + { + initialReporting = (await LoadRuntimeConfigurationAsync(options, stoppingToken)).Reporting; + } + catch (Exception exception) when (exception is IOException or JsonException or WxAgentException) + { + logger.LogWarning("Remote reporting configuration could not be loaded for offline collection; type={ExceptionType}.", exception.GetType().Name); + } + } + ReportingConfig? activeReporting = ConnectionAuthorizedReporting(initialReporting, null); var retry = RetryDelay; while (!stoppingToken.IsCancellationRequested) {