public static void ShowLicensingFailureDialog(List <LicenseFailure> licenseFailures, string exceptionMessage, Control parent) { Debug.Assert(licenseFailures.Count > 0); if (licenseFailures.Count == 1) { 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 { var failureDic = new Dictionary <SelectedItem, string>(); foreach (var f in licenseFailures) { failureDic.Add(new SelectedItem(f.Host), f.AlertText); } Program.Invoke(Program.MainWindow, () => { using (var dlg = new CommandErrorDialog(Messages.LICENSE_ERROR_TITLE, exceptionMessage, failureDic)) { dlg.ShowDialog(parent); } }); } }
public static void StartDiagnosisForm(VM vm, bool isStart) { ThreadPool.QueueUserWorkItem(delegate { string title = Messages.ERROR_DIALOG_START_VM_TITLE; string text = string.Format(Messages.ERROR_DIALOG_START_VM_TEXT, vm); if (Win32Window.GetWindowWithText(title) != null) { // don't bother showing this if there's one already up. return; } var connection = vm.Connection; Session session; try { session = connection.DuplicateSession(); if (session == null) { return; } } catch (Exception) { return; } var reasons = new Dictionary <IXenObject, string>(); foreach (Host host in connection.Cache.Hosts) { reasons[host] = string.Empty; if (!isStart && VMOperationHostCommand.VmCpuIncompatibleWithHost(host, vm)) { reasons[host] = FriendlyErrorNames.VM_INCOMPATIBLE_WITH_THIS_HOST; continue; } try { VM.assert_can_boot_here(session, vm.opaque_ref, host.opaque_ref); } catch (Failure failure) { reasons[host] = failure.Message; } catch (Exception e) { log.ErrorFormat("There was an error calling assert_can_boot_here on host {0}: {1}", host.Name(), e.Message); reasons[host] = Messages.HOST_MENU_UNKNOWN_ERROR; } } Program.Invoke(Program.MainWindow, () => { using (var dialog = new CommandErrorDialog(title, text, reasons)) dialog.ShowDialog(Program.MainWindow); }); }); }
/// <summary> /// Executes this Command on the current selection. /// </summary> public void Execute() { if (Confirm()) { CommandErrorDialog errorDialog = GetErrorDialog(); ExecuteCore(GetSelection()); if (errorDialog != null) { errorDialog.ShowDialog(Parent); } } }
public static void ShowLicensingFailureDialog(List <LicenseFailure> licenseFailures, string exceptionMessage, Control parent) { Debug.Assert(licenseFailures.Count > 0); if (licenseFailures.Count == 1) { Program.Invoke(Program.MainWindow, () => { using (var dlg = new ErrorDialog(licenseFailures[0].AlertText) { WindowTitle = Messages.LICENSE_ERROR_TITLE }) { dlg.ShowDialog(parent); } }); } else { var failureDic = new Dictionary <IXenObject, string>(); foreach (var f in licenseFailures) { failureDic.Add(f.Host, f.AlertText); } Program.Invoke(Program.MainWindow, () => { using (var dlg = new CommandErrorDialog(Messages.LICENSE_ERROR_TITLE, exceptionMessage, failureDic)) { dlg.ShowDialog(parent); } }); } }
protected override void ExecuteCore(SelectedItemCollection selection) { // find SRs that are using the storage-systems. First look in XC. var srsInUse = new List <IXenObject>(); foreach (StorageLinkSystem system in GetSelection().AsXenObjects()) { foreach (IXenConnection connection in ConnectionsManager.XenConnections.FindAll(c => c.IsConnected)) { foreach (SR sr in connection.Cache.SRs) { foreach (XenRef <PBD> pbdRef in sr.PBDs) { PBD pbd = sr.Connection.Resolve <PBD>(pbdRef); if (pbd != null && pbd.device_config.ContainsKey("storageSystemId") && pbd.device_config["storageSystemId"] == system.opaque_ref) { srsInUse.Add(sr); break; } } } } } string title = GetSelection().Count == 1 ? Messages.MAINWINDOW_CONFIRM_REMOVE_STORAGE_SYSTEM_TITLE : Messages.MAINWINDOW_CONFIRM_REMOVE_STORAGE_SYSTEMS_TITLE; if (srsInUse.Count == 0) { // now check for SRs using the the storage-systems in SL. DelegatedAsyncAction scanAction = null; scanAction = new DelegatedAsyncAction(null, ConfirmationDialogTitle, "", "", s => { foreach (StorageLinkSystem system in GetSelection().AsXenObjects()) { scanAction.Title = string.Format(Messages.STORAGELINK_SCANNING_FOR_SRS, system); scanAction.Description = string.Format(Messages.STORAGELINK_SCANNING_FOR_SRS, system); var systemSRs = system.StorageLinkConnection.FullSRRescan().FindAll(ss => ss.StorageLinkSystemId == system.StorageSystemId); srsInUse.AddRange(systemSRs.ConvertAll(slr => (IXenObject)slr)); } }, true); scanAction.AppliesTo.AddRange(GetSelection().AsXenObjects().ConvertAll(s => s.opaque_ref)); new ActionProgressDialog(scanAction, ProgressBarStyle.Marquee).ShowDialog(); if (!scanAction.Succeeded) { // scan failed. A message will have been displayed. return; } } if (srsInUse.Count > 0) { // show confirmation dialog. string text = Messages.MAINWINDOW_CONFIRM_REMOVE_STORAGE_SYSTEMS_TEXT; if (GetSelection().Count == 1) { text = string.Format(Messages.MAINWINDOW_CONFIRM_REMOVE_STORAGE_SYSTEM_TEXT, GetSelection()[0].XenObject); } var reasons = new Dictionary <SelectedItem, string>(); foreach (IXenObject x in srsInUse) { reasons[new SelectedItem(x)] = Messages.STORAGELINK_IN_USE; } var dialog = new CommandErrorDialog(title, text, reasons, CommandErrorDialog.DialogMode.OKCancel); if (dialog.ShowDialog(Parent) != DialogResult.OK) { return; } } // remove storage-system var actions = new List <AsyncAction>(); foreach (StorageLinkSystem system in GetSelection().AsXenObjects()) { actions.Add(new RemoveStorageLinkSystemAction(system)); } RunMultipleActions(actions, Messages.REMOVE_STORAGE_LINK_SYSTEMS_ACTION_TITLE, Messages.REMOVE_STORAGE_LINK_SYSTEMS_ACTION_START_DESCRIPTION, Messages.REMOVE_STORAGE_LINK_SYSTEMS_ACTION_END_DESCRIPTION, true); }