public IActionResult AddDirectScrapePost(string inputUrl) { if(string.IsNullOrEmpty(inputUrl)) { return Content("Content is null or empty!"); } _logger.LogInformation("New direct url: " + inputUrl); Scrape scrape = new Scrape(inputUrl); DownloadManager.Go(scrape, true); return Content("Direct download enqueued for " + scrape.InputUrl + ", id=" + scrape.Id ); }
public void SendScrapeAdded(Scrape scrape) { var json = JsonConvert.SerializeObject(scrape); Clients.All.broadcastScrapeAdded(json); }
public void Add(Scrape scrape) { var collection = _database.GetCollection<Scrape>("scrapes"); collection.InsertOne(scrape); }
public void Update(Scrape newScrape) { var collection = _database.GetCollection<Scrape>("scrapes"); collection.ReplaceOne(s => string.Equals(s.Id, newScrape.Id), newScrape); }
public static void Go(Scrape scrape, bool goDirect = false) { scrape.IsScrapingInProgress = true; _scrapes.Add(scrape.Id, scrape); var json = JsonConvert.SerializeObject(scrape); _hub.Clients.All.broadcastScrapeAdded(JObject.Parse(json)); _downloader.Go(scrape.Id, scrape.InputUrl, goDirect); }