Esempio n. 1
0
        /// <inheritdoc />
        public async Task <UpdateInstallationResult> HandleUpdatesAsync(bool acceptBeta)
        {
            UpdateCheckResult checkResult = null;

            try
            {
                checkResult = await this.CheckForUpdatesAsync(acceptBeta).ConfigureAwait(false);

                if (checkResult.Exception == null)
                {
                    UpdateHandler handler = new UpdateHandler(this.telimena.Messenger, this.telimena.Properties.LiveProgramInfo, new DefaultWpfInputReceiver()
                                                              , new UpdateInstaller(), this.telimena.Locator, this.telimena.telemetryModule);
                    await handler.HandleUpdates(this.telimena.Properties.UpdatePromptingMode, checkResult.ProgramUpdatesToInstall, checkResult.UpdaterUpdate).ConfigureAwait(false);
                }
                else
                {
                    throw checkResult.Exception;
                }

                return(new UpdateInstallationResult()
                {
                    CheckResult = checkResult
                });
            }
            catch (Exception ex)
            {
                TelimenaException exception = new TelimenaException("Error occurred while handling updates", this.telimena.Properties, ex);
                if (!this.telimena.Properties.SuppressAllErrors)
                {
                    throw exception;
                }

                return(new UpdateInstallationResult()
                {
                    CheckResult = checkResult
                    , Exception = exception
                });
            }
        }
Esempio n. 2
0
        /// <inheritdoc />
        public async Task <UpdateInstallationResult> InstallUpdatesAsync(UpdateCheckResult checkResult, bool takeBeta)
        {
            try
            {
                if (checkResult.ProgramUpdatesToInstall == null)
                {
                    return(new UpdateInstallationResult()
                    {
                        CheckResult = checkResult,
                        Exception = new TelimenaException("ProgramUpdatesToInstall is null")
                    });
                }
                if (!takeBeta)
                {
                    checkResult.ProgramUpdatesToInstall = checkResult.ProgramUpdatesToInstall.Where(x => x.IsBeta == false).ToList();
                }
                UpdateHandler handler = new UpdateHandler(this.telimena.Messenger, this.telimena.Properties.LiveProgramInfo, new DefaultWpfInputReceiver()
                                                          , new UpdateInstaller(), this.telimena.Locator, this.telimena.telemetryModule);
                await handler.HandleUpdates(UpdatePromptingModes.DontPrompt, checkResult.ProgramUpdatesToInstall, checkResult.UpdaterUpdate).ConfigureAwait(false);

                return(new UpdateInstallationResult()
                {
                    CheckResult = checkResult
                });
            }
            catch (Exception ex)
            {
                TelimenaException exception = new TelimenaException("Error occurred while installing updates", this.telimena.Properties, ex);
                if (!this.telimena.Properties.SuppressAllErrors)
                {
                    throw exception;
                }
                return(new UpdateInstallationResult()
                {
                    CheckResult = checkResult
                    , Exception = exception
                });
            }
        }