Ejemplo n.º 1
0
        private async Task CheckForUpdates()
        {
            if (Configuration?.General?.CheckForUpdates == true)
            {
                bool useBetaChannel = Configuration?.General?.IncludePrereleaseUpdates == true;

                LogTo.Info("Searching for app updates...");
                LogTo.Info($"Using beta channel for updates: {useBetaChannel}");

                try
                {
                    using (var mgr = await UpdateFactory.Construct(useBetaChannel))
                    {
                        var release = await mgr.UpdateApp();

                        Version newVersion = release?.Version?.Version;

                        if (newVersion == null)
                        {
                            LogTo.Warn("UpdateApp returned null");
                        }
                        else if (newVersion > Assembly.GetExecutingAssembly().GetName().Version)
                        {
                            LogTo.Info($"Updated app to {release.Version}");
                            Notifier.DisplayMessage(string.Format(Strings.UpdateHasBeenInstalled, release.Version),
                                                    NotificationType.Information | NotificationType.Restart);
                        }
                        else
                        {
                            LogTo.Info("App is up to date");
                        }
                    }
                }
                catch (Exception ex) when(ex.Message.Contains("Update.exe"))
                {
                }
                catch (Exception ex)
                {
                    LogTo.WarnException("Error during update check", ex);
                }
            }
        }
Ejemplo n.º 2
0
        public async Task OnLoad(object data)
        {
            if (!HasContexts)
            {
                var csa = new ConfirmServiceArgs(Strings.DoYouWantToAddANewAccount, Strings.NoAccountAdded);

                if (await ViewServiceRepository.Confirm(csa))
                {
                    await ViewServiceRepository.ShowAccounts(true);
                }
            }

            await CheckCredentials();

            var loadTasks = Columns.Select(c => c.Load());
            await Task.WhenAll(loadTasks);

            try
            {
                await TwitterConfig.QueryConfig();
            }
            catch (Exception ex)
            {
                LogTo.WarnException("Failed to read current config from twitter", ex);
            }

            if (Configuration?.General?.CheckForUpdates == true)
            {
                bool useBetaChannel = Configuration?.General?.IncludePrereleaseUpdates == true;

                var channelUrl = useBetaChannel
                                        ? Constants.Updates.BetaChannelUrl
                                        : Constants.Updates.ReleaseChannelUrl;

                LogTo.Info("Searching for app updates...");
                LogTo.Info($"Using beta channel for updates: {useBetaChannel}");

                try
                {
                    using (var mgr = UpdateFactory.Construct(channelUrl))
                    {
                        var release = await mgr.UpdateApp();

                        Version newVersion = release?.Version?.Version;

                        if (newVersion == null)
                        {
                            LogTo.Warn("UpdateApp returned null");
                        }
                        else if (newVersion > Assembly.GetExecutingAssembly().GetName().Version)
                        {
                            LogTo.Info($"Updated app to {release.Version}");
                            Notifier.DisplayMessage(string.Format(Strings.UpdateHasBeenInstalled, release.Version),
                                                    NotificationType.Information);
                        }
                        else
                        {
                            LogTo.Info("App is up to date");
                        }
                    }
                }
                catch (Exception ex) when(ex.Message.Contains("Update.exe"))
                {
                }
                catch (Exception ex)
                {
                    LogTo.WarnException("Error during update check", ex);
                }
            }

            await QueryRateLimit();
        }