Ejemplo n.º 1
0
        public static bool InsertRootProductMappingCacheWithBlackList(long productID, string searchEnginesServiceUrl, TimeSpan?expiry = null)
        {
            var client   = new ProtoBufServiceStackClient(searchEnginesServiceUrl);
            var response = client.Send <GetRootProductMappingResponse>(new GetRootProductMappingRequest {
                ProductID = productID, RegionID = 0, IncludeBlackList = true, GetFacet = false, SortType = RootProductMappingSortType.PriceWithVAT
            });

            if (response.RootProductMapping != null)
            {
                RootProductMappingBAL.InsertRootProductMappingIntoCache(response.RootProductMapping, 0, RootProductMappingSortType.PriceWithVAT, true, expiry);
                return(true);
            }
            else
            {
                Log.ErrorFormat("InsertRootProductMappingWithBlackListIntoCache failed - ProductID {0}", productID);
                return(false);
            }
        }
Ejemplo n.º 2
0
        public static bool InsertRootProductMappingCache(long productID, string searchEnginesServiceUrl, TimeSpan?expiry = null)
        {
            var client   = new ProtoBufServiceStackClient(searchEnginesServiceUrl);
            var response = client.Send <GetRootProductMappingResponse>(new GetRootProductMappingRequest {
                ProductID = productID, RegionID = 0, IncludeBlackList = false, GetFacet = true, SortType = RootProductMappingSortType.PriceWithVAT
            });

            if (response.RootProductMapping != null)
            {
                if (response.RootProductMapping.NumMerchant > 0)
                {
                    RedisPriceLogAdapter.PushRootProductPrice(productID, response.RootProductMapping.MinPrice, response.RootProductMapping.MaxPrice, response.RootProductMapping.MeanPrice, DateTime.Now.Date);
                }
                RootProductMappingBAL.InsertRootProductMappingIntoCache(response.RootProductMapping, 0, RootProductMappingSortType.PriceWithVAT, false, expiry);
                return(true);
            }
            else
            {
                Log.ErrorFormat("InsertRootProductMappingIntoCache failed - ProductID {0}", productID);
                return(false);
            }
        }
Ejemplo n.º 3
0
        public void IdentifyProducts()
        {
            if (_productID == 0)
            {
                MakeListProductUpToDate();
                return;
            }

            UpdateObjectValue();
            this.dBMap.ProductInfo.Rows.Clear();
            int  numProductFound = 0;
            long minPriceFound   = 0;
            long maxPriceFound   = 0;
            var  client          = new ProtoBufServiceStackClient(_searchEnginesServiceUrl);

            try
            {
                var response = client.Send <GetRootProductMappingResponse>(new GetRootProductMappingByProductIdentityRequest {
                    ProductIdentity = _productIdentity, RegionID = 0, IncludeBlackList = false, GetFacet = true
                });
                if (response.RootProductMapping != null)
                {
                    listProductFound = new List <long>();
                    foreach (var merchantProductIDs in response.RootProductMapping.ListMerchantProducts)
                    {
                        listProductFound.AddRange(merchantProductIDs.Value);
                    }
                    this.dBMap.ProductInfo.Clear();
                    var productIDMap             = new Dictionary <RedisKey, RedisValue>();
                    var listProductMapReverseKey =
                        listProductFound.Select(x => (RedisKey)(ProductConstants.REDIS_PREFIX_PRODUCT_MAP_REVERSE + x)).ToArray();
                    if (listProductMapReverseKey.Length > 0)
                    {
                        //try
                        //{
                        //    foreach (var item in listProductMapReverseKey)
                        //    {
                        //        bool bOK = _productMapRedisServer.Exist(item);
                        //        if (bOK == false)
                        //        {
                        //            MessageBox.Show("dfSD");
                        //        }
                        //    }
                        productIDMap = _productMapRedisServer.MGet(listProductMapReverseKey);
                        //    }
                        //    catch(Exception ex)
                        //    {
                        //        MessageBox.Show(ex.Message);
                        //    }
                    }
                    var merchantProducts = WebMerchantProductBAL.GetWebMerchantProductsFromCache(listProductFound);
                    foreach (var item in merchantProducts.Values)
                    {
                        var row = this.dBMap.ProductInfo.NewRow();//.NewRow();
                        row["Name"]    = item.Name;
                        row["Price"]   = item.Price;
                        row["ID"]      = item.ID;
                        row["Url"]     = item.DetailUrl;
                        row["Company"] = item.CompanyID;
                        var redisProductMapReverseKey = ProductConstants.REDIS_PREFIX_PRODUCT_MAP_REVERSE + item.ID;
                        if (productIDMap.ContainsKey(redisProductMapReverseKey))
                        {
                            row["RootID"] = productIDMap[redisProductMapReverseKey];
                        }
                        this.dBMap.ProductInfo.Rows.Add(row);
                    }
                    this.dBMap.ProductInfo.AcceptChanges();
                    //
                    numProductFound = response.RootProductMapping.ListMerchantProducts.Sum(x => x.Value.Count);
                    minPriceFound   = response.RootProductMapping.MinPrice;
                    maxPriceFound   = response.RootProductMapping.MaxPrice;
                }
                else
                {
                    numProductFound = 0;
                    minPriceFound   = 0;
                    maxPriceFound   = 0;
                }
            }
            catch (Exception ex)
            {
                Log.Error("ERROR client.Send<GetRootProductMappingResponse>", ex);
            }



            //XT-2015_08_07
            //this.RefreshDataChart(dBMap.ProductInfo);
            //Comment vì ko dùng đến nữa 19.11.2015

            textBoxNumFound.Text        = numProductFound.ToString();
            spinEditMinPriceFound.Value = minPriceFound;
            spinEditMaxPriceFound.Value = maxPriceFound;
            MakeListProductUpToDate();

            var adtJob = new QT.Moduls.Company.DBComTableAdapters.Job_WebsiteConfigLogTableAdapter();

            adtJob.Connection.ConnectionString = Server.ConnectionString;
            try
            {
                adtJob.Insert(QT.Users.User.UserID, _productID, richTextBoxNote.Text, textBoxNumFound.Text, QT.Users.JobNhapLieuStatus.NhanDienSanPham, DateTime.Now);
            }
            catch (Exception)
            {
            }
        }