示例#1
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
            }
        }
示例#2
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();
            }
        }
        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);
        }
示例#4
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);
            }
        }
示例#5
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();
                }
            }
        }
示例#6
0
        public async Task <bool> CheckForUpdatesAsync()
        {
            // Check for updates
            var check = await _updateManager.CheckForUpdatesAsync();

            return(check.CanUpdate);
        }
示例#7
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);
            }
        }
示例#8
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);
            }
        }
示例#9
0
        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);
            }
        }
示例#10
0
        public async void CheckForUpdates(bool initiatedByUser)
        {
            UpdateCheckStarted?.Invoke(this, initiatedByUser);

            CheckForUpdatesResult = await updateManager.CheckForUpdatesAsync();

            UpdateCheckFinished?.Invoke(this, CheckForUpdatesResult, initiatedByUser);
        }
示例#11
0
        public async Task <Version?> CheckForUpdatesAsync()
        {
            if (!_settingsService.IsAutoUpdateEnabled)
            {
                return(null);
            }

            var check = await _updateManager.CheckForUpdatesAsync();

            return(check.CanUpdate ? check.LastVersion : null);
        }
        private async void Populate()
        {
            if (_checkForUpdates)
            {
                await _updateManager.CheckForUpdatesAsync();
            }

            var releases = _updateManager.Releases
                           .Where(r => _settings.IncludePrereleaseUpdates || !r.IsPrerelease)
                           .OrderByDescending(r => r.Version)
                           .SkipWhile(r => String.IsNullOrWhiteSpace(r.DownloadUrl)).ToList();

            releases.ForEach(_releases.Add);

            IsUpdating = false;
            IsUpToDate = _releases.All(r => !r.IsNew);
            CanUpdate  = _releases.Any(r => r.IsNew);
        }
示例#13
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);
        }
示例#14
0
        public ShellViewModel(ISettings settings, IDialogManager dialogManager, IFlyoutManager flyoutManager, IUpdateManager updateManager, IViewModelFactory viewModelFactory, IMostRecentUsedFoldersRepository mostRecentUsedFoldersRepository) {
            _settings = settings;
            _dialogManager = dialogManager;
            _flyoutManager = flyoutManager;
            _updateManager = updateManager;
            _viewModelFactory = viewModelFactory;
            _mostRecentUsedFoldersRepository = mostRecentUsedFoldersRepository;

            _projectRepository = _viewModelFactory.CreateProjectRepositoryViewModel(new RelayCommand<ProjectViewModel>(projectViewModel => _solution.AddProject(projectViewModel.Project)));
            _updateManager.UpdatesAvailable +=
                (sender, args) => AreUpdatesAvailable = _updateManager.Releases != null && _updateManager.Releases.Any(r => r.IsNew && (_settings.IncludePrereleaseUpdates || !r.IsPrerelease));

            _showUpdatesCommand = new RelayCommand<bool>(checkForUpdates => _flyoutManager.ShowFlyout(_viewModelFactory.CreateUpdateViewModel(checkForUpdates)));
            _showSettingsCommand = new RelayCommand(OnShowSettings);
            _showAboutCommand = new RelayCommand(() => _flyoutManager.ShowFlyout(_viewModelFactory.CreateAboutViewModel()));
            _selectRootPathCommand = new AsyncRelayCommand(SelectRootPath);
            _setRootPathCommand = new AsyncRelayCommand<string>(LoadProjectsAsync, path => !String.Equals(path, RootPath));

            _updateTimer = new Timer(_ => _updateManager.CheckForUpdatesAsync(), null, -1, -1);
        }
