Slim MfApi stack to restart-only path.
Drop ping/list discovery, WinRM scripts, and heavy Java probing so only KnownContainers + MBean restart remain. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -40,7 +40,6 @@ namespace ZA.CoreService.ESBCertificateManager
|
||||
private TextBox txtCertificatePath = null!;
|
||||
private DataGridView dgvTargets = null!;
|
||||
private ComboBox cmbSonicConnection = null!;
|
||||
private Button btnLoadFromSonic = null!;
|
||||
private Label lblSonicStatus = null!;
|
||||
|
||||
private Panel navProgressPanel = null!;
|
||||
@@ -1302,14 +1301,12 @@ namespace ZA.CoreService.ESBCertificateManager
|
||||
if (_loadedTargets.Count == 0)
|
||||
{
|
||||
SetStatus(
|
||||
"Keine KnownContainers in appsettings. SonicConnections[].KnownContainers setzen oder „Container laden“.",
|
||||
"Keine KnownContainers in appsettings. SonicConnections[].KnownContainers setzen.",
|
||||
isError: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetStatus(
|
||||
$"{_loadedTargets.Count} Container aus appsettings. Optional: „Container laden“ für Live-Liste.",
|
||||
isError: false);
|
||||
SetStatus($"{_loadedTargets.Count} Container aus appsettings.", isError: false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1408,10 +1405,6 @@ namespace ZA.CoreService.ESBCertificateManager
|
||||
dgvTargets.Enabled = idle;
|
||||
}
|
||||
|
||||
if (btnLoadFromSonic is not null)
|
||||
{
|
||||
btnLoadFromSonic.Enabled = idle && _sonicDiscovery.HasConnections;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetStatus(string message, bool isError)
|
||||
@@ -1555,24 +1548,16 @@ namespace ZA.CoreService.ESBCertificateManager
|
||||
SetTargetRowStatus(targetResult.TargetId, targetResult.StatusText);
|
||||
}
|
||||
|
||||
string details = string.Join(
|
||||
Environment.NewLine + Environment.NewLine,
|
||||
runResult.TargetResults.Select(r =>
|
||||
$"{r.TargetName}: {r.StatusText}" +
|
||||
(string.IsNullOrWhiteSpace(r.Detail) ? string.Empty : Environment.NewLine + r.Detail)));
|
||||
|
||||
SetStatus(
|
||||
runResult.OverallSuccess
|
||||
? $"Neustart verifiziert ({runResult.TargetResults.Count} Ziel(e))."
|
||||
: "Neustart fehlgeschlagen oder nicht verifiziert.",
|
||||
isError: !runResult.OverallSuccess);
|
||||
|
||||
MessageBox.Show(
|
||||
this,
|
||||
details,
|
||||
runResult.OverallSuccess ? "Neustart verifiziert" : "Neustart fehlgeschlagen",
|
||||
MessageBoxButtons.OK,
|
||||
runResult.OverallSuccess ? MessageBoxIcon.Information : MessageBoxIcon.Warning);
|
||||
if (runResult.OverallSuccess)
|
||||
{
|
||||
UpdateToNextStep(4);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
@@ -1693,7 +1678,7 @@ namespace ZA.CoreService.ESBCertificateManager
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Sonic Management Console – Container-Discovery
|
||||
// Sonic – Status (KnownContainers aus appsettings)
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
private void BuildSonicDiscoveryRow(Panel card)
|
||||
@@ -1723,19 +1708,13 @@ namespace ZA.CoreService.ESBCertificateManager
|
||||
cmbSonicConnection.Items.Add(conn.Name);
|
||||
}
|
||||
|
||||
btnLoadFromSonic = CreateSecondaryButton("Container laden");
|
||||
btnLoadFromSonic.Location = new Point(392, 103);
|
||||
btnLoadFromSonic.Size = new Size(148, 28);
|
||||
btnLoadFromSonic.Enabled = _sonicDiscovery.HasConnections;
|
||||
btnLoadFromSonic.Click += async (_, _) => await LoadFromSonicAsync();
|
||||
|
||||
lblSonicStatus = new Label
|
||||
{
|
||||
ForeColor = MutedTextColor,
|
||||
Font = new Font("Segoe UI", 8.5f),
|
||||
AutoSize = true,
|
||||
MaximumSize = new Size(720, 0),
|
||||
Location = new Point(552, 100)
|
||||
Location = new Point(392, 108)
|
||||
};
|
||||
|
||||
cmbSonicConnection.SelectedIndexChanged += (_, _) => RefreshSonicStatusLine();
|
||||
@@ -1751,11 +1730,10 @@ namespace ZA.CoreService.ESBCertificateManager
|
||||
|
||||
card.Controls.Add(sonicLabel);
|
||||
card.Controls.Add(cmbSonicConnection);
|
||||
card.Controls.Add(btnLoadFromSonic);
|
||||
card.Controls.Add(lblSonicStatus);
|
||||
}
|
||||
|
||||
private void RefreshSonicStatusLine(string? suffix = null)
|
||||
private void RefreshSonicStatusLine()
|
||||
{
|
||||
if (!_sonicDiscovery.HasConnections)
|
||||
{
|
||||
@@ -1769,134 +1747,13 @@ namespace ZA.CoreService.ESBCertificateManager
|
||||
.FirstOrDefault(c => string.Equals(c.Name, selectedName, StringComparison.OrdinalIgnoreCase))
|
||||
?? _sonicDiscovery.Connections[0];
|
||||
|
||||
string sonicHome = string.IsNullOrWhiteSpace(conn.SonicHome) ? "(leer)" : conn.SonicHome.Trim();
|
||||
(string home, string? javaExe) = new SonicMfApiExecutor(conn).ResolveRuntimePaths();
|
||||
string javaDisplay = string.IsNullOrWhiteSpace(javaExe)
|
||||
? "java=? (unter SonicHome/JRE setzen)"
|
||||
? "java=? (JavaPath in appsettings setzen)"
|
||||
: $"java={javaExe}";
|
||||
string baseText =
|
||||
$"{conn.ManagementModeDisplay} | SonicHome={home} | {javaDisplay}";
|
||||
if (!string.IsNullOrWhiteSpace(suffix))
|
||||
{
|
||||
baseText = $"{suffix} | {baseText}";
|
||||
}
|
||||
|
||||
lblSonicStatus.Text = baseText;
|
||||
lblSonicStatus.Text = $"{conn.ManagementModeDisplay} | SonicHome={home} | {javaDisplay}";
|
||||
lblSonicStatus.ForeColor = string.IsNullOrWhiteSpace(javaExe) ? GoldColor : GreenColor;
|
||||
}
|
||||
|
||||
private static string TruncateStatus(string? text, int max = 120)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
return "unbekannt";
|
||||
}
|
||||
|
||||
string oneLine = text.Replace('\r', ' ').Replace('\n', ' ').Trim();
|
||||
return oneLine.Length <= max ? oneLine : oneLine[..max] + "…";
|
||||
}
|
||||
|
||||
private async Task LoadFromSonicAsync()
|
||||
{
|
||||
if (_isOperationRunning) return;
|
||||
|
||||
string? selectedConnection = cmbSonicConnection?.SelectedItem?.ToString();
|
||||
if (string.IsNullOrWhiteSpace(selectedConnection)) return;
|
||||
|
||||
btnLoadFromSonic.Enabled = false;
|
||||
lblSonicStatus.Text = $"Verbinde mit {selectedConnection}…";
|
||||
lblSonicStatus.ForeColor = GoldColor;
|
||||
|
||||
try
|
||||
{
|
||||
using CancellationTokenSource cts = new(TimeSpan.FromSeconds(30));
|
||||
SonicDiscoveryResult result = await _sonicDiscovery.DiscoverAsync(
|
||||
selectedConnection,
|
||||
_loadedTargets,
|
||||
cts.Token);
|
||||
|
||||
if (!result.Success)
|
||||
{
|
||||
RefreshSonicStatusLine($"Fehler: {TruncateStatus(result.ErrorMessage)}");
|
||||
lblSonicStatus.ForeColor = RedColor;
|
||||
SetStatus($"Sonic-Discovery fehlgeschlagen: {result.ErrorMessage}", isError: true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Grid mit entdeckten + konfigurierten Containern befüllen
|
||||
_loadedTargets = result.DiscoveredTargets;
|
||||
BindTargetsToGrid(result.DiscoveredTargets);
|
||||
|
||||
int total = result.DiscoveredTargets.Count;
|
||||
int remote = result.RawContainerNames.Count;
|
||||
string domain = string.IsNullOrWhiteSpace(result.DomainName)
|
||||
? selectedConnection
|
||||
: result.DomainName;
|
||||
|
||||
if (total == 0)
|
||||
{
|
||||
RefreshSonicStatusLine($"Verb. ok – 0 Container '{domain}'");
|
||||
lblSonicStatus.ForeColor = GoldColor;
|
||||
SetStatus(
|
||||
result.ErrorMessage
|
||||
?? $"Sonic Domain '{domain}': keine Container. KnownContainers/SonicHome in appsettings prüfen.",
|
||||
isError: true);
|
||||
}
|
||||
else if (remote == 0)
|
||||
{
|
||||
RefreshSonicStatusLine($"Verb. ok – 0 remote, {total} Config '{domain}'");
|
||||
lblSonicStatus.ForeColor = GoldColor;
|
||||
SetStatus(
|
||||
$"Domain '{domain}': Remote leer – {total} Ziel(e) aus appsettings/KnownContainers. "
|
||||
+ (result.ErrorMessage ?? string.Empty),
|
||||
isError: false);
|
||||
}
|
||||
else
|
||||
{
|
||||
RefreshSonicStatusLine($"Domain '{domain}': {remote} remote, {total} gesamt");
|
||||
SetStatus($"Sonic Domain '{domain}': {total} Ziel(e) geladen ({remote} remote).", isError: false);
|
||||
}
|
||||
|
||||
MarkUnconfiguredRows();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
RefreshSonicStatusLine("Timeout");
|
||||
lblSonicStatus.ForeColor = RedColor;
|
||||
SetStatus($"Sonic-Discovery Timeout ({selectedConnection})", isError: true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RefreshSonicStatusLine($"Fehler: {TruncateStatus(ex.Message)}");
|
||||
lblSonicStatus.ForeColor = RedColor;
|
||||
SetStatus($"Sonic-Discovery Fehler: {ex.Message}", isError: true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
btnLoadFromSonic.Enabled = _sonicDiscovery.HasConnections && !_isOperationRunning;
|
||||
RefreshActionButtonStates();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Färbt Zeilen mit unvollständiger Konfiguration (kein TargetDirectory) orange ein
|
||||
/// damit erkennbar ist, dass diese Container noch konfiguriert werden müssen.
|
||||
/// </summary>
|
||||
private void MarkUnconfiguredRows()
|
||||
{
|
||||
foreach (DataGridViewRow row in dgvTargets.Rows)
|
||||
{
|
||||
if (row.Tag is not DeploymentTarget target) continue;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(target.TargetDirectory))
|
||||
{
|
||||
row.DefaultCellStyle.ForeColor = GoldColor;
|
||||
if (row.Cells["Status"] is DataGridViewCell statusCell)
|
||||
{
|
||||
statusCell.Value = "⚠ Pfad fehlt";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user