Пример #1
0
        private bool TryDownloadUpgrade(ProductUpgrader productUpgrader, out string errorMessage)
        {
            using (ITracer activity = this.tracer.StartActivity("Checking for product upgrades.", EventLevel.Informational))
            {
                Version newerVersion = null;
                string detailedError = null;
                if (!productUpgrader.TryGetNewerVersion(out newerVersion, out detailedError))
                {
                    errorMessage = "Could not fetch new version info. " + detailedError;
                    return false;
                }

                if (newerVersion == null)
                {
                    // Already up-to-date
                    // Make sure there a no asset installers remaining in the Downloads directory. This can happen if user
                    // upgraded by manually downloading and running asset installers.
                    productUpgrader.CleanupDownloadDirectory();
                    errorMessage = null;
                    return true;
                }

                if (productUpgrader.TryDownloadNewestVersion(out detailedError))
                {
                    errorMessage = null;
                    return true;
                }
                else
                {
                    errorMessage = "Could not download product upgrade. " + detailedError;
                    return false;
                }
            }
        }
Пример #2
0
        private void TimerCallback(object unusedState)
        {
            string errorMessage = null;

            InstallerPreRunChecker prerunChecker = new InstallerPreRunChecker(this.tracer, string.Empty);
            ProductUpgrader productUpgrader = new ProductUpgrader(ProcessHelper.GetCurrentProcessVersion(), this.tracer);
            if (prerunChecker.TryRunPreUpgradeChecks(out string _) && this.TryDownloadUpgrade(productUpgrader, out errorMessage))
            {
                return;
            }

            productUpgrader.CleanupDownloadDirectory();

            if (errorMessage != null)
            {
                this.tracer.RelatedError(errorMessage);
            }
        }