Example #1
0
 public static void AddFeed(FeedModel fm, SourceModel source, bool isActive = false)
 {
     fm.Source = source;
     if (isActive)
         fm.Source.ActiveFeeds.Add(fm);
     fm.IsActive = isActive;
 }
Example #2
0
 public static void SetSourceActiveState(SourceModel sm, bool isActive)
 {
     if (isActive && !ActiveSources.Contains(sm))
         ActiveSources.Add(sm);
     else if (!isActive && ActiveSources.Contains(sm))
         ActiveSources.Remove(sm);
     sm.IsActive = isActive;
 }
Example #3
0
 public static void AddSource(SourceModel model, bool isActive = false)
 {
     if (!AllSources.Contains(model))
         AllSources.Add(model);
     if (isActive && !ActiveSources.Contains(model))
         ActiveSources.Add(model);
     if (!isActive && ActiveSources.Contains(model))
         ActiveSources.Remove(model);
     model.IsActive = isActive;
 }
Example #4
0
        private async Task TestFeedEvaluationFeedTask(ConcurrentStack<FeedModel> feeds, SourceModel source, LogEntry sourceLogEntry, AssertHelper assertHelper, bool testArticles = false)
        {
            FeedModel feed;
            while (feeds.TryPop(out feed))
            {
                var feedLogEntry = new LogEntry()
                {
                    Content = "Testing " + feed.Name + " (" + feed.Url + ")"
                };

                var msh = ArticleHelper.GetMediaSource(source.Source, SimpleIoc.Default.GetInstance<IThemeRepository>());
                var sqs = SimpleIoc.Default.GetInstance<ISqliteService>();
                var ids = SimpleIoc.Default.GetInstance<IImageDownloadService>();
                var newArticles = await msh.EvaluateFeed(feed);
                await SaveHelper.SaveFeed(feed, newArticles, sqs, ids);

                foreach (var articleModel in newArticles)
                {
                    var articleLogEntry = new LogEntry()
                    {
                        Content = "Testing " + articleModel.Title + " (" + articleModel.LogicUri + ", " + articleModel.PublicUri + ")"
                    };
                    articleModel.Feed = feed;

                    await SaveHelper.SaveArticle(articleModel, sqs);
                    await SaveHelper.SaveArticleLeadImage(articleModel, sqs, true);
                    await SaveHelper.SaveArticleContent(articleModel, sqs, true);


                    assertHelper.TestFeedArticleProperties(articleModel, articleLogEntry);

                    if (articleModel.LoadingState != LoadingState.Loaded && !await msh.EvaluateArticle(articleModel))
                    {
                        articleLogEntry.LogEntries.Add(new LogEntry()
                        {
                            Content = "Evaluation failed!",
                            IsFaillure = true
                        });
                    }
                    else
                    {
                        articleModel.LoadingState = LoadingState.Loaded;
                        assertHelper.TestFullArticleProperties(articleModel, articleLogEntry);
                    }

                    feedLogEntry.LogEntries.Add(articleLogEntry);
                }

                sourceLogEntry.LogEntries.Add(feedLogEntry);
            }
        }
 public Task<bool> SwitchSourceActiveStateAsync(SourceModel sourceModel)
 {
     return SetSourceActiveStateAsync(sourceModel, !SourceManager.GetSourceActiveState(sourceModel));
 }
 public Task<bool> SetSourceActiveStateAsync(SourceModel sourceModel, bool isActive)
 {
     SourceManager.SetSourceActiveState(sourceModel, isActive);
     _sourceCacheEntity.IsEnabledDictionary[sourceModel.Guid] = isActive;
     return SaveCache();
 }
        public ArticleRepositoryMock()
        {
            var article = GetSampleArticle();
            var article2 = GetSampleArticle();
            var sm = new SourceModel()
            {
                Abbreviation = "NZZ",
                Guid = Guid.NewGuid(),
                Source = Sources.Nzz,
                Name = "Neue Z├╝rcher Zeitung",
                LogicBaseUrl = "http://api.nzz.ch/",
                PublicBaseUrl = "http://nzz.ch/",
                IsActive = true
            };
            var sm2 = new SourceModel()
            {
                Abbreviation = "BAZ",
                Guid = Guid.NewGuid(),
                Source = Sources.Nzz,
                Name = "Basler Zeitung",
                LogicBaseUrl = "http://api.nzz.ch/",
                PublicBaseUrl = "http://nzz.ch/",
                IsActive = false
            };
            var fm = new FeedModel()
            {
                Name = "Home",
                Guid = Guid.NewGuid(),
                Source = sm,
                Url = "home",
                AllArticles =
                {
                    article,
                    article2,
                    article
                }
            };
            var fm2 = new FeedModel()
            {
                Name = "Ausland",
                Guid = Guid.NewGuid(),
                Source = sm,
                Url = "ausland",
                AllArticles =
                {
                    article,
                    article2,
                    article
                }
            };
            sm.ActiveFeeds.Add(fm);
            sm.Feeds.Add(fm);
            sm.Feeds.Add(fm2);
            sm.Feeds.Add(fm2);

            _sources.Add(sm);
            _sources.Add(sm);
            _sources.Add(sm2);
            _sources.Add(sm2);
            _sources.Add(sm);
        }
 public async Task<bool> SwitchSourceActiveStateAsync(SourceModel sourceModel)
 {
     return true;
 }
 public async Task<bool> SetSourceActiveStateAsync(SourceModel sourceModel, bool isActive)
 {
     return true; 
 }
Example #10
0
 public static bool GetSourceActiveState(SourceModel model)
 {
     return ActiveSources.Contains(model);
 }
 private async Task SwitchSourceStatus(SourceModel fm)
 {
     await _articleRepository.SwitchSourceActiveStateAsync(fm);
 }