Settings for update-checking
Exemple #1
0
        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);
                    }
                });
            }
        }
 protected void ShowVersionPopup(Version currentVersion, IEnumerable<IAppVersion> appVersions, UpdateCheckSettings updateCheckSettings)
 {
     Scheduler.Dispatcher.Schedule(() =>
     {
         UpdatePopupTool.ShowPopup(currentVersion, appVersions, updateCheckSettings, DoUpdate);
     });
 }
 protected void ShowUpdateNotification(Version currentVersion, IEnumerable<IAppVersion> appVersions, UpdateCheckSettings updateCheckSettings)
 {
     Scheduler.Dispatcher.Schedule(() =>
     {
         NotificationTool.Show(
             LocalizedStrings.LocalizedResources.UpdateNotification,
             LocalizedStrings.LocalizedResources.UpdateAvailable,
             new NotificationAction(LocalizedStrings.LocalizedResources.Show, (Action) (() =>
             {
                 ShowVersionPopup(currentVersion, appVersions, updateCheckSettings);
             })),
             new NotificationAction(LocalizedStrings.LocalizedResources.Dismiss, (Action) (() =>
             {
                 //DO nothing
             }))
         );
     });
 }
        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);
                    }
                });
            }
        }
 public static void RunUpdateCheck(string identifier, UpdateCheckSettings settings = null)
 {
     Instance.UpdateVersionIfAvailable(settings ?? UpdateCheckSettings.DefaultStartupSettings);
 }
 protected void ShowVersionPopup(Version currentVersion, IEnumerable <IAppVersion> appVersions, UpdateCheckSettings updateCheckSettings)
 {
     Scheduler.Dispatcher.Schedule(() =>
     {
         UpdatePopupTool.ShowPopup(currentVersion, appVersions, updateCheckSettings, DoUpdate);
     });
 }
 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 NavigateToUpdatePage(Version currentVersion, IEnumerable<IAppVersion> appVersions, UpdateCheckSettings updateCheckSettings)
 {
     var rootFrame = Window.Current.Content as Frame;
     dynamic parms = new DynamicNavigationParameters();
     parms.currentVersion = currentVersion;
     parms.appVersions = appVersions;
     parms.updateCheckSettings = updateCheckSettings;
     
     rootFrame.Navigate(typeof(UpdatePage), parms);
 }
 /// <summary>
 /// Call this method during startup of your app to check for Updates.
 /// </summary>
 /// <param name="this"></param>
 /// <param name="updateSettings">Settings to define context for Update checking. </param>
 /// <returns></returns>
 public static async Task CheckForAppUpdateAsync(this IHockeyClient @this, UpdateCheckSettings updateSettings = null)
 {
     HockeyClient.Current.AsInternal().CheckForInitialization();
     await UpdateManager.Current.RunUpdateCheckAsync(updateSettings).ConfigureAwait(false);
 }
 /// <summary>
 /// Check for an update on the server
 /// HockecCient needs to be configured before calling this method (normally done by configuring a crahshandler in the App() constructor)
 /// </summary>
 /// <param name="settings">[optional] custom settings</param>
 internal async Task RunUpdateCheckAsync(UpdateCheckSettings settings = null)
 {
     await UpdateVersionIfAvailable(settings ?? UpdateCheckSettings.DefaultStartupSettings);
 }
 /// <summary>
 /// Check for available updates
 /// </summary>
 /// <param name="this"></param>
 /// <param name="settings"><see cref="UpdateCheckSettings"/></param>
 public static void CheckForUpdates(this IHockeyClient @this, UpdateCheckSettings settings = null)
 {
     @this.AsInternal().CheckForInitialization();
     UpdateManager.Instance.RunUpdateCheck(settings);
 }
Exemple #13
0
        protected async void ShowUpdateNotification(Version currentVersion, IEnumerable <IAppVersion> appVersions, UpdateCheckSettings updateCheckSettings)
        {
            var dialog = new MessageDialog(LocalizedStrings.LocalizedResources.UpdateAvailable, LocalizedStrings.LocalizedResources.UpdateNotification);

            dialog.Commands.Add(new UICommand(LocalizedStrings.LocalizedResources.Show, null, true));
            dialog.Commands.Add(new UICommand(LocalizedStrings.LocalizedResources.Dismiss, null, false));

            await CoreWindow.GetForCurrentThread().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => {
                var result = await dialog.ShowAsync();
                if ((bool)result.Id)
                {
                    NavigateToUpdatePage(currentVersion, appVersions, updateCheckSettings);
                }
            });
        }
