Beispiel #1
0
        private void tsmiDismissSelected_Click(object sender, EventArgs e)
        {
            if (!Properties.Settings.Default.DoNotConfirmDismissEvents)
            {
                using (var dlog = new NoIconDialog(Messages.MESSAGEBOX_LOGS_DELETE_SELECTED,
                                                   ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
                {
                    ShowCheckbox = true,
                    CheckboxCaption = Messages.DO_NOT_SHOW_THIS_MESSAGE
                })
                {
                    var result = dlog.ShowDialog(this);
                    Properties.Settings.Default.DoNotConfirmDismissEvents = dlog.IsCheckBoxChecked;
                    Settings.TrySaveSettings();

                    if (result != DialogResult.Yes)
                    {
                        return;
                    }
                }
            }

            var actions = from DataGridViewActionRow row in dataGridView.SelectedRows where row != null && row.Action != null && row.Action.IsCompleted && row.Visible select row.Action;

            ConnectionsManager.History.RemoveAll(actions.Contains);
        }
Beispiel #2
0
        private void row_DismissalRequested(DataGridViewActionRow row)
        {
            if (ConnectionsManager.History.Count > 0)
            {
                if (!Program.RunInAutomatedTestMode && !Properties.Settings.Default.DoNotConfirmDismissEvents)
                {
                    using (var dlg = new NoIconDialog(Messages.MESSAGEBOX_LOG_DELETE,
                                                      ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
                    {
                        ShowCheckbox = true,
                        CheckboxCaption = Messages.DO_NOT_SHOW_THIS_MESSAGE
                    })
                    {
                        var result = dlg.ShowDialog(this);
                        Properties.Settings.Default.DoNotConfirmDismissEvents = dlg.IsCheckBoxChecked;
                        Settings.TrySaveSettings();

                        if (result != DialogResult.Yes)
                        {
                            return;
                        }
                    }
                }

                ConnectionsManager.History.Remove(row.Action);
            }
        }
        private void disableLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (poolsDataGridView.SelectedRows.Count != 1 || !(poolsDataGridView.SelectedRows[0] is PoolRow))
            {
                return;
            }

            var poolRow = (PoolRow)poolsDataGridView.SelectedRows[0];

            if (poolRow.Pool == null)
            {
                return;
            }
            var healthCheckSettings = poolRow.Pool.HealthCheckSettings();

            if (healthCheckSettings.Status == HealthCheckStatus.Enabled)
            {
                string msg = Helpers.GetPool(poolRow.Pool.Connection) == null
                    ? Messages.CONFIRM_DISABLE_HEALTH_CHECK_SERVER
                    : Messages.CONFIRM_DISABLE_HEALTH_CHECK_POOL;
                using (var dlg = new NoIconDialog(msg, ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo))
                {
                    if (dlg.ShowDialog(this) != DialogResult.Yes)
                    {
                        return;
                    }
                }
                healthCheckSettings.Status = HealthCheckStatus.Disabled;
                new SaveHealthCheckSettingsAction(poolRow.Pool, healthCheckSettings, null, null, null, null, false).RunAsync();
            }
        }
Beispiel #4
0
        private void tsmiDismissSelected_Click(object sender, EventArgs e)
        {
            if (!Properties.Settings.Default.DoNotConfirmDismissAlerts)
            {
                using (var dlog = new NoIconDialog(Messages.ALERT_DISMISS_SELECTED_CONFIRM,
                                                   ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
                {
                    ShowCheckbox = true,
                    CheckboxCaption = Messages.DO_NOT_SHOW_THIS_MESSAGE
                })
                {
                    var result = dlog.ShowDialog(this);
                    Properties.Settings.Default.DoNotConfirmDismissAlerts = dlog.IsCheckBoxChecked;
                    Settings.TrySaveSettings();

                    if (result != DialogResult.Yes)
                    {
                        return;
                    }
                }
            }

            if (GridViewAlerts.SelectedRows.Count > 0)
            {
                var selectedAlerts = from DataGridViewRow row in GridViewAlerts.SelectedRows select row.Tag as Alert;
                DismissAlerts(selectedAlerts.ToArray());
            }
        }
Beispiel #5
0
        protected override void Execute(List <VM> vms)
        {
            Dictionary <VM, List <VBD> > brokenCDs = new Dictionary <VM, List <VBD> >();

            foreach (VM vm in vms)
            {
                foreach (VBD vbd in vm.Connection.ResolveAll <VBD>(vm.VBDs))
                {
                    if (vbd.type == vbd_type.CD && !vbd.empty)
                    {
                        VDI vdi = vm.Connection.Resolve <VDI>(vbd.VDI);
                        SR  sr  = null;
                        if (vdi != null)
                        {
                            sr = vm.Connection.Resolve <SR>(vdi.SR);
                        }
                        if (vdi == null || sr.IsBroken(true) || sr.IsDetached())
                        {
                            if (!brokenCDs.ContainsKey(vm))
                            {
                                brokenCDs.Add(vm, new List <VBD>());
                            }

                            brokenCDs[vm].Add(vbd);
                        }
                    }
                }
            }
            if (brokenCDs.Count > 0)
            {
                DialogResult d;
                using (var dlg = new NoIconDialog(Messages.EJECT_BEFORE_VM_START_MESSAGE_BOX,
                                                  new ThreeButtonDialog.TBDButton(Messages.EJECT_BUTTON_LABEL, DialogResult.OK, selected: true),
                                                  new ThreeButtonDialog.TBDButton(Messages.IGNORE_BUTTON_LABEL, DialogResult.Ignore),
                                                  ThreeButtonDialog.ButtonCancel)
                {
                    WindowTitle = vms.Count > 1 ? Messages.STARTING_VMS_MESSAGEBOX_TITLE : Messages.STARTING_VM_MESSAGEBOX_TITLE
                })
                {
                    d = dlg.ShowDialog(MainWindowCommandInterface.Form);
                }
                if (d == DialogResult.Cancel)
                {
                    return;
                }
                if (d == DialogResult.Ignore)
                {
                    brokenCDs = null;
                }
            }
            RunAction(vms, Messages.ACTION_VMS_STARTING_ON_TITLE, Messages.ACTION_VMS_STARTING_ON_TITLE, Messages.ACTION_VM_STARTED, brokenCDs);
        }
Beispiel #6
0
        private void buttonDisableHa_Click(object sender, EventArgs e)
        {
            if (pool == null)
            {
                return;
            }

            if (!pool.ha_enabled)
            {
                // Start HA wizard
                EditHA(pool);
                return;
            }

            if (pool.ha_statefiles.All(sf => pool.Connection.Resolve(new XenRef <VDI>(sf)) == null)) //empty gives true, which is correct
            {
                using (var dlg = new ErrorDialog(string.Format(Messages.HA_DISABLE_NO_STATEFILE, Helpers.GetName(pool).Ellipsise(30)),
                                                 ThreeButtonDialog.ButtonOK)
                {
                    HelpName = "HADisable",
                    WindowTitle = Messages.DISABLE_HA
                })
                {
                    dlg.ShowDialog(this);
                    return;
                }
            }

            // Confirm the user wants to disable HA
            using (var dlg = new NoIconDialog(string.Format(Messages.HA_DISABLE_QUERY, Helpers.GetName(pool).Ellipsise(30)),
                                              ThreeButtonDialog.ButtonYes,
                                              ThreeButtonDialog.ButtonNo)
            {
                HelpName = "HADisable",
                WindowTitle = Messages.DISABLE_HA
            })
            {
                if (dlg.ShowDialog(this) != DialogResult.Yes)
                {
                    return;
                }
            }

            DisableHAAction action = new DisableHAAction(pool);

            // We will need to re-enable buttons when the action completes
            action.Completed += Program.MainWindow.action_Completed;
            action.RunAsync();
        }
Beispiel #7
0
        private void tsmiDismissAll_Click(object sender, EventArgs e)
        {
            if (ConnectionsManager.History.Count == 0)
            {
                return;
            }

            DialogResult result = DialogResult.Yes;

            if (!Program.RunInAutomatedTestMode)
            {
                if (FilterIsOn)
                {
                    using (var dlog = new NoIconDialog(Messages.MESSAGEBOX_LOGS_DELETE,
                                                       new ThreeButtonDialog.TBDButton(Messages.DISMISS_ALL_CONFIRM_BUTTON, DialogResult.Yes),
                                                       new ThreeButtonDialog.TBDButton(Messages.DISMISS_FILTERED_CONFIRM_BUTTON, DialogResult.No, ThreeButtonDialog.ButtonType.NONE),
                                                       ThreeButtonDialog.ButtonCancel))
                    {
                        result = dlog.ShowDialog(this);
                    }
                }
                else if (!Properties.Settings.Default.DoNotConfirmDismissEvents)
                {
                    using (var dlog = new NoIconDialog(Messages.MESSAGEBOX_LOGS_DELETE_NO_FILTER,
                                                       new ThreeButtonDialog.TBDButton(Messages.DISMISS_ALL_YES_CONFIRM_BUTTON, DialogResult.Yes),
                                                       ThreeButtonDialog.ButtonCancel)
                    {
                        ShowCheckbox = true,
                        CheckboxCaption = Messages.DO_NOT_SHOW_THIS_MESSAGE
                    })
                    {
                        result = dlog.ShowDialog(this);
                        Properties.Settings.Default.DoNotConfirmDismissEvents = dlog.IsCheckBoxChecked;
                        Settings.TrySaveSettings();
                    }
                }

                if (result == DialogResult.Cancel)
                {
                    return;
                }
            }

            var actions = result == DialogResult.No
                              ? (from DataGridViewActionRow row in dataGridView.Rows where row.Action != null && row.Action.IsCompleted && row.Visible select row.Action)
                              : ConnectionsManager.History.Where(action => action != null && action.IsCompleted);

            ConnectionsManager.History.RemoveAll(actions.Contains);
        }
        /// <summary>
        /// Attempts to install tools on the vm
        /// </summary>
        /// <param name="vm"></param>
        /// <returns>null if user cancels or an AsyncAction. This is either the InstallPVToolsAction or the CreateCdDriveAction if the VM needed a DVD drive.</returns>
        private void SingleVMExecute(VM vm)
        {
            if (vm.FindVMCDROM() == null)
            {
                DialogResult dialogResult;
                using (var dlg = new NoIconDialog(Messages.NEW_DVD_DRIVE_REQUIRED,
                                                  ThreeButtonDialog.ButtonYes,
                                                  ThreeButtonDialog.ButtonNo))
                {
                    dialogResult = dlg.ShowDialog(Parent);
                }
                if (dialogResult == DialogResult.Yes)
                {
                    //do not register the event ShowUserInstruction; we show explicitly a message afterwards
                    var createDriveAction = new CreateCdDriveAction(vm);

                    using (var dlg = new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee))
                        dlg.ShowDialog(Parent);

                    if (createDriveAction.Succeeded)
                    {
                        ShowMustRebootBox();
                    }

                    InstallTools?.Invoke(createDriveAction);
                }
                return;
            }

            using (var dlg = new WarningDialog(Messages.XS_TOOLS_MESSAGE_ONE_VM,
                                               new ThreeButtonDialog.TBDButton(Messages.INSTALL_XENSERVER_TOOLS_BUTTON,
                                                                               DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true),
                                               ThreeButtonDialog.ButtonCancel)
            {
                ShowLinkLabel = true,
                LinkText = Messages.INSTALLTOOLS_READ_MORE,
                LinkAction = () => Help.HelpManager.Launch("InstallToolsWarningDialog")
            })
                if (dlg.ShowDialog(Parent) == DialogResult.OK && CheckToolSrs(vm))
                {
                    var installToolsAction = new InstallPVToolsAction(vm, Properties.Settings.Default.ShowHiddenVMs);
                    installToolsAction.Completed += InstallToolsActionCompleted;

                    installToolsAction.RunAsync();
                    InstallTools?.Invoke(installToolsAction);
                }
        }
Beispiel #9
0
        private void ToolStripMenuItemDismiss_Click(object sender, EventArgs e)
        {
            if (GridViewAlerts.SelectedRows.Count != 1)
            {
                log.DebugFormat("Only 1 alert can be dismissed at a time (Attempted to dismiss {0}). Dismissing the clicked item.", GridViewAlerts.SelectedRows.Count);
            }

            DataGridViewRow clickedRow = FindAlertRow(sender as ToolStripMenuItem);

            if (clickedRow == null)
            {
                log.Debug("Attempted to dismiss alert with no alert selected.");
                return;
            }

            Alert alert = (Alert)clickedRow.Tag;

            if (alert == null)
            {
                return;
            }

            if (!Properties.Settings.Default.DoNotConfirmDismissAlerts)
            {
                using (var dlog = new NoIconDialog(Messages.ALERT_DISMISS_CONFIRM,
                                                   ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
                {
                    ShowCheckbox = true,
                    CheckboxCaption = Messages.DO_NOT_SHOW_THIS_MESSAGE
                })
                {
                    var result = dlog.ShowDialog(this);
                    Properties.Settings.Default.DoNotConfirmDismissAlerts = dlog.IsCheckBoxChecked;
                    Settings.TrySaveSettings();

                    if (result != DialogResult.Yes)
                    {
                        return;
                    }
                }
            }

            DismissAlerts(new List <Alert> {
                (Alert)clickedRow.Tag
            });
        }
Beispiel #10
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            Pool pool = selection.Count == 1 ? selection[0].PoolAncestor : null;

            if (pool == null || !pool.ha_enabled)
            {
                return;
            }

            if (pool.ha_statefiles.All(sf => pool.Connection.Resolve(new XenRef <VDI>(sf)) == null)) //empty gives true, which is correct
            {
                using (var dlg = new ErrorDialog(string.Format(Messages.HA_DISABLE_NO_STATEFILE,
                                                               Helpers.GetName(pool).Ellipsise(30)),
                                                 ThreeButtonDialog.ButtonOK)
                {
                    WindowTitle = Messages.DISABLE_HA
                })
                {
                    dlg.ShowDialog(Parent);
                    return;
                }
            }

            // Confirm the user wants to disable HA
            using (var dlg = new NoIconDialog(string.Format(Messages.HA_DISABLE_QUERY,
                                                            Helpers.GetName(pool).Ellipsise(30)),
                                              ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
            {
                HelpNameSetter = "HADisable",
                WindowTitle = Messages.DISABLE_HA
            })
            {
                if (dlg.ShowDialog(Parent) != DialogResult.Yes)
                {
                    return;
                }
            }

            var action = new DisableHAAction(pool);

            // We will need to re-enable buttons when the action completes
            action.Completed += Program.MainWindow.action_Completed;
            action.RunAsync();
        }
Beispiel #11
0
        /// <summary>
        /// Attempts to install tools on the vm
        /// </summary>
        /// <param name="vm"></param>
        /// <returns>null if user cancels or an AsyncAction. This is either the InstallPVToolsAction or the CreateCdDriveAction if the VM needed a DVD drive.</returns>
        private AsyncAction SingleVMExecute(VM vm)
        {
            if (vm.FindVMCDROM() == null)
            {
                DialogResult dialogResult;
                using (var dlg = new NoIconDialog(Messages.NEW_DVD_DRIVE_REQUIRED,
                                                  ThreeButtonDialog.ButtonYes,
                                                  ThreeButtonDialog.ButtonNo))
                {
                    dialogResult = dlg.ShowDialog(Parent);
                }
                if (dialogResult == DialogResult.Yes)
                {
                    //do not register the event ShowUserInstruction; we show explicitly a message afterwards
                    var createDriveAction = new CreateCdDriveAction(vm);

                    using (var dlg = new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee))
                    {
                        dlg.ShowDialog(Parent);
                    }

                    if (createDriveAction.Succeeded)
                    {
                        ShowMustRebootBox();
                    }
                    return(createDriveAction);
                }
            }
            else
            {
                DialogResult dr = new InstallToolsWarningDialog(vm.Connection).ShowDialog(Parent);
                if (dr == DialogResult.Yes)
                {
                    var installToolsAction = new InstallPVToolsAction(vm, Properties.Settings.Default.ShowHiddenVMs);
                    installToolsAction.Completed += InstallToolsActionCompleted;

                    installToolsAction.RunAsync();
                    return(installToolsAction);
                }
            }
            return(null);
        }
Beispiel #12
0
        private void tsmiDismissAll_Click(object sender, EventArgs e)
        {
            DialogResult result = DialogResult.Yes;

            if (FilterIsOn)
            {
                using (var dlog = new NoIconDialog(Messages.ALERT_DISMISS_ALL_CONTINUE,
                                                   new ThreeButtonDialog.TBDButton(Messages.DISMISS_ALL_CONFIRM_BUTTON, DialogResult.Yes),
                                                   new ThreeButtonDialog.TBDButton(Messages.DISMISS_FILTERED_CONFIRM_BUTTON, DialogResult.No, ThreeButtonDialog.ButtonType.NONE),
                                                   ThreeButtonDialog.ButtonCancel))
                {
                    result = dlog.ShowDialog(this);
                }
            }
            else if (!Properties.Settings.Default.DoNotConfirmDismissAlerts)
            {
                using (var dlog = new NoIconDialog(Messages.ALERT_DISMISS_ALL_NO_FILTER_CONTINUE,
                                                   new ThreeButtonDialog.TBDButton(Messages.DISMISS_ALL_YES_CONFIRM_BUTTON, DialogResult.Yes),
                                                   ThreeButtonDialog.ButtonCancel)
                {
                    ShowCheckbox = true,
                    CheckboxCaption = Messages.DO_NOT_SHOW_THIS_MESSAGE
                })
                {
                    result = dlog.ShowDialog(this);
                    Properties.Settings.Default.DoNotConfirmDismissAlerts = dlog.IsCheckBoxChecked;
                    Settings.TrySaveSettings();
                }
            }

            if (result == DialogResult.Cancel)
            {
                return;
            }

            var alerts = result == DialogResult.No
                ? (from DataGridViewRow row in GridViewAlerts.Rows select row.Tag as Alert).ToArray()
                : Alert.Alerts;

            DismissAlerts(alerts);
        }
Beispiel #13
0
 private void buttonDetach_Click(object sender, System.EventArgs e)
 {
     if ((selectedRow != null) && (_vm != null))
     {
         bool confirmed = false;
         using (var dlg = new NoIconDialog(Messages.ACTION_VUSB_DETACH_CONFIRM,
                                           ThreeButtonDialog.ButtonYes,
                                           new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, selected: true))
         {
             WindowTitle = Messages.ACTION_VUSB_DETACH
         })
         {
             if (dlg.ShowDialog(Program.MainWindow) == DialogResult.Yes)
             {
                 confirmed = true;
             }
         }
         if (confirmed)
         {
             new XenAdmin.Actions.DeleteVUSBAction(selectedRow.Vusb, _vm).RunAsync();
         }
     }
 }