示例#15
0
        public ShellViewModel(ISettings settings, IDialogManager dialogManager, IFlyoutManager flyoutManager, IUpdateManager updateManager, IViewModelFactory viewModelFactory, IMostRecentUsedFoldersRepository mostRecentUsedFoldersRepository)
        {
            _settings         = settings;
            _dialogManager    = dialogManager;
            _flyoutManager    = flyoutManager;
            _updateManager    = updateManager;
            _viewModelFactory = viewModelFactory;
            _mostRecentUsedFoldersRepository = mostRecentUsedFoldersRepository;

            _projectRepository = _viewModelFactory.CreateProjectRepositoryViewModel(new RelayCommand <ProjectViewModel>(projectViewModel => _solution.AddProject(projectViewModel.Project)));
            _updateManager.UpdatesAvailable          +=
                (sender, args) => AreUpdatesAvailable = _updateManager.Releases != null && _updateManager.Releases.Any(r => r.IsNew && (_settings.IncludePrereleaseUpdates || !r.IsPrerelease));

            ShowUpdatesCommand    = new RelayCommand <bool>(checkForUpdates => _flyoutManager.ShowFlyout(_viewModelFactory.CreateUpdateViewModel(checkForUpdates)));
            ShowSettingsCommand   = new RelayCommand(OnShowSettings);
            ShowAboutCommand      = new RelayCommand(() => _flyoutManager.ShowFlyout(_viewModelFactory.CreateAboutViewModel()));
            SelectRootPathCommand = new AsyncRelayCommand(SelectRootPath);
            SetRootPathCommand    = new AsyncRelayCommand <string>(LoadProjectsAsync, path => !String.Equals(path, RootPath));

            _updateTimer = new Timer(_ => _updateManager.CheckForUpdatesAsync(), null, -1, -1);
        }
示例#16
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);
        }
示例#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
        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);
        }
示例#19
0
        public async Task <Version> CheckForUpdateAsync()
        {
            // If auto-update is disabled - don't check for updates
            if (!_settingsService.IsAutoUpdateEnabled)
            {
                return(null);
            }

#if DEBUG
            // Never update in DEBUG mode
            return(null);
#endif

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

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

            return(_updateVersion = check.LastVersion);
        }
示例#20
0
        private async void CheckForUpdates()
        {
            label.Text            = LABEL_CHECKING;
            button.Enabled        = false;
            checkForUpdatesResult = await updateManager.CheckForUpdatesAsync();

            if (checkForUpdatesResult.CanUpdate)
            {
                label.Text     = LABEL_UPDATE_AVAILABLE;
                button.Text    = BUTTON_UPDATE_NOW;
                button.Enabled = true;
            }
            else
            {
                new Thread(() => {
                    Thread.Sleep(500);
                    Invoke((MethodInvoker) delegate() {
                        label.Text     = LABEL_NO_UPDATES;
                        button.Text    = BUTTON_CHECK_FOR_UPDATES;
                        button.Enabled = true;
                    });
                }).Start();
            }
        }
#pragma warning disable 612, 618
        /// <summary>
        /// Check for available updates asynchronously.
        /// </summary>
        /// <param name="this">The this.</param>
        /// <param name="autoShowUi">Use the default update dialogs</param>
        /// <param name="shutdownActions">Callback to gracefully stop your application. If using default-ui, call has to be provided.</param>
        /// <param name="updateAvailableAction">Callback for available versions, if you want to provide own update dialogs</param>
        /// <returns></returns>
        public static async Task <bool> CheckForUpdatesAsync(this IHockeyClient @this, bool autoShowUi, Func <bool> shutdownActions = null, Action <IAppVersion> updateAvailableAction = null)
        {
            @this.AsInternal().CheckForInitialization();
            return(await UpdateManager.CheckForUpdatesAsync(autoShowUi, shutdownActions, updateAvailableAction));
        }
示例#22
0
 public async Task <bool> CanPerformUpdateAsync()
 => (await _updateManager.CheckForUpdatesAsync()).CanUpdate;
示例#23
0
        public async Task <Version?> CheckForUpdatesAsync()
        {
            var check = await _updateManager.CheckForUpdatesAsync();

            return(check.CanUpdate ? check.LastVersion : null);
        }