public void Start() { _log.InfoFormat("Run with {0} worker", _numberThread); if (_typeRun == 0) { for (var i = 0; i < _numberThread; i++) { var indexThread = i; Task.Factory.StartNew(() => { WorkerFindNew worker = new WorkerFindNew(indexThread, _cancellTokenSource.Token, "", true); worker._eventGetCompanyCrawler += GetCompanyId; worker.Start(); }); } } else { for (var i = 0; i < this._numberThread; i++) { var indexThread = i; Task.Factory.StartNew(() => { WorkerReload worker = new WorkerReload(indexThread, _cancellTokenSource.Token, "", true); worker.EventGetCompanyCrawler += GetCompanyId; worker.Start(); }); } } }
public void WorkerReloadTest1() { Server.ConnectionString = ConfigCrawler.ConnectProduct; Server.ConnectionStringCrawler = ConfigCrawler.ConnectionCrawler; Server.LogConnectionString = ConfigCrawler.ConnectLog; WorkerReload w = new WorkerReload(8486364876483618144, ""); w.StartCrawler(); }
public void TestReload() { QT.Entities.Server.ConnectionString = ConfigCrawler.ConnectProduct; var cancellationTokenSource = new CancellationTokenSource(); long companyId = 1793534743671200240; var worker = new WorkerReload(companyId, cancellationTokenSource.Token, ""); worker.StartCrawler(); Assert.AreEqual(1, 1); }
public void WorkerReload_CrawlerTest() { Server.ConnectionString = ConfigCrawler.ConnectProduct; Server.LogConnectionString = ConfigCrawler.ConnectLog; Server.ConnectionStringCrawler = ConfigCrawler.ConnectionCrawler; var companyId = 7627466712688617332; var token = new CancellationToken(); var wokerFn = new WorkerReload(companyId, token, ""); wokerFn.StartCrawler(); Assert.AreEqual(1, 1); }
private void StartReload(int numberThread = 1, bool CheckOtherRunning = false) { for (int i = 0; i < numberThread; i++) { int iThread = i; Task.Factory.StartNew(() => { WorkerReload worker = new WorkerReload(iThread, tokenSource.Token, Guid.NewGuid().ToString(), CheckOtherRunning); worker.EventShowLog += new DelegateShowLog(ShowLogEvent); worker.EventGetCompanyCrawler += new DelegateGetCompanyCrawler(GetCompanyCrawler); worker.Start(); }); } }
public void Start(bool bFN, List <string> linkStatic = null) { Company company = new Company(_companyId); if (bFN) { this.Text = @"FN:" + company.Domain; var token = _cancellationTokenSource.Token; Task.Factory.StartNew(() => { WorkerFindNew worker = new WorkerFindNew(_companyId, ""); worker.EventReportRun += (data) => { this.Invoke(new Action(() => { txtReport.AppendText("\r\n" + data); })); }; worker.StartCrawler(linkStatic); }, token); } else { this.Text = @"RL:" + company.Domain; var token = _cancellationTokenSource.Token; Task.Factory.StartNew(() => { WorkerReload worker = new WorkerReload(_companyId, ""); worker.EventReportRun += (data) => { this.Invoke(new Action(() => { txtReport.AppendText("\r\n" + data); })); }; worker.StartCrawler(); }, token); } }
public override void ProcessMessage(RabbitMQ.Client.Events.BasicDeliverEventArgs message) { DateTime dtFrom = DateTime.Now; string mss = Encoding.UTF8.GetString(message.Body); try { JobCompanyCrawler jobCompanyCrawler = JobCompanyCrawler.ParseFromJson(mss); if (jobCompanyCrawler != null) { var fn = new WorkerReload(jobCompanyCrawler.CompanyId, ""); fn.StartCrawler(); } } catch (Exception ex) { _log.Error(ex); } int minuteRun = (int)(DateTime.Now - dtFrom).TotalMinutes; _log.Info(string.Format("Process {0} in {1}", mss, minuteRun)); this.GetChannel().BasicAck(message.DeliveryTag, false); }