Esempio n. 1
0
        public IDownloadedResource Download(RemoteResource remoteResource)
        {
            IProgressBar progressBar = _progressBar.CreateChildDownloadProgress(remoteResource.Url.OriginalString);

            try
            {
                Interlocked.Increment(ref _activeDownloadCount);

                return(DownloadResource(remoteResource, progressBar).Result);
            }
            catch (Exception ex)
            {
                if (ex is SocketException || ex is HttpRequestException)
                {
                    NoInternetConnection();
                }

                throw;
            }
            finally
            {
                progressBar.Close();
                Interlocked.Decrement(ref _activeDownloadCount);
            }
        }
Esempio n. 2
0
        public async Task UpdateApp()
        {
            try
            {
                updateManager = await UpdateManager.GitHubUpdateManager(githubUrl, appName);

                UpdateInfo info = await SearchForUpdates();

                if (Debugger.IsAttached || info.CurrentlyInstalledVersion.Version < info.FutureReleaseEntry.Version)
                {
                    MessageBoxResult result = MessageBox.Show(
                        $"A new version of PasswordManagement is available ({info.FutureReleaseEntry.Version}) {Environment.NewLine} Do you want to install it now?",
                        "New Version",
                        MessageBoxButton.YesNo,
                        MessageBoxImage.Information,
                        MessageBoxResult.Yes);

                    if (result == MessageBoxResult.Yes)
                    {
                        progressBar.Show();
                        await DownloadUpdates(info);
                        await InstallUpdates(info);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Current.Get().Error(e);
            }
            finally
            {
                updateManager.Dispose();
                progressBar.Close();
            }
        }
        public void Start()
        {
            RemoteResource root = new RemoteResource(_options, _options.BaseUrlString);

            _downloadableResources.Add(root);

            Download();

            while (IsDownloadInProgress())
            {
            }

            _progressBar.Close();
        }