예제 #1
0
        private List <CseProductInfo> ParseShoppingProducts(int cse, string source, DataTable products, DataTable productMerchants)
        {
            if (products == null || products.Rows.Count == 0)
            {
                return(null);
            }

            var productsList = new List <CseProductInfo>();

            for (int i = 0; i < products.Rows.Count; i++)
            {
                var product = new CseProductInfo();

                product.ShoppingEngine = cse;
                product.Source         = source;
                product.ProductId      = products.Rows[i]["PID"] as string;
                product.CategoryId     = products.Rows[i]["categoryID"] as string;
                product.Name           = products.Rows[i]["name"] != DBNull.Value ? ((string)products.Rows[i]["name"]).ToLower() : null;
                product.DisplayName    = products.Rows[i]["name"] as string;
                product.Description    = products.Rows[i]["fullDescription"] as string;
                product.Image          = products.Rows[i]["image"] as string;

                product.Offers = new List <CseOfferInfo>();

                if (productMerchants == null || productMerchants.Rows.Count == 0)
                {
                    continue;
                }

                var rows = productMerchants.Select("PID = '" + product.ProductId + "'");

                if (rows.Length == 0)
                {
                    continue;
                }

                for (int x = 0; x < rows.Length; x++)
                {
                    var offer = new CseOfferInfo();

                    offer.Url        = rows[x]["offerUrl"] as string;
                    offer.Price      = double.Parse((string)rows[x]["basePrice"]);
                    offer.Brand      = rows[x]["brand"] != DBNull.Value ? (string)rows[x]["brand"] : null;
                    offer.Sku        = rows[x]["sku"] != DBNull.Value ? (string)rows[x]["sku"] : null;
                    offer.Model      = rows[x]["model"] != DBNull.Value ? (string)rows[x]["model"] : null;
                    offer.MerchantId = rows[x]["mid"] != DBNull.Value ? (string)rows[x]["mid"] : null;
                    offer.Cpc        = rows[x]["cpc"] != DBNull.Value ? double.Parse((string)rows[x]["cpc"]) : 0;

                    product.Offers.Add(offer);
                }

                product.Offers   = product.Offers.OrderBy(x => x.Price).ToList();
                product.MinPrice = product.Offers[0].Price;
                product.MaxPrice = product.Offers[product.Offers.Count - 1].Price;

                productsList.Add(product);
            }

            return(productsList);
        }
예제 #2
0
        private List <CseProductInfo> ParseShopZillaProducts(string source, DataTable products, DataTable productMerchants)
        {
            if (products == null || products.Rows.Count == 0)
            {
                return(null);
            }

            var productsList = new List <CseProductInfo>();

            for (int i = 0; i < products.Rows.Count; i++)
            {
                var product = new CseProductInfo();

                product.ShoppingEngine = 2;
                product.Source         = source;
                product.ProductId      = products.Rows[i]["pid"] as string;
                product.CategoryId     = products.Rows[i]["category_id"] as string;
                product.Name           = ((string)products.Rows[i]["name"]).ToLower();
                product.DisplayName    = products.Rows[i]["name"] as string;
                product.Image          = products.Rows[i]["imageURL_small"] as string;
                product.Description    = products.Rows[i]["long_Desc"] != DBNull.Value ? (string)products.Rows[i]["long_Desc"] : null;

                product.Offers = new List <CseOfferInfo>();

                if (productMerchants == null || productMerchants.Rows.Count == 0)
                {
                    continue;
                }

                var rows = productMerchants.Select("mPID = '" + product.ProductId + "'");

                if (rows.Length == 0)
                {
                    continue;
                }

                for (int x = 0; x < rows.Length; x++)
                {
                    var offer = new CseOfferInfo();

                    offer.Url        = rows[x]["URL"] as string;
                    offer.Price      = (double)rows[x]["price"];
                    offer.MerchantId = rows[x]["mid"] != DBNull.Value ? (string)rows[x]["mid"] : null;

                    product.Offers.Add(offer);
                }

                product.Offers   = product.Offers.OrderBy(x => x.Price).ToList();
                product.MinPrice = product.Offers[0].Price;
                product.MaxPrice = product.Offers[product.Offers.Count - 1].Price;

                productsList.Add(product);
            }

            return(productsList);
        }
예제 #3
0
        private List <CseProductInfo> ParseAffiliateWindowProducts(string source, DataTable products, DataTable productMerchants)
        {
            if (products == null || products.Rows.Count == 0)
            {
                return(null);
            }

            var productsList = new List <CseProductInfo>();

            for (int i = 0; i < products.Rows.Count; i++)
            {
                var product = new CseProductInfo();

                product.ShoppingEngine = 6;
                product.Source         = source;
                product.ProductId      = products.Rows[i]["pid"] as string;
                product.Name           = ((string)products.Rows[i]["name"]).ToLower();
                product.DisplayName    = products.Rows[i]["name"] as string;
                product.Image          = (string)productMerchants.Select("iId = '" + product.ProductId + "'")[0]["sAwThumbUrl"];
                product.Description    = products.Rows[i]["short_Desc"] != DBNull.Value ? (string)products.Rows[i]["short_Desc"] : null;

                product.Offers = new List <CseOfferInfo>();

                if (productMerchants == null || productMerchants.Rows.Count == 0)
                {
                    continue;
                }

                var rows = productMerchants.Select("iId = '" + product.ProductId + "'");

                if (rows.Length == 0)
                {
                    continue;
                }

                for (int x = 0; x < rows.Length; x++)
                {
                    var offer = new CseOfferInfo();

                    offer.Url        = rows[x]["sAwDeepLink"] as string;
                    offer.Price      = (double)(float)rows[x]["fPrice"];
                    offer.MerchantId = rows[x]["iMerchantId"] != DBNull.Value ? ((int)rows[x]["iMerchantId"]).ToString() : null;

                    product.Offers.Add(offer);
                }

                product.Offers   = product.Offers.OrderBy(x => x.Price).ToList();
                product.MinPrice = product.Offers[0].Price;
                product.MaxPrice = product.Offers[product.Offers.Count - 1].Price;

                productsList.Add(product);
            }

            return(productsList);
        }