Example #1
0
 void OnUpdateCheckComplete(UpdateCheckResult result)
 {
     if (result != null && result.IsUpdated)
     {
         clientViewModel.UpdateLink = result.UpdateLink;
     }
 }
Example #2
0
        public async Task _05_CheckAndInstallUpdates_Beta()
        {
            try
            {
                VersionTuple initialVersions = this.GetVersionsFromExtractedAppFile(Apps.PackageNames.AutomaticTestsClientAppV1, TestHelpers.GetMethodName(), out FileInfo appFile);

                this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.HandleUpdatesWithBeta, Apps.Keys.AutomaticTestsClient, waitForExit: false);

                Window updateNowMsgBox =
                    await TestHelpers.WaitForWindowAsync(x => x.Equals("AutomaticTestsClient update installation"), TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                updateNowMsgBox.Get <Button>(SearchCriteria.ByText("Yes")).Click();

                Window updater = await TestHelpers.WaitForWindowAsync(x => x.Contains("AutomaticTestsClient Updater"), TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                updater.Get <Button>(SearchCriteria.ByText("Install now!")).Click();

                Window doneMsg = await TestHelpers.WaitForMessageBoxAsync(updater, "Update complete", TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                doneMsg.Get <Button>(SearchCriteria.ByText("No")).Click();

                VersionTuple newVersions = this.GetVersionsFromFile(appFile);

                await this.AssertVersionAreCorrect(newVersions, initialVersions, appFile, "3.").ConfigureAwait(false);

                //now just assert that the update check result is empty next time
                UpdateCheckResult result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.CheckAndInstallUpdates, Apps.Keys.AutomaticTestsClient, waitForExit: true);

                this.AssertNoNonBetaUpdatesToInstall(result, false);
            }
            catch (Exception ex)
            {
                throw this.CleanupAndRethrow(ex);
            }
        }
        public async Task _05_CheckAndInstallUpdates_Beta()
        {
            try
            {
                VersionTuple initialVersions = this.GetVersionsFromExtractedAppFile(Apps.PackageNames.AutomaticTestsClientAppV1, SharedTestHelpers.GetMethodName(), out FileInfo appFile);

                this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.HandleUpdatesWithBeta, Apps.Keys.AutomaticTestsClient, waitForExit: false);

                await this.PerformManualUpdate("AutomaticTestsClient", "3.");

                VersionTuple newVersions = this.GetVersionsFromFile(appFile);
                Log($"New versions: {newVersions.ToLog()}");

                this.AssertVersionAreCorrect(newVersions, initialVersions, appFile, "3.");

                //now just assert that the update check result is empty next time
                Log("Checking update info is false");
                UpdateCheckResult result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.CheckAndInstallUpdates, Apps.Keys.AutomaticTestsClient, waitForExit: true);

                this.AssertNoNonBetaUpdatesToInstall(result, false);
            }
            catch (Exception ex)
            {
                this.CleanupAndLog(ex);
                throw;
            }
        }
