Esempio n. 1
0
        public void GetAllProductHashTest1()
        {
            Server.ConnectionString = @"Data Source=42.112.28.93;Initial Catalog=QT_2;Persist Security Info=True;User ID=wss_price;Password=HzlRt4$$axzG-*UlpuL2gYDu;connection timeout=200";
            ProductAdapter   pa = new ProductAdapter(new SqlDb(Server.ConnectionString));
            CacheProductHash cacheProductHash = CacheProductHash.Instance();
            List <long>      lst = new List <long>();
            List <long>      x   = pa.GetAllProductIDsByCompany(3722972174058063651).ToList();
            var products         = cacheProductHash.GetAllProductHash(3722972174058063651, x);

            Assert.Greater(products.Count, 0);
        }
Esempio n. 2
0
        private void LoadQueue()
        {
            lock (_objLockLoadQueue)
            {
                var lstProducts = _redisProductLastUpdate.GetTopLastUpdate(_companyId, _timeStart, NumberItemInOneLoop);
                _redisProductLastUpdate.UpdateBathLastUpdateProduct(_companyId, lstProducts, DateTime.Now);

                foreach (var row in _redisProductHash.GetAllProductHash(_companyId, lstProducts))
                {
                    if (!_dicCacheProduct.ContainsKey(row.Id))
                    {
                        _dicCacheProduct.Add(row.Id, new ProductCache()
                        {
                            detail_url  = row.url,
                            fail        = 0,
                            hash_change = row.HashChange,
                            hash_image  = row.HashImage,
                            id          = row.Id,
                            igone       = 0,
                            last_change = DateTime.Now,
                            price       = row.Price
                        });
                    }

                    if (!_dicDuplicate.ContainsKey(row.HashDuplicate))
                    {
                        _dicDuplicate.Add(row.HashDuplicate, row.Id);

                        _linksQueue.Enqueue(new NSCrawler.Job()
                        {
                            ProductId = row.Id,
                            deep      = 0,
                            url       = row.url
                        });
                    }
                    else
                    {
                        _productIdWaitDeleteGroup.Add(row.Id);
                        _log.Info(string.Format("Duplicate product id {0} in db", row.Id));
                    }
                }

                foreach (var variable in _redisDesHash.GetAllProductHash(_companyId, lstProducts))
                {
                    if (!_dicHashDesc.ContainsKey(variable.Key))
                    {
                        _dicHashDesc.Add(variable.Key, variable.Value);
                    }
                }
            }
        }
Esempio n. 3
0
        private void LoadCrcOldProduct()
        {
            _crcProductOldGroup.Clear();
            var lst = _cacheLastUpdateProduct.GetAllProduct(_companyId);

            foreach (var item in _cacheProductHash.GetAllProductHash(_companyId, lst))
            {
                if (!_crcProductOldGroup.Contains(item.Id))
                {
                    _crcProductOldGroup.Add(item.Id);
                }
                if (!_dicDuplicate.ContainsKey(item.HashDuplicate))
                {
                    _dicDuplicate.Add(item.HashDuplicate, item.Id);
                }
            }
        }
Esempio n. 4
0
        private void LoadQueue()
        {
            var lstProducts = _redisLastCrl.GetTopLastUpdate(_companyId, _timeStart, LimitProductsPerReload);

            _redisLastCrl.UpdateBathLastUpdateProduct(_companyId, lstProducts, DateTime.Now);
            foreach (var row in _cacheProductHash.GetAllProductHash(_companyId, lstProducts))
            {
                if (!_dicCacheProduct.ContainsKey(row.Id))
                {
                    _dicCacheProduct.Add(row.Id, row);
                }
                if (!_dicDuplicate.ContainsKey(row.HashDuplicate))
                {
                    _dicDuplicate.Add(row.HashDuplicate, row.Id);
                    _linksQueue.Enqueue(new Job()
                    {
                        ProductId = row.Id,
                        deep      = 0,
                        url       = row.url
                    });
                }
                else
                {
                    _log.Info(string.Format(@"Push duplicate product: {0}", row.Id));
                    PushChangeProduct(new ProductEntity()
                    {
                        ID           = row.Id,
                        CompanyId    = _companyId,
                        Session      = _session,
                        DetailUrl    = row.url,
                        LastUpdate   = DateTime.Now,
                        StatusChange = new ProductStatusChange()
                        {
                            IsDuplicate = true
                        }
                    });
                }
            }
            foreach (var variable in _cacheDesHash.GetAllProductHash(_companyId, lstProducts))
            {
                if (!_dicHashDesc.ContainsKey(variable.Key))
                {
                    _dicHashDesc.Add(variable.Key, variable.Value);
                }
            }
        }
Esempio n. 5
0
        private void LoadOldData()
        {
            _crcProductOldGroup.Clear();
            var lst = _redisLastUpdateProduct.GetAllProduct(_companyId);

            foreach (var item in _cacheProductHash.GetAllProductHash(this._companyId, lst))
            {
                if (!_crcProductOldGroup.ContainsKey(item.Id))
                {
                    _crcProductOldGroup.Add(item.Id, true);
                }
                if (!_hsHashDuplicate.ContainsKey(item.HashDuplicate))
                {
                    _hsHashDuplicate.Add(item.HashDuplicate, item.Id);
                }
            }
            LoadVisitedCRC();
            LoadOldQueue();
        }
Esempio n. 6
0
 public void GetAllProductHashTest()
 {
     CacheProductHash cacheProductHash = CacheProductHash.Instance();
     var products = cacheProductHash.GetAllProductHash(2365377961928198678);
 }