Beispiel #14
0
        public static bool EnableNtolDialog(Pool pool, Host host, long currentNtol, long max)
        {
            bool doit = false;

            Program.Invoke(Program.MainWindow, delegate()
            {
                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);
                using (var dlg = new NoIconDialog(msg,
                                                  ThreeButtonDialog.ButtonYes,
                                                  new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, selected: true))
                {
                    WindowTitle = Messages.HIGH_AVAILABILITY
                })
                {
                    if (dlg.ShowDialog(Program.MainWindow) == DialogResult.Yes)
                    {
                        doit = true;
                    }
                }
            });
            return(doit);
        }
Beispiel #15
0
        /// <summary>
        /// Called with the results of an iSCSI SR.probe(), either immediately after the scan, or after the
        /// user has performed a scan, clicked 'cancel' on a dialog, and then clicked 'next' again (this
        /// avoids duplicate probing if none of the settings have changed).
        /// </summary>
        /// <returns>
        /// Whether to continue or not - wheter to format or not is stored in
        /// iScsiFormatLUN.
        /// </returns>
        private bool ExamineIscsiProbeResults(SR.SRTypes currentSrType, List <SR.SRInfo> srs)
        {
            _srToIntroduce = null;

            if (srs == null)
            {
                return(false);
            }

            try
            {
                if (!String.IsNullOrEmpty(SrWizardType.UUID))
                {
                    // Check LUN contains correct SR
                    if (srs.Count == 1 && srs[0].UUID == SrWizardType.UUID)
                    {
                        _srToIntroduce = srs[0];
                        SrType         = currentSrType; // the type of the existing SR
                        return(true);
                    }

                    errorIconAtTargetLUN.Visible  = true;
                    errorLabelAtTargetLUN.Visible = true;
                    errorLabelAtTargetLUN.Text    = String.Format(Messages.INCORRECT_LUN_FOR_SR, SrWizardType.SrName);

                    return(false);
                }
                else if (srs.Count == 0)
                {
                    // 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)
                    {
                        using (var dlg = new ErrorDialog(Messages.NEWSR_LUN_HAS_NO_SRS))
                            dlg.ShowDialog(this);

                        return(false);
                    }
                    DialogResult result = DialogResult.Yes;
                    if (!Program.RunInAutomatedTestMode)
                    {
                        using (var dlg = new WarningDialog(Messages.NEWSR_ISCSI_FORMAT_WARNING,
                                                           ThreeButtonDialog.ButtonYes,
                                                           new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, selected: true))
                        {
                            WindowTitle = Text
                        })
                        {
                            result = dlg.ShowDialog(this);
                        }
                    }

                    return(result == DialogResult.Yes);
                }
                else
                {
                    // There should be 0 or 1 SRs on the LUN
                    System.Diagnostics.Trace.Assert(srs.Count == 1);

                    // CA-17230
                    // Check this isn't a detached SR
                    SR.SRInfo info = srs[0];
                    SR        sr   = SrWizardHelpers.SrInUse(info.UUID);
                    if (sr != null)
                    {
                        DialogResult res;
                        using (var d = new NoIconDialog(string.Format(Messages.DETACHED_ISCI_DETECTED, Helpers.GetName(sr.Connection)),
                                                        new ThreeButtonDialog.TBDButton(Messages.ATTACH_SR, DialogResult.OK),
                                                        ThreeButtonDialog.ButtonCancel))
                        {
                            res = d.ShowDialog(Program.MainWindow);
                        }

                        if (res == DialogResult.Cancel)
                        {
                            return(false);
                        }

                        _srToIntroduce = info;
                        SrType         = currentSrType; // the type of the existing SR
                        return(true);
                    }

                    // An SR exists on this LUN. Ask the user if they want to attach it, format it and
                    // create a new SR, or cancel.
                    DialogResult result = Program.RunInAutomatedTestMode ? DialogResult.Yes :
                                          new IscsiChoicesDialog(Connection, info, currentSrType, SrType).ShowDialog(this);

                    switch (result)
                    {
                    case DialogResult.Yes:
                        // Reattach
                        _srToIntroduce = srs[0];
                        SrType         = currentSrType; // the type of the existing SR
                        return(true);

                    case DialogResult.No:
                        // Format - SrToIntroduce is already null
                        return(true);

                    default:
                        return(false);
                    }
                }
            }
            catch
            {
                // We really want to prevent the user getting to the next step if there is any kind of
                // exception here, since clicking 'finish' might destroy data: require another probe.
                return(false);
            }
        }
