diff --git a/XenAdmin/Actions/GUIActions/ExternalPluginAction.cs b/XenAdmin/Actions/GUIActions/ExternalPluginAction.cs index 71dd2ed51..56df34c21 100644 --- a/XenAdmin/Actions/GUIActions/ExternalPluginAction.cs +++ b/XenAdmin/Actions/GUIActions/ExternalPluginAction.cs @@ -228,14 +228,15 @@ namespace XenAdmin.Actions { Program.Invoke(Program.MainWindow, delegate { - ThreeButtonDialog d = new ThreeButtonDialog( + using (var d = new ThreeButtonDialog( new ThreeButtonDialog.Details(System.Drawing.SystemIcons.Warning, string.Format(Messages.FORCE_CLOSE_PLUGIN_PROMPT, _menuItemFeature.ToString())), "ProcessForceClosePrompt", new ThreeButtonDialog.TBDButton(Messages.FORCE_CLOSE, DialogResult.Yes), - new ThreeButtonDialog.TBDButton(Messages.ALLOW_TO_CONTINUE, DialogResult.No)); - - if (d.ShowDialog(Program.MainWindow) == DialogResult.Yes && !_extAppProcess.HasExited) - _extAppProcess.Kill(); + new ThreeButtonDialog.TBDButton(Messages.ALLOW_TO_CONTINUE, DialogResult.No))) + { + if (d.ShowDialog(Program.MainWindow) == DialogResult.Yes && !_extAppProcess.HasExited) + _extAppProcess.Kill(); + } }); } diff --git a/XenAdmin/Actions/GUIActions/Wlb/WlbOptimizePoolAction.cs b/XenAdmin/Actions/GUIActions/Wlb/WlbOptimizePoolAction.cs index 7d74c538f..88d7eac27 100644 --- a/XenAdmin/Actions/GUIActions/Wlb/WlbOptimizePoolAction.cs +++ b/XenAdmin/Actions/GUIActions/Wlb/WlbOptimizePoolAction.cs @@ -254,11 +254,14 @@ namespace XenAdmin.Actions.Wlb // Tell the user the VM will be started without HA protection. Program.Invoke(Program.MainWindow, delegate() { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( - SystemIcons.Warning, - String.Format(Messages.HA_INVALID_CONFIG_RESUME, Helpers.GetName(vm).Ellipsise(500)), - Messages.HIGH_AVAILABILITY)).ShowDialog(Program.MainWindow); + SystemIcons.Warning, + String.Format(Messages.HA_INVALID_CONFIG_RESUME, Helpers.GetName(vm).Ellipsise(500)), + Messages.HIGH_AVAILABILITY))) + { + dlg.ShowDialog(Program.MainWindow); + } }); // Set the VM to 'Do not restart'. @@ -334,11 +337,14 @@ namespace XenAdmin.Actions.Wlb Helpers.GetName(vm).Ellipsise(100)); Program.Invoke(Program.MainWindow, delegate() { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, msg, - Messages.HIGH_AVAILABILITY)).ShowDialog(Program.MainWindow); + Messages.HIGH_AVAILABILITY))) + { + dlg.ShowDialog(Program.MainWindow); + } }); } else @@ -350,17 +356,19 @@ namespace XenAdmin.Actions.Wlb Program.Invoke(Program.MainWindow, delegate() { - DialogResult r = new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, msg, Messages.HIGH_AVAILABILITY), ThreeButtonDialog.ButtonYes, - new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(Program.MainWindow); - - if (r != DialogResult.Yes) + new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) { - error = true; + DialogResult r = dlg.ShowDialog(Program.MainWindow); + if (r != DialogResult.Yes) + { + error = true; + } } }); } diff --git a/XenAdmin/Commands/ActivationRequestCommand.cs b/XenAdmin/Commands/ActivationRequestCommand.cs index ba3764276..e900e9bee 100644 --- a/XenAdmin/Commands/ActivationRequestCommand.cs +++ b/XenAdmin/Commands/ActivationRequestCommand.cs @@ -96,11 +96,16 @@ namespace XenAdmin.Commands return (DialogResult)Program.Invoke(Program.MainWindow, (DialogInvoker)delegate() { - return new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Error, string.Format(Messages.ACTIVATION_FAILED_MESSAGE, InvisibleMessages.ACTIVATION_SERVER)), "ActivationServerUnavailable", new ThreeButtonDialog.TBDButton(Messages.ACTIVATION_SAVE, DialogResult.Yes), - ThreeButtonDialog.ButtonCancel).ShowDialog(Program.MainWindow); + ThreeButtonDialog.ButtonCancel)) + { + dialogResult = dlg.ShowDialog(Program.MainWindow); + } + return dialogResult; }); } diff --git a/XenAdmin/Commands/AddHostToPoolCommand.cs b/XenAdmin/Commands/AddHostToPoolCommand.cs index f559ec70f..a052b4dcd 100644 --- a/XenAdmin/Commands/AddHostToPoolCommand.cs +++ b/XenAdmin/Commands/AddHostToPoolCommand.cs @@ -100,8 +100,11 @@ namespace XenAdmin.Commands : string.Format(Messages.ADD_HOST_TO_POOL_DISCONNECTED_POOL_MULTIPLE, Helpers.GetName(_pool).Ellipsise(500)); - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Error, message, Messages.XENCENTER)).ShowDialog(Parent); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Error, message, Messages.XENCENTER))) + { + dlg.ShowDialog(Parent); + } return; } @@ -121,9 +124,9 @@ namespace XenAdmin.Commands Helpers.FeatureForbidden(host, Host.RestrictCpuMasking) && !PoolJoinRules.FreeHostPaidMaster(host, master, false))) // in this case we can upgrade the license and then mask the CPU { - UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPUMASKING : Messages.UPSELL_BLURB_CPUMASKING + Messages.UPSELL_BLURB_CPUMASKING_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_CPUMASKING); - dlg.ShowDialog(Parent); + using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPUMASKING : Messages.UPSELL_BLURB_CPUMASKING + Messages.UPSELL_BLURB_CPUMASKING_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_CPUMASKING)) + dlg.ShowDialog(Parent); return; } @@ -221,13 +224,15 @@ namespace XenAdmin.Commands string poolName = Helpers.GetName(pool).Ellipsise(500); string hostName = Helpers.GetName(host).Ellipsise(500); string msg = string.Format(Messages.HA_HOST_ENABLE_NTOL_RAISE_QUERY, poolName, hostName, currentNtol, max); - if (new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(null, msg, Messages.HIGH_AVAILABILITY), ThreeButtonDialog.ButtonYes, - new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(Program.MainWindow) - == DialogResult.Yes) + new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) { - doit = true; + if (dlg.ShowDialog(Program.MainWindow) == DialogResult.Yes) + { + doit = true; + } } }); return doit; @@ -279,13 +284,16 @@ namespace XenAdmin.Commands msg = string.Format(f, poolName, currentNtol, hostName, targetNtol); } - if (new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.HIGH_AVAILABILITY), ThreeButtonDialog.ButtonYes, new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true) - ).ShowDialog(Program.MainWindow) == DialogResult.No) + )) { - cancel = true; + if (dlg.ShowDialog(Program.MainWindow) == DialogResult.No) + { + cancel = true; + } } }); diff --git a/XenAdmin/Commands/AddNewHostToPoolCommand.cs b/XenAdmin/Commands/AddNewHostToPoolCommand.cs index 2d5d2ffc4..0bfea13ab 100644 --- a/XenAdmin/Commands/AddNewHostToPoolCommand.cs +++ b/XenAdmin/Commands/AddNewHostToPoolCommand.cs @@ -106,7 +106,10 @@ namespace XenAdmin.Commands string text = String.Format(Messages.HOST_ALREADY_IN_POOL, hostToAdd.Name, _pool.Name, hostPool.Name); string caption = Messages.POOL_JOIN_IMPOSSIBLE; - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Exclamation, text, caption)).ShowDialog(Program.MainWindow); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Exclamation, text, caption))) + { + dlg.ShowDialog(Program.MainWindow); + } } else { diff --git a/XenAdmin/Commands/AddVirtualDiskCommand.cs b/XenAdmin/Commands/AddVirtualDiskCommand.cs index 55d3f9c76..17fcc2588 100644 --- a/XenAdmin/Commands/AddVirtualDiskCommand.cs +++ b/XenAdmin/Commands/AddVirtualDiskCommand.cs @@ -80,11 +80,14 @@ namespace XenAdmin.Commands } else { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( - SystemIcons.Error, - FriendlyErrorNames.VBDS_MAX_ALLOWED, - Messages.DISK_ADD)).ShowDialog(Program.MainWindow); + SystemIcons.Error, + FriendlyErrorNames.VBDS_MAX_ALLOWED, + Messages.DISK_ADD))) + { + dlg.ShowDialog(Program.MainWindow); + } } } else diff --git a/XenAdmin/Commands/ApplyLicenseEditionCommand.cs b/XenAdmin/Commands/ApplyLicenseEditionCommand.cs index fb9943388..4d343e632 100644 --- a/XenAdmin/Commands/ApplyLicenseEditionCommand.cs +++ b/XenAdmin/Commands/ApplyLicenseEditionCommand.cs @@ -72,30 +72,33 @@ namespace XenAdmin.Commands protected override void ExecuteCore(SelectedItemCollection selection) { ApplyLicenseEditionAction action = new ApplyLicenseEditionAction(xos, _edition, _licenseServerAddress, _licenseServerPort, null); - ActionProgressDialog actionProgress = new ActionProgressDialog(action, ProgressBarStyle.Marquee); - - // close dialog even when there's an error as this action shows its own error dialog box. - action.Completed += s => - { - Program.Invoke(Program.MainWindow, () => - { - Failure f = action.Exception as Failure; - if (f != null && f.ErrorDescription[0] == Failure.RBAC_PERMISSION_DENIED_FRIENDLY) - return; - actionProgress.Close(); - }); - - if (action.Exception != null) - { - ShowLicensingFailureDialog(action.LicenseFailures, action.Exception.Message, Parent); - } - }; - - actionProgress.ShowDialog(Parent); - - if (actionProgress.action.Succeeded) + using (var actionProgress = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) { - InvokeSuccedded(null); + //ActionProgressDialog closureDialog = actionProgress; + // close dialog even when there's an error as this action shows its own error dialog box. + action.Completed += s => + { + Program.Invoke(Program.MainWindow, () => + { + Failure f = action.Exception as Failure; + if (f != null && f.ErrorDescription[0] == Failure.RBAC_PERMISSION_DENIED_FRIENDLY) + return; + + actionProgress.Close(); + }); + + if (action.Exception != null) + { + ShowLicensingFailureDialog(action.LicenseFailures, action.Exception.Message, Parent); + } + }; + + actionProgress.ShowDialog(Parent); + + if (actionProgress.action.Succeeded) + { + InvokeSuccedded(null); + } } } @@ -111,10 +114,15 @@ namespace XenAdmin.Commands if (licenseFailures.Count == 1) { - Program.Invoke(Program.MainWindow, () => new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Error, licenseFailures[0].AlertText, - Messages.LICENSE_ERROR_TITLE), - ThreeButtonDialog.ButtonOK).ShowDialog(parent)); + Program.Invoke(Program.MainWindow, () => + { + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, licenseFailures[0].AlertText, + Messages.LICENSE_ERROR_TITLE), + ThreeButtonDialog.ButtonOK)) + { + dlg.ShowDialog(parent); + } + }); } else { @@ -125,9 +133,13 @@ namespace XenAdmin.Commands failureDic.Add(new SelectedItem(f.Host), f.AlertText); } - Program.Invoke(Program.MainWindow, () => new CommandErrorDialog( - Messages.LICENSE_ERROR_TITLE, exceptionMessage, - failureDic).ShowDialog(parent)); + Program.Invoke(Program.MainWindow, () => + { + using (var dlg = new CommandErrorDialog(Messages.LICENSE_ERROR_TITLE, exceptionMessage, failureDic)) + { + dlg.ShowDialog(parent); + } + }); } } } diff --git a/XenAdmin/Commands/AttachVirtualDiskCommand.cs b/XenAdmin/Commands/AttachVirtualDiskCommand.cs index 8e57b4953..c5acc045a 100644 --- a/XenAdmin/Commands/AttachVirtualDiskCommand.cs +++ b/XenAdmin/Commands/AttachVirtualDiskCommand.cs @@ -69,11 +69,14 @@ namespace XenAdmin.Commands if (vm.VBDs.Count >= vm.MaxVBDsAllowed) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, FriendlyErrorNames.VBDS_MAX_ALLOWED, - Messages.DISK_ATTACH)).ShowDialog(Program.MainWindow); + Messages.DISK_ATTACH))) + { + dlg.ShowDialog(Program.MainWindow); + } } else { diff --git a/XenAdmin/Commands/BaseVIFCommand.cs b/XenAdmin/Commands/BaseVIFCommand.cs index fd0c57d14..2d799b9fc 100644 --- a/XenAdmin/Commands/BaseVIFCommand.cs +++ b/XenAdmin/Commands/BaseVIFCommand.cs @@ -51,11 +51,16 @@ namespace XenAdmin.Commands var action = (AsyncAction)sender; if (action.Result == false.ToString()) MainWindowCommandInterface.Invoke(() => - new ThreeButtonDialog( + { + using (var dlg =new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Information, Messages.VIF_HOTPLUG_FAILED_MESSAGE, - Messages.VIF_HOTPLUG_FAILED_TITLE)).ShowDialog(Program.MainWindow)); + Messages.VIF_HOTPLUG_FAILED_TITLE))) + { + dlg.ShowDialog(Program.MainWindow); + } + }); } } } diff --git a/XenAdmin/Commands/Controls/AssignVMGroupToolStripMenuItem.cs b/XenAdmin/Commands/Controls/AssignVMGroupToolStripMenuItem.cs index eff2b4564..7ccdbe661 100644 --- a/XenAdmin/Commands/Controls/AssignVMGroupToolStripMenuItem.cs +++ b/XenAdmin/Commands/Controls/AssignVMGroupToolStripMenuItem.cs @@ -187,11 +187,15 @@ namespace XenAdmin.Commands text = string.Format(VMGroup.ChangeMultipleWarningString, groupName.Ellipsise(250)); } - return new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, text, VMGroup.ChangeVMsGroupString), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo). - ShowDialog() == DialogResult.Yes; + ThreeButtonDialog.ButtonNo)) + { + dialogResult = dlg.ShowDialog(); + } + return dialogResult == DialogResult.Yes; } protected override void ExecuteCore(SelectedItemCollection selection) diff --git a/XenAdmin/Commands/CrossConnectionCommand.cs b/XenAdmin/Commands/CrossConnectionCommand.cs index 0b3c91552..0e30a9a82 100644 --- a/XenAdmin/Commands/CrossConnectionCommand.cs +++ b/XenAdmin/Commands/CrossConnectionCommand.cs @@ -65,11 +65,14 @@ namespace XenAdmin.Commands if (failedConnections.Count > 0) { if (!Program.RunInAutomatedTestMode) - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, MessageBoxMessage(failedConnections), - Messages.PERMISSION_DENIED)).ShowDialog(Program.MainWindow); + Messages.PERMISSION_DENIED))) + { + dlg.ShowDialog(Program.MainWindow); + } return false; // returning false stops the command from proceeding } diff --git a/XenAdmin/Commands/CrossPoolMigrateCommand.cs b/XenAdmin/Commands/CrossPoolMigrateCommand.cs index 692a78b0a..2a3d0b0f7 100644 --- a/XenAdmin/Commands/CrossPoolMigrateCommand.cs +++ b/XenAdmin/Commands/CrossPoolMigrateCommand.cs @@ -93,9 +93,9 @@ namespace XenAdmin.Commands public static void ShowUpsellDialog(IWin32Window parent) { - UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPM : Messages.UPSELL_BLURB_CPM + Messages.UPSELL_BLURB_CPM_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_CPM); - dlg.ShowDialog(parent); + using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPM : Messages.UPSELL_BLURB_CPM + Messages.UPSELL_BLURB_CPM_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_CPM)) + dlg.ShowDialog(parent); } protected override bool CanExecute(VM vm) diff --git a/XenAdmin/Commands/DRConfigureCommand.cs b/XenAdmin/Commands/DRConfigureCommand.cs index 466b31de8..00bc3ebe3 100644 --- a/XenAdmin/Commands/DRConfigureCommand.cs +++ b/XenAdmin/Commands/DRConfigureCommand.cs @@ -118,9 +118,9 @@ namespace XenAdmin.Commands private static void ShowUpsellDialog(IWin32Window parent) { // Show upsell dialog - UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_DR); - dlg.ShowDialog(parent); + using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_DR)) + dlg.ShowDialog(parent); } protected override bool CanExecuteCore(SelectedItemCollection selection) diff --git a/XenAdmin/Commands/DRDryrunCommand.cs b/XenAdmin/Commands/DRDryrunCommand.cs index ef48b9317..06d32b154 100644 --- a/XenAdmin/Commands/DRDryrunCommand.cs +++ b/XenAdmin/Commands/DRDryrunCommand.cs @@ -94,9 +94,9 @@ namespace XenAdmin.Commands public static void ShowUpsellDialog(IWin32Window parent) { // Show upsell dialog - UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_DR); - dlg.ShowDialog(parent); + using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_DR)) + dlg.ShowDialog(parent); } protected override bool CanExecuteCore(SelectedItemCollection selection) diff --git a/XenAdmin/Commands/DRFailbackCommand.cs b/XenAdmin/Commands/DRFailbackCommand.cs index 8717289a8..56566afdb 100644 --- a/XenAdmin/Commands/DRFailbackCommand.cs +++ b/XenAdmin/Commands/DRFailbackCommand.cs @@ -97,9 +97,9 @@ namespace XenAdmin.Commands public static void ShowUpsellDialog(IWin32Window parent) { // Show upsell dialog - UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_DR); - dlg.ShowDialog(parent); + using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_DR)) + dlg.ShowDialog(parent); } protected override bool CanExecuteCore(SelectedItemCollection selection) diff --git a/XenAdmin/Commands/DRFailoverCommand.cs b/XenAdmin/Commands/DRFailoverCommand.cs index 601e83833..29296b1fe 100644 --- a/XenAdmin/Commands/DRFailoverCommand.cs +++ b/XenAdmin/Commands/DRFailoverCommand.cs @@ -94,9 +94,9 @@ namespace XenAdmin.Commands public static void ShowUpsellDialog(IWin32Window parent) { // Show upsell dialog - UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_DR); - dlg.ShowDialog(parent); + using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_DR)) + dlg.ShowDialog(parent); } protected override bool CanExecuteCore(SelectedItemCollection selection) diff --git a/XenAdmin/Commands/DeletePoolCommand.cs b/XenAdmin/Commands/DeletePoolCommand.cs index 4f6b219b1..90f373fc2 100644 --- a/XenAdmin/Commands/DeletePoolCommand.cs +++ b/XenAdmin/Commands/DeletePoolCommand.cs @@ -70,7 +70,10 @@ namespace XenAdmin.Commands if (conn.Cache.HostCount > 1) { - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Exclamation, Messages.MESSAGEBOX_SLAVES_EJECT, Messages.XENCENTER)).ShowDialog(Program.MainWindow); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Exclamation, Messages.MESSAGEBOX_SLAVES_EJECT, Messages.XENCENTER))) + { + dlg.ShowDialog(Program.MainWindow); + } return; } diff --git a/XenAdmin/Commands/DestroyBondCommand.cs b/XenAdmin/Commands/DestroyBondCommand.cs index df6537e24..79cc68a8b 100644 --- a/XenAdmin/Commands/DestroyBondCommand.cs +++ b/XenAdmin/Commands/DestroyBondCommand.cs @@ -92,41 +92,55 @@ namespace XenAdmin.Commands Pool pool = Helpers.GetPool(network.Connection); if (pool != null && pool.ha_enabled) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.BOND_DELETE_HA_ENABLED, pif.Name, pool.Name), - Messages.DELETE_BOND)).ShowDialog(Parent); + Messages.DELETE_BOND))) + { + dlg.ShowDialog(Parent); + } return; } string message = string.Format(will_disturb_secondary ? Messages.BOND_DELETE_WILL_DISTURB_BOTH : Messages.BOND_DELETE_WILL_DISTURB_PRIMARY, msg); - if (DialogResult.OK != - new ThreeButtonDialog( + + DialogResult result; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, message, Messages.DELETE_BOND), "NetworkingConfigWarning", new ThreeButtonDialog.TBDButton(Messages.BOND_DELETE_CONTINUE, DialogResult.OK), - ThreeButtonDialog.ButtonCancel).ShowDialog(Parent)) + ThreeButtonDialog.ButtonCancel)) { - return; + result = dlg.ShowDialog(Parent); } + if (DialogResult.OK != result) + return; } else if (will_disturb_secondary) { - if (DialogResult.OK != - new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.BOND_DELETE_WILL_DISTURB_SECONDARY, msg), Messages.XENCENTER), ThreeButtonDialog.ButtonOK, - ThreeButtonDialog.ButtonCancel).ShowDialog(Parent)) + ThreeButtonDialog.ButtonCancel)) + { + dialogResult = dlg.ShowDialog(Parent); + } + if (DialogResult.OK != dialogResult) return; } else { - if (DialogResult.OK != - new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.XENCENTER), new ThreeButtonDialog.TBDButton(Messages.OK, DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true), - ThreeButtonDialog.ButtonCancel).ShowDialog(Program.MainWindow)) + ThreeButtonDialog.ButtonCancel)) + { + dialogResult = dlg.ShowDialog(Parent); + } + if (DialogResult.OK != dialogResult) return; } diff --git a/XenAdmin/Commands/DisasterRecoveryCommand.cs b/XenAdmin/Commands/DisasterRecoveryCommand.cs index 0846ee022..02e720871 100644 --- a/XenAdmin/Commands/DisasterRecoveryCommand.cs +++ b/XenAdmin/Commands/DisasterRecoveryCommand.cs @@ -91,9 +91,9 @@ namespace XenAdmin.Commands public static void ShowUpsellDialog(IWin32Window parent) { // Show upsell dialog - UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_DR); - dlg.ShowDialog(parent); + using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_DR)) + dlg.ShowDialog(parent); } protected override bool CanExecuteCore(SelectedItemCollection selection) diff --git a/XenAdmin/Commands/DisconnectCommand.cs b/XenAdmin/Commands/DisconnectCommand.cs index 16d3b5e3f..03f8ae28d 100644 --- a/XenAdmin/Commands/DisconnectCommand.cs +++ b/XenAdmin/Commands/DisconnectCommand.cs @@ -129,8 +129,10 @@ namespace XenAdmin.Commands } }); - ActionProgressDialog pd = new ActionProgressDialog(waitForCancelAction, ProgressBarStyle.Marquee); - pd.ShowDialog(Parent); + using (var pd = new ActionProgressDialog(waitForCancelAction, ProgressBarStyle.Marquee)) + { + pd.ShowDialog(Parent); + } } else { diff --git a/XenAdmin/Commands/DisconnectWlbServerCommand.cs b/XenAdmin/Commands/DisconnectWlbServerCommand.cs index da57ca4cf..df725348f 100644 --- a/XenAdmin/Commands/DisconnectWlbServerCommand.cs +++ b/XenAdmin/Commands/DisconnectWlbServerCommand.cs @@ -63,9 +63,9 @@ namespace XenAdmin.Commands if (Helpers.FeatureForbidden(selection[0].XenObject, Host.RestrictWLB)) { // Show upsell dialog - UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_WLB : Messages.UPSELL_BLURB_WLB + Messages.UPSELL_BLURB_WLB_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_WLB); - dlg.ShowDialog(Parent); + using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_WLB : Messages.UPSELL_BLURB_WLB + Messages.UPSELL_BLURB_WLB_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_WLB)) + dlg.ShowDialog(Parent); return; } diff --git a/XenAdmin/Commands/DragDropCrossPoolMoveHaltedVMCommand.cs b/XenAdmin/Commands/DragDropCrossPoolMoveHaltedVMCommand.cs index 19b0cd979..3b6823536 100644 --- a/XenAdmin/Commands/DragDropCrossPoolMoveHaltedVMCommand.cs +++ b/XenAdmin/Commands/DragDropCrossPoolMoveHaltedVMCommand.cs @@ -163,10 +163,12 @@ namespace XenAdmin.Commands SR sr = cd.Connection.Resolve(vdi.SR); if (sr != null && !sr.shared) { - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Exclamation, + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Exclamation, Messages.DRAG_DROP_LOCAL_CD_LOADED, - Messages.DRAG_DROP_LOCAL_CD_LOADED_TITLE)) - .ShowDialog(MainWindowCommandInterface.Form); + Messages.DRAG_DROP_LOCAL_CD_LOADED_TITLE))) + { + dlg.ShowDialog(MainWindowCommandInterface.Form); + } return; } } diff --git a/XenAdmin/Commands/DragDropMigrateVMCommand.cs b/XenAdmin/Commands/DragDropMigrateVMCommand.cs index 3fde7c27d..e824bb44d 100644 --- a/XenAdmin/Commands/DragDropMigrateVMCommand.cs +++ b/XenAdmin/Commands/DragDropMigrateVMCommand.cs @@ -216,10 +216,12 @@ namespace XenAdmin.Commands SR sr = cd.Connection.Resolve(vdi.SR); if (sr != null && !sr.shared) { - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Exclamation, + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Exclamation, Messages.DRAG_DROP_LOCAL_CD_LOADED, - Messages.DRAG_DROP_LOCAL_CD_LOADED_TITLE)) - .ShowDialog(MainWindowCommandInterface.Form); + Messages.DRAG_DROP_LOCAL_CD_LOADED_TITLE))) + { + dlg.ShowDialog(MainWindowCommandInterface.Form); + } return; } } diff --git a/XenAdmin/Commands/ExportVMCommand.cs b/XenAdmin/Commands/ExportVMCommand.cs index 64c1c412f..16f811bb8 100644 --- a/XenAdmin/Commands/ExportVMCommand.cs +++ b/XenAdmin/Commands/ExportVMCommand.cs @@ -134,12 +134,16 @@ namespace XenAdmin.Commands string msg = string.Format(Messages.CONFIRM_EXPORT_NOT_ENOUGH_MEMORY, Util.DiskSizeString((long)neededSpace), Util.DiskSizeString((long)freeSpace), vm.Name); - DialogResult dr = new ThreeButtonDialog( + DialogResult dr; + using (var d = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, msg), "ExportVmDialogInsufficientDiskSpace", new ThreeButtonDialog.TBDButton(Messages.CONTINUE_WITH_EXPORT, DialogResult.OK), new ThreeButtonDialog.TBDButton(Messages.CHOOSE_ANOTHER_DESTINATION, DialogResult.Retry), - ThreeButtonDialog.ButtonCancel).ShowDialog(Parent); + ThreeButtonDialog.ButtonCancel)) + { + dr = d.ShowDialog(Parent); + } if (dr == DialogResult.Retry) { @@ -155,12 +159,16 @@ namespace XenAdmin.Commands string msg = string.Format(Messages.CONFIRM_EXPORT_FAT, Util.DiskSizeString((long)neededSpace), Util.DiskSizeString(4 * Util.BINARY_GIGA), vm.Name); - DialogResult dr = new ThreeButtonDialog( + DialogResult dr; + using (var d = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, msg), "ExportVmDialogFSLimitExceeded", new ThreeButtonDialog.TBDButton(Messages.CONTINUE_WITH_EXPORT, DialogResult.OK), new ThreeButtonDialog.TBDButton(Messages.CHOOSE_ANOTHER_DESTINATION, DialogResult.Retry), - ThreeButtonDialog.ButtonCancel).ShowDialog(Parent); + ThreeButtonDialog.ButtonCancel)) + { + dr = d.ShowDialog(Parent); + } if (dr == DialogResult.Retry) { diff --git a/XenAdmin/Commands/HACommand.cs b/XenAdmin/Commands/HACommand.cs index 473d9354f..bca7d3e53 100644 --- a/XenAdmin/Commands/HACommand.cs +++ b/XenAdmin/Commands/HACommand.cs @@ -82,9 +82,9 @@ namespace XenAdmin.Commands if (Helpers.FeatureForbidden(pool, Host.RestrictHA)) { // Show upsell dialog - UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_HA : Messages.UPSELL_BLURB_HA + Messages.UPSELL_BLURB_HA_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_HA); - dlg.ShowDialog(Parent); + using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_HA : Messages.UPSELL_BLURB_HA + Messages.UPSELL_BLURB_HA_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_HA)) + dlg.ShowDialog(Parent); } else if (pool.ha_enabled) { diff --git a/XenAdmin/Commands/HostMaintenanceModeCommand.cs b/XenAdmin/Commands/HostMaintenanceModeCommand.cs index af486763c..e056f8ca8 100644 --- a/XenAdmin/Commands/HostMaintenanceModeCommand.cs +++ b/XenAdmin/Commands/HostMaintenanceModeCommand.cs @@ -79,12 +79,15 @@ namespace XenAdmin.Commands if (pool != null && pool.ha_enabled && host.IsMaster()) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( - SystemIcons.Error, - String.Format(Messages.HA_CANNOT_EVACUATE_MASTER, - Helpers.GetName(host).Ellipsise(Helpers.DEFAULT_NAME_TRIM_LENGTH)), - Messages.XENCENTER)).ShowDialog(Parent); + SystemIcons.Error, + String.Format(Messages.HA_CANNOT_EVACUATE_MASTER, + Helpers.GetName(host).Ellipsise(Helpers.DEFAULT_NAME_TRIM_LENGTH)), + Messages.XENCENTER))) + { + dlg.ShowDialog(Parent); + } } else { diff --git a/XenAdmin/Commands/ImportSearchCommand.cs b/XenAdmin/Commands/ImportSearchCommand.cs index 8b96cba63..c8e83ba31 100644 --- a/XenAdmin/Commands/ImportSearchCommand.cs +++ b/XenAdmin/Commands/ImportSearchCommand.cs @@ -116,11 +116,14 @@ namespace XenAdmin.Commands { log.ErrorFormat("Failed to import search from '{0}'", filename); - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, String.Format(Messages.UNABLE_TO_IMPORT_SEARCH, filename, Branding.Search), - Messages.XENCENTER)).ShowDialog(Parent); + Messages.XENCENTER))) + { + dlg.ShowDialog(Parent); + } } } } diff --git a/XenAdmin/Commands/InstallToolsCommand.cs b/XenAdmin/Commands/InstallToolsCommand.cs index 32ead573a..d6c6ddd5a 100644 --- a/XenAdmin/Commands/InstallToolsCommand.cs +++ b/XenAdmin/Commands/InstallToolsCommand.cs @@ -119,16 +119,24 @@ namespace XenAdmin.Commands { if (vm.FindVMCDROM() == null) { - if (new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( null, Messages.NEW_DVD_DRIVE_REQUIRED, Messages.XENCENTER), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(Parent) == DialogResult.Yes) + ThreeButtonDialog.ButtonNo)) + { + dialogResult = dlg.ShowDialog(Parent); + } + if (dialogResult == DialogResult.Yes) { CreateCdDriveAction createDriveAction = new CreateCdDriveAction(vm, true,NewDiskDialog.ShowMustRebootBoxCD,NewDiskDialog.ShowVBDWarningBox); - new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee).ShowDialog(Parent); + using (var dlg = new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee)) + { + dlg.ShowDialog(Parent); + } if (createDriveAction.Succeeded) { @@ -156,8 +164,11 @@ namespace XenAdmin.Commands { Program.Invoke(Program.MainWindow, delegate { - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Error, Messages.XS_TOOLS_SR_NOT_FOUND, Messages.XENCENTER)).ShowDialog(Program.MainWindow); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Error, Messages.XS_TOOLS_SR_NOT_FOUND, Messages.XENCENTER))) + { + dlg.ShowDialog(Program.MainWindow); + } }); } @@ -180,16 +191,24 @@ namespace XenAdmin.Commands if (newDvdDrivesRequired) { - if (new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.NEW_DVD_DRIVES_REQUIRED, Messages.XENCENTER), + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.NEW_DVD_DRIVES_REQUIRED, Messages.XENCENTER), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(Parent) == DialogResult.Yes) + ThreeButtonDialog.ButtonNo)) + { + dialogResult = dlg.ShowDialog(Parent); + } + if (dialogResult == DialogResult.Yes) { foreach (VM vm in vms) { if (CanExecute(vm) && vm.FindVMCDROM() == null) { CreateCdDriveAction createDriveAction = new CreateCdDriveAction(vm, true,NewDiskDialog.ShowMustRebootBoxCD,NewDiskDialog.ShowVBDWarningBox); - new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee).ShowDialog(Parent); + using (var dlg = new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee)) + { + dlg.ShowDialog(Parent); + } } } ShowMustRebootBox(); @@ -255,11 +274,14 @@ namespace XenAdmin.Commands { if (!MainWindowCommandInterface.RunInAutomatedTestMode) { - new ThreeButtonDialog( - new ThreeButtonDialog.Details( - SystemIcons.Information, - Messages.NEW_DVD_DRIVE_REBOOT_TOOLS, - Messages.NEW_DVD_DRIVE_CREATED)).ShowDialog(Parent); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details( + SystemIcons.Information, + Messages.NEW_DVD_DRIVE_REBOOT_TOOLS, + Messages.NEW_DVD_DRIVE_CREATED))) + { + dlg.ShowDialog(Parent); + } } } diff --git a/XenAdmin/Commands/MigrateVirtualDiskCommand.cs b/XenAdmin/Commands/MigrateVirtualDiskCommand.cs index 2904b0c6a..59948dcd8 100644 --- a/XenAdmin/Commands/MigrateVirtualDiskCommand.cs +++ b/XenAdmin/Commands/MigrateVirtualDiskCommand.cs @@ -85,9 +85,9 @@ namespace XenAdmin.Commands public static void ShowUpsellDialog(IWin32Window parent) { - UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.MIGRATE_VDI_UPSELL_BLURB : Messages.MIGRATE_VDI_UPSELL_BLURB + Messages.MIGRATE_VDI_UPSELL_BLURB_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_CPM); - dlg.ShowDialog(parent); + using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.MIGRATE_VDI_UPSELL_BLURB : Messages.MIGRATE_VDI_UPSELL_BLURB + Messages.MIGRATE_VDI_UPSELL_BLURB_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_CPM)) + dlg.ShowDialog(parent); } protected override bool CanExecuteCore(SelectedItemCollection selection) diff --git a/XenAdmin/Commands/RemoveHostFromPoolCommand.cs b/XenAdmin/Commands/RemoveHostFromPoolCommand.cs index 31959c0d3..e64eaf5c0 100644 --- a/XenAdmin/Commands/RemoveHostFromPoolCommand.cs +++ b/XenAdmin/Commands/RemoveHostFromPoolCommand.cs @@ -85,11 +85,14 @@ namespace XenAdmin.Commands if (selection.Count == 1 && pool.master == host.opaque_ref) { // Trying to remove the master from a pool. - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, Messages.MESSAGEBOX_POOL_MASTER_REMOVE, - Messages.XENCENTER)).ShowDialog(MainWindowCommandInterface.Form); + Messages.XENCENTER))) + { + dlg.ShowDialog(MainWindowCommandInterface.Form); + } return; } @@ -175,11 +178,14 @@ namespace XenAdmin.Commands { MainWindowCommandInterface.Invoke(delegate { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Exclamation, string.Format(Messages.MESSAGEBOX_RECONNECT_FAIL, connection.Hostname), - Messages.MESSAGEBOX_RECONNECT_FAIL_TITLE)).ShowDialog(Parent); + Messages.MESSAGEBOX_RECONNECT_FAIL_TITLE))) + { + dlg.ShowDialog(Parent); + } }); return; } diff --git a/XenAdmin/Commands/RepairSRCommand.cs b/XenAdmin/Commands/RepairSRCommand.cs index 197b9a758..8bf9b8713 100644 --- a/XenAdmin/Commands/RepairSRCommand.cs +++ b/XenAdmin/Commands/RepairSRCommand.cs @@ -77,11 +77,14 @@ namespace XenAdmin.Commands if (srList.Find(s => !s.MultipathAOK) != null) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, Messages.MULTIPATH_FAILED, - Messages.MULTIPATHING)).ShowDialog(Parent); + Messages.MULTIPATHING))) + { + dlg.ShowDialog(Parent); + } } new RepairSRDialog(srList).Show(Parent); diff --git a/XenAdmin/Commands/RestoreHostFromBackupCommand.cs b/XenAdmin/Commands/RestoreHostFromBackupCommand.cs index dc908c177..efbe9f79f 100644 --- a/XenAdmin/Commands/RestoreHostFromBackupCommand.cs +++ b/XenAdmin/Commands/RestoreHostFromBackupCommand.cs @@ -153,11 +153,14 @@ namespace XenAdmin.Commands MainWindowCommandInterface.Invoke(delegate { - new ThreeButtonDialog( - new ThreeButtonDialog.Details( - SystemIcons.Information, - string.Format(Messages.RESTORE_FROM_BACKUP_FINALIZE, Helpers.GetName(action.Host)), - Messages.XENCENTER)).ShowDialog(Parent); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details( + SystemIcons.Information, + string.Format(Messages.RESTORE_FROM_BACKUP_FINALIZE, Helpers.GetName(action.Host)), + Messages.XENCENTER))) + { + dlg.ShowDialog(Parent); + } }); } } diff --git a/XenAdmin/Commands/StartVMCommand.cs b/XenAdmin/Commands/StartVMCommand.cs index f17a2f5aa..01e5600dd 100644 --- a/XenAdmin/Commands/StartVMCommand.cs +++ b/XenAdmin/Commands/StartVMCommand.cs @@ -101,11 +101,15 @@ namespace XenAdmin.Commands } if (brokenCDs.Count > 0) { - DialogResult d = new ThreeButtonDialog( + DialogResult d; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(null, Messages.EJECT_BEFORE_VM_START_MESSAGE_BOX, vms.Count > 1 ? Messages.STARTING_VMS_MESSAGEBOX_TITLE : Messages.STARTING_VM_MESSAGEBOX_TITLE), new ThreeButtonDialog.TBDButton(Messages.EJECT_BUTTON_LABEL, DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true), new ThreeButtonDialog.TBDButton(Messages.IGNORE_BUTTON_LABEL, DialogResult.Ignore), - ThreeButtonDialog.ButtonCancel).ShowDialog(MainWindowCommandInterface.Form); + ThreeButtonDialog.ButtonCancel)) + { + d = dlg.ShowDialog(MainWindowCommandInterface.Form); + } if (d == DialogResult.Cancel) return; if (d == DialogResult.Ignore) diff --git a/XenAdmin/Commands/TakeSnapshotCommand.cs b/XenAdmin/Commands/TakeSnapshotCommand.cs index e5568afc2..1fb61e9a3 100644 --- a/XenAdmin/Commands/TakeSnapshotCommand.cs +++ b/XenAdmin/Commands/TakeSnapshotCommand.cs @@ -99,10 +99,12 @@ namespace XenAdmin.Commands } else { - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.TAKE_SNAPSHOT_ERROR, Messages.XENCENTER)) - .ShowDialog(MainWindowCommandInterface.Form); - + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.TAKE_SNAPSHOT_ERROR, + Messages.XENCENTER))) + { + dlg.ShowDialog(MainWindowCommandInterface.Form); + } } } return null; diff --git a/XenAdmin/Commands/VMGroupCommand.cs b/XenAdmin/Commands/VMGroupCommand.cs index 630adf56e..f0eae9d8d 100644 --- a/XenAdmin/Commands/VMGroupCommand.cs +++ b/XenAdmin/Commands/VMGroupCommand.cs @@ -84,8 +84,8 @@ namespace XenAdmin.Commands public static void ShowUpsellDialog(IWin32Window parent) { - UpsellDialog dlg = new UpsellDialog(VMGroup.UpsellBlurb, VMGroup.UpsellLearnMoreUrl); - dlg.ShowDialog(parent); + using (var dlg = new UpsellDialog(VMGroup.UpsellBlurb, VMGroup.UpsellLearnMoreUrl)) + dlg.ShowDialog(parent); } protected override bool CanExecuteCore(SelectedItemCollection selection) diff --git a/XenAdmin/Commands/VMOperationCommand.cs b/XenAdmin/Commands/VMOperationCommand.cs index c03a30b50..03c76c42b 100644 --- a/XenAdmin/Commands/VMOperationCommand.cs +++ b/XenAdmin/Commands/VMOperationCommand.cs @@ -203,20 +203,18 @@ namespace XenAdmin.Commands { Program.Invoke(Program.MainWindow, () => { - if ( - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Warning, - String.Format( - isStart - ? Messages. - HA_INVALID_CONFIG_START - : Messages. - HA_INVALID_CONFIG_RESUME, - Helpers.GetName(vm).Ellipsise(500)), - Messages.HIGH_AVAILABILITY), - ThreeButtonDialog.ButtonOK, - ThreeButtonDialog.ButtonCancel).ShowDialog( - Program.MainWindow) == DialogResult.Cancel) + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, + String.Format(isStart ? Messages.HA_INVALID_CONFIG_START : Messages.HA_INVALID_CONFIG_RESUME, + Helpers.GetName(vm).Ellipsise(500)), + Messages.HIGH_AVAILABILITY), + ThreeButtonDialog.ButtonOK, + ThreeButtonDialog.ButtonCancel)) + { + dialogResult = dlg.ShowDialog(Program.MainWindow); + } + if (dialogResult == DialogResult.Cancel) { throw new CancelledException(); } @@ -304,7 +302,10 @@ namespace XenAdmin.Commands Helpers.GetName(VMStartAction.VM).Ellipsise(100)); Program.Invoke(Program.MainWindow, delegate() { - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.HIGH_AVAILABILITY)).ShowDialog(Program.MainWindow); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.HIGH_AVAILABILITY))) + { + dlg.ShowDialog(Program.MainWindow); + } }); } else @@ -316,10 +317,14 @@ namespace XenAdmin.Commands Program.Invoke(Program.MainWindow, delegate() { - DialogResult r = new ThreeButtonDialog( + DialogResult r; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.HIGH_AVAILABILITY), ThreeButtonDialog.ButtonYes, - new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(Program.MainWindow); + new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) + { + r = dlg.ShowDialog(Program.MainWindow); + } if (r == DialogResult.Yes) { diff --git a/XenAdmin/Commands/VMOperationHostCommand.cs b/XenAdmin/Commands/VMOperationHostCommand.cs index e2ccc5149..c342f5f92 100644 --- a/XenAdmin/Commands/VMOperationHostCommand.cs +++ b/XenAdmin/Commands/VMOperationHostCommand.cs @@ -185,8 +185,15 @@ namespace XenAdmin.Commands public static bool VmCpuFeaturesIncompatibleWithHost(Host targetHost, VM vm) { - // check the CPU feature compatibility for Dundee and higher hosts - if (!Helpers.DundeeOrGreater(targetHost) || !Helpers.DundeeOrGreater(vm.Connection)) + // check the CPU feature compatibility for Dundee and higher hosts + if (!Helpers.DundeeOrGreater(targetHost)) + return false; + + Host home = vm.Home(); + if (home != null && !Helpers.DundeeOrGreater(home)) + return false; + + if (home == null && !Helpers.DundeeOrGreater(vm.Connection)) return false; // only for running or suspended VMs diff --git a/XenAdmin/Commands/ViewWorkloadReportsCommand.cs b/XenAdmin/Commands/ViewWorkloadReportsCommand.cs index f796afe8c..cbec855c6 100644 --- a/XenAdmin/Commands/ViewWorkloadReportsCommand.cs +++ b/XenAdmin/Commands/ViewWorkloadReportsCommand.cs @@ -84,9 +84,9 @@ namespace XenAdmin.Commands if (Helpers.FeatureForbidden(selection[0].XenObject, Host.RestrictWLB)) { // Show upsell dialog - UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_WLB : Messages.UPSELL_BLURB_WLB + Messages.UPSELL_BLURB_WLB_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_WLB); - dlg.ShowDialog(Parent); + using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_WLB : Messages.UPSELL_BLURB_WLB + Messages.UPSELL_BLURB_WLB_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_WLB)) + dlg.ShowDialog(Parent); return; } diff --git a/XenAdmin/ConsoleView/VNCTabView.cs b/XenAdmin/ConsoleView/VNCTabView.cs index 0bf37afa3..95c04bd97 100644 --- a/XenAdmin/ConsoleView/VNCTabView.cs +++ b/XenAdmin/ConsoleView/VNCTabView.cs @@ -1200,12 +1200,16 @@ namespace XenAdmin.ConsoleView if (CanEnableRDPOnCreamOrGreater(source.Connection)) { - ThreeButtonDialog d = new ThreeButtonDialog( + DialogResult dialogResult; + using (ThreeButtonDialog dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(System.Drawing.SystemIcons.Question, Messages.FORCE_ENABLE_RDP), - "EnableRDPonVM", + "EnableRDPonVM", new ThreeButtonDialog.TBDButton(Messages.YES, DialogResult.Yes), - new ThreeButtonDialog.TBDButton(Messages.NO, DialogResult.No)); - if (d.ShowDialog(Program.MainWindow) == DialogResult.Yes) + new ThreeButtonDialog.TBDButton(Messages.NO, DialogResult.No))) + { + dialogResult = dlg.ShowDialog(Program.MainWindow); + } + if (dialogResult == DialogResult.Yes) { Session session = source.Connection.DuplicateSession(); Dictionary _arguments = new Dictionary(); @@ -1544,7 +1548,10 @@ namespace XenAdmin.ConsoleView { log.Error("Error starting PuTTY.", ex); - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.ERROR_PUTTY_LAUNCHING, Messages.XENCENTER)).ShowDialog(Parent); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.ERROR_PUTTY_LAUNCHING, Messages.XENCENTER))) + { + dlg.ShowDialog(Parent); + } } } } diff --git a/XenAdmin/Controls/BondDetails.cs b/XenAdmin/Controls/BondDetails.cs index 0256d1263..144515442 100644 --- a/XenAdmin/Controls/BondDetails.cs +++ b/XenAdmin/Controls/BondDetails.cs @@ -239,11 +239,14 @@ namespace XenAdmin.Controls if (will_disturb_primary && will_disturb_secondary) { - new ThreeButtonDialog( - new ThreeButtonDialog.Details( - SystemIcons.Error, - Messages.BOND_CREATE_WILL_DISTURB_BOTH, - Messages.BOND_CREATE)).ShowDialog(this); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details( + SystemIcons.Error, + Messages.BOND_CREATE_WILL_DISTURB_BOTH, + Messages.BOND_CREATE))) + { + dlg.ShowDialog(this); + } return DialogResult.Cancel; } @@ -253,31 +256,44 @@ namespace XenAdmin.Controls Pool pool = Helpers.GetPool(Connection); if (pool != null && pool.ha_enabled) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.BOND_CREATE_HA_ENABLED, pool.Name), - Messages.BOND_CREATE)).ShowDialog(this); + Messages.BOND_CREATE))) + { + dlg.ShowDialog(this); + } return DialogResult.Cancel; } - return new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.BOND_CREATE_WILL_DISTURB_PRIMARY, Messages.BOND_CREATE), "BondConfigError", new ThreeButtonDialog.TBDButton(Messages.BOND_CREATE_CONTINUE, DialogResult.OK), - ThreeButtonDialog.ButtonCancel).ShowDialog(this); + ThreeButtonDialog.ButtonCancel)) + { + dialogResult = dlg.ShowDialog(this); + } + return dialogResult; } if (will_disturb_secondary) { - return new ThreeButtonDialog( - new ThreeButtonDialog.Details( - SystemIcons.Warning, - Messages.BOND_CREATE_WILL_DISTURB_SECONDARY, - Messages.BOND_CREATE), - ThreeButtonDialog.ButtonOK, - ThreeButtonDialog.ButtonCancel).ShowDialog(this); + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details( + SystemIcons.Warning, + Messages.BOND_CREATE_WILL_DISTURB_SECONDARY, + Messages.BOND_CREATE), + ThreeButtonDialog.ButtonOK, + ThreeButtonDialog.ButtonCancel)) + { + dialogResult = dlg.ShowDialog(this); + } + return dialogResult; } return DialogResult.OK; diff --git a/XenAdmin/Controls/DeprecationBanner.cs b/XenAdmin/Controls/DeprecationBanner.cs index e8e3b2847..4431db1e6 100644 --- a/XenAdmin/Controls/DeprecationBanner.cs +++ b/XenAdmin/Controls/DeprecationBanner.cs @@ -74,12 +74,15 @@ namespace XenAdmin.Controls } catch (Exception) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.COULD_NOT_OPEN_URL, LinkUri.AbsoluteUri), - Messages.XENCENTER)).ShowDialog(Program.MainWindow); + Messages.XENCENTER))) + { + dlg.ShowDialog(Program.MainWindow); + } } } diff --git a/XenAdmin/Controls/GPU/GpuRow.cs b/XenAdmin/Controls/GPU/GpuRow.cs index 0072f9665..e1e6ef724 100644 --- a/XenAdmin/Controls/GPU/GpuRow.cs +++ b/XenAdmin/Controls/GPU/GpuRow.cs @@ -116,8 +116,8 @@ namespace XenAdmin.Controls.GPU if (checkBox != null) { shinyBarsContainerPanel.Controls.Add(checkBox, 0, index); - checkBox.Dock = DockStyle.Fill; - checkBox.Margin = new Padding(3, 14, 0, 0); + checkBox.Dock = DockStyle.Top; + checkBox.Margin = new Padding(6, 32, 0, 0); checkBox.CheckedChanged += CheckedChanged; checkBox.Checked = true; } diff --git a/XenAdmin/Controls/MultipleDvdIsoList.cs b/XenAdmin/Controls/MultipleDvdIsoList.cs index 7fa78f4fa..99d1cd6df 100644 --- a/XenAdmin/Controls/MultipleDvdIsoList.cs +++ b/XenAdmin/Controls/MultipleDvdIsoList.cs @@ -231,7 +231,8 @@ namespace XenAdmin.Controls if (VM != null) { CreateCdDriveAction createDriveAction = new CreateCdDriveAction(VM, false,NewDiskDialog.ShowMustRebootBoxCD,NewDiskDialog.ShowVBDWarningBox); - new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee).ShowDialog(this); + using (var dlg = new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee)) + dlg.ShowDialog(this); } } diff --git a/XenAdmin/Controls/NetworkingTab/NetworkList.cs b/XenAdmin/Controls/NetworkingTab/NetworkList.cs index 9b3d6e56b..bdff09bea 100644 --- a/XenAdmin/Controls/NetworkingTab/NetworkList.cs +++ b/XenAdmin/Controls/NetworkingTab/NetworkList.cs @@ -478,11 +478,14 @@ namespace XenAdmin.Controls.NetworkingTab if (NetworksGridView.Rows.Count >= vm.MaxVIFsAllowed) { - new ThreeButtonDialog( - new ThreeButtonDialog.Details( - SystemIcons.Error, - FriendlyErrorNames.VIFS_MAX_ALLOWED, - FriendlyErrorNames.VIFS_MAX_ALLOWED_TITLE)).ShowDialog(Program.MainWindow); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details( + SystemIcons.Error, + FriendlyErrorNames.VIFS_MAX_ALLOWED, + FriendlyErrorNames.VIFS_MAX_ALLOWED_TITLE))) + { + dlg.ShowDialog(Program.MainWindow); + } return; } @@ -574,17 +577,23 @@ namespace XenAdmin.Controls.NetworkingTab else if (XenObject is VM) { // Deleting a VIF, not a Network. - result = new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.MESSAGEBOX_VIF_DELETE, Messages.MESSAGEBOX_VIF_DELETE_TITLE), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(Program.MainWindow); + ThreeButtonDialog.ButtonNo)) + { + result = dlg.ShowDialog(Program.MainWindow); + } } else { - result = new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.MESSAGEBOX_NETWORK_DELETE, Messages.MESSAGEBOX_NETWORK_DELETE_TITLE), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(Program.MainWindow); + ThreeButtonDialog.ButtonNo)) + { + result = dlg.ShowDialog(Program.MainWindow); + } } if (result == DialogResult.Yes) diff --git a/XenAdmin/Controls/SrPicker.cs b/XenAdmin/Controls/SrPicker.cs index 1a5e1ab2b..7f45c2075 100644 --- a/XenAdmin/Controls/SrPicker.cs +++ b/XenAdmin/Controls/SrPicker.cs @@ -51,8 +51,8 @@ namespace XenAdmin.Controls private Host affinity; private SrPickerItem LastSelectedItem; - public event EventHandler ItemSelectionNull; - public event EventHandler ItemSelectionNotNull; + public event Action ItemSelectionNull; + public event Action ItemSelectionNotNull; public event EventHandler DoubleClickOnRow; public long DiskSize = 0; public long? OverridenInitialAllocationRate = null; @@ -167,13 +167,12 @@ namespace XenAdmin.Controls if (item == null || !item.Enabled) { if (ItemSelectionNull != null) - ItemSelectionNull(null, null); + ItemSelectionNull(); return; } - else if (ItemSelectionNotNull != null) - { - ItemSelectionNotNull(null, null); - } + + if (ItemSelectionNotNull != null) + ItemSelectionNotNull(); if (!item.Enabled && LastSelectedItem != null && LastSelectedItem.TheSR.opaque_ref != item.TheSR.opaque_ref) srListBox.SelectedItem = LastSelectedItem; @@ -369,7 +368,7 @@ namespace XenAdmin.Controls } if (ItemSelectionNull != null) - ItemSelectionNull(null, null); + ItemSelectionNull(); } internal void selectDefaultSROrAny() @@ -387,7 +386,7 @@ namespace XenAdmin.Controls } } if (ItemSelectionNull != null) - ItemSelectionNull(null, null); + ItemSelectionNull(); } public void selectSRorDefaultorAny(SR sr) diff --git a/XenAdmin/Controls/Wlb/WlbOptModeScheduler.cs b/XenAdmin/Controls/Wlb/WlbOptModeScheduler.cs index 42a028b84..57d4419b2 100644 --- a/XenAdmin/Controls/Wlb/WlbOptModeScheduler.cs +++ b/XenAdmin/Controls/Wlb/WlbOptModeScheduler.cs @@ -282,11 +282,14 @@ namespace XenAdmin.Controls.Wlb WlbScheduledTask checkTask = CheckForDuplicateTask(newTask); if (null != checkTask) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, Messages.WLB_TASK_SCHEDULE_CONFLICT_BLURB, - Messages.WLB_TASK_SCHEDULE_CONFLICT_TITLE)).ShowDialog(this); + Messages.WLB_TASK_SCHEDULE_CONFLICT_TITLE))) + { + dlg.ShowDialog(this); + } SelectTask(checkTask.TaskId); } else @@ -308,11 +311,14 @@ namespace XenAdmin.Controls.Wlb WlbScheduledTask checkTask = CheckForDuplicateTask(editTask); if (null != checkTask) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, Messages.WLB_TASK_SCHEDULE_CONFLICT_BLURB, - Messages.WLB_TASK_SCHEDULE_CONFLICT_TITLE)).ShowDialog(this); + Messages.WLB_TASK_SCHEDULE_CONFLICT_TITLE))) + { + dlg.ShowDialog(this); + } SelectTask(checkTask.TaskId); } else @@ -375,11 +381,14 @@ namespace XenAdmin.Controls.Wlb //if it's a duplicate task, display warning and return if (null != checkTask) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, Messages.WLB_TASK_SCHEDULE_CONFLICT_BLURB, - Messages.WLB_TASK_SCHEDULE_CONFLICT_TITLE)).ShowDialog(this); + Messages.WLB_TASK_SCHEDULE_CONFLICT_TITLE))) + { + dlg.ShowDialog(this); + } SelectTask(checkTask.TaskId); return; } @@ -646,10 +655,24 @@ namespace XenAdmin.Controls.Wlb { if (lvTaskList.SelectedItems.Count > 0) { - WlbScheduledTask task = TaskFromItem(lvTaskList.SelectedItems[0]); - DeleteTask(task); + DialogResult confirmResult; + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, + Messages.DELETE_WLB_OPTIMIZATION_SCHEDULE_WARNING, + Messages.DELETE_WLB_OPTIMIZATION_SCHEDULE_CAPTION), + ThreeButtonDialog.ButtonYes, + ThreeButtonDialog.ButtonNo)) + { + confirmResult = dlg.ShowDialog(this); + } + + if (confirmResult == DialogResult.Yes) + { + WlbScheduledTask task = TaskFromItem(lvTaskList.SelectedItems[0]); + DeleteTask(task); + weekView1.Refresh(); + } } - weekView1.Refresh(); } private void lvTaskList_SelectedIndexChanged(object sender, EventArgs e) diff --git a/XenAdmin/Controls/Wlb/WlbReportSubscriptionView.cs b/XenAdmin/Controls/Wlb/WlbReportSubscriptionView.cs index 4ee19eadc..92c745580 100644 --- a/XenAdmin/Controls/Wlb/WlbReportSubscriptionView.cs +++ b/XenAdmin/Controls/Wlb/WlbReportSubscriptionView.cs @@ -199,9 +199,11 @@ namespace XenAdmin.Controls.Wlb private void DeleteReportSubscription(object sender, EventArgs e) { SendWlbConfigurationAction action = new SendWlbConfigurationAction(_pool, this._subscription.ToDictionary(), SendWlbConfigurationKind.DeleteReportSubscription); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks); - dialog.ShowCancel = true; - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } if (action.Succeeded) { diff --git a/XenAdmin/Controls/Wlb/WlbReportView.cs b/XenAdmin/Controls/Wlb/WlbReportView.cs index 00f351f6e..7a028c2c9 100644 --- a/XenAdmin/Controls/Wlb/WlbReportView.cs +++ b/XenAdmin/Controls/Wlb/WlbReportView.cs @@ -469,11 +469,14 @@ namespace XenAdmin.Controls.Wlb } else if (StartDatePicker.Value.CompareTo(EndDatePicker.Value) > 0) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, Messages.WLB_REPORT_DATE_ORDERING_MESSAGE, - Messages.WLB_REPORT_DATE_ORDERING_CAPTION)).ShowDialog(this); + Messages.WLB_REPORT_DATE_ORDERING_CAPTION))) + { + dlg.ShowDialog(this); + } } else { @@ -499,12 +502,14 @@ namespace XenAdmin.Controls.Wlb catch (Exception ex) { log.Debug(ex, ex); - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, ex.Message, - Messages.XENCENTER)).ShowDialog(this); - return; + Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } } } @@ -985,7 +990,8 @@ namespace XenAdmin.Controls.Wlb _reportInfo.ReportName, false, parms); - new ActionProgressDialog(a, ProgressBarStyle.Marquee).ShowDialog(); + using (var dlg = new ActionProgressDialog(a, ProgressBarStyle.Marquee)) + dlg.ShowDialog(); if (a.Succeeded) { @@ -1463,7 +1469,8 @@ namespace XenAdmin.Controls.Wlb //and run our own code to export ExportReportAction action = new ExportReportAction(e.Extension.Name, ref reportViewer1); - new ActionProgressDialog(action, ProgressBarStyle.Marquee).ShowDialog(); + using (var dlg = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) + dlg.ShowDialog(); //ReportExporterDelgate exp = new ReportExporterDelgate(RunExportReport); @@ -1504,16 +1511,22 @@ namespace XenAdmin.Controls.Wlb catch (Exception ex) { log.Debug(ex, ex); - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, ex.Message, - Messages.XENCENTER)).ShowDialog(this); + Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } } finally { if (fs != null) + { fs.Close(); + fs.Dispose(); + } } } diff --git a/XenAdmin/Core/HelpersGUI.cs b/XenAdmin/Core/HelpersGUI.cs index 8234bcf25..0c5cd5af0 100644 --- a/XenAdmin/Core/HelpersGUI.cs +++ b/XenAdmin/Core/HelpersGUI.cs @@ -112,13 +112,17 @@ namespace XenAdmin.Core else msg = string.Format(msg_multiple, string.Join("\n", itemsToFixup.ConvertAll(item => item.ToString()).ToArray())); - ThreeButtonDialog dlg = new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(icon ?? SystemIcons.Exclamation, msg), helpName, new ThreeButtonDialog.TBDButton(Messages.PROCEED, DialogResult.Yes), - new ThreeButtonDialog.TBDButton(Messages.CANCEL, DialogResult.No)); + new ThreeButtonDialog.TBDButton(Messages.CANCEL, DialogResult.No))) + { + dialogResult = dlg.ShowDialog(Program.MainWindow); + } - return DialogResult.Yes == dlg.ShowDialog(Program.MainWindow); + return DialogResult.Yes == dialogResult; } return true; } diff --git a/XenAdmin/Diagnostics/Checks/AssertCanEvacuateCheck.cs b/XenAdmin/Diagnostics/Checks/AssertCanEvacuateCheck.cs index cb89aa36a..934f6cce6 100644 --- a/XenAdmin/Diagnostics/Checks/AssertCanEvacuateCheck.cs +++ b/XenAdmin/Diagnostics/Checks/AssertCanEvacuateCheck.cs @@ -52,21 +52,46 @@ namespace XenAdmin.Diagnostics.Checks { } - protected Problem CheckHost() + protected List CheckHost() { + var problems = new List(); + + var restrictMigration = Helpers.FeatureForbidden(Host.Connection, Host.RestrictIntraPoolMigrate); + + var VMsWithProblems = new List(); var residentVMs = Host.Connection.ResolveAll(Host.resident_VMs); foreach (var residentVM in residentVMs) { if (residentVM.AutoPowerOn) - return new AutoStartEnabled(this, residentVM); + { + problems.Add(new AutoStartEnabled(this, residentVM)); + VMsWithProblems.Add(residentVM.opaque_ref); + continue; + } SR sr = residentVM.FindVMCDROMSR(); if (sr != null && sr.IsToolsSR) - return new ToolsCD(this, residentVM); - if (sr != null && sr.content_type == SR.Content_Type_ISO) - return new LocalCD(this, residentVM); + { + problems.Add(new ToolsCD(this, residentVM)); + VMsWithProblems.Add(residentVM.opaque_ref); + } + else if (sr != null && sr.content_type == SR.Content_Type_ISO) + { + problems.Add(new LocalCD(this, residentVM)); + VMsWithProblems.Add(residentVM.opaque_ref); + } + + if (restrictMigration && residentVM.is_a_real_vm && !VMsWithProblems.Contains(residentVM.opaque_ref)) + { + problems.Add(new CannotMigrateVM(this, residentVM, true)); + VMsWithProblems.Add(residentVM.opaque_ref); + } } + // if VM migration is restricted, then we are already forcing all VMs to be shutdown/suspended, so there is not need to call get_vms_which_prevent_evacuation + if (restrictMigration) + return problems; + Session session = Host.Connection.DuplicateSession(); Dictionary, String[]> vms = Host.get_vms_which_prevent_evacuation(session, Host.opaque_ref); @@ -76,11 +101,14 @@ namespace XenAdmin.Diagnostics.Checks String[] exception = kvp.Value; XenRef vmRef = kvp.Key; + if (VMsWithProblems.Contains(vmRef)) + continue; + try { - // We can actually ignore some errors, indicated by null - return GetProblem(Host.Connection, vmRef, exception); - + Problem p = GetProblem(Host.Connection, vmRef, exception); + if (p != null) + problems.Add(p); } catch (Exception e) { @@ -91,10 +119,11 @@ namespace XenAdmin.Diagnostics.Checks VM vm = Host.Connection.Resolve(kvp.Key); if (vm != null) - return new CannotMigrateVM(this, vm); + problems.Add(new CannotMigrateVM(this, vm)); } } - return null; + + return problems; } private Problem GetProblem(IXenConnection connection, XenRef vmRef, string[] exception) @@ -209,7 +238,10 @@ namespace XenAdmin.Diagnostics.Checks } } - public override Problem RunCheck() + // This function only tests certain host-wide conditions. + // Further per-VM conditions are in CheckHost(). + // See RunAllChecks() for how we combine them. + protected override Problem RunCheck() { if (!Host.IsLive) return new HostNotLiveWarning(this, Host); @@ -223,7 +255,17 @@ namespace XenAdmin.Diagnostics.Checks if (Helpers.WlbEnabled(pool.Connection)) return new WLBEnabledWarning(this, pool, Host); } - return CheckHost(); + + return null; + } + + public override List RunAllChecks() + { + var list = base.RunAllChecks(); + if (list.Count > 0) + return list; + else + return CheckHost(); } public override string Description diff --git a/XenAdmin/Diagnostics/Checks/AssertCanEvacuateUpgradeCheck.cs b/XenAdmin/Diagnostics/Checks/AssertCanEvacuateUpgradeCheck.cs index 703df0344..288ac2c47 100644 --- a/XenAdmin/Diagnostics/Checks/AssertCanEvacuateUpgradeCheck.cs +++ b/XenAdmin/Diagnostics/Checks/AssertCanEvacuateUpgradeCheck.cs @@ -45,9 +45,9 @@ namespace XenAdmin.Diagnostics.Checks public AssertCanEvacuateUpgradeCheck(Host host) : base(host) { - } - - public override Problem RunCheck() + } + + protected override Problem RunCheck() { if (!Host.IsLive) return new HostNotLiveWarning(this, Host); diff --git a/XenAdmin/Diagnostics/Checks/Check.cs b/XenAdmin/Diagnostics/Checks/Check.cs index 8cc79f579..756831880 100644 --- a/XenAdmin/Diagnostics/Checks/Check.cs +++ b/XenAdmin/Diagnostics/Checks/Check.cs @@ -29,6 +29,7 @@ * SUCH DAMAGE. */ +using System.Collections.Generic; using XenAPI; using XenAdmin.Diagnostics.Problems; @@ -41,7 +42,18 @@ namespace XenAdmin.Diagnostics.Checks _host = host; } - public abstract Problem RunCheck(); + protected abstract Problem RunCheck(); + + // By default, most Checks return zero or one Problems: but a + // Check can override this to return multiple Problems + public virtual List RunAllChecks() + { + var list = new List(1); + var problem = RunCheck(); + if (problem != null) + list.Add(problem); + return list; + } public abstract string Description{ get;} diff --git a/XenAdmin/Diagnostics/Checks/DR/AssertCanBeRecoveredCheck.cs b/XenAdmin/Diagnostics/Checks/DR/AssertCanBeRecoveredCheck.cs index b62ac4dee..4fa9ba937 100644 --- a/XenAdmin/Diagnostics/Checks/DR/AssertCanBeRecoveredCheck.cs +++ b/XenAdmin/Diagnostics/Checks/DR/AssertCanBeRecoveredCheck.cs @@ -95,7 +95,7 @@ namespace XenAdmin.Diagnostics.Checks.DR return srDeviceConfigList; } - public override Problem RunCheck() + protected override Problem RunCheck() { if (MetadataSession == null) return null; diff --git a/XenAdmin/Diagnostics/Checks/DR/DrHAEnabledCheck.cs b/XenAdmin/Diagnostics/Checks/DR/DrHAEnabledCheck.cs index 434950794..49f466edf 100644 --- a/XenAdmin/Diagnostics/Checks/DR/DrHAEnabledCheck.cs +++ b/XenAdmin/Diagnostics/Checks/DR/DrHAEnabledCheck.cs @@ -44,7 +44,7 @@ namespace XenAdmin.Diagnostics.Checks.DR { } - public override Problem RunCheck() + protected override Problem RunCheck() { if (Pool == null) return null; diff --git a/XenAdmin/Diagnostics/Checks/DR/ExistingVmApplianceCheck.cs b/XenAdmin/Diagnostics/Checks/DR/ExistingVmApplianceCheck.cs index 710980c8c..22d6215a7 100644 --- a/XenAdmin/Diagnostics/Checks/DR/ExistingVmApplianceCheck.cs +++ b/XenAdmin/Diagnostics/Checks/DR/ExistingVmApplianceCheck.cs @@ -56,7 +56,7 @@ namespace XenAdmin.Diagnostics.Checks.DR vmsToRecover = vms; } - public override Problem RunCheck() + protected override Problem RunCheck() { if (applianceToRecover != null) { diff --git a/XenAdmin/Diagnostics/Checks/DR/ExistingVmCheck.cs b/XenAdmin/Diagnostics/Checks/DR/ExistingVmCheck.cs index fe10a1293..7cca8ac27 100644 --- a/XenAdmin/Diagnostics/Checks/DR/ExistingVmCheck.cs +++ b/XenAdmin/Diagnostics/Checks/DR/ExistingVmCheck.cs @@ -51,7 +51,7 @@ namespace XenAdmin.Diagnostics.Checks.DR Vm = vm; } - public override Problem RunCheck() + protected override Problem RunCheck() { foreach (VM existingVm in Pool.Connection.Cache.VMs) { diff --git a/XenAdmin/Diagnostics/Checks/DR/RunningVmApplianceCheck.cs b/XenAdmin/Diagnostics/Checks/DR/RunningVmApplianceCheck.cs index c6dfc8040..9c97ec919 100644 --- a/XenAdmin/Diagnostics/Checks/DR/RunningVmApplianceCheck.cs +++ b/XenAdmin/Diagnostics/Checks/DR/RunningVmApplianceCheck.cs @@ -55,7 +55,7 @@ namespace XenAdmin.Diagnostics.Checks.DR this.vmAppliance = vmAppliance; } - public override Problem RunCheck() + protected override Problem RunCheck() { if (vmAppliance != null) { diff --git a/XenAdmin/Diagnostics/Checks/DR/RunningVmCheck.cs b/XenAdmin/Diagnostics/Checks/DR/RunningVmCheck.cs index 7b514ea28..b09ed64e0 100644 --- a/XenAdmin/Diagnostics/Checks/DR/RunningVmCheck.cs +++ b/XenAdmin/Diagnostics/Checks/DR/RunningVmCheck.cs @@ -55,7 +55,7 @@ namespace XenAdmin.Diagnostics.Checks.DR Vm = vm; } - public override Problem RunCheck() + protected override Problem RunCheck() { foreach (VM existingVm in Pool.Connection.Cache.VMs) { diff --git a/XenAdmin/Diagnostics/Checks/HAOffCheck.cs b/XenAdmin/Diagnostics/Checks/HAOffCheck.cs index 0e8694b54..cbfd368cf 100644 --- a/XenAdmin/Diagnostics/Checks/HAOffCheck.cs +++ b/XenAdmin/Diagnostics/Checks/HAOffCheck.cs @@ -46,7 +46,7 @@ namespace XenAdmin.Diagnostics.Checks { } - public override Problem RunCheck() + protected override Problem RunCheck() { if (!Host.IsLive) return new HostNotLiveWarning(this, Host); diff --git a/XenAdmin/Diagnostics/Checks/HostHasHotfixCheck.cs b/XenAdmin/Diagnostics/Checks/HostHasHotfixCheck.cs index a376aede0..fc92f3e79 100644 --- a/XenAdmin/Diagnostics/Checks/HostHasHotfixCheck.cs +++ b/XenAdmin/Diagnostics/Checks/HostHasHotfixCheck.cs @@ -47,7 +47,7 @@ namespace XenAdmin.Diagnostics.Checks { } - public override Problem RunCheck() + protected override Problem RunCheck() { if (!Host.IsLive) return new HostNotLiveWarning(this, Host); diff --git a/XenAdmin/Diagnostics/Checks/HostHasUnsupportedStorageLinkSRCheck.cs b/XenAdmin/Diagnostics/Checks/HostHasUnsupportedStorageLinkSRCheck.cs index da57ea737..9de4fede5 100644 --- a/XenAdmin/Diagnostics/Checks/HostHasUnsupportedStorageLinkSRCheck.cs +++ b/XenAdmin/Diagnostics/Checks/HostHasUnsupportedStorageLinkSRCheck.cs @@ -46,7 +46,7 @@ namespace XenAdmin.Diagnostics.Checks { } - public override Problem RunCheck() + protected override Problem RunCheck() { if (!Host.IsLive) return new HostNotLiveWarning(this, Host); diff --git a/XenAdmin/Diagnostics/Checks/HostHasWssCheck.cs b/XenAdmin/Diagnostics/Checks/HostHasWssCheck.cs index 80719088e..fc2211e82 100644 --- a/XenAdmin/Diagnostics/Checks/HostHasWssCheck.cs +++ b/XenAdmin/Diagnostics/Checks/HostHasWssCheck.cs @@ -43,7 +43,7 @@ namespace XenAdmin.Diagnostics.Checks { } - public override Problem RunCheck() + protected override Problem RunCheck() { bool mayHaveWssVm = Host.Connection.ResolveAll(Host.resident_VMs).Any(vm =>vm != null && vm.CouldBeWss); bool mayHaveWssVdis = Host.Connection.Cache.VDIs.Any(vdi=>vdi != null && vdi.CouldBeWss); diff --git a/XenAdmin/Diagnostics/Checks/HostLivenessCheck.cs b/XenAdmin/Diagnostics/Checks/HostLivenessCheck.cs index 0ce2d5996..327388e0c 100644 --- a/XenAdmin/Diagnostics/Checks/HostLivenessCheck.cs +++ b/XenAdmin/Diagnostics/Checks/HostLivenessCheck.cs @@ -42,7 +42,7 @@ namespace XenAdmin.Diagnostics.Checks { } - public override Problem RunCheck() + protected override Problem RunCheck() { if (!Host.IsLive) { diff --git a/XenAdmin/Diagnostics/Checks/HostMaintenanceModeCheck.cs b/XenAdmin/Diagnostics/Checks/HostMaintenanceModeCheck.cs index 3223d9272..220505da8 100644 --- a/XenAdmin/Diagnostics/Checks/HostMaintenanceModeCheck.cs +++ b/XenAdmin/Diagnostics/Checks/HostMaintenanceModeCheck.cs @@ -41,7 +41,7 @@ namespace XenAdmin.Diagnostics.Checks { } - public override Problem RunCheck() + protected override Problem RunCheck() { if (!Host.IsLive) { diff --git a/XenAdmin/Diagnostics/Checks/PBDsPluggedCheck.cs b/XenAdmin/Diagnostics/Checks/PBDsPluggedCheck.cs index d24881d27..c984fd741 100644 --- a/XenAdmin/Diagnostics/Checks/PBDsPluggedCheck.cs +++ b/XenAdmin/Diagnostics/Checks/PBDsPluggedCheck.cs @@ -40,15 +40,11 @@ namespace XenAdmin.Diagnostics.Checks { public class PBDsPluggedCheck : Check { - - public PBDsPluggedCheck(Host host):base(host) { } - - - public override Problem RunCheck() + protected override Problem RunCheck() { if (!Host.IsLive) return new HostNotLiveWarning(this, Host); diff --git a/XenAdmin/Diagnostics/Checks/PatchPrecheckCheck.cs b/XenAdmin/Diagnostics/Checks/PatchPrecheckCheck.cs index d99ee1fb4..3cffd801a 100644 --- a/XenAdmin/Diagnostics/Checks/PatchPrecheckCheck.cs +++ b/XenAdmin/Diagnostics/Checks/PatchPrecheckCheck.cs @@ -50,7 +50,6 @@ namespace XenAdmin.Diagnostics.Checks private static Regex PrecheckErrorRegex = new Regex("()"); - public PatchPrecheckCheck(Host host, Pool_patch patch) : base(host) { @@ -58,7 +57,7 @@ namespace XenAdmin.Diagnostics.Checks } - public override Problem RunCheck() + protected override Problem RunCheck() { if (!Host.IsLive) return new HostNotLiveWarning(this, Host); diff --git a/XenAdmin/Diagnostics/Checks/SafeToUpgradeCheck.cs b/XenAdmin/Diagnostics/Checks/SafeToUpgradeCheck.cs index 338eb5c89..828b8b048 100644 --- a/XenAdmin/Diagnostics/Checks/SafeToUpgradeCheck.cs +++ b/XenAdmin/Diagnostics/Checks/SafeToUpgradeCheck.cs @@ -45,9 +45,9 @@ namespace XenAdmin.Diagnostics.Checks public SafeToUpgradeCheck(Host host) : base(host) { - } - - public override Problem RunCheck() + } + + protected override Problem RunCheck() { try { diff --git a/XenAdmin/Diagnostics/Checks/UpgradingFromTampaAndOlderCheck.cs b/XenAdmin/Diagnostics/Checks/UpgradingFromTampaAndOlderCheck.cs index 9ab3ff3df..2019279dd 100644 --- a/XenAdmin/Diagnostics/Checks/UpgradingFromTampaAndOlderCheck.cs +++ b/XenAdmin/Diagnostics/Checks/UpgradingFromTampaAndOlderCheck.cs @@ -43,7 +43,7 @@ namespace XenAdmin.Diagnostics.Checks { } - public override Problem RunCheck() + protected override Problem RunCheck() { bool licenseStatus = !Host.IsFreeLicense() || Host.InGrace; return !Helpers.ClearwaterOrGreater(Host) && licenseStatus ? new UpgradingFromTampaAndOlderWarning(this, Host) : null; diff --git a/XenAdmin/Diagnostics/Checks/VmprActivatedCheck.cs b/XenAdmin/Diagnostics/Checks/VmprActivatedCheck.cs index aa2b45725..87e1a945e 100644 --- a/XenAdmin/Diagnostics/Checks/VmprActivatedCheck.cs +++ b/XenAdmin/Diagnostics/Checks/VmprActivatedCheck.cs @@ -43,7 +43,7 @@ namespace XenAdmin.Diagnostics.Checks { } - public override Problem RunCheck() + protected override Problem RunCheck() { return Host.Connection.Cache.VMPPs.Count() > 0 ? new VmprActivatedWarning(this, Host) : null; } diff --git a/XenAdmin/Diagnostics/Problems/HostProblem/HostNotSafeToUpgradeWarning.cs b/XenAdmin/Diagnostics/Problems/HostProblem/HostNotSafeToUpgradeWarning.cs index 38f458178..4145ead9b 100644 --- a/XenAdmin/Diagnostics/Problems/HostProblem/HostNotSafeToUpgradeWarning.cs +++ b/XenAdmin/Diagnostics/Problems/HostProblem/HostNotSafeToUpgradeWarning.cs @@ -55,9 +55,11 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem { Program.Invoke(Program.MainWindow, delegate() { - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Warning, Message)) - .ShowDialog(); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, Message))) + { + dlg.ShowDialog(); + } }); cancelled = true; diff --git a/XenAdmin/Diagnostics/Problems/HostProblem/HostOutOfSpaceProblem.cs b/XenAdmin/Diagnostics/Problems/HostProblem/HostOutOfSpaceProblem.cs index d93e48d40..55c34069b 100644 --- a/XenAdmin/Diagnostics/Problems/HostProblem/HostOutOfSpaceProblem.cs +++ b/XenAdmin/Diagnostics/Problems/HostProblem/HostOutOfSpaceProblem.cs @@ -74,18 +74,18 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem { Program.Invoke(Program.MainWindow, delegate() { - DialogResult r = new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( - SystemIcons.Warning, - diskSpaceReq.GetSpaceRequirementsMessage()), + SystemIcons.Warning, + diskSpaceReq.GetSpaceRequirementsMessage()), new ThreeButtonDialog.TBDButton(Messages.YES, DialogResult.Yes, ThreeButtonDialog.ButtonType.ACCEPT, true), - ThreeButtonDialog.ButtonNo - ).ShowDialog(); - - - if (r == DialogResult.Yes) + ThreeButtonDialog.ButtonNo)) { - action = new CleanupDiskSpaceAction(this.Server, patch, true); + DialogResult r = dlg.ShowDialog(); + if (r == DialogResult.Yes) + { + action = new CleanupDiskSpaceAction(this.Server, patch, true); + } } }); } @@ -93,9 +93,11 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem { Program.Invoke(Program.MainWindow, delegate() { - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Warning, diskSpaceReq.GetSpaceRequirementsMessage())) - .ShowDialog(); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, diskSpaceReq.GetSpaceRequirementsMessage()))) + { + dlg.ShowDialog(); + } }); } cancelled = action == null; diff --git a/XenAdmin/Diagnostics/Problems/HostProblem/NotEnoughMem.cs b/XenAdmin/Diagnostics/Problems/HostProblem/NotEnoughMem.cs index 22233932e..6851a9964 100644 --- a/XenAdmin/Diagnostics/Problems/HostProblem/NotEnoughMem.cs +++ b/XenAdmin/Diagnostics/Problems/HostProblem/NotEnoughMem.cs @@ -58,15 +58,17 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem protected override AsyncAction CreateAction(out bool cancelled) { - SelectVMsToSuspendDialog dlg = new SelectVMsToSuspendDialog(Server); - if (dlg.ShowDialog() == DialogResult.OK) + using (var dlg = new SelectVMsToSuspendDialog(Server)) { - cancelled = false; + if (dlg.ShowDialog() == DialogResult.OK) + { + cancelled = false; - VmsToSuspend = dlg.SelectedVMsToSuspend; - VmsToShutdown = dlg.SelectedVMsToShutdown; + VmsToSuspend = dlg.SelectedVMsToSuspend; + VmsToShutdown = dlg.SelectedVMsToShutdown; - return new SuspendAndShutdownVMsAction(Server.Connection, Server, VmsToSuspend, VmsToShutdown); + return new SuspendAndShutdownVMsAction(Server.Connection, Server, VmsToSuspend, VmsToShutdown); + } } cancelled = true; diff --git a/XenAdmin/Diagnostics/Problems/ProblemWithInformationUrl.cs b/XenAdmin/Diagnostics/Problems/ProblemWithInformationUrl.cs index f38ab6136..388d31d21 100644 --- a/XenAdmin/Diagnostics/Problems/ProblemWithInformationUrl.cs +++ b/XenAdmin/Diagnostics/Problems/ProblemWithInformationUrl.cs @@ -64,12 +64,15 @@ namespace XenAdmin.Diagnostics.Problems } catch (Exception) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.COULD_NOT_OPEN_URL, - UriToLaunch.AbsoluteUri), - Messages.XENCENTER)).ShowDialog(Program.MainWindow); + UriToLaunch != null ? UriToLaunch.AbsoluteUri : string.Empty), + Messages.XENCENTER))) + { + dlg.ShowDialog(Program.MainWindow); + } } } } diff --git a/XenAdmin/Diagnostics/Problems/VMProblem/CannotMigrateVM.cs b/XenAdmin/Diagnostics/Problems/VMProblem/CannotMigrateVM.cs index 0a189e341..27c10048f 100644 --- a/XenAdmin/Diagnostics/Problems/VMProblem/CannotMigrateVM.cs +++ b/XenAdmin/Diagnostics/Problems/VMProblem/CannotMigrateVM.cs @@ -38,12 +38,22 @@ namespace XenAdmin.Diagnostics.Problems.VMProblem { public class CannotMigrateVM : VMProblem { - public CannotMigrateVM(Check check, VM vm) - : base(check, vm) { } + private readonly bool licenseRestriction; + + public CannotMigrateVM(Check check, VM vm, bool licenseRestriction = false) + : base(check, vm) + { + this.licenseRestriction = licenseRestriction; + } public override string Description { - get { return String.Format(Messages.UPDATES_WIZARD_CANNOT_MIGRATE_VM_UNKNOWN_REASON, VM.Name); } + get + { + return String.Format(licenseRestriction + ? Messages.UPDATES_WIZARD_CANNOT_MIGRATE_VM_LICENSE_REASON + : Messages.UPDATES_WIZARD_CANNOT_MIGRATE_VM_UNKNOWN_REASON, VM.Name); + } } } } diff --git a/XenAdmin/Diagnostics/Problems/VMProblem/ExistingVmProblem.cs b/XenAdmin/Diagnostics/Problems/VMProblem/ExistingVmProblem.cs index 987caa891..461784793 100644 --- a/XenAdmin/Diagnostics/Problems/VMProblem/ExistingVmProblem.cs +++ b/XenAdmin/Diagnostics/Problems/VMProblem/ExistingVmProblem.cs @@ -67,10 +67,15 @@ namespace XenAdmin.Diagnostics.Problems.VMProblem { Program.AssertOnEventThread(); - if (new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, String.Format(Messages.CONFIRM_DELETE_VM, VM.Name, VM.Connection.Name), Messages.ACTION_SHUTDOWN_AND_DESTROY_VM_TITLE), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog() == DialogResult.Yes) + ThreeButtonDialog.ButtonNo)) + { + dialogResult = dlg.ShowDialog(); + } + if (dialogResult == DialogResult.Yes) { cancelled = false; List vms = new List { VM }; diff --git a/XenAdmin/Diagnostics/Problems/VmApplianceProblem/ExistingVmApplianceProblem.cs b/XenAdmin/Diagnostics/Problems/VmApplianceProblem/ExistingVmApplianceProblem.cs index b52106cb6..bc497a3a9 100644 --- a/XenAdmin/Diagnostics/Problems/VmApplianceProblem/ExistingVmApplianceProblem.cs +++ b/XenAdmin/Diagnostics/Problems/VmApplianceProblem/ExistingVmApplianceProblem.cs @@ -70,11 +70,16 @@ namespace XenAdmin.Diagnostics.Problems.VmApplianceProblem { Program.AssertOnEventThread(); string vmNames = string.Join(",", (from vm in vmsToDestroy select vm.Name).ToArray()); - - if (new ThreeButtonDialog( + + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, String.Format(Messages.CONFIRM_DELETE_VMS, vmNames, vmsToDestroy[0].Connection.Name), Messages.ACTION_SHUTDOWN_AND_DESTROY_VMS_TITLE), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog() == DialogResult.Yes) + ThreeButtonDialog.ButtonNo)) + { + dialogResult = dlg.ShowDialog(); + } + if (dialogResult == DialogResult.Yes) { cancelled = false; return new ShutdownAndDestroyVMsAction(vmsToDestroy[0].Connection, vmsToDestroy); diff --git a/XenAdmin/Diagnostics/Problems/WarningWithInformationUrl.cs b/XenAdmin/Diagnostics/Problems/WarningWithInformationUrl.cs index abc5940f5..e2a01bd76 100644 --- a/XenAdmin/Diagnostics/Problems/WarningWithInformationUrl.cs +++ b/XenAdmin/Diagnostics/Problems/WarningWithInformationUrl.cs @@ -59,12 +59,15 @@ namespace XenAdmin.Diagnostics.Problems } catch (Exception) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.COULD_NOT_OPEN_URL, - UriToLaunch.AbsoluteUri), - Messages.XENCENTER)).ShowDialog(Program.MainWindow); + UriToLaunch != null ? UriToLaunch.AbsoluteUri : string.Empty), + Messages.XENCENTER))) + { + dlg.ShowDialog(Program.MainWindow); + } } } } diff --git a/XenAdmin/Dialogs/AboutDialog.ja.resx b/XenAdmin/Dialogs/AboutDialog.ja.resx index 576e1acba..bc7796ddd 100644 --- a/XenAdmin/Dialogs/AboutDialog.ja.resx +++ b/XenAdmin/Dialogs/AboutDialog.ja.resx @@ -463,7 +463,7 @@ GrowAndShrink - 423, 216 + 423, 321 Tahoma, 8pt diff --git a/XenAdmin/Dialogs/AboutDialog.zh-CN.resx b/XenAdmin/Dialogs/AboutDialog.zh-CN.resx index 9c7fe1324..b32edf327 100644 --- a/XenAdmin/Dialogs/AboutDialog.zh-CN.resx +++ b/XenAdmin/Dialogs/AboutDialog.zh-CN.resx @@ -463,7 +463,7 @@ GrowAndShrink - 423, 216 + 423, 321 Tahoma, 8pt diff --git a/XenAdmin/Dialogs/AttachDiskDialog.cs b/XenAdmin/Dialogs/AttachDiskDialog.cs index 449641c2b..ed7774b87 100644 --- a/XenAdmin/Dialogs/AttachDiskDialog.cs +++ b/XenAdmin/Dialogs/AttachDiskDialog.cs @@ -220,10 +220,13 @@ namespace XenAdmin.Dialogs { Program.Invoke(Program.MainWindow, delegate() { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, - FriendlyErrorNames.VBDS_MAX_ALLOWED, Messages.DISK_ATTACH)).ShowDialog(Program.MainWindow); + FriendlyErrorNames.VBDS_MAX_ALLOWED, Messages.DISK_ATTACH))) + { + dlg.ShowDialog(Program.MainWindow); + } }); // Give up return; diff --git a/XenAdmin/Dialogs/BallooningDialogBase.cs b/XenAdmin/Dialogs/BallooningDialogBase.cs index 1559ae226..cc4c901ad 100644 --- a/XenAdmin/Dialogs/BallooningDialogBase.cs +++ b/XenAdmin/Dialogs/BallooningDialogBase.cs @@ -118,10 +118,16 @@ namespace XenAdmin.Dialogs msg = (VMs.Count == 1 ? Messages.CONFIRM_CHANGE_MEMORY_MAX_SINGULAR : Messages.CONFIRM_CHANGE_MEMORY_MAX_PLURAL); else msg = (VMs.Count == 1 ? Messages.CONFIRM_CHANGE_MEMORY_SINGULAR : Messages.CONFIRM_CHANGE_MEMORY_PLURAL); - if (DialogResult.Yes != new ThreeButtonDialog( + + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.XENCENTER), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(parentWindow)) + ThreeButtonDialog.ButtonNo)) + { + dialogResult = dlg.ShowDialog(parentWindow); + } + if (DialogResult.Yes != dialogResult) return null; break; } diff --git a/XenAdmin/Dialogs/ConnectionLostDialogLauncher.cs b/XenAdmin/Dialogs/ConnectionLostDialogLauncher.cs index 34766c4bc..7b279b863 100644 --- a/XenAdmin/Dialogs/ConnectionLostDialogLauncher.cs +++ b/XenAdmin/Dialogs/ConnectionLostDialogLauncher.cs @@ -89,9 +89,13 @@ namespace XenAdmin.Dialogs private void LaunchDialog() { fired = true; - Program.Invoke(Program.MainWindow, ()=> - new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, DisplayMessage, Messages.XENCENTER), - new ThreeButtonDialog.TBDButton(Messages.OK, DialogResult.OK)).ShowDialog(Program.MainWindow)); + Program.Invoke(Program.MainWindow, () => + { using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, DisplayMessage, Messages.XENCENTER), + new ThreeButtonDialog.TBDButton(Messages.OK, DialogResult.OK))) + { + dlg.ShowDialog(Program.MainWindow); + } + }); } } } diff --git a/XenAdmin/Dialogs/CopyVMDialog.cs b/XenAdmin/Dialogs/CopyVMDialog.cs index e7e31ab3d..4445963b4 100644 --- a/XenAdmin/Dialogs/CopyVMDialog.cs +++ b/XenAdmin/Dialogs/CopyVMDialog.cs @@ -60,8 +60,8 @@ namespace XenAdmin.Dialogs IsRealVm = !vm.is_a_template; TheVM = vm; srPicker1.Usage = SrPicker.SRPickerType.MoveOrCopy; - srPicker1.ItemSelectionNotNull += new EventHandler(srPicker1_ItemSelectionNotNull); - srPicker1.ItemSelectionNull += new EventHandler(srPicker1_ItemSelectionNull); + srPicker1.ItemSelectionNotNull += srPicker1_ItemSelectionNotNull; + srPicker1.ItemSelectionNull += srPicker1_ItemSelectionNull; Host affinity = TheVM.Home(); srPicker1.Connection = TheVM.Connection; srPicker1.DiskSize = vm.TotalVMSize; @@ -104,12 +104,12 @@ namespace XenAdmin.Dialogs srPicker1.selectDefaultSROrAny(); } - private void srPicker1_ItemSelectionNull(object sender, EventArgs e) + private void srPicker1_ItemSelectionNull() { EnableMoveButton(); } - private void srPicker1_ItemSelectionNotNull(object sender, EventArgs e) + private void srPicker1_ItemSelectionNotNull() { EnableMoveButton(); } diff --git a/XenAdmin/Dialogs/EditVmHaPrioritiesDialog.cs b/XenAdmin/Dialogs/EditVmHaPrioritiesDialog.cs index ce0825147..c1f2beffd 100644 --- a/XenAdmin/Dialogs/EditVmHaPrioritiesDialog.cs +++ b/XenAdmin/Dialogs/EditVmHaPrioritiesDialog.cs @@ -157,11 +157,14 @@ namespace XenAdmin.Dialogs { Program.Invoke(this, delegate() { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Exclamation, String.Format(Messages.HA_WAS_DISABLED, pool.Name), - Messages.HIGH_AVAILABILITY)).ShowDialog(this); + Messages.HIGH_AVAILABILITY))) + { + dlg.ShowDialog(this); + } this.Close(); }); } @@ -179,10 +182,15 @@ namespace XenAdmin.Dialogs long newNtol = assignPriorities.Ntol; // User has configured ntol to be zero. Check this is what they want (since it is practically useless). - if (newNtol == 0 && new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.HA_NTOL_ZERO_QUERY, Messages.HIGH_AVAILABILITY), ThreeButtonDialog.ButtonYes, - new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(this) == DialogResult.No) + new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) + { + dialogResult = dlg.ShowDialog(this); + } + if (newNtol == 0 && dialogResult == DialogResult.No) { return; } diff --git a/XenAdmin/Dialogs/EvacuateHostDialog.cs b/XenAdmin/Dialogs/EvacuateHostDialog.cs index 83348e9a5..1a132e203 100644 --- a/XenAdmin/Dialogs/EvacuateHostDialog.cs +++ b/XenAdmin/Dialogs/EvacuateHostDialog.cs @@ -320,7 +320,8 @@ namespace XenAdmin.Dialogs SetSession(saveVMsAction); SetSession(action); saveVMsAction.RunAsync(); - new ActionProgressDialog(action, ProgressBarStyle.Blocks).ShowDialog(this); + using (var dlg = new ActionProgressDialog(action, ProgressBarStyle.Blocks)) + dlg.ShowDialog(this); RefreshEntermaintenanceButton(); } @@ -767,11 +768,14 @@ namespace XenAdmin.Dialogs case Failure.HOST_NOT_ENOUGH_FREE_MEMORY: if (vmRef == null) - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, Messages.EVACUATE_HOST_NOT_ENOUGH_MEMORY, - Messages.EVACUATE_HOST_NOT_ENOUGH_MEMORY_TITLE)).ShowDialog(this); + Messages.EVACUATE_HOST_NOT_ENOUGH_MEMORY_TITLE))) + { + dlg.ShowDialog(this); + } vmRef = ErrorDescription[1]; UpdateVMWithError(vmRef, String.Empty, CanSuspendVm(vmRef) ? Solution.Suspend : Solution.Shutdown); @@ -786,11 +790,14 @@ namespace XenAdmin.Dialogs } if (vmRef == null) - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, Messages.EVACUATE_HOST_NO_OTHER_HOSTS, - Messages.EVACUATE_HOST_NO_OTHER_HOSTS_TITLE)).ShowDialog(this); + Messages.EVACUATE_HOST_NO_OTHER_HOSTS_TITLE))) + { + dlg.ShowDialog(this); + } break; diff --git a/XenAdmin/Dialogs/IscsiDeviceConfigDialog.cs b/XenAdmin/Dialogs/IscsiDeviceConfigDialog.cs index 18f9fef29..091b831d3 100644 --- a/XenAdmin/Dialogs/IscsiDeviceConfigDialog.cs +++ b/XenAdmin/Dialogs/IscsiDeviceConfigDialog.cs @@ -472,10 +472,11 @@ namespace XenAdmin.Dialogs } IscsiPopulateLunsAction.Completed += IscsiPopulateLunsAction_Completed; - ActionProgressDialog dialog = - new ActionProgressDialog(IscsiPopulateLunsAction, ProgressBarStyle.Marquee); - dialog.ShowCancel = true; - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(IscsiPopulateLunsAction, ProgressBarStyle.Marquee)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } } private void IscsiPopulateLunsAction_Completed(ActionBase sender) diff --git a/XenAdmin/Dialogs/LicenseManager/LicenseManagerController.cs b/XenAdmin/Dialogs/LicenseManager/LicenseManagerController.cs index 1568975c2..275bb989f 100644 --- a/XenAdmin/Dialogs/LicenseManager/LicenseManagerController.cs +++ b/XenAdmin/Dialogs/LicenseManager/LicenseManagerController.cs @@ -156,11 +156,14 @@ namespace XenAdmin.Dialogs private void ShowPoolHostNotConnectedError() { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, Messages.SELECTED_HOST_POOL_NOT_CONNECTED, - Messages.XENCENTER)).ShowDialog(View.Parent); + Messages.XENCENTER))) + { + dlg.ShowDialog(View.Parent); + } } private void SummariseDisconnectedRows(List rowsChecked) @@ -264,12 +267,14 @@ namespace XenAdmin.Dialogs } catch (Exception) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, - string.Format(Messages.LICENSE_SERVER_COULD_NOT_OPEN_LINK, - url), - Messages.XENCENTER)).ShowDialog(View.Parent); + string.Format(Messages.LICENSE_SERVER_COULD_NOT_OPEN_LINK, url), + Messages.XENCENTER))) + { + dlg.ShowDialog(View.Parent); + } } }; } diff --git a/XenAdmin/Dialogs/LicenseManager/OpenLicenseFileDialog.cs b/XenAdmin/Dialogs/LicenseManager/OpenLicenseFileDialog.cs index e63a637a0..0af3fff68 100644 --- a/XenAdmin/Dialogs/LicenseManager/OpenLicenseFileDialog.cs +++ b/XenAdmin/Dialogs/LicenseManager/OpenLicenseFileDialog.cs @@ -96,9 +96,11 @@ namespace XenAdmin.Dialogs { oldDir = Directory.GetCurrentDirectory(); ApplyLicenseAction action = new ApplyLicenseAction(host.Connection, host, Dialog.FileName, activateFreeLicense); - ActionProgressDialog actionProgress = new ActionProgressDialog(action, ProgressBarStyle.Marquee); - actionProgress.Text = title; - actionProgress.ShowDialog(parent); + using (var actionProgress = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) + { + actionProgress.Text = title; + actionProgress.ShowDialog(parent); + } } finally { diff --git a/XenAdmin/Dialogs/MoveVirtualDiskDialog.cs b/XenAdmin/Dialogs/MoveVirtualDiskDialog.cs index b94e54cb9..22e8f3b34 100644 --- a/XenAdmin/Dialogs/MoveVirtualDiskDialog.cs +++ b/XenAdmin/Dialogs/MoveVirtualDiskDialog.cs @@ -85,12 +85,12 @@ namespace XenAdmin.Dialogs get { return srPicker1; } } - private void srPicker1_ItemSelectionNull(object sender, EventArgs e) + private void srPicker1_ItemSelectionNull() { updateButtons(); } - private void srPicker1_ItemSelectionNotNull(object sender, EventArgs e) + private void srPicker1_ItemSelectionNotNull() { updateButtons(); } diff --git a/XenAdmin/Dialogs/NetworkingProperties.cs b/XenAdmin/Dialogs/NetworkingProperties.cs index ad06970b1..582b45bff 100644 --- a/XenAdmin/Dialogs/NetworkingProperties.cs +++ b/XenAdmin/Dialogs/NetworkingProperties.cs @@ -456,11 +456,14 @@ namespace XenAdmin.Dialogs } catch (Failure) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, Messages.NETWORK_RECONFIG_CONNECTION_LOST, - Messages.XENCENTER)).ShowDialog(this); + Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } this.Close(); return; } @@ -502,12 +505,16 @@ namespace XenAdmin.Dialogs string title = Pool == null ? Messages.NETWORKING_PROPERTIES_WARNING_CHANGING_MANAGEMENT_HOST : Messages.NETWORKING_PROPERTIES_WARNING_CHANGING_MANAGEMENT_POOL; - if (DialogResult.OK != - new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, title), "NetworkingPropertiesPMIWarning", new ThreeButtonDialog.TBDButton(Messages.NETWORKING_PROPERTIES_CHANGING_MANAGEMENT_CONTINUE, DialogResult.OK), - ThreeButtonDialog.ButtonCancel).ShowDialog(this)) + ThreeButtonDialog.ButtonCancel)) + { + dialogResult = dlg.ShowDialog(this); + } + if (DialogResult.OK != dialogResult) { DialogResult = System.Windows.Forms.DialogResult.None; return; diff --git a/XenAdmin/Dialogs/NewDiskDialog.cs b/XenAdmin/Dialogs/NewDiskDialog.cs index 1a56d4fd0..d11c0baad 100644 --- a/XenAdmin/Dialogs/NewDiskDialog.cs +++ b/XenAdmin/Dialogs/NewDiskDialog.cs @@ -79,8 +79,8 @@ namespace XenAdmin.Dialogs // Add events NameTextBox.Text = GetDefaultVDIName(); SrListBox.srListBox.SelectedIndexChanged += new EventHandler(srListBox_SelectedIndexChanged); - SrListBox.ItemSelectionNotNull += new EventHandler(SrListBox_ItemSelectionNotNull); - SrListBox.ItemSelectionNull += new EventHandler(SrListBox_ItemSelectionNull); + SrListBox.ItemSelectionNotNull += SrListBox_ItemSelectionNotNull; + SrListBox.ItemSelectionNull += SrListBox_ItemSelectionNull; srListBox_SelectedIndexChanged(null, null); DiskSizeNumericUpDown.TextChanged += new EventHandler(DiskSizeNumericUpDown_TextChanged); @@ -178,12 +178,12 @@ namespace XenAdmin.Dialogs return Helpers.MakeUniqueName(Messages.DEFAULT_VDI_NAME, usedNames); } - void SrListBox_ItemSelectionNull(object sender, EventArgs e) + void SrListBox_ItemSelectionNull() { SelectionNull = true; } - void SrListBox_ItemSelectionNotNull(object sender, EventArgs e) + void SrListBox_ItemSelectionNotNull() { SelectionNull = false; } @@ -234,10 +234,15 @@ namespace XenAdmin.Dialogs XenAPI.SR sr = SrListBox.SR; if (!sr.shared && TheVM != null && TheVM.HaPriorityIsRestart()) { - if (new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.NEW_SR_DIALOG_ATTACH_NON_SHARED_DISK_HA, Messages.XENCENTER), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(Program.MainWindow) != DialogResult.Yes) + ThreeButtonDialog.ButtonNo)) + { + dialogResult = dlg.ShowDialog(Program.MainWindow); + } + if (dialogResult != DialogResult.Yes) return; new HAUnprotectVMAction(TheVM).RunExternal(TheVM.Connection.Session); } @@ -699,13 +704,13 @@ namespace XenAdmin.Dialogs { if (!Program.RunInAutomatedTestMode) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Information, - Messages. - NEWDISKWIZARD_MESSAGE, - Messages. - NEWDISKWIZARD_MESSAGE_TITLE)) - .ShowDialog(Program.MainWindow); + Messages.NEWDISKWIZARD_MESSAGE, + Messages.NEWDISKWIZARD_MESSAGE_TITLE))) + { + dlg.ShowDialog(Program.MainWindow); + } } }); } diff --git a/XenAdmin/Dialogs/NewPoolDialog.cs b/XenAdmin/Dialogs/NewPoolDialog.cs index 7e636398e..e333fe785 100644 --- a/XenAdmin/Dialogs/NewPoolDialog.cs +++ b/XenAdmin/Dialogs/NewPoolDialog.cs @@ -161,9 +161,9 @@ namespace XenAdmin.Dialogs Helpers.FeatureForbidden(host, Host.RestrictCpuMasking) && !PoolJoinRules.FreeHostPaidMaster(host, master, false))) // in this case we can upgrade the license and then mask the CPU { - UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPUMASKING : Messages.UPSELL_BLURB_CPUMASKING + Messages.UPSELL_BLURB_CPUMASKING_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_CPUMASKING); - dlg.ShowDialog(this); + using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPUMASKING : Messages.UPSELL_BLURB_CPUMASKING + Messages.UPSELL_BLURB_CPUMASKING_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_CPUMASKING)) + dlg.ShowDialog(this); return; } diff --git a/XenAdmin/Dialogs/NewTagDialog.cs b/XenAdmin/Dialogs/NewTagDialog.cs index 68e993109..08f69d4e0 100644 --- a/XenAdmin/Dialogs/NewTagDialog.cs +++ b/XenAdmin/Dialogs/NewTagDialog.cs @@ -316,12 +316,15 @@ namespace XenAdmin.Dialogs { string tag = tagsListView.SelectedItems[0].Text; - ThreeButtonDialog tbd = new ThreeButtonDialog( + DialogResult result; + using (var tbd = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, String.Format(Messages.CONFIRM_DELETE_TAG, tag), Messages.CONFIRM_DELETE_TAG_TITLE), new ThreeButtonDialog.TBDButton(Messages.OK, DialogResult.OK), - ThreeButtonDialog.ButtonCancel); - - DialogResult result = tbd.ShowDialog(this); + ThreeButtonDialog.ButtonCancel)) + { + result = tbd.ShowDialog(this); + } + if (result != DialogResult.OK) return; diff --git a/XenAdmin/Dialogs/PropertiesDialog.cs b/XenAdmin/Dialogs/PropertiesDialog.cs index 52e648fe7..43e4a19f7 100644 --- a/XenAdmin/Dialogs/PropertiesDialog.cs +++ b/XenAdmin/Dialogs/PropertiesDialog.cs @@ -197,7 +197,7 @@ namespace XenAdmin.Dialogs ShowTab(PoolGpuEditPage = new PoolGpuEditPage()); } - if (is_pool_or_standalone && Helpers.DundeeOrGreater(xenObject.Connection)) + if (is_pool_or_standalone && !Helpers.FeatureForbidden(xenObject.Connection, Host.RestrictSslLegacySwitch)) ShowTab(SecurityEditPage = new SecurityEditPage()); if (is_network) @@ -272,7 +272,7 @@ namespace XenAdmin.Dialogs if (vbdEditPages.Count <= 0) return; - ActionProgressDialog dialog = new ActionProgressDialog( + using (var dialog = new ActionProgressDialog( new DelegatedAsyncAction(vdi.Connection, Messages.DEVICE_POSITION_SCANNING, Messages.DEVICE_POSITION_SCANNING, Messages.DEVICE_POSITION_SCANNED, delegate(Session session) @@ -280,9 +280,11 @@ namespace XenAdmin.Dialogs foreach (VBDEditPage page in vbdEditPages) page.UpdateDevicePositions(session); }), - ProgressBarStyle.Continuous); - dialog.ShowCancel = true; - dialog.ShowDialog(Program.MainWindow); + ProgressBarStyle.Continuous)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(Program.MainWindow); + } } finally { diff --git a/XenAdmin/Dialogs/RoleElevationDialog.cs b/XenAdmin/Dialogs/RoleElevationDialog.cs index 07a0a2fd5..24398081f 100644 --- a/XenAdmin/Dialogs/RoleElevationDialog.cs +++ b/XenAdmin/Dialogs/RoleElevationDialog.cs @@ -114,7 +114,8 @@ namespace XenAdmin.Dialogs } }); - new ActionProgressDialog(loginAction, ProgressBarStyle.Marquee, false).ShowDialog(this); + using (var dlg = new ActionProgressDialog(loginAction, ProgressBarStyle.Marquee, false)) + dlg.ShowDialog(this); // The exception would have been handled by the action progress dialog, just return the user to the sudo dialog if (loginAction.Exception != null) @@ -139,11 +140,14 @@ namespace XenAdmin.Dialogs catch (Exception ex) { log.DebugFormat("Exception when attempting to sudo action: {0} ", ex); - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, String.Format(Messages.USER_AUTHORIZATION_FAILED, TextBoxUsername.Text), - Messages.XENCENTER)).ShowDialog(Parent); + Messages.XENCENTER))) + { + dlg.ShowDialog(Parent); + } } finally { @@ -177,11 +181,14 @@ namespace XenAdmin.Dialogs private void ShowNotAuthorisedDialog() { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, Messages.USER_NOT_AUTHORIZED, - Messages.PERMISSION_DENIED)).ShowDialog(this); + Messages.PERMISSION_DENIED))) + { + dlg.ShowDialog(this); + } } private bool SessionAuthorized(Session s) diff --git a/XenAdmin/Dialogs/VIFDialog.cs b/XenAdmin/Dialogs/VIFDialog.cs index 11f7bccb3..172d69753 100644 --- a/XenAdmin/Dialogs/VIFDialog.cs +++ b/XenAdmin/Dialogs/VIFDialog.cs @@ -373,9 +373,13 @@ namespace XenAdmin.Dialogs var vm = xenConnection.Resolve(vif.VM); if (vif != ExistingVif && vif.MAC == SelectedMac && vm != null && vm.is_a_real_vm) { - DialogResult result = MacAddressDuplicationWarningDialog( + DialogResult result; + using (var dlg = MacAddressDuplicationWarningDialog( SelectedMac, - vm.NameWithLocation).ShowDialog(Program.MainWindow); + vm.NameWithLocation)) + { + result = dlg.ShowDialog(Program.MainWindow); + } return (result == DialogResult.Yes); } } diff --git a/XenAdmin/Dialogs/VMAppliances/VMAppliancesDialog.cs b/XenAdmin/Dialogs/VMAppliances/VMAppliancesDialog.cs index be7846404..409aaaa34 100644 --- a/XenAdmin/Dialogs/VMAppliances/VMAppliancesDialog.cs +++ b/XenAdmin/Dialogs/VMAppliances/VMAppliancesDialog.cs @@ -368,12 +368,14 @@ namespace XenAdmin.Dialogs.VMAppliances text = string.Format(numberOfProtectedVMs == 0 ? Messages.CONFIRM_DELETE_VM_APPLIANCES_0 : Messages.CONFIRM_DELETE_VM_APPLIANCES, numberOfProtectedVMs); } - if (new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, text, Messages.DELETE_VM_APPLIANCE_TITLE), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(this) == DialogResult.Yes) - - new DestroyVMApplianceAction(Pool.Connection, selectedAppliances).RunAsync(); + ThreeButtonDialog.ButtonNo)) + { + if (dlg.ShowDialog(this) == DialogResult.Yes) + new DestroyVMApplianceAction(Pool.Connection, selectedAppliances).RunAsync(); + } } private void toolStripButtonEdit_Click(object sender, EventArgs e) diff --git a/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.cs b/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.cs index e2113a028..a8aed37b9 100644 --- a/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.cs +++ b/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.cs @@ -92,12 +92,12 @@ namespace XenAdmin.Dialogs.VMDialogs buttonMove.Enabled = srPicker1.SR != null; } - private void srPicker1_ItemSelectionNull(object sender, EventArgs e) + private void srPicker1_ItemSelectionNull() { EnableMoveButton(); } - private void srPicker1_ItemSelectionNotNull(object sender, EventArgs e) + private void srPicker1_ItemSelectionNotNull() { EnableMoveButton(); } diff --git a/XenAdmin/Dialogs/VMProtectionRecovery/VMProtectionPoliciesDialog.cs b/XenAdmin/Dialogs/VMProtectionRecovery/VMProtectionPoliciesDialog.cs index f2476d5e4..1328b2f49 100644 --- a/XenAdmin/Dialogs/VMProtectionRecovery/VMProtectionPoliciesDialog.cs +++ b/XenAdmin/Dialogs/VMProtectionRecovery/VMProtectionPoliciesDialog.cs @@ -220,13 +220,14 @@ namespace XenAdmin.Dialogs.VMProtection_Recovery text = string.Format(numberOfProtectedVMs == 0 ? Messages.CONFIRM_DELETE_POLICIES_0 : Messages.CONFIRM_DELETE_POLICIES, numberOfProtectedVMs); } - if (new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, text, Messages.DELETE_VM_PROTECTION_TITLE), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(this) == DialogResult.Yes) - - new DestroyPolicyAction(Pool.Connection, selectedPolicies).RunAsync(); - + ThreeButtonDialog.ButtonNo)) + { + if (dlg.ShowDialog(this) == DialogResult.Yes) + new DestroyPolicyAction(Pool.Connection, selectedPolicies).RunAsync(); + } } private VMPP currentSelected = null; diff --git a/XenAdmin/Dialogs/WarningDialogs/InstallToolsWarningDialog.cs b/XenAdmin/Dialogs/WarningDialogs/InstallToolsWarningDialog.cs index 5ae6e6864..192908154 100644 --- a/XenAdmin/Dialogs/WarningDialogs/InstallToolsWarningDialog.cs +++ b/XenAdmin/Dialogs/WarningDialogs/InstallToolsWarningDialog.cs @@ -88,14 +88,16 @@ namespace XenAdmin.Dialogs if (sr.IsToolsSR && sr.IsBroken()) { Hide(); - if (new ThreeButtonDialog( - new ThreeButtonDialog.Details( - SystemIcons.Warning, - Messages.BROKEN_TOOLS_PROMPT, - Messages.INSTALL_XS_TOOLS), - ThreeButtonDialog.ButtonOK, - ThreeButtonDialog.ButtonCancel - ).ShowDialog(this) != DialogResult.OK) + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.BROKEN_TOOLS_PROMPT, + Messages.INSTALL_XS_TOOLS), + ThreeButtonDialog.ButtonOK, + ThreeButtonDialog.ButtonCancel)) + { + dialogResult = dlg.ShowDialog(this); + } + if (dialogResult != DialogResult.OK) { DialogResult = DialogResult.No; Close(); diff --git a/XenAdmin/Dialogs/Wlb/WlbConfigurationDialog.cs b/XenAdmin/Dialogs/Wlb/WlbConfigurationDialog.cs index 0704f69c2..14aefc01f 100644 --- a/XenAdmin/Dialogs/Wlb/WlbConfigurationDialog.cs +++ b/XenAdmin/Dialogs/Wlb/WlbConfigurationDialog.cs @@ -110,9 +110,11 @@ namespace XenAdmin.Dialogs.Wlb private WlbPoolConfiguration RetrieveWLBConfiguration() { RetrieveWlbConfigurationAction action = new RetrieveWlbConfigurationAction(_pool); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks); - dialog.ShowCancel = true; - dialog.ShowDialog(this); + using (ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } if (!action.Succeeded || null == action.WlbConfiguration || action.WlbConfiguration.Count == 0) { diff --git a/XenAdmin/Dialogs/Wlb/WlbCredentialsDialog.cs b/XenAdmin/Dialogs/Wlb/WlbCredentialsDialog.cs index 65dee6ea0..a0af39640 100644 --- a/XenAdmin/Dialogs/Wlb/WlbCredentialsDialog.cs +++ b/XenAdmin/Dialogs/Wlb/WlbCredentialsDialog.cs @@ -156,9 +156,11 @@ namespace XenAdmin.Dialogs.Wlb EnableWLBAction action = new EnableWLBAction(_pool); // We will need to re-enable buttons when the action completes action.Completed += Program.MainWindow.action_Completed; - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks); - dialog.ShowCancel = true; - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } Program.MainWindow.UpdateToolbars(); return action.Succeeded; @@ -182,9 +184,11 @@ namespace XenAdmin.Dialogs.Wlb string xsPassword = textboxXSPassword.Text; InitializeWLBAction action = new InitializeWLBAction(_pool, wlbUrl, wlbUserName, wlbPassword, xsUserName, xsPassword); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks); - dialog.ShowCancel = true; - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } Program.MainWindow.UpdateToolbars(); return action.Succeeded; diff --git a/XenAdmin/Dialogs/Wlb/WlbReportSubscriptionDialog.cs b/XenAdmin/Dialogs/Wlb/WlbReportSubscriptionDialog.cs index bdcc1cbc6..a7b0b0fb7 100644 --- a/XenAdmin/Dialogs/Wlb/WlbReportSubscriptionDialog.cs +++ b/XenAdmin/Dialogs/Wlb/WlbReportSubscriptionDialog.cs @@ -403,9 +403,11 @@ namespace XenAdmin.Dialogs.Wlb _subscription.ReportParameters = rps; SendWlbConfigurationAction action = new SendWlbConfigurationAction(this._pool, _subscription.ToDictionary(), SendWlbConfigurationKind.SetReportSubscription); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks); - dialog.ShowCancel = true; - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } if (action.Succeeded) { @@ -414,11 +416,14 @@ namespace XenAdmin.Dialogs.Wlb } else if(!action.Cancelled) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, String.Format(Messages.WLB_SUBSCRIPTION_ERROR, _subscription.Description), - Messages.XENCENTER)).ShowDialog(this); + Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } //log.ErrorFormat("There was an error calling SendWlbConfigurationAction to SetReportSubscription {0}, Action Result: {1}.", _subscription.Description, action.Result); DialogResult = DialogResult.None; } diff --git a/XenAdmin/Help/HelpManager.cs b/XenAdmin/Help/HelpManager.cs index ed236c0ac..76857bf0b 100644 --- a/XenAdmin/Help/HelpManager.cs +++ b/XenAdmin/Help/HelpManager.cs @@ -72,11 +72,14 @@ namespace XenAdmin.Help log.DebugFormat("Help ID for {0} is {1}", pageref, s); if (Properties.Settings.Default.DebugHelp && !Program.RunInAutomatedTestMode) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Information, string.Format(Messages.MESSAGEBOX_HELP_TOPICS, s, pageref), - Messages.XENCENTER)).ShowDialog(w); + Messages.XENCENTER))) + { + dlg.ShowDialog(w); + } } w.ShowHelpTopic(s); } @@ -88,11 +91,14 @@ namespace XenAdmin.Help { if (Properties.Settings.Default.DebugHelp) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.MESSAGEBOX_HELP_TOPIC_NOT_FOUND, pageref), - Messages.MESSAGEBOX_HELP_TOPIC_NOT_FOUND)).ShowDialog(w); + Messages.MESSAGEBOX_HELP_TOPIC_NOT_FOUND))) + { + dlg.ShowDialog(w); + } } w.ShowHelpTOC(); } @@ -106,11 +112,14 @@ namespace XenAdmin.Help { if (Properties.Settings.Default.DebugHelp) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.MESSAGEBOX_HELP_TOPIC_NOT_FOUND, pageref), - Messages.MESSAGEBOX_HELP_TOPIC_NOT_FOUND)).ShowDialog(w); + Messages.MESSAGEBOX_HELP_TOPIC_NOT_FOUND))) + { + dlg.ShowDialog(w); + } } w.ShowHelpTOC(); } diff --git a/XenAdmin/MainWindow.cs b/XenAdmin/MainWindow.cs index 65d1ca803..7feb3b77e 100644 --- a/XenAdmin/MainWindow.cs +++ b/XenAdmin/MainWindow.cs @@ -514,11 +514,14 @@ namespace XenAdmin { log.Error("Could not load settings.", ex); Program.CloseSplash(); - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.MESSAGEBOX_LOAD_CORRUPTED, Settings.GetUserConfigPath()), - Messages.MESSAGEBOX_LOAD_CORRUPTED_TITLE)).ShowDialog(this); + Messages.MESSAGEBOX_LOAD_CORRUPTED_TITLE))) + { + dlg.ShowDialog(this); + } Application.Exit(); return; // Application.Exit() does not exit the current method. } @@ -1725,10 +1728,11 @@ namespace XenAdmin private void DoLicenseAction(Host host, string filePath) { ApplyLicenseAction action = new ApplyLicenseAction(host.Connection, host, filePath); - ActionProgressDialog actionProgress = new ActionProgressDialog(action, ProgressBarStyle.Marquee); - - actionProgress.Text = Messages.INSTALL_LICENSE_KEY; - actionProgress.ShowDialog(this); + using (var actionProgress = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) + { + actionProgress.Text = Messages.INSTALL_LICENSE_KEY; + actionProgress.ShowDialog(this); + } } private void dialog_HelpRequest(object sender, EventArgs e) @@ -2137,11 +2141,14 @@ namespace XenAdmin } catch (ConfigurationErrorsException ex) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.MESSAGEBOX_SAVE_CORRUPTED, Settings.GetUserConfigPath()), - Messages.MESSAGEBOX_SAVE_CORRUPTED_TITLE)).ShowDialog(this); + Messages.MESSAGEBOX_SAVE_CORRUPTED_TITLE))) + { + dlg.ShowDialog(this); + } log.Error("Couldn't save settings"); log.Error(ex, ex); } @@ -3039,11 +3046,15 @@ namespace XenAdmin var details = new ThreeButtonDialog.Details(SystemIcons.Exclamation, args.Length == 0 ? msg : string.Format(msg, args), title); - var dialog = String.IsNullOrEmpty(helpName) + DialogResult dialogResult; + using (var dialog = String.IsNullOrEmpty(helpName) ? new ThreeButtonDialog(details, buttons) - : new ThreeButtonDialog(details, helpName, buttons); + : new ThreeButtonDialog(details, helpName, buttons)) + { + dialogResult = dialog.ShowDialog(parent ?? Program.MainWindow); + } - if (dialog.ShowDialog(parent ?? Program.MainWindow) != DialogResult.Yes) + if (dialogResult != DialogResult.Yes) return false; @@ -3072,11 +3083,14 @@ namespace XenAdmin if (parent.Disposing || parent.IsDisposed) return; } - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, Messages.DISCONNECTED_BEFORE_ACTION_STARTED, - Messages.XENCENTER)).ShowDialog(parent); + Messages.XENCENTER))) + { + dlg.ShowDialog(parent); + } } private static void Trim(object[] args) @@ -3161,9 +3175,11 @@ namespace XenAdmin { log.ErrorFormat("Failed to import server list from '{0}'", dialog.FileName); - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Error, Messages.ERRO_IMPORTING_SERVER_LIST, Messages.XENCENTER)) - .ShowDialog(this); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Error, Messages.ERRO_IMPORTING_SERVER_LIST, Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } } } } diff --git a/XenAdmin/Network/XenConnectionUI.cs b/XenAdmin/Network/XenConnectionUI.cs index e36ffb105..c8bc39374 100644 --- a/XenAdmin/Network/XenConnectionUI.cs +++ b/XenAdmin/Network/XenConnectionUI.cs @@ -129,33 +129,43 @@ namespace XenAdmin.Network { if (pool_name == oldHost) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Information, string.Format(Messages.OLD_CONNECTION_ALREADY_CONNECTED, pool_name), - Messages.ADD_NEW_CONNECT_TO)).ShowDialog(owner); + Messages.ADD_NEW_CONNECT_TO))) + { + dlg.ShowDialog(owner); + } } else { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Information, string.Format(Messages.SLAVE_ALREADY_CONNECTED, oldHost, pool_name), - Messages.ADD_NEW_CONNECT_TO)).ShowDialog(owner); + Messages.ADD_NEW_CONNECT_TO))) + { + dlg.ShowDialog(owner); + } } } } else { - if (DialogResult.Yes == - new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, String.Format(Messages.SLAVE_CONNECTION_ERROR, oldHost, poolMasterName), Messages.CONNECT_TO_SERVER), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(owner)) + ThreeButtonDialog.ButtonNo)) + { + dialogResult = dlg.ShowDialog(owner); + } + if (DialogResult.Yes == dialogResult) { ((XenConnection) connection).Hostname = poolMasterName; BeginConnect(connection, true, owner, false); @@ -231,11 +241,14 @@ namespace XenAdmin.Network { ConnectionExists c = error as ConnectionExists; - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Information, c.GetDialogMessage(connection), - Messages.XENCENTER)).ShowDialog(owner); + Messages.XENCENTER))) + { + dlg.ShowDialog(owner); + } } } else if (error is ArgumentException) @@ -279,21 +292,29 @@ namespace XenAdmin.Network if (((XenConnection)connection).fromDialog) { - if (DialogResult.Retry == new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Error, text, Messages.CONNECT_TO_SERVER), new ThreeButtonDialog.TBDButton(Messages.RETRY_BUTTON_LABEL, DialogResult.Retry, ThreeButtonDialog.ButtonType.ACCEPT, true), - ThreeButtonDialog.ButtonCancel).ShowDialog(owner)) + ThreeButtonDialog.ButtonCancel)) + { + dialogResult = dlg.ShowDialog(owner); + } + if (DialogResult.Retry == dialogResult) { new AddServerDialog(connection, false).Show(owner); } } else { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, text, - Messages.CONNECT_TO_SERVER)).ShowDialog(owner); + Messages.CONNECT_TO_SERVER))) + { + dlg.ShowDialog(owner); + } } } diff --git a/XenAdmin/PasswordsRequest.cs b/XenAdmin/PasswordsRequest.cs index 2d8a68be4..9be50ad1b 100644 --- a/XenAdmin/PasswordsRequest.cs +++ b/XenAdmin/PasswordsRequest.cs @@ -217,11 +217,14 @@ namespace XenAdmin catch (ConfigurationErrorsException ex) { log.Error("Could not load settings.", ex); - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.MESSAGEBOX_LOAD_CORRUPTED, Settings.GetUserConfigPath()), - Messages.MESSAGEBOX_LOAD_CORRUPTED_TITLE)).ShowDialog(Program.MainWindow); + Messages.MESSAGEBOX_LOAD_CORRUPTED_TITLE))) + { + dlg.ShowDialog(Program.MainWindow); + } Application.Exit(); return; } @@ -239,11 +242,14 @@ namespace XenAdmin } catch (Exception exn) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.MESSAGEBOX_PASSWORD_WRITE_FAILED, exn.Message), - Messages.XENCENTER)).ShowDialog(Program.MainWindow); + Messages.XENCENTER))) + { + dlg.ShowDialog(Program.MainWindow); + } Application.Exit(); } } diff --git a/XenAdmin/Program.cs b/XenAdmin/Program.cs index ef7a2accf..0cbeaceeb 100644 --- a/XenAdmin/Program.cs +++ b/XenAdmin/Program.cs @@ -205,7 +205,7 @@ namespace XenAdmin log.Error("Could not load settings.", ex); var msg = string.Format("{0}\n\n{1}", Messages.MESSAGEBOX_LOAD_CORRUPTED_TITLE, string.Format(Messages.MESSAGEBOX_LOAD_CORRUPTED, Settings.GetUserConfigPath())); - var dlog = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error,msg,Messages.XENCENTER)) + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error,msg,Messages.XENCENTER)) { StartPosition = FormStartPosition.CenterScreen, //For reasons I do not fully comprehend at the moment, the runtime @@ -213,8 +213,10 @@ namespace XenAdmin //ShowInTaskbar is false. However it's a good idea anyway to show it //in the taskbar since the main form is not launcched at this point. ShowInTaskbar = true - }; - dlog.ShowDialog(); + }) + { + dlg.ShowDialog(); + } Application.Exit(); return; } @@ -583,17 +585,18 @@ namespace XenAdmin { string filepath = GetLogFile(); - ThreeButtonDialog d = new ThreeButtonDialog( + using (var d = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, String.Format(Messages.MESSAGEBOX_PROGRAM_UNEXPECTED, HelpersGUI.DateTimeToString(DateTime.Now, "yyyy-MM-dd HH:mm:ss", false), filepath), - Messages.MESSAGEBOX_PROGRAM_UNEXPECTED_TITLE)); - - // CA-44733 - if (MainWindow != null && !IsExiting(MainWindow) && !MainWindow.InvokeRequired) - d.ShowDialog(MainWindow); - else - d.ShowDialog(); + Messages.MESSAGEBOX_PROGRAM_UNEXPECTED_TITLE))) + { + // CA-44733 + if (MainWindow != null && !IsExiting(MainWindow) && !MainWindow.InvokeRequired) + d.ShowDialog(MainWindow); + else + d.ShowDialog(); + } } } catch (Exception exception) @@ -607,7 +610,10 @@ namespace XenAdmin } if (!RunInAutomatedTestMode) { - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, exception.ToString(), Messages.XENCENTER)).ShowDialog(); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, exception.ToString(), Messages.XENCENTER))) + { + dlg.ShowDialog(); + } // To be handled by WER throw; } @@ -742,7 +748,10 @@ namespace XenAdmin } else { - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, msg, Messages.MESSAGEBOX_PROGRAM_UNEXPECTED_TITLE)).ShowDialog(); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, msg, Messages.MESSAGEBOX_PROGRAM_UNEXPECTED_TITLE))) + { + dlg.ShowDialog(); + } } } @@ -751,7 +760,10 @@ namespace XenAdmin string s = GetLogFile_(); if (s == null) { - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.MESSAGEBOX_LOGFILE_MISSING, Messages.XENCENTER)).ShowDialog(); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.MESSAGEBOX_LOGFILE_MISSING, Messages.XENCENTER))) + { + dlg.ShowDialog(); + } } else { diff --git a/XenAdmin/Settings.cs b/XenAdmin/Settings.cs index efcf7ec24..be276983f 100644 --- a/XenAdmin/Settings.cs +++ b/XenAdmin/Settings.cs @@ -407,12 +407,15 @@ namespace XenAdmin catch (ConfigurationErrorsException ex) { // Show a warning to the user and exit the application. - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.MESSAGEBOX_SAVE_CORRUPTED, Settings.GetUserConfigPath()), Messages.MESSAGEBOX_SAVE_CORRUPTED_TITLE) - ).ShowDialog(Program.MainWindow); + )) + { + dlg.ShowDialog(Program.MainWindow); + } log.Error("Could not save settings. Exiting application."); log.Error(ex, ex); @@ -465,7 +468,10 @@ namespace XenAdmin // Ugly, but we need to warn the user... if (!Program.RunInAutomatedTestMode) - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Exclamation, Messages.MESSAGEBOX_SESSION_SAVE_UNABLE, Messages.MESSAGEBOX_SESSION_SAVE_UNABLE_TITLE)).ShowDialog(); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Exclamation, Messages.MESSAGEBOX_SESSION_SAVE_UNABLE, Messages.MESSAGEBOX_SESSION_SAVE_UNABLE_TITLE))) + { + dlg.ShowDialog(); + } } } diff --git a/XenAdmin/SettingsPanels/CPUMemoryEditPage.cs b/XenAdmin/SettingsPanels/CPUMemoryEditPage.cs index 14021a22f..2abf10485 100644 --- a/XenAdmin/SettingsPanels/CPUMemoryEditPage.cs +++ b/XenAdmin/SettingsPanels/CPUMemoryEditPage.cs @@ -306,9 +306,15 @@ namespace XenAdmin.SettingsPanels if (!Program.RunInAutomatedTestMode && vm.power_state != vm_power_state.Halted) { if (!HasMemoryChanged) - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Information, Messages.VM_VCPU_CHANGES_NOT_SUPPORTED_MESSAGE, Messages.VM_LIVE_CHANGES_NOT_SUPPORTED_TITLE)).ShowDialog(); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Information, Messages.VM_VCPU_CHANGES_NOT_SUPPORTED_MESSAGE, Messages.VM_LIVE_CHANGES_NOT_SUPPORTED_TITLE))) + { + dlg.ShowDialog(); + } else if (!MROrGreater) - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Information, Messages.VM_VCPU_CHANGES_NOT_SUPPORTED_MESSAGE, Messages.VM_LIVE_CHANGES_NOT_SUPPORTED_TITLE)).ShowDialog(); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Information, Messages.VM_VCPU_CHANGES_NOT_SUPPORTED_MESSAGE, Messages.VM_LIVE_CHANGES_NOT_SUPPORTED_TITLE))) + { + dlg.ShowDialog(); + } // If it is >= Midnight Ride, and memory has changed (which can only happen in the free version), // we have already given a message in ValidToSave that the VM will be forcibly rebooted, so no // further message is needed here. diff --git a/XenAdmin/SettingsPanels/VBDEditPage.cs b/XenAdmin/SettingsPanels/VBDEditPage.cs index f253426c1..4e53cc3a0 100644 --- a/XenAdmin/SettingsPanels/VBDEditPage.cs +++ b/XenAdmin/SettingsPanels/VBDEditPage.cs @@ -276,13 +276,21 @@ namespace XenAdmin.SettingsPanels { // Check user has entered valid params if (DevicePositionChanged && - vdi.type == vdi_type.system && - DialogResult.Yes != new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.EDIT_SYS_DISK_WARNING, Messages.EDIT_SYS_DISK_WARNING_TITLE), - ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(this)) + vdi.type == vdi_type.system) { - return null; + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.EDIT_SYS_DISK_WARNING, + Messages.EDIT_SYS_DISK_WARNING_TITLE), + ThreeButtonDialog.ButtonYes, + ThreeButtonDialog.ButtonNo)) + { + dialogResult = dlg.ShowDialog(this); + } + if (DialogResult.Yes != dialogResult) + { + return null; + } } bool diskAccessPriorityEnabled = diskAccessPriorityTrackBar.Enabled; @@ -343,12 +351,14 @@ namespace XenAdmin.SettingsPanels ) ) { - Program.Invoke(Program.MainWindow, () => new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Information, - Messages. - DEVICE_POSITION_RESTART_REQUIRED, - Messages.XENCENTER)). - ShowDialog(Program.MainWindow)); + Program.Invoke(Program.MainWindow, () => + { + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Information, Messages.DEVICE_POSITION_RESTART_REQUIRED, Messages.XENCENTER))) + { + dlg.ShowDialog(Program.MainWindow); + } + }); } } diff --git a/XenAdmin/SettingsPanels/Wlb/WlbAutomationPage.cs b/XenAdmin/SettingsPanels/Wlb/WlbAutomationPage.cs index a26d2ba82..77cd56b38 100644 --- a/XenAdmin/SettingsPanels/Wlb/WlbAutomationPage.cs +++ b/XenAdmin/SettingsPanels/Wlb/WlbAutomationPage.cs @@ -217,11 +217,14 @@ namespace XenAdmin.SettingsPanels (!_poolConfiguration.HostConfigurations.ContainsKey(host.uuid) || !_poolConfiguration.HostConfigurations[host.uuid].LastPowerOnSucceeded)) { - DialogResult dr = - new ThreeButtonDialog( + DialogResult dr; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.WLB_UNTESTED_HOST_WARNING, Messages.WLB_UNTESTED_HOST_CAPTION), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(); + ThreeButtonDialog.ButtonNo)) + { + dr = dlg.ShowDialog(); + } if (dr == DialogResult.No) { e.NewValue = e.CurrentValue; diff --git a/XenAdmin/TabPages/AdPage.cs b/XenAdmin/TabPages/AdPage.cs index f8a9d8383..8151b0fab 100644 --- a/XenAdmin/TabPages/AdPage.cs +++ b/XenAdmin/TabPages/AdPage.cs @@ -733,13 +733,17 @@ namespace XenAdmin.TabPages string msg = string.Format(Messages.AD_LEAVE_CONFIRM, Helpers.GetName(pool).Ellipsise(50).EscapeAmpersands(), Domain); - DialogResult r = new ThreeButtonDialog( + DialogResult r; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( null, msg, Messages.AD_FEATURE_NAME), ThreeButtonDialog.ButtonYes, - new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(this); + new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) + { + r = dlg.ShowDialog(this); + } //CA-64818: DialogResult can be No if the No button has been hit //or Cancel if the dialog has been closed from the control box @@ -752,10 +756,14 @@ namespace XenAdmin.TabPages string msg = string.Format(pool.name_label.Length > 0 ? Messages.AD_LEAVE_WARNING : Messages.AD_LEAVE_WARNING_HOST, Helpers.GetName(pool).Ellipsise(50), Domain); - DialogResult r = new ThreeButtonDialog( + DialogResult r; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.ACTIVE_DIRECTORY_TAB_TITLE), ThreeButtonDialog.ButtonYes, - new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(this); + new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) + { + r = dlg.ShowDialog(this); + } //CA-64818: DialogResult can be No if the No button has been hit //or Cancel if the dialog has been closed from the control box @@ -831,13 +839,17 @@ namespace XenAdmin.TabPages ? string.Format(Messages.QUESTION_REMOVE_AD_USER_ONE, subjectsToRemove[0].DisplayName ?? subjectsToRemove[0].SubjectName) : string.Format(Messages.QUESTION_REMOVE_AD_USER_MANY, subjectsToRemove.Count); - DialogResult questionDialog = new ThreeButtonDialog( + DialogResult questionDialog; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( null, removeMessage, Messages.AD_FEATURE_NAME), ThreeButtonDialog.ButtonYes, - new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(this); + new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) + { + questionDialog = dlg.ShowDialog(this); + } //CA-64818: DialogResult can be No if the No button has been hit //or Cancel if the dialog has been closed from the control box @@ -864,13 +876,17 @@ namespace XenAdmin.TabPages string msg = string.Format(entry.IsGroup ? Messages.AD_CONFIRM_SUICIDE_GROUP : Messages.AD_CONFIRM_SUICIDE, subjectName, Helpers.GetName(pool).Ellipsise(50)); - DialogResult r = new ThreeButtonDialog( + DialogResult r; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, msg, Messages.AD_FEATURE_NAME), ThreeButtonDialog.ButtonYes, - new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(this); + new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) + { + r = dlg.ShowDialog(this); + } //CA-64818: DialogResult can be No if the No button has been hit //or Cancel if the dialog has been closed from the control box @@ -1019,9 +1035,9 @@ namespace XenAdmin.TabPages if (Helpers.FeatureForbidden(pool.Connection, Host.RestrictRBAC)) { // Show upsell dialog - UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_RBAC : Messages.UPSELL_BLURB_RBAC + Messages.UPSELL_BLURB_RBAC_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_RBAC); - dlg.ShowDialog(this); + using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_RBAC : Messages.UPSELL_BLURB_RBAC + Messages.UPSELL_BLURB_RBAC_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_RBAC)) + dlg.ShowDialog(this); return; } @@ -1077,13 +1093,17 @@ namespace XenAdmin.TabPages { if (entry.opaque_ref == session.Subject) { - DialogResult r = new ThreeButtonDialog( + DialogResult r; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, warnMsg, Messages.AD_FEATURE_NAME), ThreeButtonDialog.ButtonYes, - new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(this); + new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) + { + r = dlg.ShowDialog(this); + } //CA-64818: DialogResult can be No if the No button has been hit //or Cancel if the dialog has been closed from the control box @@ -1102,13 +1122,17 @@ namespace XenAdmin.TabPages if (!suicide)//CA-68645 { - DialogResult questionDialog = new ThreeButtonDialog( - new ThreeButtonDialog.Details( - SystemIcons.Warning, - logoutMessage, - Messages.AD_FEATURE_NAME), - ThreeButtonDialog.ButtonYes, - new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(this); + DialogResult questionDialog; + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details( + SystemIcons.Warning, + logoutMessage, + Messages.AD_FEATURE_NAME), + ThreeButtonDialog.ButtonYes, + new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) + { + questionDialog = dlg.ShowDialog(this); + } //CA-64818: DialogResult can be No if the No button has been hit //or Cancel if the dialog has been closed from the control box diff --git a/XenAdmin/TabPages/GeneralTabPage.cs b/XenAdmin/TabPages/GeneralTabPage.cs index 7cce38e55..6708f78e3 100644 --- a/XenAdmin/TabPages/GeneralTabPage.cs +++ b/XenAdmin/TabPages/GeneralTabPage.cs @@ -1861,7 +1861,10 @@ namespace XenAdmin.TabPages catch (Exception ex) { log.Error("Error starting PuTTY.", ex); - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.ERROR_PUTTY_LAUNCHING, Messages.XENCENTER)).ShowDialog(Parent); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.ERROR_PUTTY_LAUNCHING, Messages.XENCENTER))) + { + dlg.ShowDialog(Parent); + } } } } diff --git a/XenAdmin/TabPages/HAPage.cs b/XenAdmin/TabPages/HAPage.cs index f0c8f94b2..7be4d3688 100644 --- a/XenAdmin/TabPages/HAPage.cs +++ b/XenAdmin/TabPages/HAPage.cs @@ -628,14 +628,18 @@ namespace XenAdmin.TabPages } // Offer to disable HA - DialogResult dr = new ThreeButtonDialog( + DialogResult dr; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( null, string.Format(Messages.HA_DISABLE_QUERY, Helpers.GetName(pool).Ellipsise(30)), Messages.DISABLE_HA), "HADisable", ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(this); + ThreeButtonDialog.ButtonNo)) + { + dr = dlg.ShowDialog(this); + } if (dr != DialogResult.Yes) return; diff --git a/XenAdmin/TabPages/HistoryPage.cs b/XenAdmin/TabPages/HistoryPage.cs index 5b2ed5d83..6769a09d2 100644 --- a/XenAdmin/TabPages/HistoryPage.cs +++ b/XenAdmin/TabPages/HistoryPage.cs @@ -327,14 +327,23 @@ namespace XenAdmin.TabPages private void row_DismissalRequested(DataGridViewActionRow row) { - if (ConnectionsManager.History.Count > 0 && - (Program.RunInAutomatedTestMode || - new ThreeButtonDialog( - new ThreeButtonDialog.Details(null, Messages.MESSAGEBOX_LOG_DELETE), - ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(this) == DialogResult.Yes)) + if (ConnectionsManager.History.Count > 0) { - ConnectionsManager.History.Remove(row.Action); + DialogResult dialogResult = DialogResult.Yes; + if (!Program.RunInAutomatedTestMode) + { + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(null, Messages.MESSAGEBOX_LOG_DELETE), + ThreeButtonDialog.ButtonYes, + ThreeButtonDialog.ButtonNo)) + { + dialogResult = dlg.ShowDialog(this); + } + } + if (dialogResult == DialogResult.Yes) + { + ConnectionsManager.History.Remove(row.Action); + } } } diff --git a/XenAdmin/TabPages/ManageUpdatesPage.cs b/XenAdmin/TabPages/ManageUpdatesPage.cs index ace378229..d937ba55c 100644 --- a/XenAdmin/TabPages/ManageUpdatesPage.cs +++ b/XenAdmin/TabPages/ManageUpdatesPage.cs @@ -649,11 +649,14 @@ namespace XenAdmin.TabPages string disconnectedServerNames = clickedRow.Cells[ColumnLocation.Index].Value.ToString(); - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.UPDATES_WIZARD_DISCONNECTED_SERVER, disconnectedServerNames), - Messages.UPDATES_WIZARD)).ShowDialog(this); + Messages.UPDATES_WIZARD))) + { + dlg.ShowDialog(this); + } } }); } @@ -904,11 +907,14 @@ namespace XenAdmin.TabPages } catch (Exception) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.LICENSE_SERVER_COULD_NOT_OPEN_LINK, InvisibleMessages.LICENSE_SERVER_DOWNLOAD_LINK), - Messages.XENCENTER)).ShowDialog(this); + Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } } } diff --git a/XenAdmin/TabPages/PerformancePage.cs b/XenAdmin/TabPages/PerformancePage.cs index a28e53c8c..6e52d66a9 100644 --- a/XenAdmin/TabPages/PerformancePage.cs +++ b/XenAdmin/TabPages/PerformancePage.cs @@ -303,9 +303,9 @@ namespace XenAdmin.TabPages private void ShowUpsell() { - UpsellDialog upsellDialog = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_PERFORMANCE : Messages.UPSELL_BLURB_PERFORMANCE + Messages.UPSELL_BLURB_PERFORMANCE_MORE, - InvisibleMessages.UPSELL_LEARNMOREURL_PERFORMANCE); - upsellDialog.ShowDialog(this); + using (var upsellDialog = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_PERFORMANCE : Messages.UPSELL_BLURB_PERFORMANCE + Messages.UPSELL_BLURB_PERFORMANCE_MORE, + InvisibleMessages.UPSELL_LEARNMOREURL_PERFORMANCE)) + upsellDialog.ShowDialog(this); } private void MoveGraphUp() diff --git a/XenAdmin/TabPages/SnapshotsPage.cs b/XenAdmin/TabPages/SnapshotsPage.cs index 5271e9244..f7179406a 100644 --- a/XenAdmin/TabPages/SnapshotsPage.cs +++ b/XenAdmin/TabPages/SnapshotsPage.cs @@ -1518,10 +1518,15 @@ namespace XenAdmin.TabPages else text = string.Format(Messages.ARCHIVE_SNAPSHOT_NOW_TEXT_MULTIPLE, VM.Connection.Resolve(VM.protection_policy).archive_target_config_location); - if (new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Information, text, Messages.ARCHIVE_VM_PROTECTION_TITLE), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog() == DialogResult.Yes) + ThreeButtonDialog.ButtonNo)) + { + dialogResult = dlg.ShowDialog(this); + } + if (dialogResult == DialogResult.Yes) { foreach (var snapshot in selectedSnapshots) { @@ -1531,14 +1536,21 @@ namespace XenAdmin.TabPages } else { - if (new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Error, Messages.POLICY_DOES_NOT_HAVE_ARCHIVE, Messages.POLICY_DOES_NOT_HAVE_ARCHIVE_TITLE), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog() == DialogResult.Yes) + ThreeButtonDialog.ButtonNo)) { - var dialog = new PropertiesDialog(vmpp); - dialog.SelectNewPolicyArchivePage(); - dialog.ShowDialog(this); + dialogResult = dlg.ShowDialog(this); + } + if (dialogResult == DialogResult.Yes) + { + using (var dialog = new PropertiesDialog(vmpp)) + { + dialog.SelectNewPolicyArchivePage(); + dialog.ShowDialog(this); + } } } } diff --git a/XenAdmin/TabPages/WLBPage.cs b/XenAdmin/TabPages/WLBPage.cs index 88270c54e..1206df72c 100644 --- a/XenAdmin/TabPages/WLBPage.cs +++ b/XenAdmin/TabPages/WLBPage.cs @@ -209,9 +209,11 @@ namespace XenAdmin.TabPages } SendWlbConfigurationAction action = new SendWlbConfigurationAction(_pool, PoolConfiguration.ToDictionary(), kind); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks); - dialog.ShowCancel = true; - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } Program.MainWindow.UpdateToolbars(); } @@ -550,10 +552,14 @@ namespace XenAdmin.TabPages if (scheduledPerfMode != _wlbPoolConfiguration.PerformanceMode) { string blurb = string.Format(Messages.WLB_PROMPT_FOR_MODE_CHANGE_BLURB, getOptModeText(scheduledPerfMode), getOptModeText(_wlbPoolConfiguration.PerformanceMode)); - DialogResult drModeCheck = new ThreeButtonDialog( + DialogResult drModeCheck; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(null, blurb, Messages.WLB_PROMPT_FOR_MODE_CHANGE_CAPTION), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(this); + ThreeButtonDialog.ButtonNo)) + { + drModeCheck = dlg.ShowDialog(this); + } if (drModeCheck == DialogResult.Yes) { diff --git a/XenAdmin/TestResources/credits.xml b/XenAdmin/TestResources/credits.xml index c363b6809..6d70f1fe5 100755 --- a/XenAdmin/TestResources/credits.xml +++ b/XenAdmin/TestResources/credits.xml @@ -18,7 +18,7 @@ - + diff --git a/XenAdmin/WinformsXenAdminConfigProvider.cs b/XenAdmin/WinformsXenAdminConfigProvider.cs index 2d2b3a349..7bf14bb78 100644 --- a/XenAdmin/WinformsXenAdminConfigProvider.cs +++ b/XenAdmin/WinformsXenAdminConfigProvider.cs @@ -109,9 +109,12 @@ namespace XenAdmin catch (ConfigurationErrorsException e) { log.Error("Error parsing 'ProxySetting' from settings - settings file deemed corrupt", e); - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, string.Format(Messages.MESSAGEBOX_LOAD_CORRUPTED, Settings.GetUserConfigPath()), - Messages.MESSAGEBOX_LOAD_CORRUPTED_TITLE)).ShowDialog(); + Messages.MESSAGEBOX_LOAD_CORRUPTED_TITLE))) + { + dlg.ShowDialog(); + } Environment.Exit(1); } diff --git a/XenAdmin/Wizards/BugToolWizardFiles/BugToolPageDestination.cs b/XenAdmin/Wizards/BugToolWizardFiles/BugToolPageDestination.cs index 13a0e0dae..48a907351 100644 --- a/XenAdmin/Wizards/BugToolWizardFiles/BugToolPageDestination.cs +++ b/XenAdmin/Wizards/BugToolWizardFiles/BugToolPageDestination.cs @@ -198,7 +198,8 @@ namespace XenAdmin.Wizards.BugToolWizardFiles Registry.HealthCheckUploadTokenDomainName, Registry.HealthCheckDiagnosticDomainName, Registry.HealthCheckProductKey, TokenExpiration, false); - new ActionProgressDialog(action, ProgressBarStyle.Blocks).ShowDialog(Parent); + using (var dlg = new ActionProgressDialog(action, ProgressBarStyle.Blocks)) + dlg.ShowDialog(Parent); if (!action.Succeeded) { diff --git a/XenAdmin/Wizards/BugToolWizardFiles/BugToolPageSelectCapabilities.cs b/XenAdmin/Wizards/BugToolWizardFiles/BugToolPageSelectCapabilities.cs index 54f89c46c..89c451bd6 100644 --- a/XenAdmin/Wizards/BugToolWizardFiles/BugToolPageSelectCapabilities.cs +++ b/XenAdmin/Wizards/BugToolWizardFiles/BugToolPageSelectCapabilities.cs @@ -242,11 +242,14 @@ namespace XenAdmin.Wizards.BugToolWizardFiles if (combination == null || combination.Count <= 0) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, Messages.SERVER_STATUS_REPORT_CAPABILITIES_FAILED, - Messages.SERVER_STATUS_REPORT)).ShowDialog(this); + Messages.SERVER_STATUS_REPORT))) + { + dlg.ShowDialog(this); + } cancelled = true; return; @@ -435,11 +438,14 @@ namespace XenAdmin.Wizards.BugToolWizardFiles } catch { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, Messages.HOMEPAGE_ERROR_MESSAGE, - Messages.XENCENTER)).ShowDialog(this); + Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } } } diff --git a/XenAdmin/Wizards/BugToolWizardFiles/BugToolWizard.cs b/XenAdmin/Wizards/BugToolWizardFiles/BugToolWizard.cs index a225ac98d..db4547cf8 100644 --- a/XenAdmin/Wizards/BugToolWizardFiles/BugToolWizard.cs +++ b/XenAdmin/Wizards/BugToolWizardFiles/BugToolWizard.cs @@ -80,10 +80,15 @@ namespace XenAdmin.Wizards string path = bugToolPageDestination1.OutputFile; if (File.Exists(path)) { - if (new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.FILE_X_EXISTS_OVERWRITE, path), Messages.XENCENTER), ThreeButtonDialog.ButtonOK, - new ThreeButtonDialog.TBDButton(Messages.CANCEL, DialogResult.Cancel, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(this) != DialogResult.OK) + new ThreeButtonDialog.TBDButton(Messages.CANCEL, DialogResult.Cancel, ThreeButtonDialog.ButtonType.CANCEL, true))) + { + dialogResult = dlg.ShowDialog(this); + } + if (dialogResult != DialogResult.OK) { FinishCanceled(); return; @@ -103,11 +108,14 @@ namespace XenAdmin.Wizards catch (Exception exn) { // Failure - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.COULD_NOT_WRITE_FILE, path, exn.Message), - Messages.XENCENTER)).ShowDialog(this); + Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } FinishCanceled(); return; } @@ -117,9 +125,11 @@ namespace XenAdmin.Wizards // zip up the report files and save them to the chosen file Actions.ZipStatusReportAction action = new Actions.ZipStatusReportAction(bugToolPageRetrieveData.OutputFolder, bugToolPageDestination1.OutputFile); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks); - dialog.ShowCancel = true; - dialog.ShowDialog(); + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(); + } if (!action.Succeeded) { @@ -134,8 +144,8 @@ namespace XenAdmin.Wizards var uploadAction = new Actions.UploadServerStatusReportAction(bugToolPageDestination1.OutputFile, bugToolPageDestination1.UploadToken, bugToolPageDestination1.CaseNumber, Registry.HealthCheckUploadDomainName, false); - dialog = new ActionProgressDialog(uploadAction, ProgressBarStyle.Marquee) {ShowCancel = true}; - dialog.ShowDialog(); + using (var dialog = new ActionProgressDialog(uploadAction, ProgressBarStyle.Marquee) {ShowCancel = true}) + dialog.ShowDialog(); } // Save away the output path for next time @@ -151,11 +161,14 @@ namespace XenAdmin.Wizards if (!hostList.Any(h => h.HasCrashDumps)) break; - DialogResult result = new ThreeButtonDialog( + DialogResult result; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(null, Messages.REMOVE_CRASHDUMP_QUESTION, Messages.REMOVE_CRASHDUMP_FILES), ThreeButtonDialog.ButtonYes, - ThreeButtonDialog.ButtonNo).ShowDialog(this); - + ThreeButtonDialog.ButtonNo)) + { + result = dlg.ShowDialog(this); + } if (result == DialogResult.Yes) { foreach (Host host in hostList) diff --git a/XenAdmin/Wizards/CrossPoolMigrateWizard/CrossPoolMigrateWizard.cs b/XenAdmin/Wizards/CrossPoolMigrateWizard/CrossPoolMigrateWizard.cs index f0bc1e941..8c2e422df 100644 --- a/XenAdmin/Wizards/CrossPoolMigrateWizard/CrossPoolMigrateWizard.cs +++ b/XenAdmin/Wizards/CrossPoolMigrateWizard/CrossPoolMigrateWizard.cs @@ -244,7 +244,10 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard private static void ShowErrorMessageBox(string message) { - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, message)).ShowDialog(Program.MainWindow); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, message))) + { + dlg.ShowDialog(Program.MainWindow); + } } private void CreateMappingsFromSelection(IEnumerable selection) @@ -473,9 +476,11 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard internal static void ShowWarningMessageBox(string message) { - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Warning, message, Messages.CPM_WIZARD_TITLE)).ShowDialog( - Program.MainWindow); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, message, Messages.CPM_WIZARD_TITLE))) + { + dlg.ShowDialog(Program.MainWindow); + } } } } diff --git a/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.cs b/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.cs index 30efdefde..7eedf3a7b 100644 --- a/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.cs +++ b/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.cs @@ -85,8 +85,8 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard public override void PopulatePage() { srPicker1.Usage = SrPicker.SRPickerType.MoveOrCopy; - srPicker1.ItemSelectionNotNull += new EventHandler(srPicker1_ItemSelectionNotNull); - srPicker1.ItemSelectionNull += new EventHandler(srPicker1_ItemSelectionNull); + srPicker1.ItemSelectionNotNull += srPicker1_ItemSelectionNotNull; + srPicker1.ItemSelectionNull += srPicker1_ItemSelectionNull; Host affinity = TheVM.Home(); srPicker1.Connection = TheVM.Connection; srPicker1.DiskSize = TheVM.TotalVMSize; @@ -167,12 +167,12 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard OnPageUpdated(); } - private void srPicker1_ItemSelectionNull(object sender, EventArgs e) + private void srPicker1_ItemSelectionNull() { EnableMoveButton(); } - private void srPicker1_ItemSelectionNotNull(object sender, EventArgs e) + private void srPicker1_ItemSelectionNotNull() { EnableMoveButton(); } diff --git a/XenAdmin/Wizards/DRWizards/DRFailoverWizardPrecheckPage.cs b/XenAdmin/Wizards/DRWizards/DRFailoverWizardPrecheckPage.cs index 9ba7078c0..218bb3955 100644 --- a/XenAdmin/Wizards/DRWizards/DRFailoverWizardPrecheckPage.cs +++ b/XenAdmin/Wizards/DRWizards/DRFailoverWizardPrecheckPage.cs @@ -227,10 +227,12 @@ namespace XenAdmin.Wizards.DRWizards private DataGridViewRow ExecuteCheck(Check check) { - Problem problem = check.RunCheck(); - if (problem != null) + var problems = check.RunAllChecks(); + if (problems.Count != 0) { - return new PreCheckItemRow(problem); + // None of the checks used in the DR wizard returns more than one problem, so we just take the first. + // (Even if they did, we would only suffer the usability problem described in CA-77990). + return new PreCheckItemRow(problems[0]); } return new PreCheckItemRow(check); } diff --git a/XenAdmin/Wizards/DRWizards/DRFailoverWizardStoragePage.cs b/XenAdmin/Wizards/DRWizards/DRFailoverWizardStoragePage.cs index 3255fc22e..46e5a97a6 100644 --- a/XenAdmin/Wizards/DRWizards/DRFailoverWizardStoragePage.cs +++ b/XenAdmin/Wizards/DRWizards/DRFailoverWizardStoragePage.cs @@ -277,9 +277,13 @@ namespace XenAdmin.Wizards.DRWizards else { if (succeeded) - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Information, Messages.DR_WIZARD_STORAGEPAGE_SCAN_RESULT_NONE, - Messages.XENCENTER)).ShowDialog(this); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Information, + Messages.DR_WIZARD_STORAGEPAGE_SCAN_RESULT_NONE, + Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } } } @@ -290,8 +294,8 @@ namespace XenAdmin.Wizards.DRWizards return false; FibreChannelProbeAction action = new FibreChannelProbeAction(master); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee); - dialog.ShowDialog(this); //Will block until dialog closes, action completed + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) + dialog.ShowDialog(this); //Will block until dialog closes, action completed if (!action.Succeeded) return false; @@ -346,7 +350,8 @@ namespace XenAdmin.Wizards.DRWizards // Start probe SrProbeAction srProbeAction = new SrProbeAction(Connection, master, type, dconf, smconf); - new ActionProgressDialog(srProbeAction, ProgressBarStyle.Marquee).ShowDialog(this); + using (var dlg = new ActionProgressDialog(srProbeAction, ProgressBarStyle.Marquee)) + dlg.ShowDialog(this); if (!srProbeAction.Succeeded) return false; @@ -411,9 +416,11 @@ namespace XenAdmin.Wizards.DRWizards { var newDevice = kvp.Value; DrTaskCreateAction action = new DrTaskCreateAction(Connection, newDevice); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee); - dialog.ShowCancel = true; - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } if(!cldl.IsStillConnected(Connection)) return; @@ -477,8 +484,8 @@ namespace XenAdmin.Wizards.DRWizards if (!cldl.IsStillConnected(Connection)) return; - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee); - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) + dialog.ShowDialog(this); if (!cldl.IsStillConnected(Connection)) return; @@ -503,8 +510,8 @@ namespace XenAdmin.Wizards.DRWizards try { VdiLoadMetadataAction action = new VdiLoadMetadataAction(Connection, vdi); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee); - dialog.ShowDialog(this); //Will block until dialog closes, action completed + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) + dialog.ShowDialog(this); //Will block until dialog closes, action completed if (action.Succeeded && action.MetadataSession != null) { diff --git a/XenAdmin/Wizards/HAWizard.cs b/XenAdmin/Wizards/HAWizard.cs index f7187f2f6..0abce67bd 100644 --- a/XenAdmin/Wizards/HAWizard.cs +++ b/XenAdmin/Wizards/HAWizard.cs @@ -89,11 +89,14 @@ namespace XenAdmin.Wizards if (brokenSRs.Count > 0) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, String.Format(Messages.HA_SRS_BROKEN_WARNING, String.Join("\n", brokenSRs.ToArray())), - Messages.HIGH_AVAILABILITY)).ShowDialog(this); + Messages.HIGH_AVAILABILITY))) + { + dlg.ShowDialog(this); + } } base.OnShown(e); diff --git a/XenAdmin/Wizards/HAWizard_Pages/ChooseSR.cs b/XenAdmin/Wizards/HAWizard_Pages/ChooseSR.cs index bddbee1ad..7c143ea92 100644 --- a/XenAdmin/Wizards/HAWizard_Pages/ChooseSR.cs +++ b/XenAdmin/Wizards/HAWizard_Pages/ChooseSR.cs @@ -78,10 +78,12 @@ namespace XenAdmin.Wizards.HAWizard_Pages // Start action and show progress with a dialog GetHeartbeatSRsAction action = new GetHeartbeatSRsAction(pool); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks); - dialog.ShowCancel = true; - dialog.ShowDialog(this); - if (dialog.action.Cancelled || dialog.action.Cancelling || !dialog.action.IsCompleted) + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } + if (action.Cancelled || action.Cancelling || !action.IsCompleted) return false; if (!action.Succeeded || action.SRs.Count == 0) diff --git a/XenAdmin/Wizards/ImportWizard/NetworkPickerPage.cs b/XenAdmin/Wizards/ImportWizard/NetworkPickerPage.cs index c8da4feea..6e07c5668 100644 --- a/XenAdmin/Wizards/ImportWizard/NetworkPickerPage.cs +++ b/XenAdmin/Wizards/ImportWizard/NetworkPickerPage.cs @@ -343,9 +343,12 @@ namespace XenAdmin.Wizards.ImportWizard { if (m_networkGridView.Rows.Count >= m_vm.MaxVIFsAllowed) { - new ThreeButtonDialog(new ThreeButtonDialog.Details( + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details( SystemIcons.Error, - FriendlyErrorNames.VIFS_MAX_ALLOWED, FriendlyErrorNames.VIFS_MAX_ALLOWED_TITLE)).ShowDialog(Program.MainWindow); + FriendlyErrorNames.VIFS_MAX_ALLOWED, FriendlyErrorNames.VIFS_MAX_ALLOWED_TITLE))) + { + dlg.ShowDialog(Program.MainWindow); + } return; } diff --git a/XenAdmin/Wizards/ImportWizard/StoragePickerPage.Designer.cs b/XenAdmin/Wizards/ImportWizard/StoragePickerPage.Designer.cs index 13d905e1b..f85b46a99 100644 --- a/XenAdmin/Wizards/ImportWizard/StoragePickerPage.Designer.cs +++ b/XenAdmin/Wizards/ImportWizard/StoragePickerPage.Designer.cs @@ -37,8 +37,8 @@ this.m_srPicker.Connection = null; resources.ApplyResources(this.m_srPicker, "m_srPicker"); this.m_srPicker.Name = "m_srPicker"; - this.m_srPicker.ItemSelectionNull += new System.EventHandler(this.m_srPicker_ItemSelectionNull); - this.m_srPicker.ItemSelectionNotNull += new System.EventHandler(this.m_srPicker_ItemSelectionNotNull); + this.m_srPicker.ItemSelectionNull += new System.Action(this.m_srPicker_ItemSelectionNull); + this.m_srPicker.ItemSelectionNotNull += new System.Action(this.m_srPicker_ItemSelectionNotNull); // // StoragePickerPage // diff --git a/XenAdmin/Wizards/ImportWizard/StoragePickerPage.cs b/XenAdmin/Wizards/ImportWizard/StoragePickerPage.cs index 7e269c9e2..b18734cad 100644 --- a/XenAdmin/Wizards/ImportWizard/StoragePickerPage.cs +++ b/XenAdmin/Wizards/ImportWizard/StoragePickerPage.cs @@ -301,7 +301,7 @@ namespace XenAdmin.Wizards.ImportWizard }); } - private void m_srPicker_ItemSelectionNotNull(object sender, EventArgs e) + private void m_srPicker_ItemSelectionNotNull() { if (ImportInProgress()) return; @@ -310,7 +310,7 @@ namespace XenAdmin.Wizards.ImportWizard IsDirty = true; } - private void m_srPicker_ItemSelectionNull(object sender, EventArgs e) + private void m_srPicker_ItemSelectionNull() { if (ImportInProgress()) return; diff --git a/XenAdmin/Wizards/NewSRWizard.cs b/XenAdmin/Wizards/NewSRWizard.cs index f89b89f94..fa5b31128 100644 --- a/XenAdmin/Wizards/NewSRWizard.cs +++ b/XenAdmin/Wizards/NewSRWizard.cs @@ -472,8 +472,11 @@ namespace XenAdmin.Wizards if (pool == null) { log.Error("New SR Wizard: Pool has disappeared"); - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.NEW_SR_CONNECTION_LOST, Helpers.GetName(xenConnection)), Messages.XENCENTER)).ShowDialog(this); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.NEW_SR_CONNECTION_LOST, Helpers.GetName(xenConnection)), Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } closeWizard = true; return; @@ -483,8 +486,11 @@ namespace XenAdmin.Wizards if (master == null) { log.Error("New SR Wizard: Master has disappeared"); - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.NEW_SR_CONNECTION_LOST, Helpers.GetName(xenConnection)), Messages.XENCENTER)).ShowDialog(this); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.NEW_SR_CONNECTION_LOST, Helpers.GetName(xenConnection)), Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } closeWizard = true; return; @@ -525,20 +531,21 @@ namespace XenAdmin.Wizards } ProgressBarStyle progressBarStyle = FinalAction is SrIntroduceAction ? ProgressBarStyle.Blocks : ProgressBarStyle.Marquee; - ActionProgressDialog dialog = new ActionProgressDialog(FinalAction, progressBarStyle) {ShowCancel = true}; - - if (m_srWizardType is SrWizardType_LvmoHba || m_srWizardType is SrWizardType_Fcoe) + using (var dialog = new ActionProgressDialog(FinalAction, progressBarStyle) {ShowCancel = true}) { - ActionProgressDialog closureDialog = dialog; - // close dialog even when there's an error for HBA SR type as there will be the Summary page displayed. - FinalAction.Completed += - s => Program.Invoke(Program.MainWindow, () => + if (m_srWizardType is SrWizardType_LvmoHba || m_srWizardType is SrWizardType_Fcoe) + { + ActionProgressDialog closureDialog = dialog; + // close dialog even when there's an error for HBA SR type as there will be the Summary page displayed. + FinalAction.Completed += + s => Program.Invoke(Program.MainWindow, () => { if (closureDialog != null) closureDialog.Close(); }); + } + dialog.ShowDialog(this); } - dialog.ShowDialog(this); if (m_srWizardType is SrWizardType_LvmoHba || m_srWizardType is SrWizardType_Fcoe) { @@ -551,9 +558,11 @@ namespace XenAdmin.Wizards if (!FinalAction.Succeeded && FinalAction is SrReattachAction && _srToReattach.HasPBDs) { // reattach failed. Ensure PBDs are now unplugged and destroyed. - dialog = new ActionProgressDialog(new SrAction(SrActionKind.UnplugAndDestroyPBDs, _srToReattach), progressBarStyle); - dialog.ShowCancel = false; - dialog.ShowDialog(); + using (var dialog = new ActionProgressDialog(new SrAction(SrActionKind.UnplugAndDestroyPBDs, _srToReattach), progressBarStyle)) + { + dialog.ShowCancel = false; + dialog.ShowDialog(); + } } // If action failed and frontend wants to stay open, just return @@ -674,10 +683,15 @@ namespace XenAdmin.Wizards // introduce if (m_srWizardType.ShowIntroducePrompt) { - return DialogResult.Yes == new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, String.Format(Messages.NEWSR_MULTI_POOL_WARNING, m_srWizardType.UUID), Text), ThreeButtonDialog.ButtonYes, - new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(this); + new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) + { + dialogResult = dlg.ShowDialog(this); + } + return DialogResult.Yes == dialogResult; } } @@ -686,10 +700,15 @@ namespace XenAdmin.Wizards // Reattach if (m_srWizardType.ShowReattachWarning) { - return DialogResult.Yes == new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, String.Format(Messages.NEWSR_MULTI_POOL_WARNING, _srToReattach.Name), Text), ThreeButtonDialog.ButtonYes, - new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(this); + new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) + { + dialogResult = dlg.ShowDialog(this); + } + return DialogResult.Yes == dialogResult; } } else @@ -701,13 +720,18 @@ namespace XenAdmin.Wizards // Warn user SR is already attached to other pool, and then introduce to this pool - return DialogResult.OK == new ThreeButtonDialog( + DialogResult dialogResult; + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, string.Format(Messages.ALREADY_ATTACHED_ELSEWHERE, _srToReattach.Name, Helpers.GetName(xenConnection), Text)), ThreeButtonDialog.ButtonOK, - ThreeButtonDialog.ButtonCancel).ShowDialog(this); + ThreeButtonDialog.ButtonCancel)) + { + dialogResult = dlg.ShowDialog(this); + } + return DialogResult.OK == dialogResult; } } @@ -725,11 +749,14 @@ namespace XenAdmin.Wizards if (xenTabPageChooseSrType.MatchingFrontends <= 0) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, String.Format(Messages.CANNOT_FIND_SR_WIZARD_TYPE, _srToReattach.type), - Messages.XENCENTER)).ShowDialog(this); + Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } Close(); } diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFSFrontend.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFSFrontend.cs index 7b73706b8..2e8c3457c 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFSFrontend.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CIFSFrontend.cs @@ -147,9 +147,11 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends // Start probe SrProbeAction action = new SrProbeAction(Connection, master, SR.SRTypes.smb, dconf); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee); - dialog.ShowCancel = true; - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } if (radioButtonCifsNew.Enabled) radioButtonCifsNew.Checked = true; diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CSLG.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CSLG.cs index 61030a1b1..ae88c801d 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CSLG.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CSLG.cs @@ -140,17 +140,19 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends if (_srToReattach == null || _srToReattach.type == "cslg") { var action = new SrCslgAdaptersScanAction(Connection); - var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee); - // never show the error message if it fails. - action.Completed += s => + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) { - if (!action.Succeeded) + // never show the error message if it fails. + action.Completed += s => { - Program.Invoke(dialog, dialog.Close); - } - }; + if (!action.Succeeded) + { + Program.Invoke(dialog, dialog.Close); + } + }; - dialog.ShowDialog(this); + dialog.ShowDialog(this); + } if (action.Succeeded) { var adapters = action.GetAdapters(); diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CslgLocation.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CslgLocation.cs index a6211c2c0..1c70b773a 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CslgLocation.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/CslgLocation.cs @@ -127,8 +127,8 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends var scanAction = new SrCslgStoragePoolScanAction(Connection, credentials.Host, credentials.Username, credentials.PasswordSecret, SystemStorage.StorageSystemId, SelectedStorageAdapter.Id); - ActionProgressDialog dialog = new ActionProgressDialog(scanAction, ProgressBarStyle.Marquee); - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(scanAction, ProgressBarStyle.Marquee)) + dialog.ShowDialog(this); if (scanAction.Succeeded) StoragePools = scanAction.CslgStoragePools; @@ -148,7 +148,8 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends private void buttonDiscoverBostonSS_Click(object sender, EventArgs e) { SrCslgStorageSystemScanAction action = new SrCslgStorageSystemScanAction(Connection, SelectedStorageAdapter.Id, textBoxTarget.Text, textBoxUsername.Text, textBoxPassword.Text); - new ActionProgressDialog(action, ProgressBarStyle.Marquee).ShowDialog(this); + using (var dlg = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) + dlg.ShowDialog(this); var items = new List(); if (action.Succeeded) diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/FilerDetails.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/FilerDetails.cs index 27a3e6b8e..2d66e0026 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/FilerDetails.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/FilerDetails.cs @@ -131,9 +131,11 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends SrScanAction scanAction = new SrScanAction(Connection, textBoxNetappHostAddress.Text, textBoxNetappUsername.Text, textBoxNetappPassword.Text, IsNetApp ? SR.SRTypes.netapp : SR.SRTypes.equal); - ActionProgressDialog dialog = new ActionProgressDialog(scanAction, ProgressBarStyle.Marquee); - dialog.ShowCancel = true; - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(scanAction, ProgressBarStyle.Marquee)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } if (scanAction.Succeeded) { diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoHBA.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoHBA.cs index 457465130..1ff660225 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoHBA.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoHBA.cs @@ -95,7 +95,8 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends LvmOhbaSrDescriptor descr = CreateSrDescriptor(device); var action = new SrProbeAction(Connection, master, SrType, descr.DeviceConfig); - new ActionProgressDialog(action, ProgressBarStyle.Marquee).ShowDialog(this); + using (var dlg = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) + dlg.ShowDialog(this); if (!action.Succeeded) { @@ -328,8 +329,8 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends return false; FibreChannelProbeAction action = new FibreChannelProbeAction(master, SrType); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee); - dialog.ShowDialog(owner); //Will block until dialog closes, action completed + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) + dialog.ShowDialog(owner); //Will block until dialog closes, action completed if (!action.Succeeded) return false; @@ -340,8 +341,11 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends if (devices.Count == 0) { - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.FIBRECHANNEL_NO_RESULTS, Messages.XENCENTER)).ShowDialog(); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.FIBRECHANNEL_NO_RESULTS, Messages.XENCENTER))) + { + dlg.ShowDialog(); + } return false; } @@ -351,8 +355,11 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends { log.Debug("Exception parsing result of fibre channel scan", e); log.Debug(e, e); - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.FIBRECHANNEL_XML_ERROR, Messages.XENCENTER)).ShowDialog(); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.FIBRECHANNEL_XML_ERROR, Messages.XENCENTER))) + { + dlg.ShowDialog(); + } return false; } diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs index d3d464bc3..6e1cdb618 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs @@ -149,9 +149,11 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends // Start probe SrProbeAction IscsiProbeAction = new SrProbeAction(Connection, master, SR.SRTypes.lvmoiscsi, dconf); - ActionProgressDialog dialog = new ActionProgressDialog(IscsiProbeAction, ProgressBarStyle.Marquee); - dialog.ShowCancel = true; - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(IscsiProbeAction, ProgressBarStyle.Marquee)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } // Probe has been performed. Now ask the user if they want to Reattach/Format/Cancel. // Will return false on cancel @@ -753,16 +755,25 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends // No existing SRs were found on this LUN. If allowed to create new SR, ask the user if they want to proceed and format. if (!SrWizardType.AllowToCreateNewSr) { - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Error, Messages.NEWSR_LUN_HAS_NO_SRS, Messages.XENCENTER)).ShowDialog(this); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Error, Messages.NEWSR_LUN_HAS_NO_SRS, Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } return false; } - DialogResult result = Program.RunInAutomatedTestMode ? DialogResult.Yes : - new ThreeButtonDialog( + DialogResult result = DialogResult.Yes; + if (!Program.RunInAutomatedTestMode) + { + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.NEWSR_ISCSI_FORMAT_WARNING, this.Text), ThreeButtonDialog.ButtonYes, - new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(this); + new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true))) + { + result = dlg.ShowDialog(this); + } + } return result == DialogResult.Yes; } @@ -777,12 +788,15 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends SR sr = SrWizardHelpers.SrInUse(info.UUID); if (sr != null) { - ThreeButtonDialog d = new ThreeButtonDialog( + DialogResult res; + using (var d = new ThreeButtonDialog( new ThreeButtonDialog.Details(null, string.Format(Messages.DETACHED_ISCI_DETECTED, Helpers.GetName(sr.Connection))), new ThreeButtonDialog.TBDButton(Messages.ATTACH_SR, DialogResult.OK), - ThreeButtonDialog.ButtonCancel); + ThreeButtonDialog.ButtonCancel)) + { + res = d.ShowDialog(Program.MainWindow); + } - DialogResult res = d.ShowDialog(Program.MainWindow); if (res == DialogResult.Cancel) return false; diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/VHDoNFS.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/VHDoNFS.cs index 8ceb30abd..61db8dd0c 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/VHDoNFS.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/VHDoNFS.cs @@ -151,9 +151,11 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends // Start probe SrProbeAction action = new SrProbeAction(Connection, master, SR.SRTypes.nfs, dconf); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee); - dialog.ShowCancel = true; - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } try { diff --git a/XenAdmin/Wizards/NewVMWizard/Page_CloudConfigParameters.cs b/XenAdmin/Wizards/NewVMWizard/Page_CloudConfigParameters.cs index 948f8b1e0..c66f53605 100644 --- a/XenAdmin/Wizards/NewVMWizard/Page_CloudConfigParameters.cs +++ b/XenAdmin/Wizards/NewVMWizard/Page_CloudConfigParameters.cs @@ -191,7 +191,10 @@ namespace XenAdmin.Wizards.NewVMWizard { GetDefaultParameters(); if (errorRetrievingConfigParameters) - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.VM_CLOUD_CONFIG_DRIVE_CANNOT_RETRIEVE_DEFAULT)).ShowDialog(this); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.VM_CLOUD_CONFIG_DRIVE_CANNOT_RETRIEVE_DEFAULT))) + { + dlg.ShowDialog(this); + } } #region Implementation of IEditPage diff --git a/XenAdmin/Wizards/NewVMWizard/Page_InstallationMedia.cs b/XenAdmin/Wizards/NewVMWizard/Page_InstallationMedia.cs index b9ed9e322..abe09635b 100644 --- a/XenAdmin/Wizards/NewVMWizard/Page_InstallationMedia.cs +++ b/XenAdmin/Wizards/NewVMWizard/Page_InstallationMedia.cs @@ -325,7 +325,8 @@ namespace XenAdmin.Wizards.NewVMWizard { System.Threading.Thread.Sleep(10000); }, true); - new ActionProgressDialog(waitAction, System.Windows.Forms.ProgressBarStyle.Marquee).ShowDialog(this); + using (var dlg = new ActionProgressDialog(waitAction, System.Windows.Forms.ProgressBarStyle.Marquee)) + dlg.ShowDialog(this); // Set the connection on the drop down iso box. This causes a complete refresh rather than a mini one - otherwise we miss out on // getting event handlers for the new SR diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard.cs index ac4061ad1..8e40f2dd0 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard.cs @@ -281,8 +281,8 @@ namespace XenAdmin.Wizards.PatchingWizard using (MultipleAction multipleAction = new MultipleAction(xenConnection, title, startDescription, endDescription, subActions, false, true)) { - ActionProgressDialog dialog = new ActionProgressDialog(multipleAction, ProgressBarStyle.Blocks); - dialog.ShowDialog(Program.MainWindow); + using (var dialog = new ActionProgressDialog(multipleAction, ProgressBarStyle.Blocks)) + dialog.ShowDialog(Program.MainWindow); } } } diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PatchingPage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PatchingPage.cs index 818ffe38f..5c3d72b79 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PatchingPage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PatchingPage.cs @@ -474,9 +474,10 @@ namespace XenAdmin.Wizards.PatchingWizard if (!(exception is SupplementalPackInstallFailedException)) return; var msg = string.Format(Messages.SUPP_PACK_INSTALL_FAILED_MORE_INFO, exception.Message); - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Error, msg)) - .ShowDialog(this); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, msg))) + { + dlg.ShowDialog(this); + } } } } diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs index 3ad0dded2..53db0f640 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs @@ -223,11 +223,20 @@ namespace XenAdmin.Wizards.PatchingWizard catch (Exception) { } } - private PreCheckHostRow ExecuteCheck(Check check) + private List ExecuteCheck(Check check) { - Problem problem = check.RunCheck(); - if (problem != null) + var rows = new List(); + + var problems = check.RunAllChecks(); + if (problems.Count == 0) { + rows.Add(new PreCheckHostRow(check)); + return rows; + } + + foreach (var pr in problems) + { + var problem = pr; // we need this line because we sometimes reassign it below if (problem is HostNotLive) { // this host is no longer live -> remove all previous problems regarding this host @@ -242,10 +251,10 @@ namespace XenAdmin.Wizards.PatchingWizard } else ProblemsResolvedPreCheck.Add(problem); - - return new PreCheckHostRow(problem); + + rows.Add(new PreCheckHostRow(problem)); } - return new PreCheckHostRow(check); + return rows; } private int _numberChecks = 0; @@ -287,10 +296,12 @@ namespace XenAdmin.Wizards.PatchingWizard } Check check = checkGroup[j]; - PreCheckHostRow row = ExecuteCheck(check); - if (precheckResult != PreCheckResult.Failed && row.Problem != null) - precheckResult = row.IsProblem ? PreCheckResult.Failed : PreCheckResult.Warning; - _worker.ReportProgress(PercentageSelectedServers(j + 1), row); + foreach (PreCheckHostRow row in ExecuteCheck(check)) + { + if (precheckResult != PreCheckResult.Failed && row.Problem != null) + precheckResult = row.IsProblem ? PreCheckResult.Failed : PreCheckResult.Warning; + _worker.ReportProgress(PercentageSelectedServers(j + 1), row); + } } lock (_update_grid_lock) @@ -577,9 +588,12 @@ namespace XenAdmin.Wizards.PatchingWizard (preCheckHostRow.Problem as ProblemWithInformationUrl).LaunchUrlInBrowser(); else if (!cancelled) - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Information, + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Information, string.Format(Messages.PATCHING_WIZARD_SOLVE_MANUALLY, preCheckHostRow.Problem.Description).Replace("\\n", "\n"), - Messages.PATCHINGWIZARD_PRECHECKPAGE_TEXT)).ShowDialog(this); + Messages.PATCHINGWIZARD_PRECHECKPAGE_TEXT))) + { + dlg.ShowDialog(this); + } } } @@ -610,12 +624,9 @@ namespace XenAdmin.Wizards.PatchingWizard actions.Add(action); } } - foreach (var asyncAction in actions) - { - _progressDialog = new ActionProgressDialog(asyncAction, ProgressBarStyle.Blocks); - _progressDialog.ShowDialog(this); - Program.Invoke(Program.MainWindow, RefreshRechecks); - } + var multipleAction = new ParallelAction(Messages.PATCHINGWIZARD_PRECHECKPAGE_RESOLVING_ALL, Messages.PATCHINGWIZARD_PRECHECKPAGE_RESOLVING_ALL, Messages.COMPLETED, actions, true, false); + _progressDialog = new ActionProgressDialog(multipleAction, ProgressBarStyle.Blocks); + _progressDialog.ShowDialog(this); Program.Invoke(Program.MainWindow, RefreshRechecks); } diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectPatchPage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectPatchPage.cs index f3de64649..b58dcb5f8 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectPatchPage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectPatchPage.cs @@ -218,8 +218,11 @@ namespace XenAdmin.Wizards.PatchingWizard private void PageLeaveCancelled(string message) { - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Warning, message, Messages.UPDATES_WIZARD)).ShowDialog(this); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, message, Messages.UPDATES_WIZARD))) + { + dlg.ShowDialog(this); + } ((PatchGridViewRow)dataGridViewPatches.SelectedRows[0]).UpdateDetails(); } @@ -355,8 +358,11 @@ namespace XenAdmin.Wizards.PatchingWizard } else { - new ThreeButtonDialog(new ThreeButtonDialog.Details( - SystemIcons.Error, string.Format(Messages.UPDATES_WIZARD_NOTVALID_EXTENSION, Branding.Update), Messages.UPDATES)).ShowDialog(this); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details( + SystemIcons.Error, string.Format(Messages.UPDATES_WIZARD_NOTVALID_EXTENSION, Branding.Update), Messages.UPDATES))) + { + dlg.ShowDialog(this); + } } } diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectServers.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectServers.cs index 1c4bb40cc..6a7d406e1 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectServers.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectServers.cs @@ -280,7 +280,10 @@ namespace XenAdmin.Wizards.PatchingWizard if (pool != null) nameLabel = pool.Name; - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.RBAC_UPDATES_WIZARD, master.Connection.Username, nameLabel), Messages.UPDATES_WIZARD)).ShowDialog(this); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.RBAC_UPDATES_WIZARD, master.Connection.Username, nameLabel), Messages.UPDATES_WIZARD))) + { + dlg.ShowDialog(this); + } cancel = true; base.PageLeave(direction, ref cancel); @@ -313,10 +316,13 @@ namespace XenAdmin.Wizards.PatchingWizard if (disconnectedServerNames.Count > 0) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.UPDATES_WIZARD_DISCONNECTED_SERVER, Helpers.StringifyList(disconnectedServerNames)), - Messages.UPDATES_WIZARD)).ShowDialog(this); + Messages.UPDATES_WIZARD))) + { + dlg.ShowDialog(this); + } return false; } return true; diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_UploadPage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_UploadPage.cs index cabc80a50..f1e8b6409 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_UploadPage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_UploadPage.cs @@ -515,9 +515,11 @@ namespace XenAdmin.Wizards.PatchingWizard { var msgtemplate = SelectedExistingPatch.host_patches.Count > 0 ? Messages.PATCH_DOWNLOAD_FAILED_MORE_INFO : Messages.PATCH_DOWNLOAD_FAILED_MORE_INFO_NOT_APPLIED; var msg = string.Format(msgtemplate, SelectedExistingPatch.name_label, SelectedExistingPatch.Connection.Name, Branding.Update); - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Error, msg)) - .ShowDialog(this); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Error, msg))) + { + dlg.ShowDialog(this); + } } if (diskSpaceRequirements == null) @@ -525,31 +527,37 @@ namespace XenAdmin.Wizards.PatchingWizard if (diskSpaceRequirements.CanCleanup) { - ThreeButtonDialog d = new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Warning, diskSpaceRequirements.GetSpaceRequirementsMessage()), + using (var d = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, + diskSpaceRequirements.GetSpaceRequirementsMessage()), new ThreeButtonDialog.TBDButton(Messages.OK, DialogResult.OK), - new ThreeButtonDialog.TBDButton(Messages.CANCEL, DialogResult.Cancel)); - - if (d.ShowDialog(this) == DialogResult.OK) + new ThreeButtonDialog.TBDButton(Messages.CANCEL, DialogResult.Cancel))) { - // do the cleanup and retry uploading - CleanupDiskSpaceAction action = new CleanupDiskSpaceAction(diskSpaceRequirements.Host, null, true); + if (d.ShowDialog(this) == DialogResult.OK) + { + // do the cleanup and retry uploading + CleanupDiskSpaceAction action = new CleanupDiskSpaceAction(diskSpaceRequirements.Host, null, + true); - action.Completed += delegate - { - if (action.Succeeded) - { - Program.Invoke(Program.MainWindow, TryUploading); - } - }; - action.RunAsync(); + action.Completed += delegate + { + if (action.Succeeded) + { + Program.Invoke(Program.MainWindow, TryUploading); + } + }; + action.RunAsync(); + } } } else { - new ThreeButtonDialog( - new ThreeButtonDialog.Details(SystemIcons.Warning, diskSpaceRequirements.GetSpaceRequirementsMessage())) - .ShowDialog(this); + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Warning, + diskSpaceRequirements.GetSpaceRequirementsMessage()))) + { + dlg.ShowDialog(this); + } } } } diff --git a/XenAdmin/Wizards/PatchingWizard/PlanActions/PatchPrechecksOnMultipleHostsAction.cs b/XenAdmin/Wizards/PatchingWizard/PlanActions/PatchPrechecksOnMultipleHostsAction.cs index ff287d720..4b8f83c32 100644 --- a/XenAdmin/Wizards/PatchingWizard/PlanActions/PatchPrechecksOnMultipleHostsAction.cs +++ b/XenAdmin/Wizards/PatchingWizard/PlanActions/PatchPrechecksOnMultipleHostsAction.cs @@ -70,8 +70,13 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions try { var check = new PatchPrecheckCheck(host, mapping.Pool_patch); - var problem = check.RunCheck(); - + var problems = check.RunAllChecks(); + + Diagnostics.Problems.Problem problem = null; + + if (problems != null && problems.Count > 0) + problem = problems[0]; + if (problem != null) { throw new Exception(string.Format("{0}: {1}. {2}", host, problem.Title, problem.Description)); diff --git a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizard.cs b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizard.cs index 8dd1f87ed..85b2aa4a5 100644 --- a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizard.cs +++ b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizard.cs @@ -80,10 +80,12 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard .Any(master => master != null && master.Connection.Cache.SRs.Any(sr => sr.IsBroken(true))); if(brokenSRs) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, - Messages.BROKEN_SRS_AFTER_UPGRADE)) - .ShowDialog(Program.MainWindow); + Messages.BROKEN_SRS_AFTER_UPGRADE))) + { + dlg.ShowDialog(Program.MainWindow); + } } base.FinishWizard(); } @@ -151,8 +153,8 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard Messages.REVERTED_WIZARD_CHANGES, subActions, false, true)) { - ActionProgressDialog dialog = new ActionProgressDialog(multipleAction, ProgressBarStyle.Blocks); - dialog.ShowDialog(Program.MainWindow); + using (var dialog = new ActionProgressDialog(multipleAction, ProgressBarStyle.Blocks)) + dialog.ShowDialog(Program.MainWindow); } } } diff --git a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardSelectPool.cs b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardSelectPool.cs index 16fe90ec5..b443e91ae 100644 --- a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardSelectPool.cs +++ b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardSelectPool.cs @@ -95,9 +95,12 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard { if (!(selectedMaster.Connection.Session.IsLocalSuperuser || selectedMaster.Connection.Session.Roles.Any(role => role.name_label == Role.MR_ROLE_POOL_ADMIN))) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.RBAC_UPGRADE_WIZARD_MESSAGE, selectedMaster.Connection.Username, - selectedMaster.Name), Messages.ROLLING_POOL_UPGRADE)).ShowDialog(this); + selectedMaster.Name), Messages.ROLLING_POOL_UPGRADE))) + { + dlg.ShowDialog(this); + } DeselectMaster(selectedMaster); cancel = true; return; @@ -124,10 +127,13 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard if (disconnectedServerNames.Count > 0) { - new ThreeButtonDialog( + using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.ROLLING_UPGRADE_DISCONNECTED_SERVER, Helpers.StringifyList(disconnectedServerNames)), - Messages.ROLLING_POOL_UPGRADE)).ShowDialog(this); + Messages.ROLLING_POOL_UPGRADE))) + { + dlg.ShowDialog(this); + } return false; } return true; diff --git a/XenAdmin/Wlb/WlbReports/WorkloadReports.cs b/XenAdmin/Wlb/WlbReports/WorkloadReports.cs index fa6133244..4ac7b4e55 100644 --- a/XenAdmin/Wlb/WlbReports/WorkloadReports.cs +++ b/XenAdmin/Wlb/WlbReports/WorkloadReports.cs @@ -173,7 +173,10 @@ namespace XenAdmin catch (Exception ex) { log.Debug(ex, ex); - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.WLBREPORT_REPORT_CONFIG_ERROR, Messages.XENCENTER)).ShowDialog(this); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.WLBREPORT_REPORT_CONFIG_ERROR, Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } errorLoading = true; } finally @@ -402,9 +405,11 @@ namespace XenAdmin WlbPoolConfiguration poolConfiguration; RetrieveWlbConfigurationAction action = new RetrieveWlbConfigurationAction(_pool); - ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks); - dialog.ShowCancel = true; - dialog.ShowDialog(this); + using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(this); + } if (action.Succeeded) { @@ -539,7 +544,8 @@ namespace XenAdmin true, parms); - new ActionProgressDialog(action, ProgressBarStyle.Marquee).ShowDialog(); + using (var dlg = new ActionProgressDialog(action, ProgressBarStyle.Marquee)) + dlg.ShowDialog(); returnValue = action.Result; @@ -933,7 +939,10 @@ namespace XenAdmin catch (Exception ex) { log.Debug(ex, ex); - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.WLBREPORT_REPORT_CONFIG_ERROR, Messages.XENCENTER)).ShowDialog(this); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.WLBREPORT_REPORT_CONFIG_ERROR, Messages.XENCENTER))) + { + dlg.ShowDialog(this); + } this.Close(); } } @@ -1045,7 +1054,10 @@ namespace XenAdmin /// private void wlbReportView1_PoolConnectionLost(object sender, EventArgs e) { - new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Information, String.Format(Messages.WLB_REPORT_POOL_CONNECTION_LOST, _pool.Name), Messages.WLBREPORT_POOL_CONNECTION_LOST_CAPTION)).ShowDialog(this); + using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Information, String.Format(Messages.WLB_REPORT_POOL_CONNECTION_LOST, _pool.Name), Messages.WLBREPORT_POOL_CONNECTION_LOST_CAPTION))) + { + dlg.ShowDialog(this); + } this.Close(); this.Dispose(); diff --git a/XenAdminTests/Diagnostics/DiagnosticsTests.cs b/XenAdminTests/Diagnostics/DiagnosticsTests.cs index 64603c970..f9864b66a 100644 --- a/XenAdminTests/Diagnostics/DiagnosticsTests.cs +++ b/XenAdminTests/Diagnostics/DiagnosticsTests.cs @@ -55,8 +55,8 @@ namespace XenAdminTests.Diagnostics //Execute the check var check = new HostLivenessCheck(host); - var problem = check.RunCheck(); - Assert.IsNull(problem); + var problems = check.RunAllChecks(); + Assert.IsEmpty(problems); fake.VerifyAll(); } @@ -68,8 +68,9 @@ namespace XenAdminTests.Diagnostics //Execute the check var check = new HostMaintenanceModeCheck(host); - var problem = check.RunCheck(); - Assert.AreEqual(typeof(HostMaintenanceMode),problem.GetType()); + var problems = check.RunAllChecks(); + Assert.IsNotEmpty(problems); + Assert.AreEqual(typeof(HostMaintenanceMode), problems[0].GetType()); fake.VerifyAll(); } @@ -81,8 +82,9 @@ namespace XenAdminTests.Diagnostics //Execute the check var check = new HostMaintenanceModeCheck(host); - var problem = check.RunCheck(); - Assert.AreEqual(typeof(HostMaintenanceMode), problem.GetType()); + var problems = check.RunAllChecks(); + Assert.IsNotEmpty(problems); + Assert.AreEqual(typeof(HostMaintenanceMode), problems[0].GetType()); mock.VerifyAll(); } @@ -94,8 +96,9 @@ namespace XenAdminTests.Diagnostics //Execute the check var check = new HostLivenessCheck(host); - var problem = check.RunCheck(); - Assert.AreEqual(typeof(HostNotLive), problem.GetType()); + var problems = check.RunAllChecks(); + Assert.IsNotEmpty(problems); + Assert.AreEqual(typeof(HostNotLive), problems[0].GetType()); mock.VerifyAll(); } #endregion @@ -109,8 +112,8 @@ namespace XenAdminTests.Diagnostics //Execute the check var check = new HAOffCheck(host); - var problem = check.RunCheck(); - Assert.IsNull(problem); + var problems = check.RunAllChecks(); + Assert.IsEmpty(problems); } [Test] @@ -119,8 +122,8 @@ namespace XenAdminTests.Diagnostics var host = GetHostLiveness(GetMockConnectionWithCache(), true, false, true); //Execute the check var check = new HAOffCheck(host); - var problem = check.RunCheck(); - Assert.IsNull(problem); + var problems = check.RunAllChecks(); + Assert.IsEmpty(problems); } [Test] @@ -130,9 +133,9 @@ namespace XenAdminTests.Diagnostics //Execute the check var check = new HAOffCheck(host); - var problem = check.RunCheck(); - Assert.IsNotNull(problem); - Assert.AreEqual(typeof(HAEnabledProblem), problem.GetType()); + var problems = check.RunAllChecks(); + Assert.IsNotEmpty(problems); + Assert.AreEqual(typeof(HAEnabledProblem), problems[0].GetType()); } #endregion @@ -146,8 +149,8 @@ namespace XenAdminTests.Diagnostics var host = GetHostLiveness(mockConnection, true, false, true); //Execute the check var check = new PBDsPluggedCheck(host); - var problem = check.RunCheck(); - Assert.IsNull(problem); + var problems = check.RunAllChecks(); + Assert.IsEmpty(problems); } [Test] @@ -162,8 +165,8 @@ namespace XenAdminTests.Diagnostics host.Connection.Cache.UpdateFrom(host.Connection, listofchanges); //Execute the check var check = new PBDsPluggedCheck(host); - var problem = check.RunCheck(); - Assert.IsNull(problem); + var problems = check.RunAllChecks(); + Assert.IsEmpty(problems); } #endregion diff --git a/XenAdminTests/Diagnostics/UpgradingFromTampaAndOlderCheckTests.cs b/XenAdminTests/Diagnostics/UpgradingFromTampaAndOlderCheckTests.cs index 30a3b594d..d4999c48c 100644 --- a/XenAdminTests/Diagnostics/UpgradingFromTampaAndOlderCheckTests.cs +++ b/XenAdminTests/Diagnostics/UpgradingFromTampaAndOlderCheckTests.cs @@ -126,7 +126,7 @@ namespace XenAdminTests.Diagnostics host.Setup(h => h.IsFreeLicense()).Returns(tc.IsFree); host.Setup(h => h.InGrace).Returns(tc.InGrace); UpgradingFromTampaAndOlderCheck check = new UpgradingFromTampaAndOlderCheck(host.Object); - Assert.AreEqual(tc.ExpectProblem, check.RunCheck()!=null, "Problem found"); + Assert.AreEqual(tc.ExpectProblem, check.RunAllChecks().Count != 0, "Problem found"); } } } diff --git a/XenAdminTests/XenAdminTests.csproj b/XenAdminTests/XenAdminTests.csproj index 14af6a66d..0e6a0f4b9 100644 --- a/XenAdminTests/XenAdminTests.csproj +++ b/XenAdminTests/XenAdminTests.csproj @@ -67,6 +67,7 @@ + diff --git a/XenModel/Actions/ParallelAction.cs b/XenModel/Actions/ParallelAction.cs index 8a63f3545..69c1bf886 100644 --- a/XenModel/Actions/ParallelAction.cs +++ b/XenModel/Actions/ParallelAction.cs @@ -44,58 +44,120 @@ namespace XenAdmin.Actions /// public class ParallelAction : MultipleAction { + //Change parameter to increase the number of concurrent actions running private const int DEFAULT_MAX_NUMBER_OF_PARALLEL_ACTIONS = 25; - //Change parameter to increase the number of concurrent actions running - private readonly ProduceConsumerQueue _queuePC; + private Dictionary> actionsByConnection = new Dictionary>(); + private Dictionary queuesByConnection = new Dictionary(); - public ParallelAction (IXenConnection connection, string title, string startDescription, string endDescription, List subActions) - : base(connection, title, startDescription, endDescription, subActions) + private List actionsWithNoConnection = new List(); + private ProduceConsumerQueue queueWithNoConnection; + + private readonly int maxNumberOfParallelActions; + + public ParallelAction(IXenConnection connection, string title, string startDescription, string endDescription, List subActions, bool suppressHistory, bool showSubActionsDetails, int maxNumberOfParallelActions = DEFAULT_MAX_NUMBER_OF_PARALLEL_ACTIONS) + : base(connection, title, startDescription, endDescription, subActions, suppressHistory, showSubActionsDetails) { - _queuePC = new ProduceConsumerQueue(Math.Min(DEFAULT_MAX_NUMBER_OF_PARALLEL_ACTIONS, subActions.Count)); + actionsByConnection.Add(connection, subActions); + this.maxNumberOfParallelActions = maxNumberOfParallelActions; } - public ParallelAction(IXenConnection connection, string title, string startDescription, string endDescription, List subActions, int maxNumberOfParallelActions) - : base(connection, title, startDescription, endDescription, subActions) + public ParallelAction(IXenConnection connection, string title, string startDescription, string endDescription, List subActions, int maxNumberOfParallelActions = DEFAULT_MAX_NUMBER_OF_PARALLEL_ACTIONS) + : this(connection, title, startDescription, endDescription, subActions, false, false, maxNumberOfParallelActions) + { } + + /// + /// Use this constructor to create a cross connection ParallelAction. + /// It takes a list of any number of actions, separates them by connections + /// and runs a certain number of them simultaneously on each connection, all connections in parallel. + /// Once one simultaneous action is finished the next one in the queue is started until all are complete. + /// + public ParallelAction(string title, string startDescription, string endDescription, List subActions, bool suppressHistory, bool showSubActionsDetails, int maxNumberOfParallelActions = DEFAULT_MAX_NUMBER_OF_PARALLEL_ACTIONS) + : base(null, title, startDescription, endDescription, subActions, suppressHistory, showSubActionsDetails) { - _queuePC = new ProduceConsumerQueue(Math.Min(maxNumberOfParallelActions, subActions.Count)); + GroupActionsByConnection(); + this.maxNumberOfParallelActions = maxNumberOfParallelActions; } + public ParallelAction(string title, string startDescription, string endDescription, List subActions, int maxNumberOfParallelActions = DEFAULT_MAX_NUMBER_OF_PARALLEL_ACTIONS) + : this(title, startDescription, endDescription, subActions, false, false, maxNumberOfParallelActions) + { } + + private void GroupActionsByConnection() + { + foreach (AsyncAction action in subActions) + { + if (action.Connection != null) + { + if (action.Connection.IsConnected) + { + if (!actionsByConnection.ContainsKey(action.Connection)) + { + actionsByConnection.Add(action.Connection, new List()); + } + + actionsByConnection[action.Connection].Add(action); + } + } + else + { + actionsWithNoConnection.Add(action); + } + } + } + + protected override void RunSubActions(List exceptions) { - foreach (AsyncAction subAction in subActions) + foreach (IXenConnection connection in actionsByConnection.Keys) { - AsyncAction action = subAction; - action.Completed += action_Completed; - _queuePC.EnqueueItem( - () => - { - try - { - action.RunExternal(Session); - } - catch (Exception e) - { - Failure f = e as Failure; - if (f != null && Connection != null && - f.ErrorDescription[0] == Failure.RBAC_PERMISSION_DENIED) - { - Failure.ParseRBACFailure(f, Connection, Session ?? Connection.Session); - } - exceptions.Add(e); - // Record the first exception we come to. Though later if there are more than one we will replace this with non specific one. - if (Exception == null) - Exception = e; - } - }); - + queuesByConnection[connection] = new ProduceConsumerQueue(Math.Min(maxNumberOfParallelActions, actionsByConnection[connection].Count)); + foreach (AsyncAction subAction in actionsByConnection[connection]) + { + EnqueueAction(subAction, queuesByConnection[connection], exceptions); + } } + + if (actionsWithNoConnection.Count > 0) + queueWithNoConnection = new ProduceConsumerQueue(Math.Min(maxNumberOfParallelActions, actionsWithNoConnection.Count)); + + foreach (AsyncAction subAction in actionsWithNoConnection) + { + EnqueueAction(subAction, queueWithNoConnection, exceptions); + } + lock (_lock) { Monitor.Wait(_lock); } } + void EnqueueAction(AsyncAction action, ProduceConsumerQueue queue, List exceptions) + { + action.Completed += action_Completed; + queue.EnqueueItem( + () => + { + try + { + action.RunExternal(action.Session); + } + catch (Exception e) + { + Failure f = e as Failure; + if (f != null && Connection != null && + f.ErrorDescription[0] == Failure.RBAC_PERMISSION_DENIED) + { + Failure.ParseRBACFailure(f, action.Connection, action.Session ?? action.Connection.Session); + } + exceptions.Add(e); + // Record the first exception we come to. Though later if there are more than one we will replace this with non specific one. + if (Exception == null) + Exception = e; + } + }); + } + private readonly object _lock = new object(); private volatile int i = 0; @@ -112,9 +174,15 @@ namespace XenAdmin.Actions protected override void MultipleAction_Completed(ActionBase sender) { - base.MultipleAction_Completed(sender); - _queuePC.StopWorkers(false); + + foreach (IXenConnection connection in queuesByConnection.Keys) + { + queuesByConnection[connection].StopWorkers(false); + } + + if (queueWithNoConnection != null) + queueWithNoConnection.StopWorkers(false); } } } diff --git a/XenModel/Actions/VM/VMSnapshotCreateAction.cs b/XenModel/Actions/VM/VMSnapshotCreateAction.cs index 4d672b276..ad6b13923 100644 --- a/XenModel/Actions/VM/VMSnapshotCreateAction.cs +++ b/XenModel/Actions/VM/VMSnapshotCreateAction.cs @@ -76,7 +76,21 @@ namespace XenAdmin.Actions protected override void Run() { Description = Messages.SNAPSHOTTING; - + + // Take screenshot before snapshot begins, to avoid possible console switching (CA-211369) + // The screenshot is optional. If it throws an exception, we will do without it. CA-37095/CA-37103. + Image snapshot = null; + try + { + if (VM.power_state == vm_power_state.Running && m_Type == SnapshotType.DISK_AND_MEMORY) + { + // use the sudo credentials for the snapshot (can be null) (CA-91132) + snapshot = _screenShotProvider(VM, sudoUsername, sudoPassword); + } + } + catch (Exception) + { + } if (m_Type == SnapshotType.QUIESCED_DISK) { @@ -97,21 +111,7 @@ namespace XenAdmin.Actions string newVmRef = taskResult.Substring(7, taskResult.Length - 15); XenAPI.VM.set_name_description(Session, newVmRef, m_NewDescription); - // The screenshot is optional. If it throws an exception, we will do without it. CA-37095/CA-37103. - try - { - if (VM.power_state == vm_power_state.Running && m_Type == SnapshotType.DISK_AND_MEMORY) - { - // use the sudo credentials for the snapshot (can be null) (CA-91132) - using (Image snapshot = _screenShotProvider(VM, sudoUsername, sudoPassword)) - { - SaveImageInBlob(newVmRef, snapshot); - } - } - } - catch (Exception) - { - } + SaveImageInBlob(newVmRef, snapshot); Description = Messages.SNAPSHOTTED; } diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 901653a0c..a95748671 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34209 +// Runtime Version:4.0.30319.18444 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -10309,6 +10309,24 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Delete WLB Optimization Scheduler. + /// + public static string DELETE_WLB_OPTIMIZATION_SCHEDULE_CAPTION { + get { + return ResourceManager.GetString("DELETE_WLB_OPTIMIZATION_SCHEDULE_CAPTION", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to This will delete the selected scheduler. Continue?. + /// + public static string DELETE_WLB_OPTIMIZATION_SCHEDULE_WARNING { + get { + return ResourceManager.GetString("DELETE_WLB_OPTIMIZATION_SCHEDULE_WARNING", resourceCulture); + } + } + /// /// Looks up a localized string similar to Deleted tag '{0}'. /// @@ -22995,9 +23013,9 @@ namespace XenAdmin { /// /// Looks up a localized string similar to SMB servers are a common form of Windows shared filesystem infrastructure, and can be used as a storage repository substrate for virtual disks. /// - ///As SMB storage repositories are shared, the virtual disks stored in them allow VMs to be started on any server in a resource pool and to be migrated between them using XenMotion. + ///As SMB storage repositories are shared, the virtual disks stored in them allow VMs to be started on any server in a resource pool and to be migrated between them using Live Migration. /// - ///When you configure a SMB storage repository, you simply provide the hostname or IP address of the SMB server, the username, the password and the path to a directory that will be used [rest of string was truncated]";. + ///When you configure a SMB storage repository, you simply provide the hostname or IP address of the SMB server, the username, the password and the path to a directory that will be [rest of string was truncated]";. /// public static string NEWSR_CIFS_BLURB { get { @@ -23123,7 +23141,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Dell EqualLogic is a scalable form of high performance network attached storage, which supports the addition of capacity without downtime. You can use Dell EqualLogic shared storage to support [XenServer] features such as XenMotion and High Availability.. + /// Looks up a localized string similar to Dell EqualLogic is a scalable form of high performance network attached storage, which supports the addition of capacity without downtime. You can use Dell EqualLogic shared storage to support [XenServer] features such as Live Migration and High Availability.. /// public static string NEWSR_EQUAL_LOGIC_BLURB { get { @@ -23604,9 +23622,9 @@ namespace XenAdmin { /// /// Looks up a localized string similar to NFS servers are a common form of shared filesystem infrastructure, and can be used as a storage repository substrate for virtual disks. /// - ///As NFS storage repositories are shared, the virtual disks stored in them allow VMs to be started on any server in a resource pool and to be migrated between them using XenMotion. + ///As NFS storage repositories are shared, the virtual disks stored in them allow VMs to be started on any server in a resource pool and to be migrated between them using Live Migration. /// - ///When you configure an NFS storage repository, you simply provide the hostname or IP address of the NFS server and the path to a directory that will be used to contain the storage repository. [rest of string was truncated]";. + ///When you configure an NFS storage repository, you simply provide the hostname or IP address of the NFS server and the path to a directory that will be used to contain the storage reposit [rest of string was truncated]";. /// public static string NEWSR_VHDONFS_BLURB { get { @@ -25972,6 +25990,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Resolving issues.... + /// + public static string PATCHINGWIZARD_PRECHECKPAGE_RESOLVING_ALL { + get { + return ResourceManager.GetString("PATCHINGWIZARD_PRECHECKPAGE_RESOLVING_ALL", resourceCulture); + } + } + /// /// Looks up a localized string similar to Prechecks. /// @@ -32441,6 +32468,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Cannot migrate VM '{0}' due to license restrictions.. + /// + public static string UPDATES_WIZARD_CANNOT_MIGRATE_VM_LICENSE_REASON { + get { + return ResourceManager.GetString("UPDATES_WIZARD_CANNOT_MIGRATE_VM_LICENSE_REASON", resourceCulture); + } + } + /// /// Looks up a localized string similar to Cannot migrate VM '{0}' for an unknown reason. See application logs for more details.. /// diff --git a/XenModel/Messages.ja.resx b/XenModel/Messages.ja.resx index 994158b59..c9e3e44d5 100644 --- a/XenModel/Messages.ja.resx +++ b/XenModel/Messages.ja.resx @@ -3715,6 +3715,12 @@ VM 移行処理のパフォーマンスや信頼性を向上させるため、 VM 保護ポリシーの削除 + + Delete WLB Optimization Scheduler + + + This will delete the selected scheduler. Continue? + タグ '{0}' を削除しています @@ -7860,7 +7866,7 @@ SCSI ID: {2} SMB サーバーは、広く使用されている共有ファイルシステム インフラストラクチャの形式で、仮想ディスクのストレージ リポジトリ サブストレートとして使用することができます。 -SMB ストレージ リポジトリは共有されているため、その中に仮想ディスクを格納することで、リソース プール内の任意のサーバーでの VM の起動が可能になり、XenMotion による移行機能も提供されます。 +SMB ストレージ リポジトリは共有されているため、その中に仮想ディスクを格納することで、リソース プール内の任意のサーバーでの VM の起動が可能になり、Live Migration による移行機能も提供されます。 SMB ストレージ リポジトリを構成する場合は、SMB サーバーのホスト名または IP アドレス、ユーザー名、パスワード、およびそのストレージ リポジトリを格納するディレクトリのパスを入力します。プール内のすべてのサーバーにそのパスがエクスポートされるように SMB サーバーを構成してください。 @@ -7907,7 +7913,7 @@ SMB ストレージ リポジトリを構成する場合は、SMB サーバー シン - Dell EqualLogic は、高性能かつスケーラブルなネットワーク接続ストレージで、ダウンタイムのない容量増設をサポートしています。Dell EqualLogic 共有ストレージを使用すると、XenMotion や高可用性などの [XenServer] 機能をサポートできます。 + Dell EqualLogic は、高性能かつスケーラブルなネットワーク接続ストレージで、ダウンタイムのない容量増設をサポートしています。Dell EqualLogic 共有ストレージを使用すると、Live Migration や高可用性などの [XenServer] 機能をサポートできます。 Dell EqualLogic SR [{0} ({1})] @@ -8082,7 +8088,7 @@ VM の複製では、ファイラの複製機能とスナップショット機 NFS サーバーは、広く使用されている共有ファイルシステム インフラストラクチャの形式で、仮想ディスクのストレージ リポジトリ サブストレートとして使用することができます。 -NFS ストレージ リポジトリは共有されているため、その中に仮想ディスクを格納することで、リソース プール内の任意のサーバーでの VM の起動が可能になり、XenMotion による移行機能も提供されます。 +NFS ストレージ リポジトリは共有されているため、その中に仮想ディスクを格納することで、リソース プール内の任意のサーバーでの VM の起動が可能になり、Live Migration による移行機能も提供されます。 NFS ストレージ リポジトリを構成する場合は、NFS サーバーのホスト名または IP アドレスと、そのストレージ リポジトリを格納するディレクトリのパスを入力します。プール内のすべてのサーバーにそのパスがエクスポートされるように NFS サーバーを構成してください。 diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index cb1c1276b..700d8bcd4 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -3714,6 +3714,12 @@ This will also delete its subfolders. Delete VM Protection Policy + + Delete WLB Optimization Scheduler + + + This will delete the selected scheduler. Continue? + Deleting tag '{0}' @@ -7865,7 +7871,7 @@ You should only proceed if you have verified that these settings are correct. SMB servers are a common form of Windows shared filesystem infrastructure, and can be used as a storage repository substrate for virtual disks. -As SMB storage repositories are shared, the virtual disks stored in them allow VMs to be started on any server in a resource pool and to be migrated between them using XenMotion. +As SMB storage repositories are shared, the virtual disks stored in them allow VMs to be started on any server in a resource pool and to be migrated between them using Live Migration. When you configure a SMB storage repository, you simply provide the hostname or IP address of the SMB server, the username, the password and the path to a directory that will be used to contain the storage repository. The SMB server must be configured to export the specified path to all servers in the pool. @@ -7912,7 +7918,7 @@ When you configure a SMB storage repository, you simply provide the hostname or Thin - Dell EqualLogic is a scalable form of high performance network attached storage, which supports the addition of capacity without downtime. You can use Dell EqualLogic shared storage to support [XenServer] features such as XenMotion and High Availability. + Dell EqualLogic is a scalable form of high performance network attached storage, which supports the addition of capacity without downtime. You can use Dell EqualLogic shared storage to support [XenServer] features such as Live Migration and High Availability. Dell EqualLogic SR [{0} ({1})] @@ -8087,7 +8093,7 @@ VM cloning uses the snapshot and clone capabilities of the filer to provide high NFS servers are a common form of shared filesystem infrastructure, and can be used as a storage repository substrate for virtual disks. -As NFS storage repositories are shared, the virtual disks stored in them allow VMs to be started on any server in a resource pool and to be migrated between them using XenMotion. +As NFS storage repositories are shared, the virtual disks stored in them allow VMs to be started on any server in a resource pool and to be migrated between them using Live Migration. When you configure an NFS storage repository, you simply provide the hostname or IP address of the NFS server and the path to a directory that will be used to contain the storage repository. The NFS server must be configured to export the specified path to all servers in the pool. @@ -8979,6 +8985,9 @@ However, there is not enough space to perform the repartitioning, so the current Resolve + + Resolving issues... + Prechecks @@ -11217,6 +11226,9 @@ Check your settings and try again. Cannot migrate VM '{0}' + + Cannot migrate VM '{0}' due to license restrictions. + Cannot migrate VM '{0}' for an unknown reason. See application logs for more details. diff --git a/XenModel/Messages.zh-CN.resx b/XenModel/Messages.zh-CN.resx index 21aa536d7..69468cb0f 100644 --- a/XenModel/Messages.zh-CN.resx +++ b/XenModel/Messages.zh-CN.resx @@ -1,4 +1,4 @@ - +