public void Dispose() { if (_producerDuplicateProduct != null) { _producerDuplicateProduct.Dispose(); } if (_producerEndCrawler != null) { _producerEndCrawler.Dispose(); } if (_producerProductChange != null) { _producerProductChange.Dispose(); } if (_producerReportError != null) { _producerReportError.Dispose(); } if (_producerReportSessionRunning != null) { _producerReportSessionRunning.Dispose(); } if (_producerProductChange != null) { _producerProductChange.Dispose(); } }
private void RunReportRunning() { var tokenReport = _tokenSource.Token; Task.Factory.StartNew(() => { ProducerBasic producerReportSessionRunning = null; try { producerReportSessionRunning = new ProducerBasic(RabbitMQManager.GetRabbitMQServer(ConfigCrawler.KeyRabbitMqCrawler), ConfigCrawler.ExchangeSessionRunning, ConfigCrawler.RoutingkeySessionRunning); while (true) { string mss = Newtonsoft.Json.JsonConvert.SerializeObject(new ReportSessionRunning() { Thread = _nameThread, CompanyId = _companyId, Ip = Dns.GetHostName(), Session = _session, StartAt = _timeStart, Type = "FindNew", MachineCode = Server.MachineCode }); _log.Info(string.Format("Running Findnew {0} {1} {2}'", this._companyId, (this._company != null) ? this._company.Domain : "", (DateTime.Now - this._timeStart).Minutes)); tokenReport.ThrowIfCancellationRequested(); producerReportSessionRunning.PublishString(mss, true, 300); Thread.Sleep(20000); } } catch (OperationCanceledException ex) { _log.Info("End thread report running"); if (producerReportSessionRunning != null) { producerReportSessionRunning.Dispose(); } return; } catch (Exception ex) { // ignored } }, tokenReport); }
private void RunReportRunning() { var tokenReportSession = TokenSource.Token; Task.Factory.StartNew(() => { ProducerBasic producerReportSessionRunning = null; try { producerReportSessionRunning = new ProducerBasic(RabbitMQManager.GetRabbitMQServer(ConfigCrawler.KeyRabbitMqCrawler), ConfigCrawler.ExchangeSessionRunning, ConfigCrawler.RoutingkeySessionRunning); while (true) { tokenReportSession.ThrowIfCancellationRequested(); var mss = new ReportSessionRunning() { Thread = _nameThread, CompanyId = _companyId, Ip = Dns.GetHostName(), Session = _session, StartAt = _timeStart, Type = "Reload", MachineCode = Server.MachineCode }; producerReportSessionRunning.PublishString(Newtonsoft.Json.JsonConvert.SerializeObject(mss), true, 300); _log.Info(string.Format("Running Reload {0} {1} {2}'", this._companyId, (this._company != null) ? this._company.Domain : "", (DateTime.Now - this._timeStart).Minutes)); Thread.Sleep(60000); } } catch (OperationCanceledException ex) { _log.Info(string.Format("Stop reporting session:{0}", _session)); if (producerReportSessionRunning != null) { producerReportSessionRunning.Dispose(); } return; } catch (Exception ex01) { _producerReportError.PublishString(Newtonsoft.Json.JsonConvert.SerializeObject(new ErrorCrawler() { CompanyId = _companyId, ProductId = 0, TimeError = DateTime.Now, Message = ex01.Message + "\n" + ex01.StackTrace, Url = "" }), true, 0); } }, tokenReportSession); }
public void Dispose() { if (_producerReportError != null) { _producerReportError.Dispose(); } if (_producerProductChange != null) { _producerProductChange.Dispose(); } if (_producerPushCompanyReload != null) { _producerPushCompanyReload.Dispose(); } if (_producerDuplicateProduct != null) { _producerDuplicateProduct.Dispose(); } if (_producerEndCrawler != null) { _producerEndCrawler.Dispose(); } }