コード例 #1
0
        private static void isNewVersion(Boolean isSquirrelInstall)
        {
            string settingsVersion = string.IsNullOrEmpty(Settings.Instance.Version) ? "Unknown" : Settings.Instance.Version;

            if (settingsVersion != Application.ProductVersion)
            {
                log.Info("New version detected - upgraded from " + settingsVersion + " to " + Application.ProductVersion);
                Program.ManageStartupRegKey(recreate: true);
                Settings.Instance.Version = Application.ProductVersion;
                if (Application.ProductVersion.EndsWith(".0"))   //Release notes not updated for hotfixes.
                {
                    System.Diagnostics.Process.Start("https://github.com/phw198/OutlookGoogleCalendarSync/blob/master/docs/Release%20Notes.md");
                    if (isSquirrelInstall)
                    {
                        Analytics.Send("squirrel", "upgrade", "from=" + settingsVersion + ";to=" + Application.ProductVersion);
                    }
                }
            }

            //Check upgrade to Squirrel release went OK
            try {
                if (isSquirrelInstall)
                {
                    Int32  upgradedFrom       = Int16.MaxValue;
                    String expectedInstallDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                    expectedInstallDir = Path.Combine(expectedInstallDir, "OutlookGoogleCalendarSync");
                    String paddedVersion = "";
                    if (settingsVersion != "Unknown")
                    {
                        foreach (String versionBit in settingsVersion.Split('.'))
                        {
                            paddedVersion += versionBit.PadLeft(2, '0');
                        }
                        upgradedFrom = Convert.ToInt32(paddedVersion);
                    }
                    if ((settingsVersion == "Unknown" || upgradedFrom < 2050000) &&
                        !System.Windows.Forms.Application.ExecutablePath.ToString().StartsWith(expectedInstallDir))
                    {
                        log.Warn("OGCS is running from " + System.Windows.Forms.Application.ExecutablePath.ToString());
                        MessageBox.Show("A suspected improper install location has been detected.\r\n" +
                                        "Click 'OK' for further details.", "Improper Install Location",
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        System.Diagnostics.Process.Start("https://github.com/phw198/OutlookGoogleCalendarSync/issues/265");
                    }
                }
            } catch (System.Exception ex) {
                log.Warn("Failed to determine if OGCS is installed in the correct location.");
                log.Error(ex.Message);
            }
        }
コード例 #2
0
        public NotificationTray(NotifyIcon icon) {
            this.icon = icon;
            this.icon.ContextMenuStrip = new ContextMenuStrip();
            this.icon.ContextMenuStrip.Opening += ContextMenuStrip_Opening;
            this.icon.MouseClick += notifyIcon_Click;
            this.icon.MouseDoubleClick += notifyIcon_DoubleClick;
            this.icon.BalloonTipClicked += notifyIcon_BubbleClick;
            this.icon.Visible = true;
            buildMenu();

            if (OutlookOgcs.Calendar.OOMsecurityInfo) {
                ShowBubbleInfo("Your Outlook security settings may not be optimal.\r\n" +
                    "Click here for further details.", ToolTipIcon.Warning, "OOMsecurity");
                Analytics.Send(Analytics.Category.ogcs, Analytics.Action.setting, "OOMsecurity;SyncCount=" + Settings.Instance.CompletedSyncs);
            }
        }
コード例 #3
0
 private static void onInitialInstall(Version version)
 {
     try {
         using (var mgr = new Squirrel.UpdateManager(null, "OutlookGoogleCalendarSync")) {
             log.Info("Creating shortcuts.");
             mgr.CreateShortcutsForExecutable(Path.GetFileName(System.Windows.Forms.Application.ExecutablePath),
                                              Squirrel.ShortcutLocation.Desktop | Squirrel.ShortcutLocation.StartMenu, false);
             log.Debug("Creating uninstaller registry keys.");
             mgr.CreateUninstallerRegistryEntry().Wait();
         }
     } catch (System.Exception ex) {
         log.Error("Problem encountered on initiall install.");
         OGCSexception.Analyse(ex, true);
     }
     Analytics.Send(Analytics.Category.squirrel, Analytics.Action.install, version.ToString());
     onFirstRun();
 }
コード例 #4
0
 private static void onFirstRun()
 {
     try {
         log.Debug("Removing ClickOnce install...");
         var migrator = new ClickOnceToSquirrelMigrator.InSquirrelAppMigrator(Application.ProductName);
         migrator.Execute().Wait();
         log.Info("ClickOnce install has been removed.");
         Analytics.Send(Analytics.Category.squirrel, Analytics.Action.uninstall, "clickonce");
     } catch (System.AggregateException ae) {
         foreach (System.Exception ex in ae.InnerExceptions)
         {
             clickOnceUninstallError(ex);
         }
     } catch (System.Exception ex) {
         clickOnceUninstallError(ex);
     }
 }
コード例 #5
0
        public static void TrackVersions()
        {
            if (System.Diagnostics.Debugger.IsAttached)
            {
                return;
            }

            //OUTLOOK CLIENT
            String outlookVersion = "Unknown";

            try {
                switch (OutlookOgcs.Factory.OutlookVersion)
                {
                case 11: outlookVersion = "2003"; break;

                case 12: outlookVersion = "2007"; break;

                case 14: outlookVersion = "2010"; break;

                case 15: outlookVersion = "2013"; break;

                case 16: outlookVersion = "2016"; break;

                case 17: outlookVersion = "2019"; break;

                default: outlookVersion = "Unknown-" + OutlookOgcs.Factory.OutlookVersion; break;
                }
            } catch (System.Exception ex) {
                log.Fail("Failed determining Outlook client version.");
                if (ex is ApplicationException)
                {
                    throw ex;
                }
                OGCSexception.Analyse(ex);
                outlookVersion = "Unknown";
            }
            Analytics.Send(Analytics.Category.outlook, Analytics.Action.version, outlookVersion);

            //OGCS APPLICATION
            Analytics.Send(Analytics.Category.ogcs, Analytics.Action.version, System.Windows.Forms.Application.ProductVersion);
        }
コード例 #6
0
 private static void onAppUninstall(Version version)
 {
     try {
         using (var mgr = new Squirrel.UpdateManager(null, "OutlookGoogleCalendarSync")) {
             log.Info("Removing shortcuts.");
             mgr.RemoveShortcutsForExecutable(Path.GetFileName(System.Windows.Forms.Application.ExecutablePath),
                                              Squirrel.ShortcutLocation.Desktop | Squirrel.ShortcutLocation.StartMenu);
             String startMenuFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "Paul Woolcock");
             Directory.Delete(startMenuFolder);
             log.Debug("Removing registry uninstall keys.");
             mgr.RemoveUninstallerRegistryEntry();
         }
         Analytics.Send(Analytics.Category.squirrel, Analytics.Action.uninstall, version.ToString());
         if (MessageBox.Show("Sorry to see you go!\nCould you spare 30 seconds for some feedback?", "Uninstalling OGCS",
                             MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             log.Debug("User opted to give feedback.");
             Analytics.Send(Analytics.Category.squirrel, Analytics.Action.uninstall, Application.ProductVersion + "-feedback");
             System.Diagnostics.Process.Start("https://docs.google.com/forms/d/e/1FAIpQLSfRWYFdgyfbFJBMQ0dz14patu195KSKxdLj8lpWvLtZn-GArw/viewform");
         }
         else
         {
             log.Debug("User opted not to give feedback.");
         }
         log.Info("Deleting directory " + Path.GetDirectoryName(Settings.ConfigFile));
         try {
             log.Logger.Repository.Shutdown();
             log4net.LogManager.Shutdown();
             Directory.Delete(Path.GetDirectoryName(Settings.ConfigFile), true);
         } catch (System.Exception ex) {
             try { log.Error(ex.Message); } catch { }
         }
     } catch (System.Exception ex) {
         log.Error("Problem encountered on app uninstall.");
         OGCSexception.Analyse(ex, true);
     }
 }
コード例 #7
0
        /// <summary>
        /// When an error is logged, check if user has chosen to upload logs or not
        /// </summary>
        protected override void Append(LoggingEvent loggingEvent)
        {
            if (!GoogleOgcs.ErrorReporting.Initialised || errorOccurred)
            {
                return;
            }
            errorOccurred = true;
            String configSetting = null;

            if (Settings.IsLoaded)
            {
                configSetting = Settings.Instance.CloudLogging.ToString();
            }
            else
            {
                configSetting = XMLManager.ImportElement("CloudLogging", Settings.ConfigFile);
            }

            if (!string.IsNullOrEmpty(configSetting))
            {
                if (configSetting == "true" && GoogleOgcs.ErrorReporting.GetThreshold().ToString().ToUpper() != "ALL")
                {
                    GoogleOgcs.ErrorReporting.SetThreshold(true);
                    replayLogs();
                }
                else if (configSetting == "false" && GoogleOgcs.ErrorReporting.GetThreshold().ToString().ToUpper() != "OFF")
                {
                    GoogleOgcs.ErrorReporting.SetThreshold(false);
                }
                return;
            }

            //Cloud logging value not set yet - let's ask the user
            Forms.ErrorReporting frm = new Forms.ErrorReporting();
            DialogResult         dr  = frm.ShowDialog();

            if (dr == DialogResult.Cancel)
            {
                errorOccurred = false;
                return;
            }
            Boolean confirmative = dr == DialogResult.Yes;

            if (Settings.IsLoaded)
            {
                Settings.Instance.CloudLogging = confirmative;
            }
            else
            {
                XMLManager.ExportElement("CloudLogging", confirmative, Settings.ConfigFile);
            }
            Analytics.Send(Analytics.Category.ogcs, Analytics.Action.setting, "CloudLogging=" + confirmative.ToString());

            try {
                Forms.Main.Instance.SetControlPropertyThreadSafe(Forms.Main.Instance.cbCloudLogging, "Checked", confirmative);
            } catch { }

            if (confirmative)
            {
                replayLogs();
            }
        }
コード例 #8
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.");
                            Analytics.Send(Analytics.Category.squirrel, Analytics.Action.upgrade, squirrelAnalyticsLabel + ";later");
                        }
                        else if (dr == DialogResult.Ignore)
                        {
                            Analytics.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.");
                                Analytics.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))
                                    {
                                        Analytics.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)
                                        {
                                            Analytics.Send(Analytics.Category.squirrel, Analytics.Action.download, squirrelAnalyticsLabel + ";from-website");
                                            System.Diagnostics.Process.Start("https://phw198.github.io/OutlookGoogleCalendarSync/");
                                        }
                                        else
                                        {
                                            Analytics.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)
                                    {
                                        Analytics.Send(Analytics.Category.squirrel, Analytics.Action.download, squirrelAnalyticsLabel + ";from-website");
                                        System.Diagnostics.Process.Start("https://phw198.github.io/OutlookGoogleCalendarSync/");
                                    }
                                    else
                                    {
                                        Analytics.Send(Analytics.Category.squirrel, Analytics.Action.download, squirrelAnalyticsLabel + ";gave-up");
                                    }
                                    break;
                                }
                            }

                            try {
                                log.Debug("Download complete.");
                                Analytics.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) {
                Analytics.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);
        }