public void AddLog(LogEntry entry) { _logs.Add(entry); if (_logs.Count > 10000) { TemporarySafe(); } }
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); } }
private async Task TestFeedEvaluationSourceTask(ConcurrentStack<SourceModel> sources, Logger logger) { var assertHelper = new AssertHelper(); SourceModel source; while (sources.TryPop(out source)) { var sourceLogEntry = new LogEntry() { Content = "Testing " + source.Name }; var feeds = new ConcurrentStack<FeedModel>(source.Feeds); var tasks = new List<Task>(); for (int i = 0; i < _maxThreads; i++) { tasks.Add(TestFeedEvaluationFeedTask(feeds, source, sourceLogEntry, assertHelper)); } await Task.WhenAll(tasks); assertHelper.NotAlwaysDefinedPropertiesCheckOut(source.Source); logger.AddLog(sourceLogEntry); } }