コード例 #1
0
        public async Task <Version> CheckPrepareUpdateAsync()
        {
            try
            {
                // Check for updates
                var check = await _updateManager.CheckForUpdatesAsync();

                if (!check.CanUpdate)
                {
                    return(null);
                }

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

                return(_updateVersion = check.LastVersion);
            }
            catch (UpdaterAlreadyLaunchedException)
            {
                return(null);
            }
            catch (LockFileNotAcquiredException)
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: UpdateView.cs プロジェクト: Issung/SorterExpress
        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();
                }
            }
        }
コード例 #3
0
ファイル: UpdateService.cs プロジェクト: r15ch13/LightBulb
        public async Task <Version?> CheckPrepareUpdateAsync()
        {
            try
            {
                // Check for updates
                var check = await _updateManager.CheckForUpdatesAsync();

                if (!check.CanUpdate)
                {
                    return(null);
                }

                // Prepare update
                if (check.LastVersion != GetLastPreparedUpdate())
                {
                    await _updateManager.PrepareUpdateAsync(check.LastVersion);
                }

                return(check.LastVersion);
            }
            catch
            {
                // Failure to check for updates shouldn't crash the app
                return(null);
            }
        }
コード例 #4
0
        public async Task <Version> CheckPrepareUpdateAsync()
        {
            try
            {
                // If auto-update is disabled - don't check for updates
                if (!_settingsService.IsAutoUpdateEnabled)
                {
                    return(null);
                }

                // Check for updates
                var check = await _updateManager.CheckForUpdatesAsync();

                if (!check.CanUpdate)
                {
                    return(null);
                }

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

                return(_updateVersion = check.LastVersion);
            }
            catch (UpdaterAlreadyLaunchedException)
            {
                return(null);
            }
            catch (LockFileNotAcquiredException)
            {
                return(null);
            }
        }
コード例 #5
0
        public async Task <Version> CheckPrepareUpdateAsync()
        {
            // If auto-update is disabled - don't check for updates
            if (!_settingsService.IsAutoUpdateEnabled)
            {
                return(null);
            }

            // Cleanup leftover files
            _manager.Cleanup();

            // Check for updates
            var check = await _manager.CheckForUpdatesAsync();

            if (!check.CanUpdate)
            {
                return(null);
            }

            // Prepare the update
            if (!_manager.IsUpdatePrepared(check.LastVersion))
            {
                await _manager.PrepareUpdateAsync(check.LastVersion);
            }

            return(_updateVersion = check.LastVersion);
        }
コード例 #6
0
        public async Task <Version?> CheckPrepareUpdateAsync()
        {
            if (!_settingsService.IsAutoUpdateEnabled)
            {
                return(null);
            }

            try
            {
                // Check for updates
                var check = await _updateManager.CheckForUpdatesAsync();

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

                // Prepare update
                if (check.LastVersion != GetLastPreparedUpdate())
                {
                    await _updateManager.PrepareUpdateAsync(check.LastVersion);
                }

                return(check.LastVersion);
            }
            catch
            {
                // Failure to check for updates shouldn't crash the app
                return(null);
            }
        }
コード例 #7
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();
            }
        }
コード例 #8
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();
                }
            }
        }
コード例 #9
0
        public async Task CheckPrepareUpdateAsync()
        {
            if (!_settingsService.IsAutoUpdateEnabled)
            {
                return;
            }

            try
            {
                var check = await _updateManager.CheckForUpdatesAsync();

                if (!check.CanUpdate || check.LastVersion is null)
                {
                    return;
                }

                if (check.LastVersion != TryGetLastPreparedUpdate())
                {
                    await _updateManager.PrepareUpdateAsync(check.LastVersion);
                }
            }
            catch
            {
                // Failure to check for updates shouldn't crash the app
            }
        }
コード例 #10
0
 public async Task PrepareUpdateAsync()
 {
     // Prepare the update
     if (!_manager.IsUpdatePrepared(_updateVersion))
     {
         await _manager.PrepareUpdateAsync(_updateVersion);
     }
 }
コード例 #11
0
 public async Task PrepareUpdateAsync(Version version)
 {
     try
     {
         await _updateManager.PrepareUpdateAsync(_updateVersion = version);
     }
     catch (UpdaterAlreadyLaunchedException)
     {
         // Ignore race conditions
     }
     catch (LockFileNotAcquiredException)
     {
         // Ignore race conditions
     }
 }
コード例 #12
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);
        }
コード例 #13
0
        public async Task PrepareUpdateAsync(Version version)
        {
            if (!_settingsService.IsAutoUpdateEnabled)
            {
                return;
            }

            try
            {
                await _updateManager.PrepareUpdateAsync(_updateVersion = version);
            }
            catch (UpdaterAlreadyLaunchedException)
            {
                // Ignore race conditions
            }
            catch (LockFileNotAcquiredException)
            {
                // Ignore race conditions
            }
        }
コード例 #14
0
ファイル: UpdateController.cs プロジェクト: roetherb/GChan
        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();
            }
        }
コード例 #15
0
        public async Task <Version> CheckPrepareUpdateAsync()
        {
            // Cleanup leftover files
            _updateManager.Cleanup();

            // Check for updates
            var check = await _updateManager.CheckForUpdatesAsync();

            if (!check.CanUpdate)
            {
                return(null);
            }

            // Prepare the update
            if (!_updateManager.IsUpdatePrepared(check.LastVersion))
            {
                await _updateManager.PrepareUpdateAsync(check.LastVersion);
            }

            return(_updateVersion = check.LastVersion);
        }
コード例 #16
0
        private async Task <bool> PrepareUpdateAsync()
        {
            var check = await _updateManager.CheckForUpdatesAsync();

            if (check.CanUpdate)
            {
                try
                {
                    await _updateManager.PrepareUpdateAsync(check.LastVersion);
                }
                catch (Exception e)
                    when(e is UpdaterAlreadyLaunchedException || e is LockFileNotAcquiredException)
                    {
                        // Ignore race conditions
                        return(false);
                    }

                return(true);
            }

            return(false);
        }
コード例 #17
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);
        }
コード例 #18
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);
        }