示例#1
0
    public async void method_0()
    {
        lXwNBETlUICPpizJQplTWzgWkAbIA ppizJqplTwzgWkAbIa = this;
        UpdateManager updateManager = new UpdateManager(UjhNUECyvifOzVkmQlhIqhYWIGFh.string_0, (string)null, (string)null, (IFileDownloader)null);

        try
        {
            UpdateInfo updateInfo = await updateManager.CheckForUpdate(false, (Action <int>) null);

            if (updateInfo.get_CurrentlyInstalledVersion() != null)
            {
                ppizJqplTwzgWkAbIa.fBNJIXiYZSrrQLEPrbpdSeciniHk_0.CurrentVersion = ((object)updateInfo.get_CurrentlyInstalledVersion().get_Version()).ToString();
            }
            if (updateInfo.get_FutureReleaseEntry() != null)
            {
                ppizJqplTwzgWkAbIa.fBNJIXiYZSrrQLEPrbpdSeciniHk_0.LatestVersion = ((object)updateInfo.get_FutureReleaseEntry().get_Version()).ToString();
            }
            updateInfo.FetchReleaseNotes();
            ppizJqplTwzgWkAbIa.fBNJIXiYZSrrQLEPrbpdSeciniHk_0.UpdateEnabled = true;
        }
        finally
        {
            if (updateManager != null)
            {
                ((IDisposable)updateManager).Dispose();
            }
        }
        updateManager = (UpdateManager)null;
    }
