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