diff --git a/CHANGELOG.md b/CHANGELOG.md index f56222773f..3c4410727d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - Build on and target .Net 9 rather than 8 +- Simplify DB Patching Interface + ## [8.4.2] - 2024-12-18 - Fix issue with MEF constructing Remote Table Attachers diff --git a/Rdmp.UI/TestsAndSetup/StartupUI.cs b/Rdmp.UI/TestsAndSetup/StartupUI.cs index 03236997e8..a913486201 100644 --- a/Rdmp.UI/TestsAndSetup/StartupUI.cs +++ b/Rdmp.UI/TestsAndSetup/StartupUI.cs @@ -265,8 +265,8 @@ private void HandleDatabaseFoundOnSimpleUI(PlatformDatabaseFoundEventArgs eventA case RDMPPlatformDatabaseStatus.RequiresPatching: - if (MessageBox.Show($"Patching Required on database of type {eventArgs.Patcher.Name}", "Patch", - MessageBoxButtons.YesNo) == DialogResult.Yes) + if (MessageBox.Show($"Patching Required on database of type {eventArgs.Patcher.Name}", "Patch RDMP", + MessageBoxButtons.OKCancel) == DialogResult.OK) { PatchingUI.ShowIfRequired( eventArgs.Repository.DiscoveredServer.GetCurrentDatabase(), @@ -275,8 +275,8 @@ private void HandleDatabaseFoundOnSimpleUI(PlatformDatabaseFoundEventArgs eventA } else { - MessageBox.Show("Patching was cancelled, application will exit"); - Application.Exit(); + MessageBox.Show("Patching was cancelled. Apply Patch to use the latest version of RDMP. Application will exit."); + Environment.Exit(0); } break; diff --git a/Rdmp.UI/Versioning/PatchingUI.cs b/Rdmp.UI/Versioning/PatchingUI.cs index d168e69380..47e9ba8a4c 100644 --- a/Rdmp.UI/Versioning/PatchingUI.cs +++ b/Rdmp.UI/Versioning/PatchingUI.cs @@ -30,7 +30,6 @@ public partial class PatchingUI : Form private readonly DiscoveredDatabase _database; private readonly ITableRepository _repository; - private bool _yesToAll; private IPatcher _patcher; private PatchingUI(DiscoveredDatabase database, ITableRepository repository, IPatcher patcher) @@ -38,9 +37,8 @@ private PatchingUI(DiscoveredDatabase database, ITableRepository repository, IPa _database = database; _repository = repository; _patcher = patcher; - InitializeComponent(); - + this.btnAttemptPatching.Enabled = false; if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) return; @@ -57,6 +55,8 @@ private PatchingUI(DiscoveredDatabase database, ITableRepository repository, IPa { tbDatabase.Text = $"{_database.GetRuntimeName()}, Version:{repository.GetVersion()}"; } + btnAttemptPatching_Click(null, null); + } private void btnAttemptPatching_Click(object sender, EventArgs e) @@ -68,8 +68,8 @@ private void btnAttemptPatching_Click(object sender, EventArgs e) var mds = new MasterDatabaseScriptExecutor(_database); - mds.PatchDatabase(_patcher, toMem, PreviewPatch, - () => MessageBox.Show("Backup Database First", "Backup", MessageBoxButtons.YesNo) == DialogResult.Yes); + mds.PatchDatabase(_patcher, toMem, (Patch p) => true, + () => false); //if it crashed during patching if (toMem.GetWorst() == CheckResult.Fail) @@ -92,7 +92,7 @@ private void btnAttemptPatching_Click(object sender, EventArgs e) checksUI1.OnCheckPerformed(new CheckEventArgs("Patching Successful", CheckResult.Success, null)); - if (MessageBox.Show("Application will now restart", "Close?", MessageBoxButtons.YesNo) == DialogResult.Yes) + if (MessageBox.Show("Application will now restart", "Restart Application", MessageBoxButtons.OK) == DialogResult.OK) ApplicationRestarter.Restart(); } catch (Exception exception) @@ -106,22 +106,4 @@ public static void ShowIfRequired(DiscoveredDatabase database, ITableRepository if (Patch.IsPatchingRequired(database, patcher, out _, out _, out _) == Patch.PatchingState.Required) new PatchingUI(database, repository, patcher).ShowDialog(); } - - - private bool PreviewPatch(Patch patch) - { - if (_yesToAll) - return true; - - var preview = new SQLPreviewWindow(patch.locationInAssembly, "The following SQL Patch will be run:", - patch.GetScriptBody()); - try - { - return preview.ShowDialog() == DialogResult.OK; - } - finally - { - _yesToAll = preview.YesToAll; - } - } } \ No newline at end of file