Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/RDMP-236 Simplify UII DB Patching Process #2108

Merged
merged 5 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Rdmp.UI/TestsAndSetup/StartupUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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;
Expand Down
30 changes: 6 additions & 24 deletions Rdmp.UI/Versioning/PatchingUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@ 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)
{
_database = database;
_repository = repository;
_patcher = patcher;

InitializeComponent();

this.btnAttemptPatching.Enabled = false;
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
return;

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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;
}
}
}
Loading