示例#2
0
        /// <returns>True if the user has upgraded</returns>
        private async Task <Boolean> githubCheck()
        {
            log.Debug("Checking for Squirrel update...");
            UpdateManager updateManager = null;

            isBusy = true;
            try {
                String installRootDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                if (string.IsNullOrEmpty(nonGitHubReleaseUri))
                {
                    updateManager = await Squirrel.UpdateManager.GitHubUpdateManager("https://github.com/phw198/OutlookGoogleCalendarSync", "OutlookGoogleCalendarSync", installRootDir,
                                                                                     prerelease : Settings.Instance.AlphaReleases);
                }
                else
                {
                    updateManager = new Squirrel.UpdateManager(nonGitHubReleaseUri, "OutlookGoogleCalendarSync", installRootDir);
                }

                UpdateInfo updates = await updateManager.CheckForUpdate();

                if (updates.ReleasesToApply.Any())
                {
                    if (updates.CurrentlyInstalledVersion != null)
                    {
                        log.Info("Currently installed version: " + updates.CurrentlyInstalledVersion.Version.ToString());
                    }
                    log.Info("Found " + updates.ReleasesToApply.Count() + " newer releases available.");

                    foreach (ReleaseEntry update in updates.ReleasesToApply.OrderBy(x => x.Version).Reverse())
                    {
                        log.Info("Found a new " + update.Version.SpecialVersion + " version: " + update.Version.Version.ToString());

                        if (!this.isManualCheck && update.Version.Version.ToString() == Settings.Instance.SkipVersion)
                        {
                            log.Info("The user has previously requested to skip this version.");
                            break;
                        }

                        String releaseNotes = "";
                        if (nonGitHubReleaseUri != null)
                        {
                            releaseNotes = update.GetReleaseNotes(nonGitHubReleaseUri);
                        }
                        else
                        {
                            //Somewhat annoyingly we have to download the release in order to get the release notes, as they are embedded in the .nupkg upgrade file(s)
                            try {
                                updateManager.DownloadReleases(new[] { update }).Wait(30 * 1000);
                                System.Collections.Generic.Dictionary <ReleaseEntry, String> allReleaseNotes = updates.FetchReleaseNotes();
                                releaseNotes = allReleaseNotes[update];
                            } catch (System.Exception ex) {
                                OGCSexception.Analyse(ex);
                                log.Error("Failed pre-fetching release notes. " + ex.Message);
                                releaseNotes = null;
                            }
                        }

                        DialogResult dr = DialogResult.Cancel;
                        if (!string.IsNullOrEmpty(releaseNotes))
                        {
                            log.Debug("Release notes retrieved.");
                        }
                        var t = new System.Threading.Thread(() => new Forms.UpdateInfo(update.Version.Version.ToString(), update.Version.SpecialVersion, releaseNotes, out dr));
                        t.SetApartmentState(System.Threading.ApartmentState.STA);
                        t.Start();
                        t.Join();

                        String squirrelAnalyticsLabel = "from=" + Application.ProductVersion + ";to=" + update.Version.Version.ToString();
                        if (dr == DialogResult.No)
                        {
                            log.Info("User chose not to upgrade right now.");
                            Telemetry.Send(Analytics.Category.squirrel, Analytics.Action.upgrade, squirrelAnalyticsLabel + ";later");
                        }
                        else if (dr == DialogResult.Ignore)
                        {
                            Telemetry.Send(Analytics.Category.squirrel, Analytics.Action.upgrade, squirrelAnalyticsLabel + ";skipped");
                        }
                        else if (dr == DialogResult.Yes)
                        {
                            log.Debug("Download started...");
                            if (!updateManager.DownloadReleases(new[] { update }).Wait(60 * 1000))
                            {
                                log.Warn("The download failed to completed within 60 seconds.");
                                Telemetry.Send(Analytics.Category.squirrel, Analytics.Action.download, squirrelAnalyticsLabel + ";timedout");
                                if (MessageBox.Show("The update failed to download.", "Download timed out", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation) == DialogResult.Retry)
                                {
                                    if (!updateManager.DownloadReleases(new[] { update }).Wait(60 * 1000))
                                    {
                                        Telemetry.Send(Analytics.Category.squirrel, Analytics.Action.download, squirrelAnalyticsLabel + ";retry-timedout");
                                        if (MessageBox.Show("The update failed to download again.\nTo download from the project website, click Yes.", "Download timed out", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                                        {
                                            Telemetry.Send(Analytics.Category.squirrel, Analytics.Action.download, squirrelAnalyticsLabel + ";from-website");
                                            System.Diagnostics.Process.Start("https://phw198.github.io/OutlookGoogleCalendarSync/");
                                        }
                                        else
                                        {
                                            Telemetry.Send(Analytics.Category.squirrel, Analytics.Action.download, squirrelAnalyticsLabel + ";gave-up");
                                        }
                                        break;
                                    }
                                }
                                else
                                {
                                    if (MessageBox.Show("Would you like to download directly from the project website?", "Go to OGCS website", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                                    {
                                        Telemetry.Send(Analytics.Category.squirrel, Analytics.Action.download, squirrelAnalyticsLabel + ";from-website");
                                        System.Diagnostics.Process.Start("https://phw198.github.io/OutlookGoogleCalendarSync/");
                                    }
                                    else
                                    {
                                        Telemetry.Send(Analytics.Category.squirrel, Analytics.Action.download, squirrelAnalyticsLabel + ";gave-up");
                                    }
                                    break;
                                }
                            }

                            try {
                                log.Debug("Download complete.");
                                Telemetry.Send(Analytics.Category.squirrel, Analytics.Action.download, squirrelAnalyticsLabel + ";successful");
                                log.Info("Applying the updated release...");
                                updateManager.ApplyReleases(updates).Wait();

                                log.Info("The application has been successfully updated.");
                                MessageBox.Show("The application has been updated and will now restart.",
                                                "OGCS successfully updated!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                restartUpdateExe = updateManager.RootAppDirectory + "\\Update.exe";
                                return(true);
                            } catch (System.AggregateException ae) {
                                foreach (System.Exception ex in ae.InnerExceptions)
                                {
                                    OGCSexception.Analyse(ex, true);
                                    ex.Data.Add("analyticsLabel", squirrelAnalyticsLabel);
                                    throw new ApplicationException("Failed upgrading OGCS.", ex);
                                }
                            } catch (System.Exception ex) {
                                OGCSexception.Analyse(ex, true);
                                ex.Data.Add("analyticsLabel", squirrelAnalyticsLabel);
                                throw new ApplicationException("Failed upgrading OGCS.", ex);
                            }
                        }
                        break;
                    }
                }
                else
                {
                    log.Info("Already running the latest version of OGCS.");
                    if (this.isManualCheck)   //Was a manual check, so give feedback
                    {
                        MessageBox.Show("You are already running the latest version of OGCS.", "Latest Version", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            } catch (ApplicationException ex) {
                Telemetry.Send(Analytics.Category.squirrel, Analytics.Action.download, ex.Data["analyticsLabel"] + ";failed");
                throw ex;
            } catch (System.AggregateException ae) {
                log.Error("Failed checking for update.");
                foreach (System.Exception ex in ae.InnerExceptions)
                {
                    OGCSexception.Analyse(ex, true);
                    throw ex;
                }
            } catch (System.Exception ex) {
                log.Error("Failed checking for update.");
                OGCSexception.Analyse(ex, true);
                throw ex;
            } finally {
                isBusy = false;
                updateManager.Dispose();
            }
            return(false);
        }