示例#1
0
        public void FinalizeUpdate(bool needRestart)
        {
            try
            {
                // Check if an update is pending
                if (_updateVersion == null)
                {
                    return;
                }

                // Check if the updater has already been launched
                if (_updaterLaunched)
                {
                    return;
                }

                // Launch the updater
                _updateManager.LaunchUpdater(_updateVersion, needRestart);
                _updaterLaunched = true;
            }
            catch (UpdaterAlreadyLaunchedException)
            {
            }
            catch (LockFileNotAcquiredException)
            {
            }
        }
        public void FinalizeUpdate(bool needRestart)
        {
            if (!_settingsService.IsAutoUpdateEnabled)
            {
                return;
            }

            if (_updateVersion == null || !_updatePrepared || _updaterLaunched)
            {
                return;
            }

            try
            {
                _updateManager.LaunchUpdater(_updateVersion, needRestart);
                _updaterLaunched = true;
            }
            catch (UpdaterAlreadyLaunchedException)
            {
                // Ignore race conditions
            }
            catch (LockFileNotAcquiredException)
            {
                // Ignore race conditions
            }
        }
示例#3
0
        public void FinalizePendingUpdates()
        {
            if (!_settingsService.IsAutoUpdateEnabled)
            {
                return;
            }

            try
            {
                // Get last prepared update
                var updateVersion = GetLastPreparedUpdate();
                if (updateVersion == null)
                {
                    return;
                }

                // Don't update if the prepared update is a downgrade
                if (App.Version >= updateVersion)
                {
                    return;
                }

                // Launch updater and restart
                _updateManager.LaunchUpdater(updateVersion);
                Environment.Exit(0);
            }
            catch (UpdaterAlreadyLaunchedException)
            {
                // Ignore race conditions
            }
            catch (LockFileNotAcquiredException)
            {
                // Ignore race conditions
            }
        }
示例#4
0
        public async void CheckForUpdate()
        {
            var check = await _updateManager.CheckForUpdatesAsync();

            // If there are none, notify user and return
            if (!check.CanUpdate)
            {
                return;
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("There are updates available.");
            }

            // Prepare the latest update
            await _updateManager.PrepareUpdateAsync(check.LastVersion);

            // Launch updater and exit
            _updateManager.LaunchUpdater(check.LastVersion);
            if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Count() > 0)
            {
                //System.Windows.MessageBox.Show("Closed to update", "WallEngine Updater", System.Windows.MessageBoxButton.OK);
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            }
        }
示例#5
0
        private async void button_Click(object sender, EventArgs e)
        {
            if (button.Text == BUTTON_CHECK_FOR_UPDATES)
            {
                CheckForUpdates();
            }
            if (button.Text == BUTTON_UPDATE_NOW)
            {
                DialogResult result = MessageBox.Show(
                    $"There is an update available. Your current version is {currentVersion}, the latest version is {checkForUpdatesResult.LastVersion}. Would you like to update to the latest version?",
                    "Update Available",
                    MessageBoxButtons.YesNo
                    );

                if (result == DialogResult.Yes)
                {
                    UpdateStarted?.Invoke(this, EventArgs.Empty);

                    label.Text = LABEL_UPDATING;
                    button.Hide();
                    progressBar.Show();

                    // Prepare the latest update
                    await updateManager.PrepareUpdateAsync(checkForUpdatesResult.LastVersion, progress);

                    // Launch updater and exit
                    updateManager.LaunchUpdater(checkForUpdatesResult.LastVersion);

                    Application.Exit();
                }
            }
        }
示例#6
0
        public void FinalizePendingUpdates()
        {
            if (!_settingsService.IsAutoUpdateEnabled)
            {
                return;
            }

            try
            {
                var updateVersion = GetLastPreparedUpdate();
                if (updateVersion == null)
                {
                    return;
                }

                if (App.Version >= updateVersion)
                {
                    return;
                }

                _updateManager.LaunchUpdater(updateVersion);
                Environment.Exit(0);
            }
            catch (UpdaterAlreadyLaunchedException)
            {
                // Ignore race conditions
            }
            catch (LockFileNotAcquiredException)
            {
                // Ignore race conditions
            }
        }
示例#7
0
        private async void checkForUpdatesButton_Click(object sender, EventArgs e)
        {
            // Check for updates
            var check = await updateManager.CheckForUpdatesAsync();

            // If there are none, notify user and return
            if (!check.CanUpdate)
            {
                MessageBox.Show("There are no updates available.");
                return;
            }
            else
            {
                DialogResult result = MessageBox.Show(
                    $"There is an update available. Your current version is {currentVersion}, the latest version is {check.LastVersion}. Would you like to update to the latest version?",
                    "Update Available",
                    MessageBoxButtons.YesNo
                    );

                if (result == DialogResult.Yes)
                {
                    // Prepare the latest update
                    await updateManager.PrepareUpdateAsync(check.LastVersion);

                    // Launch updater and exit
                    updateManager.LaunchUpdater(check.LastVersion);
                    Application.Exit();
                }
            }
        }
        public void FinalizeUpdate()
        {
            // Check if an update is pending
            if (_updateVersion == null)
            {
                return;
            }

            // Check if the update has already been finalized
            if (_updateFinalized)
            {
                return;
            }

            // Launch the updater
            _manager.LaunchUpdater(_updateVersion, NeedRestart);
            _updateFinalized = true;
        }
