feat(deployment): DeployToSiteAsync for single-site artifact deployment
Claude-Session: https://claude.ai/code/session_01MtdgwpEeCUn6cUA5f1LMPj
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Text.Json;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Deployment;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Sites;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Services;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Artifacts;
|
||||
@@ -232,6 +233,38 @@ public class ArtifactDeploymentService
|
||||
if (sites.Count == 0)
|
||||
return Result<ArtifactDeploymentSummary>.Failure("No sites configured.");
|
||||
|
||||
return await DeployCoreAsync(sites, user, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deploys system-wide artifacts to a single site (management-API --site-id path).
|
||||
/// </summary>
|
||||
/// <param name="siteId">The database identifier of the target site.</param>
|
||||
/// <param name="user">The user initiating the deployment.</param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
/// <returns>A summary of the artifact deployment result for the single site.</returns>
|
||||
public async Task<Result<ArtifactDeploymentSummary>> DeployToSiteAsync(
|
||||
int siteId,
|
||||
string user,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var site = await _siteRepo.GetSiteByIdAsync(siteId, cancellationToken);
|
||||
if (site is null)
|
||||
return Result<ArtifactDeploymentSummary>.Failure($"Site with ID {siteId} not found.");
|
||||
|
||||
return await DeployCoreAsync([site], user, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Core deployment path shared by the all-sites and single-site entry points.
|
||||
/// Builds a per-site command with that site's data connections and deploys to
|
||||
/// every supplied site under one logical deployment id.
|
||||
/// </summary>
|
||||
private async Task<Result<ArtifactDeploymentSummary>> DeployCoreAsync(
|
||||
IReadOnlyList<Site> sites,
|
||||
string user,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var deploymentId = Guid.NewGuid().ToString("N");
|
||||
var perSiteResults = new Dictionary<string, SiteArtifactResult>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user