internal async Task UpdateVersionIfAvailable(UpdateCheckSettings updateCheckSettings) { if (CheckWithUpdateFrequency(updateCheckSettings.UpdateCheckFrequency) && NetworkInterface.GetIsNetworkAvailable()) { Exception thrownException = null; try { var currentVersion = new Version(HockeyClient.Current.AsInternal().VersionInfo); var appVersions = await HockeyClient.Current.AsInternal().GetAppVersionsAsync(); var newestAvailableAppVersion = appVersions.FirstOrDefault(); if (appVersions.Any() && new Version(newestAvailableAppVersion.Version) > currentVersion && (updateCheckSettings.CustomDoShowUpdateFunc == null || updateCheckSettings.CustomDoShowUpdateFunc(newestAvailableAppVersion))) { if (updateCheckSettings.UpdateMode.Equals(UpdateMode.InApp) || (updateCheckSettings.EnforceUpdateIfMandatory && newestAvailableAppVersion.Mandatory)) { NavigateToUpdatePage(currentVersion, appVersions, updateCheckSettings); } else { ShowUpdateNotification(currentVersion, appVersions, updateCheckSettings); } } else { if (updateCheckSettings.UpdateMode.Equals(UpdateMode.InApp)) { await(new MessageDialog(LocalizedStrings.LocalizedResources.NoUpdateAvailable).ShowAsync()); } } } catch (Exception e) { thrownException = e; HockeyClient.Current.AsInternal().HandleInternalUnhandledException(e); } //Don't show errors durgin update-check on startup if (thrownException != null && updateCheckSettings.UpdateMode.Equals(UpdateMode.InApp)) { await CoreWindow.GetForCurrentThread().Dispatcher.RunAsync(CoreDispatcherPriority.Low, async() => { await new MessageDialog(LocalizedStrings.LocalizedResources.UpdateUnknownError).ShowAsync(); }); } } }
internal void UpdateVersionIfAvailable(UpdateCheckSettings updateCheckSettings) { //TODO manual mode and no network => show message if (CheckWithUpdateFrequency(updateCheckSettings.UpdateCheckFrequency) && NetworkInterface.GetIsNetworkAvailable()) { var task = HockeyClient.Current.AsInternal().GetAppVersionsAsync(); task.ContinueWith((finishedTask) => { if (finishedTask.Exception == null) { var appVersions = finishedTask.Result; var newestAvailableAppVersion = appVersions.FirstOrDefault(); var currentVersion = new Version(ManifestHelper.GetAppVersion()); if (appVersions.Any() && new Version(newestAvailableAppVersion.Version) > currentVersion && (updateCheckSettings.CustomDoShowUpdateFunc == null || updateCheckSettings.CustomDoShowUpdateFunc(newestAvailableAppVersion))) { if (updateCheckSettings.UpdateMode.Equals(UpdateMode.InApp) || (updateCheckSettings.EnforceUpdateIfMandatory && newestAvailableAppVersion.Mandatory)) { ShowVersionPopup(currentVersion, appVersions, updateCheckSettings); } else { ShowUpdateNotification(currentVersion, appVersions, updateCheckSettings); } } else { if (updateCheckSettings.UpdateMode.Equals(UpdateMode.InApp)) { Scheduler.Dispatcher.Schedule(() => MessageBox.Show(LocalizedStrings.LocalizedResources.NoUpdateAvailable)); } } } else { HockeyClient.Current.AsInternal().HandleInternalUnhandledException(finishedTask.Exception); } }); } }
internal async Task UpdateVersionIfAvailable(UpdateCheckSettings updateCheckSettings) { if (CheckWithUpdateFrequency(updateCheckSettings.UpdateCheckFrequency) && NetworkInterface.GetIsNetworkAvailable()) { Exception thrownException = null; try { var currentVersion = new Version(HockeyClient.Current.AsInternal().VersionInfo); var appVersions = await HockeyClient.Current.AsInternal().GetAppVersionsAsync(); var newestAvailableAppVersion = appVersions.FirstOrDefault(); if (appVersions.Any() && new Version(newestAvailableAppVersion.Version) > currentVersion && (updateCheckSettings.CustomDoShowUpdateFunc == null || updateCheckSettings.CustomDoShowUpdateFunc(newestAvailableAppVersion))) { if (updateCheckSettings.UpdateMode.Equals(UpdateMode.InApp) || (updateCheckSettings.EnforceUpdateIfMandatory && newestAvailableAppVersion.Mandatory)) { NavigateToUpdatePage(currentVersion, appVersions, updateCheckSettings); } else { ShowUpdateNotification(currentVersion, appVersions, updateCheckSettings); } } else { if (updateCheckSettings.UpdateMode.Equals(UpdateMode.InApp)) { await (new MessageDialog(LocalizedStrings.LocalizedResources.NoUpdateAvailable).ShowAsync()); } } } catch (Exception e) { thrownException = e; HockeyClient.Current.AsInternal().HandleInternalUnhandledException(e); } //Don't show errors durgin update-check on startup if (thrownException != null && updateCheckSettings.UpdateMode.Equals(UpdateMode.InApp)) { await CoreWindow.GetForCurrentThread().Dispatcher.RunAsync(CoreDispatcherPriority.Low, async () => { await new MessageDialog(LocalizedStrings.LocalizedResources.UpdateUnknownError).ShowAsync(); }); } } }