Improve Sonic Java discovery beyond SonicHome\jre layouts.
Parse setenv scripts, search recursively under Sonic/MQ/ESB roots, and surface resolved SonicHome + java paths in the UI and full error lists. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1781,11 +1781,6 @@ namespace ZA.CoreService.ESBCertificateManager
|
|||||||
cmbSonicConnection.Items.Add(conn.Name);
|
cmbSonicConnection.Items.Add(conn.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmbSonicConnection.Items.Count > 0)
|
|
||||||
{
|
|
||||||
cmbSonicConnection.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
btnLoadFromSonic = CreateSecondaryButton("Container laden");
|
btnLoadFromSonic = CreateSecondaryButton("Container laden");
|
||||||
btnLoadFromSonic.Location = new Point(392, 103);
|
btnLoadFromSonic.Location = new Point(392, 103);
|
||||||
btnLoadFromSonic.Size = new Size(148, 28);
|
btnLoadFromSonic.Size = new Size(148, 28);
|
||||||
@@ -1797,20 +1792,19 @@ namespace ZA.CoreService.ESBCertificateManager
|
|||||||
ForeColor = MutedTextColor,
|
ForeColor = MutedTextColor,
|
||||||
Font = new Font("Segoe UI", 8.5f),
|
Font = new Font("Segoe UI", 8.5f),
|
||||||
AutoSize = true,
|
AutoSize = true,
|
||||||
Location = new Point(552, 109)
|
MaximumSize = new Size(720, 0),
|
||||||
|
Location = new Point(552, 100)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!_sonicDiscovery.HasConnections)
|
cmbSonicConnection.SelectedIndexChanged += (_, _) => RefreshSonicStatusLine();
|
||||||
|
|
||||||
|
if (cmbSonicConnection.Items.Count > 0)
|
||||||
{
|
{
|
||||||
lblSonicStatus.Text = "Keine Sonic-Verbindung in appsettings konfiguriert";
|
cmbSonicConnection.SelectedIndex = 0;
|
||||||
lblSonicStatus.ForeColor = RedColor;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SonicConnection first = _sonicDiscovery.Connections[0];
|
RefreshSonicStatusLine();
|
||||||
lblSonicStatus.Text =
|
|
||||||
$"{_sonicDiscovery.Connections.Count} Verb. | {first.ManagementModeDisplay} | {first.DomainName} | {first.ConnectionUrl}";
|
|
||||||
lblSonicStatus.ForeColor = GreenColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
card.Controls.Add(sonicLabel);
|
card.Controls.Add(sonicLabel);
|
||||||
@@ -1819,6 +1813,44 @@ namespace ZA.CoreService.ESBCertificateManager
|
|||||||
card.Controls.Add(lblSonicStatus);
|
card.Controls.Add(lblSonicStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RefreshSonicStatusLine(string? suffix = null)
|
||||||
|
{
|
||||||
|
if (!_sonicDiscovery.HasConnections)
|
||||||
|
{
|
||||||
|
lblSonicStatus.Text = "Keine Sonic-Verbindung in appsettings konfiguriert";
|
||||||
|
lblSonicStatus.ForeColor = RedColor;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? selectedName = cmbSonicConnection?.SelectedItem?.ToString();
|
||||||
|
SonicConnection conn = _sonicDiscovery.Connections
|
||||||
|
.FirstOrDefault(c => string.Equals(c.Name, selectedName, StringComparison.OrdinalIgnoreCase))
|
||||||
|
?? _sonicDiscovery.Connections[0];
|
||||||
|
|
||||||
|
(string sonicHome, string? javaExe) = new SonicMfApiExecutor(conn).ResolveRuntimePaths();
|
||||||
|
string javaDisplay = string.IsNullOrWhiteSpace(javaExe) ? "java=?" : javaExe;
|
||||||
|
string baseText =
|
||||||
|
$"{conn.ManagementModeDisplay} | SonicHome={sonicHome} | {javaDisplay}";
|
||||||
|
if (!string.IsNullOrWhiteSpace(suffix))
|
||||||
|
{
|
||||||
|
baseText = $"{suffix} | {baseText}";
|
||||||
|
}
|
||||||
|
|
||||||
|
lblSonicStatus.Text = baseText;
|
||||||
|
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()
|
private async Task LoadFromSonicAsync()
|
||||||
{
|
{
|
||||||
if (_isOperationRunning) return;
|
if (_isOperationRunning) return;
|
||||||
@@ -1840,7 +1872,7 @@ namespace ZA.CoreService.ESBCertificateManager
|
|||||||
|
|
||||||
if (!result.Success)
|
if (!result.Success)
|
||||||
{
|
{
|
||||||
lblSonicStatus.Text = $"Fehler: {result.ErrorMessage}";
|
RefreshSonicStatusLine($"Fehler: {TruncateStatus(result.ErrorMessage)}");
|
||||||
lblSonicStatus.ForeColor = RedColor;
|
lblSonicStatus.ForeColor = RedColor;
|
||||||
SetStatus($"Sonic-Discovery fehlgeschlagen: {result.ErrorMessage}", isError: true);
|
SetStatus($"Sonic-Discovery fehlgeschlagen: {result.ErrorMessage}", isError: true);
|
||||||
return;
|
return;
|
||||||
@@ -1858,7 +1890,7 @@ namespace ZA.CoreService.ESBCertificateManager
|
|||||||
|
|
||||||
if (total == 0)
|
if (total == 0)
|
||||||
{
|
{
|
||||||
lblSonicStatus.Text = $"Verb. ok – 0 Container in Domain '{domain}'";
|
RefreshSonicStatusLine($"Verb. ok – 0 Container '{domain}'");
|
||||||
lblSonicStatus.ForeColor = GoldColor;
|
lblSonicStatus.ForeColor = GoldColor;
|
||||||
SetStatus(
|
SetStatus(
|
||||||
result.ErrorMessage
|
result.ErrorMessage
|
||||||
@@ -1867,7 +1899,7 @@ namespace ZA.CoreService.ESBCertificateManager
|
|||||||
}
|
}
|
||||||
else if (remote == 0)
|
else if (remote == 0)
|
||||||
{
|
{
|
||||||
lblSonicStatus.Text = $"Verb. ok – Domain '{domain}': 0 remote, {total} aus Config";
|
RefreshSonicStatusLine($"Verb. ok – 0 remote, {total} Config '{domain}'");
|
||||||
lblSonicStatus.ForeColor = GoldColor;
|
lblSonicStatus.ForeColor = GoldColor;
|
||||||
SetStatus(
|
SetStatus(
|
||||||
$"Domain '{domain}': Remote leer – {total} Ziel(e) aus appsettings/KnownContainers. "
|
$"Domain '{domain}': Remote leer – {total} Ziel(e) aus appsettings/KnownContainers. "
|
||||||
@@ -1876,8 +1908,7 @@ namespace ZA.CoreService.ESBCertificateManager
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lblSonicStatus.Text = $"Domain '{domain}': {remote} remote, {total} gesamt";
|
RefreshSonicStatusLine($"Domain '{domain}': {remote} remote, {total} gesamt");
|
||||||
lblSonicStatus.ForeColor = GreenColor;
|
|
||||||
SetStatus($"Sonic Domain '{domain}': {total} Ziel(e) geladen ({remote} remote).", isError: false);
|
SetStatus($"Sonic Domain '{domain}': {total} Ziel(e) geladen ({remote} remote).", isError: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1885,13 +1916,13 @@ namespace ZA.CoreService.ESBCertificateManager
|
|||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
lblSonicStatus.Text = "Timeout – Verbindung nicht erreichbar";
|
RefreshSonicStatusLine("Timeout");
|
||||||
lblSonicStatus.ForeColor = RedColor;
|
lblSonicStatus.ForeColor = RedColor;
|
||||||
SetStatus($"Sonic-Discovery Timeout ({selectedConnection})", isError: true);
|
SetStatus($"Sonic-Discovery Timeout ({selectedConnection})", isError: true);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
lblSonicStatus.Text = $"Fehler: {ex.Message}";
|
RefreshSonicStatusLine($"Fehler: {TruncateStatus(ex.Message)}");
|
||||||
lblSonicStatus.ForeColor = RedColor;
|
lblSonicStatus.ForeColor = RedColor;
|
||||||
SetStatus($"Sonic-Discovery Fehler: {ex.Message}", isError: true);
|
SetStatus($"Sonic-Discovery Fehler: {ex.Message}", isError: true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,12 +127,15 @@ public sealed class SonicConnection
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Sonic-Installationsroot, z.B. "C:\Sonic\MQ10.0" (enthält lib\*.jar für MfApi).</summary>
|
/// <summary>
|
||||||
|
/// Sonic-/MQ-/ESB-Installationsroot, z.B. "C:\Sonic\MQ10.0" (Client-JARs oft unter lib).
|
||||||
|
/// Bei ESB-Home: ggf. MfClientLibPath auf MQ\lib setzen.
|
||||||
|
/// </summary>
|
||||||
public string SonicHome { get; init; } = @"C:\Sonic\MQ10.0";
|
public string SonicHome { get; init; } = @"C:\Sonic\MQ10.0";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Optional: JRE/JDK-Home (z.B. C:\Sonic\MQ10.0\jre) oder Pfad zu java.exe.
|
/// Optional: JRE/JDK-Home (z.B. C:\Sonic\MQ10.0\jre) oder Pfad zu java.exe.
|
||||||
/// Leer = automatische Suche (JAVA_HOME, PATH, SonicHome\jre, Program Files\…).
|
/// Leer = automatische Suche (JAVA_HOME/JRE_HOME, setenv.bat, rekursiv unter SonicHome, Registry, …).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string JavaHome { get; init; } = string.Empty;
|
public string JavaHome { get; init; } = string.Empty;
|
||||||
|
|
||||||
@@ -143,7 +146,7 @@ public sealed class SonicConnection
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Optionaler Pfad zu Sonic-Client-JARs für MfApi (mgmt_client.jar etc.).
|
/// Optionaler Pfad zu Sonic-Client-JARs für MfApi (mgmt_client.jar etc.).
|
||||||
/// Leer = SonicHome\lib.
|
/// Leer = SonicHome\lib, MQ_HOME\lib, ESB_HOME\lib bzw. nested MQ*/lib.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string MfClientLibPath { get; init; } = string.Empty;
|
public string MfClientLibPath { get; init; } = string.Empty;
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -14,8 +14,9 @@
|
|||||||
"Username": "Administrator",
|
"Username": "Administrator",
|
||||||
"Password": "Administrator",
|
"Password": "Administrator",
|
||||||
// Standard: Sonic MF Management API (IAgentProxy.restart) – kein WinRM.
|
// Standard: Sonic MF Management API (IAgentProxy.restart) – kein WinRM.
|
||||||
// Benötigt JRE + Client-JARs unter SonicHome\\lib (oder MfClientLibPath).
|
// Benötigt JRE + Client-JARs unter SonicHome\\lib (oder MfClientLibPath / MQ_HOME).
|
||||||
// Java: oft unter SonicHome\\jre – sonst JavaHome/JavaPath setzen (kein systemweites JAVA_HOME nötig).
|
// Java-Suche: JavaPath/JavaHome, JAVA_HOME/JRE_HOME, setenv.bat, rekursiv unter SonicHome
|
||||||
|
// (nicht nur SonicHome\\jre\\bin\\java.exe), Registry, where.exe. Optional JavaHome/JavaPath setzen.
|
||||||
// Optional-Fallback: "WinRm" / "LocalCmd" (stopcontainer/startcontainer).
|
// Optional-Fallback: "WinRm" / "LocalCmd" (stopcontainer/startcontainer).
|
||||||
"ManagementMode": "MfApi",
|
"ManagementMode": "MfApi",
|
||||||
"SonicHome": "C:\\Sonic\\MQ10.0",
|
"SonicHome": "C:\\Sonic\\MQ10.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user