Auto-migrate SonicContainer schema on startup, rename legacy typo columns, and use fallback SQL when the column is not yet present. Co-authored-by: Cursor <cursoragent@cursor.com>
96 lines
2.6 KiB
C#
96 lines
2.6 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using ZA.CoreService.ESBCertificateManager.Configuration;
|
|
using ZA.CoreService.ESBCertificateManager.Models;
|
|
using ZA.CoreService.ESBCertificateManager.Services;
|
|
using ZA.CoreService.ESBCertificateManager.Setup;
|
|
|
|
namespace ZA.CoreService.ESBCertificateManager;
|
|
|
|
internal static class Program
|
|
{
|
|
[STAThread]
|
|
private static void Main()
|
|
{
|
|
ApplicationConfiguration.Initialize();
|
|
|
|
try
|
|
{
|
|
AppSettings settings =
|
|
AppSettingsLoader.Load();
|
|
|
|
SonicSetupRepository repository =
|
|
new(
|
|
settings.Database.ConnectionString);
|
|
|
|
SetupCoordinator coordinator =
|
|
new(
|
|
settings,
|
|
repository);
|
|
|
|
SetupCheckResult setupResult =
|
|
coordinator
|
|
.CheckAsync()
|
|
.GetAwaiter()
|
|
.GetResult();
|
|
|
|
if (!setupResult.IsReady)
|
|
{
|
|
using SetupWizardForm setupForm =
|
|
new(
|
|
coordinator,
|
|
isSettingsMode: false);
|
|
|
|
DialogResult setupDialogResult =
|
|
setupForm.ShowDialog();
|
|
|
|
if (setupDialogResult != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
|
|
SetupCheckResult finalCheck =
|
|
coordinator
|
|
.CheckAsync()
|
|
.GetAwaiter()
|
|
.GetResult();
|
|
|
|
if (!finalCheck.IsReady)
|
|
{
|
|
MessageBox.Show(
|
|
"Einrichtung unvollständig.",
|
|
"Einstellungen",
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Warning);
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
try
|
|
{
|
|
DatabaseSchemaPatcher
|
|
.EnsureCertificateCheckUrlColumnAsync(
|
|
settings.Database.ConnectionString)
|
|
.GetAwaiter()
|
|
.GetResult();
|
|
}
|
|
catch
|
|
{
|
|
// Ohne ALTER-Rechte weiter starten; Repositories nutzen Fallback-SQL.
|
|
}
|
|
|
|
Application.Run(
|
|
new Form1());
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
MessageBox.Show(
|
|
"Start fehlgeschlagen.",
|
|
"Fehler",
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
}
|