示例#9
0
        public void FinalizeUpdate(bool needRestart)
        {
            // Check if an update is pending
            if (_updateVersion == null)
            {
                return;
            }

            // Check if the updater has already been launched
            if (_updaterLaunched)
            {
                return;
            }

            // Launch the updater
            _updateManager.LaunchUpdater(_updateVersion, needRestart);
            _updaterLaunched = true;
        }
示例#10
0
        /// <summary>
        /// Checks for new version and performs an update if available.
        /// </summary>
        public static async Task CheckPerformUpdateAsync(this IUpdateManager manager, bool restart = true,
                                                         IProgress <double>?progress = null, CancellationToken cancellationToken = default)
        {
            // Check
            var result = await manager.CheckForUpdatesAsync(cancellationToken);

            if (!result.CanUpdate || result.LastVersion == null)
            {
                return;
            }

            // Prepare
            await manager.PrepareUpdateAsync(result.LastVersion, progress, cancellationToken);

            // Apply
            manager.LaunchUpdater(result.LastVersion, restart);

            // Exit
            Environment.Exit(0);
        }
示例#11
0
        public bool InstallPendingUpdate(bool withRestart = true)
        {
            var lastPreparedVersion = _updateManager.GetPreparedUpdates().LastOrDefault();

            if (lastPreparedVersion != null)
            {
                try
                {
                    _updateManager.LaunchUpdater(lastPreparedVersion, withRestart);
                    return(true);
                }
                catch (Exception e)
                    when(e is UpdaterAlreadyLaunchedException || e is LockFileNotAcquiredException)
                    {
                        // Ignore race conditions
                    }
            }

            return(false);
        }
示例#12
0
        public async Task PerformUpdate()
        {
            if (CheckForUpdatesResult.CanUpdate)
            {
                UpdateStarted?.Invoke(this);

                // Prepare the latest update
                await updateManager.PrepareUpdateAsync(CheckForUpdatesResult.LastVersion, Progress);

                // Launch updater and exit
                updateManager.LaunchUpdater(CheckForUpdatesResult.LastVersion);

                infoForm?.Close();

                Program.mainForm.FormClosing -= Program.mainForm.MainForm_FormClosing;

                Utils.SaveURLs(Program.mainForm.Model.Boards, Program.mainForm.Model.Threads);

                Application.Exit();
            }
        }
示例#13
0
        public void FinalizeUpdate(bool needRestart)
        {
            try
            {
                if (_updateVersion == null || _updaterLaunched)
                {
                    return;
                }

                _updateManager.LaunchUpdater(_updateVersion, needRestart);

                _updaterLaunched = true;
            }
            catch (UpdaterAlreadyLaunchedException)
            {
                // Ignore race conditions
            }
            catch (LockFileNotAcquiredException)
            {
                // Ignore race conditions
            }
        }
示例#14
0
        /// <summary>
        /// Checks for new version and performs an update if available.
        /// </summary>
        public static async Task CheckPerformUpdateAsync(this IUpdateManager manager, bool restart = true,
                                                         IProgress <double> progress = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            manager.GuardNotNull(nameof(manager));

            // Check
            var result = await manager.CheckForUpdatesAsync().ConfigureAwait(false);

            if (!result.CanUpdate)
            {
                return;
            }

            // Prepare
            await manager.PrepareUpdateAsync(result.LastVersion, progress, cancellationToken).ConfigureAwait(false);

            // Apply
            manager.LaunchUpdater(result.LastVersion, restart);

            // Exit
            Environment.Exit(0);
        }
示例#15
0
        public async Task PerformUpdateAsync(ProgressDialogController progressDialog)
        {
            var result = await _updateManager.CheckForUpdatesAsync();

            if (!result.CanUpdate)
            {
                return;
            }

            var progress = new Progress <double>();

            progress.ProgressChanged += (s, e) =>
            {
                progressDialog.SetProgress(e);
            };

            await _updateManager.PrepareUpdateAsync(result.LastVersion, progress);

            _updateManager.LaunchUpdater(result.LastVersion);

            Environment.Exit(0);
        }
示例#16
0
 /// <summary>
 /// Launches an external executable that will apply an update to given version, once this application exits.
 /// The updater can be instructed to also restart the application after it's updated.
 /// If the application is to be restarted, it will receive the same command line arguments as it did initially.
 /// </summary>
 public static void LaunchUpdater(this IUpdateManager manager, Version version, bool restart = true) =>
 manager.LaunchUpdater(version, restart, EnvironmentEx.GetCommandLineWithoutExecutable());