Beispiel #16
0
        internal void EditWLB(Pool pool)
        {
            // Do nothing if there is a WLB action in progress
            if (HelpersGUI.FindActiveWLBAction(pool.Connection) != null)
            {
                log.Debug("Not opening WLB dialog: an WLB action is in progress");
                return;
            }

            if (!pool.Connection.IsConnected)
            {
                log.Debug("Not opening WLB dialog: the connection to the pool is now closed");
                return;
            }

            try
            {
                WlbConfigurationDialog wlbConfigDialog = new WlbConfigurationDialog(pool);
                DialogResult           dr = wlbConfigDialog.ShowDialog();

                if (dr == DialogResult.OK)
                {
                    _wlbPoolConfiguration = wlbConfigDialog.WlbPoolConfiguration;

                    //check to see if the current opt mode matches the current schedule
                    if (_wlbPoolConfiguration.AutomateOptimizationMode)
                    {
                        WlbPoolPerformanceMode scheduledPerfMode = _wlbPoolConfiguration.ScheduledTasks.GetCurrentScheduledPerformanceMode();
                        if (scheduledPerfMode != _wlbPoolConfiguration.PerformanceMode)
                        {
                            string       blurb = string.Format(Messages.WLB_PROMPT_FOR_MODE_CHANGE_BLURB, getOptModeText(scheduledPerfMode), getOptModeText(_wlbPoolConfiguration.PerformanceMode));
                            DialogResult drModeCheck;
                            using (var dlg = new NoIconDialog(blurb,
                                                              ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
                            {
                                WindowTitle = Messages.WLB_PROMPT_FOR_MODE_CHANGE_CAPTION
                            })
                            {
                                drModeCheck = dlg.ShowDialog(this);
                            }

                            if (drModeCheck == DialogResult.Yes)
                            {
                                _wlbPoolConfiguration.PerformanceMode = scheduledPerfMode;
                            }
                        }
                    }
                    SaveWLBConfig(_wlbPoolConfiguration);
                }
            }
            catch (Exception ex)
            {
                log.Debug("Unable to open the WLB configuration dialog.", ex);
                return;
            }

            if (!(WlbServerState.GetState(_pool) == WlbServerState.ServerState.NotConfigured))
            {
                RetrieveConfiguration();
            }
        }
Beispiel #17
0
        private void toolStripButtonExport_Click(object sender, EventArgs e)
        {
            bool exportAll = true;

            if (FilterIsOn)
            {
                using (var dlog = new NoIconDialog(Messages.CONVERSION_EXPORT_ALL_OR_FILTERED,
                                                   new ThreeButtonDialog.TBDButton(Messages.EXPORT_ALL_BUTTON, DialogResult.Yes),
                                                   new ThreeButtonDialog.TBDButton(Messages.EXPORT_FILTERED_BUTTON, DialogResult.No, ThreeButtonDialog.ButtonType.NONE),
                                                   ThreeButtonDialog.ButtonCancel))
                {
                    var result = dlog.ShowDialog(this);

                    if (result == DialogResult.No)
                    {
                        exportAll = false;
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }

            string fileName;

            using (SaveFileDialog dialog = new SaveFileDialog
            {
                AddExtension = true,
                Filter = string.Format("{0} (*.csv)|*.csv|{1} (*.txt)|*.txt|{2} (*.*)|*.*",
                                       Messages.CSV_DESCRIPTION, Messages.TXT_DESCRIPTION, Messages.ALL_FILES),
                FilterIndex = 0,
                Title = Messages.EXPORT_ALL,
                RestoreDirectory = true,
                DefaultExt = "csv",
                CheckPathExists = false,
                OverwritePrompt = true
            })
            {
                if (dialog.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
                fileName = dialog.FileName;
            }

            new DelegatedAsyncAction(null,
                                     string.Format(Messages.CONVERSION_EXPORT, fileName),
                                     string.Format(Messages.CONVERSION_EXPORTING, fileName),
                                     string.Format(Messages.CONVERSION_EXPORTED, fileName),
                                     s =>
            {
                using (StreamWriter stream = new StreamWriter(fileName, false, Encoding.UTF8))
                {
                    stream.WriteLine(string.Join(",", DetailHeaders.Select(v => $"\"{v}\"")));

                    if (exportAll)
                    {
                        var exportable = new List <Conversion>(CurrentConversionList);
                        foreach (var conv in exportable)
                        {
                            stream.WriteLine(string.Join(",", GetDetailValues(conv).Select(v => $"\"{v}\"")));
                        }
                    }
                    else
                    {
                        foreach (ConversionRow row in dataGridViewConversions.Rows)
                        {
                            if (row != null)
                            {
                                stream.WriteLine(string.Join(",", GetDetailValues(row.Conversion).Select(v => $"\"{v}\"")));
                            }
                        }
                    }
                }
            }).RunAsync();
        }
Beispiel #18
0
        private void CheckVersionCompatibility()
        {
            statusLabel.Text = Messages.CONVERSION_VERSION_CHECK;

            ThreadPool.QueueUserWorkItem(obj =>
            {
                const int sleep = 3000, timeout = 120000;
                var tries       = timeout / sleep;

                Exception ex   = null;
                string version = null;

                while (tries > 0)
                {
                    try
                    {
                        version = _conversionClient.GetVpxVersion();

                        if (!string.IsNullOrEmpty(version))
                        {
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        ex = e;
                    }

                    Thread.Sleep(sleep);
                    tries--;
                }

                if (string.IsNullOrEmpty(version))
                {
                    log.Error("Cannot retrieve XCM VPX version.", ex);

                    Program.Invoke(this, () =>
                    {
                        statusLabel.Image = Images.StaticImages._000_error_h32bit_16;
                        statusLabel.Text  = Messages.CONVERSION_VERSION_CHECK_FAILURE;
                        statusLinkLabel.Reset();
                    });

                    return;
                }

                Program.Invoke(this, () =>
                {
                    if (!Version.TryParse(version, out Version result) ||
                        result.CompareTo(ConversionVpxMinimumSupportedVersion) < 0)
                    {
                        statusLabel.Image = Images.StaticImages._000_error_h32bit_16;
                        statusLabel.Text  = Messages.CONVERSION_VERSION_INCOMPATIBILITY;
                        statusLinkLabel.Reset(Messages.MORE_INFO, () =>
                        {
                            using (var dlog = new NoIconDialog(string.Format(Messages.CONVERSION_VERSION_INCOMPATIBILITY_INFO, BrandManager.ProductVersion70)))
                            {
                                dlog.ShowDialog(this);
                            }
                        });
                        return;
                    }

                    statusLabel.Image = Images.StaticImages.xcm;
                    statusLabel.Text  = Messages.CONVERSION_CONNECTING_VPX_SUCCESS;
                    statusLinkLabel.Reset();

                    timerVpx.Start();
                    FetchConversionHistory();
                });
            });
        }
Beispiel #19
0
        private void buttonJoinLeave_Click(object sender, EventArgs e)
        {
            Program.AssertOnEventThread();
            if (buttonJoinLeave.Text == Messages.AD_JOIN_DOMAIN)
            {
                // We're enabling AD
                // Obtain domain, username and password; store the domain and username
                // so the user won't have to retype it for future join attempts

                using (var joinPrompt = new AdPasswordPrompt(true)
                {
                    Domain = _storedDomain, Username = _storedUsername
                })
                {
                    var result = joinPrompt.ShowDialog(this);
                    _storedDomain   = joinPrompt.Domain;
                    _storedUsername = joinPrompt.Username;

                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }

                    new EnableAdAction(_connection, joinPrompt.Domain, joinPrompt.Username, joinPrompt.Password).RunAsync();
                }
            }
            else
            {
                // We're disabling AD

                // Warn if the user will boot himself out by disabling AD
                Session session = _connection.Session;
                if (session == null)
                {
                    return;
                }

                if (session.IsLocalSuperuser)
                {
                    // User is authenticated using local root account. Confirm anyway.
                    string msg = string.Format(Messages.AD_LEAVE_CONFIRM,
                                               Helpers.GetName(_connection).Ellipsise(50).EscapeAmpersands(), Domain.Ellipsise(30));

                    DialogResult r;
                    using (var dlg = new NoIconDialog(msg,
                                                      ThreeButtonDialog.ButtonYes,
                                                      new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, selected: true))
                    {
                        WindowTitle = Messages.AD_FEATURE_NAME
                    })
                    {
                        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
                    if (r != DialogResult.Yes)
                    {
                        return;
                    }
                }
                else
                {
                    // Warn user will be booted out.
                    string msg = string.Format(Helpers.GetPool(_connection) != null ? Messages.AD_LEAVE_WARNING : Messages.AD_LEAVE_WARNING_HOST,
                                               Helpers.GetName(_connection).Ellipsise(50), Domain.Ellipsise(30));

                    DialogResult r;
                    using (var dlg = new WarningDialog(msg,
                                                       ThreeButtonDialog.ButtonYes,
                                                       new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, selected: true))
                    {
                        WindowTitle = Messages.ACTIVE_DIRECTORY_TAB_TITLE
                    })
                    {
                        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
                    if (r != DialogResult.Yes)
                    {
                        return;
                    }
                }

                Host master = Helpers.GetMaster(_connection);
                if (master == null)
                {
                    // Really shouldn't happen unless we have been very slow with the cache
                    log.Error("Could not retrieve master when trying to look up domain..");
                    throw new Exception(Messages.CONNECTION_IO_EXCEPTION);
                }

                using (var passPrompt = new AdPasswordPrompt(false, master.external_auth_service_name))
                {
                    var result = passPrompt.ShowDialog(this);
                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }

                    var creds = new Dictionary <string, string>();
                    if (result != DialogResult.Ignore)
                    {
                        creds.Add(DisableAdAction.KEY_USER, passPrompt.Username);
                        creds.Add(DisableAdAction.KEY_PASSWORD, passPrompt.Password);
                    }

                    new DisableAdAction(_connection, creds).RunAsync();
                }
            }
        }
Beispiel #20
0
        private void ButtonRemove_Click(object sender, EventArgs e)
        {
            Program.AssertOnEventThread();

            // Double check, this method is called from a context menu as well and the state could have changed under it
            if (!ButtonRemove.Enabled)
            {
                return;
            }

            List <Subject> subjectsToRemove = new List <Subject>();

            foreach (AdSubjectRow r in GridViewSubjectList.SelectedRows)
            {
                subjectsToRemove.Add(r.subject);
            }

            var removeMessage = subjectsToRemove.Count == 1
                ? 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;

            using (var dlg = new NoIconDialog(removeMessage,
                                              ThreeButtonDialog.ButtonYes,
                                              new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, selected: true))
            {
                WindowTitle = Messages.AD_FEATURE_NAME
            })
            {
                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
            if (questionDialog != DialogResult.Yes)
            {
                return;
            }

            // Warn if user is revoking his currently-in-use credentials
            Session session = _connection.Session;

            if (session != null && session.SessionSubject != null)
            {
                foreach (Subject entry in subjectsToRemove)
                {
                    if (entry.opaque_ref == session.SessionSubject)
                    {
                        string subjectName = entry.DisplayName ?? entry.SubjectName;
                        if (subjectName == null)
                        {
                            subjectName = entry.subject_identifier;
                        }
                        else
                        {
                            subjectName = subjectName.Ellipsise(256);
                        }
                        string msg = string.Format(entry.IsGroup ? Messages.AD_CONFIRM_SUICIDE_GROUP : Messages.AD_CONFIRM_SUICIDE,
                                                   subjectName, Helpers.GetName(_connection).Ellipsise(50));

                        DialogResult r;
                        using (var dlg = new WarningDialog(msg,
                                                           ThreeButtonDialog.ButtonYes,
                                                           new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, selected: true))
                        {
                            WindowTitle = Messages.AD_FEATURE_NAME
                        })
                        {
                            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
                        if (r != DialogResult.Yes)
                        {
                            return;
                        }

                        break;
                    }
                }
            }

            var action = new AddRemoveSubjectsAction(_connection, new List <string>(), subjectsToRemove);

            using (var dlog = new ActionProgressDialog(action, ProgressBarStyle.Continuous))
                dlog.ShowDialog(this);
        }
Beispiel #21
0
        protected override void FinishWizard()
        {
            AsyncAction action;

            if (bugToolPageDestination1.Upload)
            {
                // The MultipleAction is only used as a wrapper, we will suppress its history and expose the sub-actions in the history
                List <AsyncAction>    subActions = new List <AsyncAction>();
                ZipStatusReportAction zipAction  = new ZipStatusReportAction(bugToolPageRetrieveData.OutputFolder, bugToolPageDestination1.OutputFile, false);
                subActions.Add(zipAction);
                UploadServerStatusReportAction uploadAction = new UploadServerStatusReportAction(bugToolPageDestination1.OutputFile,   // tmp folder
                                                                                                 bugToolPageDestination1.UploadToken,  // upload token
                                                                                                 bugToolPageDestination1.CaseNumber,   // case id
                                                                                                 Registry.HealthCheckUploadDomainName, // domain name
                                                                                                 false);                               // suppressHistory
                subActions.Add(uploadAction);
                action = new MultipleAction(null, Messages.BUGTOOL_SAVING, Messages.BUGTOOL_SAVING, Messages.COMPLETED, subActions, true);
            }
            else
            {
                action = new ZipStatusReportAction(bugToolPageRetrieveData.OutputFolder, bugToolPageDestination1.OutputFile, false);
            }

            action.RunAsync();

            log.Debug("Cleaning up crash dump logs on server");
            var capabilities = bugToolPageSelectCapabilities1.Capabilities;

            foreach (Capability c in capabilities)
            {
                if (c.Key == "host-crashdump-dumps" && c.Checked)
                {
                    var hostList = bugToolPageSelectHosts1.SelectedHosts;
                    if (!hostList.Any(h => h.HasCrashDumps()))
                    {
                        break;
                    }

                    DialogResult result;
                    using (var dlg = new NoIconDialog(Messages.REMOVE_CRASHDUMP_QUESTION,
                                                      ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
                    {
                        WindowTitle = Messages.REMOVE_CRASHDUMP_FILES
                    })
                    {
                        result = dlg.ShowDialog(this);
                    }
                    if (result == DialogResult.Yes)
                    {
                        foreach (Host host in hostList)
                        {
                            if (host != null && host.HasCrashDumps())
                            {
                                new Actions.DestroyHostCrashDumpAction(host).RunAsync();
                            }
                        }
                    }
                    break;
                }
            }

            base.FinishWizard();
        }
Beispiel #22
0
        private void toolStripButtonExportAll_Click(object sender, EventArgs e)
        {
            bool exportAll = true;

            if (FilterIsOn)
            {
                using (var dlog = new NoIconDialog(Messages.ALERT_EXPORT_ALL_OR_FILTERED,
                                                   new ThreeButtonDialog.TBDButton(Messages.EXPORT_ALL_BUTTON, DialogResult.Yes),
                                                   new ThreeButtonDialog.TBDButton(Messages.EXPORT_FILTERED_BUTTON, DialogResult.No, ThreeButtonDialog.ButtonType.NONE),
                                                   ThreeButtonDialog.ButtonCancel))
                {
                    var result = dlog.ShowDialog(this);
                    if (result == DialogResult.No)
                    {
                        exportAll = false;
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }

            string fileName;

            using (SaveFileDialog dialog = new SaveFileDialog
            {
                AddExtension = true,
                Filter = string.Format("{0} (*.csv)|*.csv|{1} (*.*)|*.*",
                                       Messages.CSV_DESCRIPTION, Messages.ALL_FILES),
                FilterIndex = 0,
                Title = Messages.EXPORT_ALL,
                RestoreDirectory = true,
                DefaultExt = "csv",
                CheckPathExists = false,
                OverwritePrompt = true
            })
            {
                if (dialog.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
                fileName = dialog.FileName;
            }

            new DelegatedAsyncAction(null,
                                     string.Format(Messages.EXPORT_SYSTEM_ALERTS, fileName),
                                     string.Format(Messages.EXPORTING_SYSTEM_ALERTS, fileName),
                                     string.Format(Messages.EXPORTED_SYSTEM_ALERTS, fileName),
                                     delegate
            {
                using (StreamWriter stream = new StreamWriter(fileName, false, Encoding.UTF8))
                {
                    stream.WriteLine("{0},{1},{2},{3},{4}", Messages.TITLE,
                                     Messages.SEVERITY, Messages.DESCRIPTION,
                                     Messages.APPLIES_TO, Messages.TIMESTAMP);

                    if (exportAll)
                    {
                        foreach (Alert a in Alert.Alerts)
                        {
                            if (!a.Dismissing)
                            {
                                stream.WriteLine(a.GetAlertDetailsCSVQuotes());
                            }
                        }
                    }
                    else
                    {
                        foreach (DataGridViewRow row in GridViewAlerts.Rows)
                        {
                            if (row.Tag is Alert a && !a.Dismissing)
                            {
                                stream.WriteLine(a.GetAlertDetailsCSVQuotes());
                            }
                        }
                    }
                }
            }).RunAsync();