Example #4
0
        /// <summary>
        /// Checks for version and shows message
        /// </summary>
        /// <param name="showIfCurrent">show message or not if current version</param>
        private void CheckForUpdate(bool showIfCurrent)
        {
            UpdateChecker     updater     = new UpdateChecker(this);
            UpdateCheckResult checkResult = updater.CheckForUpdate(true);

            switch (checkResult)
            {
            case UpdateCheckResult.CheckError:
                // nothing to do as updater displayed error
                break;

            case UpdateCheckResult.CurrentVersion:
                if (showIfCurrent)
                {
                    MessageBox.Show(this,
                                    Resources.FormGUI_checkForUpdateToolStripMenuItem_Click_The_version_is_most_current,
                                    Resources.FormGUI_checkForUpdateToolStripMenuItem_Click_Version_check, MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                break;

            case UpdateCheckResult.UpdatePresent:
                // if new version found - display the "new version found" dialog
                ShowUpdateMessage(updater.CurrentVersion, updater.UpdateVersion, updater.UpdatePath);
                break;
            }
        }
Example #5
0
        /// <summary>
        /// 同步检查更新
        /// </summary>
        /// <param name="enableEmbedDialog">是否启用内置对话框,默认为 <code>true</code>,也就是允许当发现新版本时先弹出提示或进行相关操作。</param>
        /// <returns></returns>
        public UpdateCheckResult CheckUpdateSync(bool enableEmbedDialog = true)
        {
            Context.EnableEmbedDialog = enableEmbedDialog;

            var               evt    = new ManualResetEvent(false);
            EventHandler      eh     = null;
            UpdateCheckResult result = null;

            eh = (_, __) =>
            {
                Delegate.RemoveAll(CheckUpdateComplete, eh);
                if (Context.Exception != null)
                {
                    result = new UpdateCheckResult(false, true, false, null, Context.Exception);
                }
                else if (Context.HasUpdate)
                {
                    result = new UpdateCheckResult(true, false, true, new Version(Context.UpdateInfo.AppVersion), null);
                }
                else
                {
                    result = new UpdateCheckResult(true, false, false, null, null);
                }

                evt.Set();
            };
            CheckUpdateComplete += eh;
            BeginCheckUpdateInProcess();

            evt.WaitOne();

            return(result);
        }
Example #6
0
        /// <inheritdoc />
        public async Task <UpdateInstallationResult> InstallUpdatesAsync(UpdateCheckResult checkResult, bool takeBeta)
        {
            try
            {
                if (!takeBeta)
                {
                    checkResult.ProgramUpdatesToInstall = checkResult.ProgramUpdatesToInstall.Where(x => x.IsBeta == false).ToList();
                }
                UpdateHandler handler = new UpdateHandler(this.telimena.Messenger, this.telimena.Properties.LiveProgramInfo, new DefaultWpfInputReceiver()
                                                          , new UpdateInstaller(), this.telimena.Locator);
                await handler.HandleUpdates(UpdatePromptingModes.DontPrompt, checkResult.ProgramUpdatesToInstall, checkResult.UpdaterUpdate).ConfigureAwait(false);

                return(new UpdateInstallationResult()
                {
                    CheckResult = checkResult
                });
            }
            catch (Exception ex)
            {
                TelimenaException exception = new TelimenaException("Error occurred while installing updates", this.telimena.Properties, ex);
                if (!this.telimena.Properties.SuppressAllErrors)
                {
                    throw exception;
                }
                return(new UpdateInstallationResult()
                {
                    CheckResult = checkResult
                    , Exception = exception
                });
            }
        }
        public async Task <bool> CheckForUpdate()
        {
            if (Resized == false)
            {
                return(false);
            }
            bool success = false;

            Console.WriteLine("Checking for update ...");
            UpdateCheckResult result = new UpdateCheckResult();

            try
            {
                Electron.Notification.Show(new NotificationOptions("Hello", await Electron.App.GetVersionAsync()));
                Electron.AutoUpdater.AutoDownload = false;
                resultTask = Electron.AutoUpdater.CheckForUpdatesAsync();
                //resultTask = Electron.AutoUpdater.CheckForUpdatesAsync();
                //resultTask = Electron.AutoUpdater.CheckForUpdatesAndNotifyAsync();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }

            Console.WriteLine("Update Check running?!");
            return(success);
        }
        public void Test_OnlyUpdaterUpdates()
        {
            ITelimena sut = TelimenaFactory.Construct(new TelimenaStartupInfo(Guid.NewGuid(), Helpers.TeliUri)
            {
                SuppressAllErrors = false
            });


            UpdateResponse latestVersionResponse = new UpdateResponse
            {
                UpdatePackages = new List <UpdatePackageData> {
                    new UpdatePackageData {
                        FileName = DefaultToolkitNames.UpdaterFileName, Version = "1.2"
                    }
                }
            };

            Helpers.SetupMockHttpClient(sut, this.GetMockClientForCheckForUpdates(sut.Properties.TelemetryKey, new UpdateResponse(), latestVersionResponse));

            UpdateCheckResult response = sut.Update.CheckForUpdatesAsync().GetAwaiter().GetResult();

            Assert.IsFalse(response.IsUpdateAvailable);
            Assert.AreEqual(0, response.ProgramUpdatesToInstall.Count);
            Assert.AreEqual("1.2", response.UpdaterUpdate.Version);
            Assert.IsNull(response.Exception);
        }
Example #9
0
        public async Task _04_MsiCheckAndInstallUpdates()
        {
            this.ProductCodesTest_InstallersTestAppMsi3(); //sanity check to save time
            try
            {
                this.UninstallPackages(Apps.ProductCodes.InstallersTestAppMsi3V1, Apps.ProductCodes.InstallersTestAppMsi3V2);

                VersionTuple initialVersions = this.GetVersionsFromMsiApp(Apps.PackageNames.InstallersTestAppMsi3V1, Apps.Paths.InstallersTestAppMsi3, Apps.ProductCodes.InstallersTestAppMsi3V1);

                UpdateCheckResult result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(Apps.Paths.InstallersTestAppMsi3, Actions.CheckAndInstallUpdates, Apps.Keys.InstallersTestAppMsi3);
                Assert.IsNull(result.Exception);
                Window updater = await TestHelpers.WaitForWindowAsync(x => x.Contains("InstallersTestApp.Msi3Installer"), TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                updater.Get <Button>(SearchCriteria.ByText("OK")).Click();


                this.VerifyVersionsAreUpdatedAfterInstallation(initialVersions);


                //now just assert that the update check result is empty next time
                result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(Apps.Paths.InstallersTestAppMsi3, Actions.CheckAndInstallUpdates, Apps.Keys.InstallersTestAppMsi3);

                this.AssertNoNonBetaUpdatesToInstall(result, false);

                this.UninstallPackages(Apps.ProductCodes.InstallersTestAppMsi3V1, Apps.ProductCodes.InstallersTestAppMsi3V2);
            }
            catch (Exception ex)
            {
                throw this.CleanupAndRethrow(ex);
            }
        }
Example #10
0
        /// <summary>
        /// 任务模式检查更新。任务将会返回新版本号,如果返回null,则意味着没找到新版本。
        /// </summary>
        /// <param name="enableEmbedDialog">是否启用内置对话框,默认为 <code>true</code>,也就是允许当发现新版本时先弹出提示或进行相关操作。</param>
        /// <returns></returns>
        public Task <Version> CheckUpdateTask(bool enableEmbedDialog = true)
        {
            Context.EnableEmbedDialog = enableEmbedDialog;

            var tcs = new TaskCompletionSource <Version>();

            EventHandler      eh     = null;
            UpdateCheckResult result = null;

            eh = (_, __) =>
            {
                Delegate.RemoveAll(CheckUpdateComplete, eh);
                if (Context.Exception != null)
                {
                    tcs.SetException(Context.Exception);
                }
                else if (Context.HasUpdate)
                {
                    tcs.SetResult(new Version(Context.UpdateInfo.AppVersion));
                }
                else
                {
                    tcs.SetResult(null);
                }
            };
            CheckUpdateComplete += eh;
            BeginCheckUpdateInProcess();

            return(tcs.Task);
        }
Example #11
0
        private string PresentResponse(UpdateCheckResult response)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings {
                ContractResolver = new MyContractResolver(),
            };

            return(JsonConvert.SerializeObject(response, settings));
        }
 internal UpdateNoticeWindow(UpdateCheckResult e)
 {
     InitializeComponent();
     Owner                 = App.Current.MainWindow;
     this.result           = e;
     LH.Content            = result.Header;
     LbPublishTime.Content = result.Time.ToString("MM/dd/yyyy");
     TextBoxContent.Text   = result.Message;
 }
Example #13
0
 private void AssertNoNonBetaUpdatesToInstall(UpdateCheckResult result, bool betaUpdateMightStillBeAvailable)
 {
     Assert.IsNull(result.Exception);
     Assert.AreEqual(0, result.ProgramUpdatesToInstall.Count(x => !x.IsBeta));
     if (!betaUpdateMightStillBeAvailable)
     {
         Assert.AreEqual(0, result.ProgramUpdatesToInstall.Count);
         Assert.IsFalse(result.IsUpdateAvailable);
     }
 }
Example #14
0
        async void CheckForUpdates()
        {
            if (!SettingsProvider.Current.Settings.GeneralSettings.CheckForUpdates)
            {
                return;
            }

            UpdateCheckResult result = await Task.Run(() => UpdateNotifier.CheckForUpdate(SettingsProvider.Current.Settings.GeneralSettings.FirstRun));

            OnUpdateCheckComplete(result);
        }
Example #15
0
    public void StartResourceUpdate(UpdateCheckResult result, IUpdateSysDelegate del)
    {
        if (m_state == State.Upgrading)
        {
            Debug.LogError("already in upgrading state");
            return;
        }

        if (!result.NeedUpdate)
        {
            Debug.LogError("donot need update");
            return;
        }

        var list = result.ResInfoList;

        if (list == null || list.Count == 0)
        {
            Debug.LogError("empty res list");
            return;
        }

        m_delegate = del;
        _StartUpdate();

        for (int i = 0; i < list.Count; i++)
        {
            var info = list[i];

            IUpdateExecutor executor = GetUpdateExecutor(info.type);
            if (executor != null)
            {
                //JobQueueCoroutine需要重构下更易用
                UpdateResourceParam param = new UpdateResourceParam();
                param.executor = executor;
                param.info     = info;
                param.context  = m_context;

                m_updateCount++;
                m_CoroutineJobQueue.PushJob(_UpdateResCoroutine, param);
            }
            else
            {
                Debug.LogError("UpdateExecutor not registered for type:" + info.type);
            }
        }

        m_CoroutineJobQueue.StartJobCoroutine();
    }
        private void ValidateFaultyTeli(ITelimena teli)
        {
            Assert.IsTrue(teli.GetType() == typeof(NullObjectTelimena));
            teli.Track.Event("There should be no error here even though it is not working");
            teli.Track.View("There should be no error here even though it is not working");
            teli.Track.Log(LogLevel.Warn, "There should be no error here even though it is not working");
            teli.Track.SendAllDataNow();

            UpdateCheckResult result = teli.Update.CheckForUpdates();

            Assert.AreEqual("Update check handled by NullObjectTelemetryModule", result.Exception.Message);
            UpdateInstallationResult result2 = teli.Update.HandleUpdatesAsync(true).Result;

            Assert.IsNotNull(teli.Properties);
        }
        public void Test_NoUpdates()
        {
            ITelimena sut = TelimenaFactory.Construct(new TelimenaStartupInfo(Guid.NewGuid(), Helpers.TeliUri)
            {
                SuppressAllErrors = false
            });

            Helpers.SetupMockHttpClient(sut, this.GetMockClientForCheckForUpdates(sut.Properties.TelemetryKey, new UpdateResponse(), new UpdateResponse()));

            UpdateCheckResult response = sut.Update.CheckForUpdatesAsync().GetAwaiter().GetResult();

            Assert.IsFalse(response.IsUpdateAvailable);
            Assert.AreEqual(0, response.ProgramUpdatesToInstall.Count);
            Assert.IsNull(response.UpdaterUpdate);
            Assert.IsNull(response.Exception);
        }
Example #18
0
        public async Task <UpdateDownloadResult> DownloadUpdateAsync(UpdateCheckResult updateCheckResult, IProgress <object> progressHandler,
                                                                     CancellationToken cancellationToken)
        {
            UpdateDownloadResult result = new UpdateDownloadResult();
            string downloadDirectory    = Path.Combine(Environment.AppDataDirectory, "Updates");

            if (!Directory.Exists(downloadDirectory))
            {
                Directory.CreateDirectory(downloadDirectory);
            }
            result.DownloadFilePath = Path.Combine(downloadDirectory, updateCheckResult.FileName);
            result.DownloadResult   = await DownloadUtils.DownloadFileAsync(httpClient, updateCheckResult.DownloadUrl, result.DownloadFilePath, false,
                                                                            progressHandler, cancellationToken);

            return(result);
        }
Example #19
0
        void UpdateStatus(UpdateCheckResult status)
        {
            switch (status)
            {
            // nothing to do for UpdateCheckResult.Yes, the correct hyperlinked text is in the XAML as the default
            case UpdateCheckResult.No:
                statusText.Text = "CoCEd is up to date.";
                break;

            case UpdateCheckResult.Unknown:
                statusText.Text = "Check failed. An unexpected problem occurred.";
                break;
            }
            checkingGrid.Visibility = Visibility.Collapsed;
            statusGrid.Visibility   = Visibility.Visible;
        }
Example #20
0
        public async Task <UpdateCheckResult> CheckForUpdateAsync()
        {
            UpdateCheckResult result = null;

            if (httpClient != null)
            {
                string url = GITHUB_RELEASE_API_URL;
                Logger.Debug($"Sending a request to {url}");
                HttpResponseMessage response = await httpClient.GetAsync(url);

                Logger.Debug($"Response status code: {(int)response.StatusCode} {response.StatusCode}.");
                Logger.Debug("Response headers:", response.Headers.ToString().TrimEnd(), response.Content.Headers.ToString().TrimEnd());
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    throw new Exception($"GitHub API returned {(int)response.StatusCode} {response.StatusCode}.");
                }
                string responseContent = await response.Content.ReadAsStringAsync();

                Logger.Debug("Response content:", responseContent);
                List <GitHubApiRelease> releases;
                try
                {
                    releases = JsonConvert.DeserializeObject <List <GitHubApiRelease> >(responseContent);
                }
                catch (Exception exception)
                {
                    throw new Exception("GitHub API response is not a valid JSON string.", exception);
                }
                Logger.Debug($"{releases.Count} releases have been parsed from the GitHub API response.");
                if (releases.Any())
                {
                    GitHubApiRelease latestRelease = releases.First();
                    Logger.Debug($@"Latest release is ""{latestRelease.Name}"".");
                    if (latestRelease.Name != CURRENT_GITHUB_RELEASE_NAME && latestRelease.Name != ignoreReleaseName)
                    {
                        GitHubApiRelease.Asset asset = latestRelease.Assets.FirstOrDefault(assetItem => assetItem.Name == expectedAssetName);
                        if (asset != null)
                        {
                            Logger.Debug($"New asset is {asset.Name} ({asset.Size} bytes), download URL = {asset.DownloadUrl}.");
                            result = new UpdateCheckResult(latestRelease.Name, latestRelease.PublishedAt, asset.Name, asset.Size, asset.DownloadUrl);
                        }
                    }
                }
            }
            return(result);
        }
Example #21
0
        public async Task _02_HandleUpdates_NonBeta()
        {
            try
            {
                VersionTuple initialVersions = await this.GetVersionsFromApp(Apps.PackageNames.AutomaticTestsClientAppV1, SharedTestHelpers.GetMethodName()).ConfigureAwait(false);

                UpdateCheckResult result = this.LaunchTestsAppNewInstanceAndGetResult <UpdateCheckResult>(out FileInfo appFile, Actions.HandleUpdates, Apps.Keys.AutomaticTestsClient, Apps.PackageNames.AutomaticTestsClientAppV1
                                                                                                          , SharedTestHelpers.GetMethodName(), waitForExit: false);

                Window updateNowMsgBox =
                    await WindowHelpers.WaitForWindowAsync(x => x.Equals("AutomaticTestsClient update installation"), TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                this.CheckProperUpdateVersionDownloadedInMessageBo(updateNowMsgBox, "2.");

                updateNowMsgBox.Get <Button>(SearchCriteria.ByText("Yes")).Click();
                Log("Clicked yes");
                Window updater = await WindowHelpers.WaitForWindowAsync(x => x.Contains("AutomaticTestsClient Updater"), TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                updater.Get <Button>(SearchCriteria.ByText("Install now!")).Click();
                Log("Clicked Install now!");

                Window doneMsg = await WindowHelpers.WaitForMessageBoxAsync(updater, "Update complete", TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                doneMsg.Get <Button>(SearchCriteria.ByText("Yes")).Click();
                Log("Clicked yes");

                Window appWarning = await WindowHelpers.WaitForWindowAsync(x => x.Equals("AutomaticTestsClient - This app requires arguments to run")
                                                                           , TimeSpan.FromMinutes(2)).ConfigureAwait(false);

                Log("Reading versions");

                VersionTuple newVersions = await this.GetVersionFromMsgBox(appWarning).ConfigureAwait(false);

                this.AssertVersionAreCorrect(newVersions, initialVersions, appFile, "2.");

                Log("Checking update info is false");
                //now just assert that the update check result is empty next time
                result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.CheckAndInstallUpdates, Apps.Keys.AutomaticTestsClient, waitForExit: true);

                this.AssertNoNonBetaUpdatesToInstall(result, true);
            }
            catch (Exception ex)
            {
                throw this.CleanupAndRethrow(ex);
            }
        }
Example #22
0
        public static void ElectronUpdate()
        {
            Console.WriteLine("Checking for update ...");
            Electron.AutoUpdater.OnError             += (message) => Electron.Dialog.ShowErrorBox("Error", message);
            Electron.AutoUpdater.OnCheckingForUpdate += async() => await Electron.Dialog.ShowMessageBoxAsync("Checking for Update");

            Electron.AutoUpdater.OnUpdateNotAvailable += async(info) => await Electron.Dialog.ShowMessageBoxAsync("Update not available");

            Electron.AutoUpdater.OnUpdateAvailable += async(info) => await Electron.Dialog.ShowMessageBoxAsync("Update available" + info.Version);

            Electron.AutoUpdater.OnDownloadProgress += (info) =>
            {
                var message1    = "Download speed: " + info.BytesPerSecond + "\n<br/>";
                var message2    = "Downloaded " + info.Percent + "%" + "\n<br/>";
                var message3    = $"({info.Transferred}/{info.Total})" + "\n<br/>";
                var message4    = "Progress: " + info.Progress + "\n<br/>";
                var information = message1 + message2 + message3 + message4;

                var mainWindow = Electron.WindowManager.BrowserWindows.First();
                Electron.IpcMain.Send(mainWindow, "auto-update-reply", information);
            };
            Electron.AutoUpdater.OnUpdateDownloaded += async(info) => await Electron.Dialog.ShowMessageBoxAsync("Update complete!" + info.Version);


            // Electron.NET CLI Command for deploy:
            // electronize build /target win /electron-params --publish=always
            var mainWindow = Electron.WindowManager.BrowserWindows.First();
            UpdateCheckResult updateCheckResult = new UpdateCheckResult();

            // Electron.NET CLI Command for deploy:
            // electronize build /target win /electron-params --publish=always

            var currentVersion = Electron.App.GetVersionAsync().GetAwaiter().GetResult();

            Electron.AutoUpdater.AutoDownload = false;
            updateCheckResult = Electron.AutoUpdater.CheckForUpdatesAsync().GetAwaiter().GetResult();
            var    availableVersion = updateCheckResult.UpdateInfo.Version;
            string information      = $"Current version: {currentVersion} - available version: {availableVersion}";

            Electron.IpcMain.Send(mainWindow, "auto-update-reply", information);

            Console.WriteLine("Checking for update done.");
        }
Example #23
0
        private void CheckAndInstallUpdates(ITelimena telimena, bool takeBeta)
        {
            Console.WriteLine($"Starting {MethodBase.GetCurrentMethod().Name}...");

            UpdateCheckResult result = telimena.Update.CheckForUpdates();

            Console.WriteLine($"Finished update check. Update available: {result.IsUpdateAvailable}...");

            JsonSerializerSettings settings = new JsonSerializerSettings {
                ContractResolver = new MyJsonContractResolver(), TypeNameHandling = TypeNameHandling.Auto
            };

            Console.WriteLine(JsonConvert.SerializeObject(result, settings));

            UpdateInstallationResult installationResult = telimena.Update.InstallUpdates(result, takeBeta);


            Console.WriteLine($"Finished {MethodBase.GetCurrentMethod().Name}");
        }
Example #24
0
        public static void checkForUpdate(Action <UpdateCheckResult> checkCompletedCallback, AtlasPluginManager pluginManager, LicenseManager licenseManager)
        {
            //Check for updates on a background thread
            ThreadPool.QueueUserWorkItem(state =>
            {
                UpdateCheckResult result = UpdateCheckResult.NoUpdates;
                try
                {
                    ServerUpdateInfo updateInfo = getUpdateInfo(licenseManager);
                    if (updateInfo.RemotePlatformVersion > CurrentVersion)
                    {
                        result |= UpdateCheckResult.PlatformUpdate;
                    }
                    else
                    {
                        foreach (var pluginUpdate in updateInfo.PluginUpdateInfo)
                        {
                            AtlasPlugin plugin = pluginManager.getPlugin(pluginUpdate.PluginId);
                            if (plugin != null && pluginUpdate.Version > plugin.Version)
                            {
                                result |= UpdateCheckResult.PluginUpdates;
                                break;
                            }
                        }
                        foreach (var dependencyUpdate in updateInfo.DependencyUpdateInfo)
                        {
                            AtlasPlugin plugin = pluginManager.getPlugin(dependencyUpdate.PluginId);
                            if (plugin != null && dependencyUpdate.Version > plugin.Version)
                            {
                                result |= UpdateCheckResult.PluginUpdates;
                                break;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Error("Could not read update status from the server. Reason:\n{0}", e.Message);
                }

                ThreadManager.invoke(checkCompletedCallback, result);
            });
        }
        public async Task _03_CheckAndInstallUpdates_NonBeta()
        {
            try
            {
                VersionTuple initialVersions    = this.GetVersionsFromExtractedAppFile(Apps.PackageNames.AutomaticTestsClientAppV1, SharedTestHelpers.GetMethodName(), out FileInfo appFile);
                var          installationResult = this.LaunchTestsAppAndGetResult <UpdateInstallationResult>(appFile, Actions.CheckAndInstallUpdates, Apps.Keys.AutomaticTestsClient, waitForExit: false);

                if (installationResult?.Exception != null)
                {
                    throw installationResult.Exception;
                }

                Window updater = await WindowHelpers.WaitForWindowAsync(x => x.Contains("AutomaticTestsClient Updater"), TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                this.CheckProperUpdateVersionDownloadedInUpdater(updater, "2.");
                WindowHelpers.ClickButtonByText(updater, "Install now!");

                Log("Clicked Install now!");

                Window doneMsg = await WindowHelpers.WaitForMessageBoxAsync(updater, "Update complete", TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                WindowHelpers.ClickButtonByText(doneMsg, "Yes");
                Log("Clicked yes");

                VersionTuple newVersions = this.GetVersionsFromApp(appFile);
                Log($"New versions: {newVersions.ToLog()}");

                this.AssertVersionAreCorrect(newVersions, initialVersions, appFile, "2.");

                //now just assert that the update check result is empty next time
                Log("Checking update info is false");

                UpdateCheckResult result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.CheckAndInstallUpdates, Apps.Keys.AutomaticTestsClient, waitForExit: true);
                this.AssertNoNonBetaUpdatesToInstall(result, true);
            }
            catch (Exception ex)
            {
                this.CleanupAndLog(ex);
                throw;
            }
        }
Example #26
0
        void UpdateStatus(UpdateCheckResult status)
        {
            Logger.Trace(String.Format("UpdateStatus: {0}", status));

            switch (status)
            {
            // nothing to do for UpdateCheckResult. Yes, the correct hyperlinked text is in the XAML as the default
            case UpdateCheckResult.No:
                statusText.Text = "TiTsEd is up to date.";
                break;

            case UpdateCheckResult.Unknown:
                statusText.Text = "Check failed. An unexpected problem occurred.";
                break;

            default:
                break;
            }
            checkingGrid.Visibility = Visibility.Collapsed;
            statusGrid.Visibility   = Visibility.Visible;
        }
Example #27
0
 private void NotifyUpdates(UpdateCheckResult updateCheckResult, bool manual)
 {
     if (updateCheckResult.Equals(UpdateCheckResult.UpdateAvailable))
     {
         //Ask user if he wants to update
         _eventAggregator.PublishOnUIThreadAsync(new ShowQuestionDialogMessage
         {
             Title    = Resources.Strings.S_MSG_UPDATE_TITLE,
             Content  = Resources.Strings.S_MSG_UPDATE_CONTENT,
             Callback = r =>
             {
                 if (r.Equals(MessageDialogResult.Affirmative))
                 {
                     RunUpdater();
                 }
             }
         });
     }
     else if (manual)
     {
         if (updateCheckResult.Equals(UpdateCheckResult.NoUpdateAvailable))
         {
             //Notify no updates found
             _eventAggregator.PublishOnUIThreadAsync(new ShowDialogMessage
             {
                 Title   = Resources.Strings.S_MSG_NO_UPDATES_TITLE,
                 Content = Resources.Strings.S_MSG_NO_UPDATES_CONTENT
             });
         }
         else
         {
             //Notify error while checking updates
             _eventAggregator.PublishOnUIThreadAsync(new ShowDialogMessage
             {
                 Title   = Resources.Strings.S_MSG_UPDATE_ERROR_TITLE,
                 Content = Resources.Strings.S_MSG_UPDATE_ERROR_CONTENT
             });
         }
     }
 }
Example #28
0
        public async Task <UpdateCheckResult> CheckForUpdateAsync(bool ignoreSpecifiedRelease)
        {
            UpdateCheckResult result = null;

            if (httpClient != null)
            {
                DownloadUtils.DownloadPageResult downloadPageResult = await DownloadUtils.DownloadPageAsync(httpClient, updateUrl,
                                                                                                            CancellationToken.None);

                if (downloadPageResult.HttpStatusCode != HttpStatusCode.OK)
                {
                    throw new Exception($"GitHub API returned {(int)downloadPageResult.HttpStatusCode} {downloadPageResult.HttpStatusCode}.");
                }
                List <GitHubApiRelease> releases;
                try
                {
                    releases = JsonConvert.DeserializeObject <List <GitHubApiRelease> >(downloadPageResult.PageContent);
                }
                catch (Exception exception)
                {
                    throw new Exception("GitHub API response is not a valid JSON string.", exception);
                }
                Logger.Debug($"{releases.Count} releases have been parsed from the GitHub API response.");
                if (releases.Any())
                {
                    GitHubApiRelease latestRelease = releases.First();
                    Logger.Debug($@"Latest release is ""{latestRelease.Name}"".");
                    if (latestRelease.Name != CURRENT_GITHUB_RELEASE_NAME && (!ignoreSpecifiedRelease || latestRelease.Name != ignoreReleaseName))
                    {
                        GitHubApiRelease.Asset asset = latestRelease.Assets.FirstOrDefault(assetItem => assetItem.Name == expectedAssetName);
                        if (asset != null)
                        {
                            Logger.Debug($"New asset is {asset.Name} ({asset.Size} bytes), download URL = {asset.DownloadUrl}.");
                            result = new UpdateCheckResult(latestRelease.Name, latestRelease.PublishedAt, asset.Name, asset.Size, asset.DownloadUrl);
                        }
                    }
                }
            }
            return(result);
        }
Example #29
0
        /// <inheritdoc />
        public async Task <UpdateInstallationResult> HandleUpdatesAsync(bool acceptBeta)
        {
            UpdateCheckResult checkResult = null;

            try
            {
                checkResult = await this.CheckForUpdatesAsync(acceptBeta).ConfigureAwait(false);

                if (checkResult.Exception == null)
                {
                    UpdateHandler handler = new UpdateHandler(this.telimena.Messenger, this.telimena.Properties.LiveProgramInfo, new DefaultWpfInputReceiver()
                                                              , new UpdateInstaller(), this.telimena.Locator, this.telimena.telemetryModule);
                    await handler.HandleUpdates(this.telimena.Properties.UpdatePromptingMode, checkResult.ProgramUpdatesToInstall, checkResult.UpdaterUpdate).ConfigureAwait(false);
                }
                else
                {
                    throw checkResult.Exception;
                }

                return(new UpdateInstallationResult()
                {
                    CheckResult = checkResult
                });
            }
            catch (Exception ex)
            {
                TelimenaException exception = new TelimenaException("Error occurred while handling updates", this.telimena.Properties, ex);
                if (!this.telimena.Properties.SuppressAllErrors)
                {
                    throw exception;
                }

                return(new UpdateInstallationResult()
                {
                    CheckResult = checkResult
                    , Exception = exception
                });
            }
        }
Example #30
0
        //Check to see if there is an update.
        private void CheckForUpdatesDoWork(object sender, DoWorkEventArgs e)
        {
            UpdateCheckResult result = new UpdateCheckResult();

            result.LatestVersion = new Version();
            String downloadedText = DownloadString((String)e.Argument);

            if (downloadedText == null)
            {
                e.Result = result; return;
            }

            String[] lines = StringToLines(downloadedText);

            for (Int32 i = 0; i <= lines.GetUpperBound(0); i++)
            {
                String[] splitLine = lines[i].Split(new String[] { "=" }, StringSplitOptions.None);
                switch (splitLine[0].ToLower())
                {
                case "version":
                    result.LatestVersion = new Version(splitLine[1]);
                    if (result.LatestVersion > appVersion)
                    {
                        result.UpdateAvailable = true;
                    }
                    break;

                case "change log":
                    result.ChangeLogUrl = splitLine[1];
                    break;

                case "url":
                    result.UpdateFileListUrl = splitLine[1];
                    break;
                }
            }
            e.Result = result;
        }
Example #31
0
        //Check to see if there is an update.
        private void CheckForUpdatesDoWork(object sender, DoWorkEventArgs e)
        {
            UpdateCheckResult result = new UpdateCheckResult();
            result.LatestVersion = new Version();
            String downloadedText = DownloadString((String)e.Argument);

            if (downloadedText == null) { e.Result = result; return; }

            String[] lines = StringToLines(downloadedText);

            for (Int32 i = 0; i <= lines.GetUpperBound(0); i++)
            {
                String[] splitLine = lines[i].Split(new String[] { "=" }, StringSplitOptions.None);
                switch (splitLine[0].ToLower())
                {
                    case "version":
                        result.LatestVersion = new Version(splitLine[1]);
                        if (result.LatestVersion > appVersion)
                        { result.UpdateAvailable = true;}
                        break;
                    case "change log":
                        result.ChangeLogUrl = splitLine[1];
                        break;
                    case "url":
                        result.UpdateFileListUrl = splitLine[1];
                        break;
                }
            }
            e.Result = result;
        }
Example #32
0
 void UpdateStatus(UpdateCheckResult status)
 {
     switch (status)
     {
         // nothing to do for UpdateCheckResult.Yes, the correct hyperlinked text is in the XAML as the default
         case UpdateCheckResult.No:
             statusText.Text = "CoCEd is up to date.";
             break;
         case UpdateCheckResult.Unknown:
             statusText.Text = "Check failed. An unexpected problem occurred.";
             break;
     }
     checkingGrid.Visibility = Visibility.Collapsed;
     statusGrid.Visibility = Visibility.Visible;
 }
Example #33
0
	public void Check(System.Version localVersion, System.Action<UpdateCheckResult> onFinish)
	{
		var res = new UpdateCheckResult();
		onFinish(res);
	}