Exemplo n.º 1
0
 public Magpie(AppInfo appInfo, IDebuggingInfoLogger debuggingInfoLogger = null,
               IAnalyticsLogger analyticsLogger = null)
 {
     AppInfo                 = appInfo;
     _logger                 = debuggingInfoLogger ?? new DebuggingWindowViewModel();
     _analyticsLogger        = analyticsLogger ?? new AnalyticsLogger();
     RemoteContentDownloader = new DefaultRemoteContentDownloader();
     UpdateDecider           = new UpdateDecider(_logger);
     BestChannelFinder       = new BestChannelFinder(_logger);
 }
Exemplo n.º 2
0
        private async Task Check(string appcastUrl, CheckState checkState, int channelId = 1, bool showDebuggingWindow = false)
        {
            _logger.Log(string.Format("Starting fetching remote channel content from address: {0}", appcastUrl));
            try
            {
                var data = await RemoteContentDownloader.DownloadStringContent(appcastUrl, _logger).ConfigureAwait(true);

                if (string.IsNullOrWhiteSpace(data))
                {
                    if (checkState == CheckState.Force || checkState == CheckState.ChannelSwitch)
                    {
                        ShowErrorWindow();
                    }
                    return;
                }

                var appcast = ParseAppcast(data);

                if (checkState == CheckState.ChannelSwitch && FailedToEnroll(appcast, channelId))
                {
                    return;
                }

                var channelToUpdateFrom = BestChannelFinder.Find(channelId, appcast.Channels);

                if (UpdateDecider.ShouldUpdate(channelToUpdateFrom, checkState == CheckState.Force || checkState == CheckState.ChannelSwitch))
                {
                    _analyticsLogger.LogUpdateAvailable(channelToUpdateFrom);
                    await ShowUpdateWindow(channelToUpdateFrom);
                }
                else if (checkState == CheckState.Force)
                {
                    ShowNoUpdatesWindow();
                }
                AppInfo.SubscribedChannel = channelId;
            }
            catch (Exception ex)
            {
                _logger.Log(string.Format("Error parsing remote channel: {0}", ex.Message));
            }
            finally
            {
                _logger.Log("Finished fetching remote channel content");
            }
        }
Exemplo n.º 3
0
        private async Task Check(string appcastUrl, int channelId = 1, bool showDebuggingWindow = false,
                                 bool forceCheck = false)
        {
            _logger.Log(string.Format("Starting fetching remote channel content from address: {0}", appcastUrl));
            try
            {
                var data = await RemoteContentDownloader.DownloadStringContent(appcastUrl, _logger).ConfigureAwait(true);

                if (string.IsNullOrWhiteSpace(data))
                {
                    if (forceCheck)
                    {
                        ShowErrorWindow();
                    }
                    return;
                }

                var appcast = ParseAppcast(data);
                OnRemoteAppcastAvailableEvent(new SingleEventArgs <RemoteAppcast>(appcast));
                var channelToUpdateFrom = BestChannelFinder.Find(channelId, appcast.Channels);
                if (UpdateDecider.ShouldUpdate(channelToUpdateFrom, forceCheck))
                {
                    _analyticsLogger.LogUpdateAvailable(channelToUpdateFrom);
                    await ShowUpdateWindow(channelToUpdateFrom);
                }
                else if (forceCheck)
                {
                    ShowNoUpdatesWindow();
                }
            }
            catch (Exception ex)
            {
                _logger.Log(string.Format("Error parsing remote channel: {0}", ex.Message));
            }
            finally
            {
                _logger.Log("Finished fetching remote channel content");
            }
        }