public async Task RegisterAsync(DownloaderAgent agent) { using (var conn = new MySqlConnection(_options.ConnectionString)) { await conn.ExecuteAsync( $"INSERT IGNORE INTO dotnetspider.downloader_agent (id, `name`, processor_count, total_memory, creation_time, last_modification_time) VALUES (@Id, @Name, @ProcessorCount, @TotalMemory, @CreationTime, @LastModificationTime);", agent); } }
public Task RegisterAsync(DownloaderAgent agent) { _agents.AddOrUpdate(agent.Id, x => agent, (s, a) => { a.CreationTime = DateTime.Now; a.LastModificationTime = DateTime.Now; return(a); }); return(Task.CompletedTask); }
public Task RegisterAsync(DownloaderAgent agent) { _agents.AddOrUpdate(agent.Id, x => agent, (s, a) => { a.LastModificationTime = DateTime.Now; return(a); }); #if NETFRAMEWORK return(DotnetSpider.Core.Framework.CompletedTask); #else return(Task.CompletedTask); #endif }
void IDisposable.Dispose() { Instnce = null; Agent = null; // clearing events OnDownloadAllComplete = null; OnDownloadFileAdded = null; OnDownloadFileComplete = null; OnDownloadFileProgress = null; OnDownloadFileStarted = null; OnDownloadPause = null; OnDownloadResume = null; OnDownloadStop = null; }
/// <summary> /// Set up new downloder object /// </summary> public Downloader(string downloadsFolder = null) { if (downloadsFolder == null) { DownloadsPath = DownloaderOptions.DownloadsPath; } else { DownloadsPath = downloadsFolder; } Instnce = this; Agent = new DownloaderAgent(this); Console.WriteLine("New Devhus.Downloader is created"); }
public Task RegisterAsync(DownloaderAgent agent) { agent.LastModificationTime = DateTime.Now; _agents.TryAdd(agent.Id, agent); return(Task.CompletedTask); }
public static bool IsActive(this DownloaderAgent agent) { return((DateTime.Now - agent.LastModificationTime).TotalSeconds <= 12); }