Exemple #14
0
        internal void NavigateToUpdatePage(Version currentVersion, IEnumerable <IAppVersion> appVersions, UpdateCheckSettings updateCheckSettings)
        {
            var     rootFrame = Window.Current.Content as Frame;
            dynamic parms     = new DynamicNavigationParameters();

            parms.currentVersion      = currentVersion;
            parms.appVersions         = appVersions;
            parms.updateCheckSettings = updateCheckSettings;

            rootFrame.Navigate(typeof(UpdatePage), parms);
        }
 /// <summary>
 /// Check for an update on the server
 /// HockecCient needs to be configured before calling this method (normally done by configuring a crahshandler in the App() constructor)
 /// </summary>
 /// <param name="settings">[optional] custom settings</param>
 public void RunUpdateCheck(UpdateCheckSettings settings = null)
 {
     UpdateVersionIfAvailable(settings ?? UpdateCheckSettings.DefaultStartupSettings);
 }
        protected async void ShowUpdateNotification(Version currentVersion, IEnumerable<IAppVersion> appVersions, UpdateCheckSettings updateCheckSettings)
        {
            var dialog = new MessageDialog(LocalizedStrings.LocalizedResources.UpdateAvailable, LocalizedStrings.LocalizedResources.UpdateNotification);

            dialog.Commands.Add(new UICommand(LocalizedStrings.LocalizedResources.Show, null, true));
            dialog.Commands.Add(new UICommand(LocalizedStrings.LocalizedResources.Dismiss, null, false));

            await CoreWindow.GetForCurrentThread().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => {
                var result = await dialog.ShowAsync();
                if ((bool)result.Id)
                {
                    NavigateToUpdatePage(currentVersion, appVersions, updateCheckSettings);
                }
            });
        }
 public static void RunUpdateCheck(string identifier, UpdateCheckSettings settings = null)
 {
     Instance.UpdateVersionIfAvailable(settings ?? UpdateCheckSettings.DefaultStartupSettings);
 }
Exemple #18
0
 /// <summary>
 /// Call this method during startup of your app to check for Updates.
 /// </summary>
 /// <param name="this"></param>
 /// <param name="updateSettings">Settings to define context for Update checking. </param>
 /// <returns></returns>
 public static async Task CheckForAppUpdateAsync(this IHockeyClient @this, UpdateCheckSettings updateSettings = null)
 {
     HockeyClient.Current.AsInternal().CheckForInitialization();
     await UpdateManager.Current.RunUpdateCheckAsync(updateSettings).ConfigureAwait(false);
 }
 protected void ShowUpdateNotification(Version currentVersion, IEnumerable <IAppVersion> appVersions, UpdateCheckSettings updateCheckSettings)
 {
     Scheduler.Dispatcher.Schedule(() =>
     {
         NotificationTool.Show(
             LocalizedStrings.LocalizedResources.UpdateNotification,
             LocalizedStrings.LocalizedResources.UpdateAvailable,
             new NotificationAction(LocalizedStrings.LocalizedResources.Show, (Action)(() =>
         {
             ShowVersionPopup(currentVersion, appVersions, updateCheckSettings);
         })),
             new NotificationAction(LocalizedStrings.LocalizedResources.Dismiss, (Action)(() =>
         {
             //DO nothing
         }))
             );
     });
 }
 /// <summary>
 /// Check for an update on the server
 /// HockecCient needs to be configured before calling this method (normally done by configuring a crahshandler in the App() constructor)
 /// </summary>
 /// <param name="settings">[optional] custom settings</param>
 public void RunUpdateCheck(UpdateCheckSettings settings = null)
 {
     UpdateVersionIfAvailable(settings ?? UpdateCheckSettings.DefaultStartupSettings);
 }
 /// <summary>
 /// Check for available updates
 /// </summary>
 /// <param name="this"></param>
 /// <param name="settings"><see cref="UpdateCheckSettings"/></param>
 public static void CheckForUpdates(this IHockeyClient @this, UpdateCheckSettings settings = null)
 {
     @this.AsInternal().CheckForInitialization();
     UpdateManager.Instance.RunUpdateCheck(settings);
 }
Exemple #22
0
 /// <summary>
 /// Check for an update on the server
 /// HockecCient needs to be configured before calling this method (normally done by configuring a crahshandler in the App() constructor)
 /// </summary>
 /// <param name="settings">[optional] custom settings</param>
 internal async Task RunUpdateCheckAsync(UpdateCheckSettings settings = null)
 {
     await UpdateVersionIfAvailable(settings ?? UpdateCheckSettings.DefaultStartupSettings);
 }