Ejemplo n.º 1
0
        private void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (!rebooting)
            {
                return;
            }

            Program.Invoke(invokingControl, () =>
            {
                using (var dialog = new NonModalThreeButtonDialog(SystemIcons.Exclamation,
                                                                  Messages.ROLLING_UPGRADE_TIMEOUT, Messages.ROLLING_POOL_UPGRADE,
                                                                  Messages.KEEP_WAITING_BUTTON_LABEL, Messages.CANCEL))
                {
                    if (dialog.ShowDialog(invokingControl) != DialogResult.OK)
                    {
                        Cancel();
                    }
                }
            });
        }
        protected override void RunWithSession(ref Session session)
        {
            //Show dialog prepare host boot from CD or PXE boot and click OK to reboot

            Program.Invoke(invokingControl, () =>
            {
                using (var dialog = new NonModalThreeButtonDialog(SystemIcons.Information,
                                                                  string.Format(Messages.ROLLING_UPGRADE_REBOOT_MESSAGE, GetResolvedHost().Name()),
                                                                  Messages.ROLLING_POOL_UPGRADE, Messages.REBOOT, Messages.SKIP_SERVER))
                {
                    if (dialog.ShowDialog(invokingControl) != DialogResult.OK) // Cancel or Unknown
                    {
                        if (GetResolvedHost().IsMaster())
                        {
                            Error = new ApplicationException(Messages.EXCEPTION_USER_CANCELLED_MASTER);
                            throw Error;
                        }

                        Error = new CancelledException();
                    }
                }
            });

            if (Error != null)
            {
                return;
            }

            var    hostObj = GetResolvedHost();
            string beforeRebootProductVersion = hostObj.LongProductVersion();
            string hostName = hostObj.Name();

            do
            {
                if (Cancelling)
                {
                    break;
                }

                Upgrade(ref session);

                hostObj = GetResolvedHost();
                if (Helpers.SameServerVersion(hostObj, beforeRebootProductVersion))
                {
                    var obj = hostObj;
                    Program.Invoke(invokingControl, () =>
                    {
                        using (var dialog = new NonModalThreeButtonDialog(SystemIcons.Exclamation,
                                                                          string.Format(Messages.ROLLING_UPGRADE_REBOOT_AGAIN_MESSAGE, hostName),
                                                                          Messages.ROLLING_POOL_UPGRADE,
                                                                          Messages.REBOOT_AGAIN_BUTTON_LABEL, Messages.SKIP_SERVER))
                        {
                            if (dialog.ShowDialog(invokingControl) == DialogResult.OK)
                            {
                                return;
                            }

                            if (obj.IsMaster())
                            {
                                Error = new Exception(Messages.HOST_REBOOTED_SAME_VERSION);
                                throw Error;
                            }
                            Error = new CancelledException();
                            Cancel();
                        }
                    });
                }
                else
                {
                    break;
                }
            } while (true);
        }