Пример #1
0
        public void End()
        {
            string strLog = string.Format("End crawler {1} {0}", _session, _typeEnd);

            if (EventReportRun != null)
            {
                EventReportRun(strLog);
            }
            _log.Info(strLog);
            UpdateEndCrawl(new CrawlerSessionLog()
            {
                CompanyId    = _companyId,
                Domain       = _company.Domain,
                StartAt      = _timeStart,
                EndAt        = DateTime.Now,
                CountVisited = _countVisited,
                Ip           = Dns.GetHostName(),
                Session      = _session,
                TypeRun      = "AUTO",
                TypeCrawler  = 1,
                CountChange  = _countChange,
                TotalProduct = _company.TotalProduct,
                CountProduct = _countProduct,
                TypeEnd      = _typeEnd.ToString()
            });

            _cacheWaitCrawler.SetNexReload(_companyId, _config.MinHourReload);
            _cacheWaitCrawler.SetRemoveRunningCrawler(_companyId);

            TokenSource.Cancel();
        }
Пример #2
0
        public void End()
        {
            string strLog = string.Format("End crawler {0}", _typeEnd);

            if (EventReportRun != null)
            {
                EventReportRun(strLog);
            }
            _log.Info(strLog);


            this.UpdateEndCrawl(new CrawlerSessionLog()
            {
                CompanyId              = _companyId,
                Domain                 = _company.Domain,
                StartAt                = _timeStart,
                EndAt                  = DateTime.Now,
                CountVisited           = _countVisited,
                Ip                     = Dns.GetHostName(),
                Session                = _session,
                TypeRun                = "AUTO",
                TypeCrawler            = 0,
                CountChange            = _countNewProduct,
                TotalProduct           = _company.TotalProduct,
                CountProduct           = 0,
                TypeEnd                = _typeEnd.ToString(),
                NumberDuplicateProduct = _hsDuplicateProduct.Count
            });

            if (_typeEnd != TypeEnd.Success)
            {
                SaveChange();
            }
            else
            {
                var queueTableAdapter = new QueueTableAdapter();
                queueTableAdapter.Connection.ConnectionString = ConfigCrawler.ConnectionCrawlerQueue;
                queueTableAdapter.DeleteByCompanyId(_companyId);
                queueTableAdapter.Connection.Close();
                _cacheCrcVisited.RemoveCrcVited(_companyId);
            }
            _cacheWaitCrawler.SetRemoveRunningCrawler(_companyId);
            _cacheWaitCrawler.SetNexFindNew(_companyId, 1);

            _tokenSource.Cancel();
        }