using System.Linq; using System.Threading.Tasks; using System.Collections.Generic; using Classes; using Database; using Aggregator; namespace Main.Jobs { public static class AggregatorJob { private static List configs = new List { new Config { Source = "BBC", Title = 0, Description = 1, ArticleLink = 2, ImageLink = 5, PublishDate = 4 }, new Config { Source = "Sky", Title = 0, Description = 2, ArticleLink = 1, ImageLink = 7, PublishDate = 3 }, new Config { Source = "ABC", Title = 7, Description = 11, ArticleLink = 8, ImageLink = 0, PublishDate = 10 } }; private static List sites = new List { "http://feeds.bbci.co.uk/news/rss.xml", "http://feeds.skynews.com/feeds/rss/world.xml", "https://abcnews.go.com/abcnews/topstories" }; public static async Task Process(DatabaseContext context) { var articles = await parseMultiple(); await context.InsertArticles(articles); } private static async Task> parseMultiple() { var xmls = new List(); foreach (string site in sites) { xmls.Add(await Download.DownloadXML(site)); } return ParserService.ParseMultiple(xmls.ToArray(), configs).ToList(); } } }