/// <summary>
        /// Gets the newest available programme version.
        /// </summary>
        /// <returns>The newest available programme version,
        /// or 69.69.69.69 if now information could be retrieved.</returns>
        private Version GetNewProgrammeVersion(out string p_strDownloadUri)
        {
            ExtendedWebClient wclNewVersion = new ExtendedWebClient(15000);
            Version           verNew        = new Version("69.69.69.69");

            p_strDownloadUri = String.Empty;
            try
            {
                GithubReleaseParser release = new GithubReleaseParser();

                if (release.GetLatestVersion())
                {
                    verNew           = new Version(release.LatestVersion);
                    p_strDownloadUri = release.LatestVersionUrl;
                    Console.Error.WriteLine("latest version = {0}", verNew.ToString());
                    Console.Error.WriteLine("latest version url = {0}", p_strDownloadUri);
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("ProgrammeUpdater::GetNewProgrammeVersion:: error - {0}", e.Message);
                Console.Error.WriteLine(e.ToString());
            }

            return(verNew);
        }
示例#2
0
        private async void StartUpdateCheck()
        {
            cancellationTokenSource = new CancellationTokenSource();
            updateTimeoutTimer.Start();
            TimeoutUpDown.IsEnabled = false;
            checkInProgress         = true;
            int updateTimeOut = (int)TimeoutUpDown.Value;

            timeoutCountdown = updateTimeOut;
            try
            {
                string currentVersion  = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                bool   updateAvailable = await GithubReleaseParser.GetUpdateAvailableAsync(currentVersion, "AWilliams17", "Halo-CE-Mouse-Tool", updateTimeOut, cancellationTokenSource.Token);

                ShowUpdateAvailableDialog(updateAvailable);
            }
            catch (WebException ex)
            {
                System.Media.SystemSounds.Hand.Play();
                MessageBox.Show($"Update Check Failed: '{ex.Message}'", "Update Check Failed");
            }
            finally
            {
                StopUpdateCheck();
            }
        }
        private async void Update()
        {
            try
            {
                bool updateAvailable = false;

                DispatcherTimer.Tick    += DispatcherTimer_Tick;
                DispatcherTimer.Interval = new TimeSpan(0, 0, 1);
                DispatcherTimer.Start();

                updateAvailable = await GithubReleaseParser.GetUpdateAvailableAsync("AWilliams17", "Starbound-Asset-Ripper", 5, cancellationTokenSource.Token);

                DispatcherTimer.Stop();
                if (updateAvailable)
                {
                    string updateAvailableMessage = "An update is available. Would you like to go to the download page?";
                    var    userAction             = MessageBox.Show(updateAvailableMessage, "Update Available", MessageBoxButton.YesNo);
                    if (userAction == MessageBoxResult.Yes)
                    {
                        Process.Start("https://github.com/AWilliams17/Starbound-Asset-Ripper/releases");
                    }
                }
                else
                {
                    MessageBox.Show("No updates found.", "No updates available.");
                }
            }
            catch (WebException ex)
            {
                DispatcherTimer.Stop(); // So that when an error message comes up the timer still isn't ticking.
                if (ex.Status == WebExceptionStatus.Timeout)
                {
                    MessageBox.Show("Check Timed Out after 5 seconds", "Check Timed Out");
                }
                else
                {
                    MessageBox.Show($"Error occurred while checking for updates: {ex.Message}", "Error checking for updates");
                }
            }
            Close();
        }