Esempio n. 1
0
	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 );
	}
Esempio n. 2
0
	public void SendScrapeAdded(Scrape scrape)
	{
	    var json = JsonConvert.SerializeObject(scrape);
	    Clients.All.broadcastScrapeAdded(json);
	}
Esempio n. 3
0
	public void Add(Scrape scrape)
	{
	    var collection = _database.GetCollection<Scrape>("scrapes");
	    collection.InsertOne(scrape);
	}
Esempio n. 4
0
	public void Update(Scrape newScrape)
	{
	    var collection = _database.GetCollection<Scrape>("scrapes");
	    collection.ReplaceOne(s => string.Equals(s.Id, newScrape.Id), newScrape);
	}
Esempio n. 5
0
	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);
	}