Esempio n. 1
0
        private void InitSession()
        {
            _countVisited       = 0;
            _totalProductBefore = 0;
            _countLink          = 0;
            _countChange        = 0;

            _session = Guid.NewGuid().ToString();
            _tokenCrawler.ThrowIfCancellationRequested();
            if (!_productAdapter.AllowCrawlFindNew(_companyId))
            {
                return;
            }
            _company          = new QT.Entities.Company(this._companyId);
            _config           = new Configuration(_companyId, true);
            _visitRegexs      = _config.VisitUrlsRegex;
            _detailLinkRegexs = _config.ProductUrlsRegex;

            _extraRegexNoVisitFn = _productAdapter.GetEtraRegexByTypeWeb(_companyId);
            _noCrawlerRegexs     = _config.NoVisitUrlRegex;
            _noCrawlerRegexs.AddRange(Common.noCrawlerRegexDefault);
            _noCrawlerRegexs.AddRange(_extraRegexNoVisitFn);

            string rootUrl = _company.Website;

            _urlCurrent  = "";
            startCrawler = DateTime.Now;
            _linkQueue.Clear();
            _visitedCrc.Clear();
            _rootUri = Common.GetUriFromUrl(_company.Website);
            ClearOldCache();
            _linkQueue.Enqueue(_company.Website);
            LoadOldData();
            _totalProduct = _crcProductOldGroup.Count;
        }