public static bool NtolDialog(HostAbstractAction action, Pool pool, long currentNtol, long targetNtol)
        {
            bool cancel = false;

            Program.Invoke(Program.MainWindow, delegate()
            {
                string poolName = Helpers.GetName(pool).Ellipsise(500);
                string hostName = Helpers.GetName(action.Host).Ellipsise(500);

                string msg;
                if (targetNtol == 0)
                {
                    string f;
                    if (action is EvacuateHostAction)
                    {
                        f = Messages.HA_HOST_DISABLE_NTOL_ZERO;
                    }
                    else if (action is RebootHostAction)
                    {
                        f = Messages.HA_HOST_REBOOT_NTOL_ZERO;
                    }
                    else
                    {
                        f = Messages.HA_HOST_SHUTDOWN_NTOL_ZERO;
                    }

                    msg = string.Format(f, poolName, hostName);
                }
                else
                {
                    string f;
                    if (action is EvacuateHostAction)
                    {
                        f = Messages.HA_HOST_DISABLE_NTOL_DROP;
                    }
                    else if (action is RebootHostAction)
                    {
                        f = Messages.HA_HOST_REBOOT_NTOL_DROP;
                    }
                    else
                    {
                        f = Messages.HA_HOST_SHUTDOWN_NTOL_DROP;
                    }

                    msg = string.Format(f, poolName, currentNtol, hostName, targetNtol);
                }

                if (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;
                }
            });
            return(cancel);
        }
Exemple #2
0
 /// <summary>
 /// Whether there is a HostAction in progress that pertains to the given host.
 /// Must be called on the event thread.
 /// </summary>
 /// <param name="host">May not be null.</param>
 /// <returns></returns>
 internal static bool HasActiveHostAction(Host host)
 {
     Program.AssertOnEventThread();
     foreach (ActionBase action in ConnectionsManager.History)
     {
         HostAbstractAction hostAction = action as HostAbstractAction;
         if (hostAction != null && !hostAction.Cancelled && !hostAction.IsCompleted && host.Connection == hostAction.Connection)
         {
             return(true);
         }
     }
     return(false);
 }