Esempio n. 1
0
        private List <SkuMap> GetSkumapDetail(string html)
        {
            string subMap = GetSubString(html, "skuMap", ",propertyMemoMap").Trim().TrimStart(':');
            JavaScriptSerializer        serializer = JavaScriptSerializer.CreateInstance();
            HashObject                  hash       = serializer.Deserialize <HashObject>(subMap);
            List <SkuMap>               listSkuMap = new List <SkuMap>();
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            foreach (string key in hash.Keys)
            {
                SkuMap map = new SkuMap();
                map.Key = key;
                HashObject temp = (HashObject)hash[key];
                map.PromotionPrice = map.OriginalPrice = temp.GetValue <decimal>("price");
                map.SkuId          = temp.GetValue <string>("skuId");
                string[]      keyItems = key.Trim(';').Split(';');
                StringBuilder sbuilder = new StringBuilder();
                for (var i = 0; i < keyItems.Length; i++)
                {
                    string item = keyItems[i];

                    string itemName;
                    if (!dictionary.TryGetValue(item, out itemName))
                    {
                        itemName = GetItemName(item, html);
                        dictionary.Add(item, itemName);
                    }
                    sbuilder.AppendFormat("{0},", itemName);
                }
                map.Title = sbuilder.ToString().Substring(0, sbuilder.Length - 1);
                listSkuMap.Add(map);
            }
            return(listSkuMap);
        }
Esempio n. 2
0
        private List <SkuMap> GetSkumapTmallDetail(HashObject data)
        {
            List <SkuMap> list = new List <SkuMap>();

            string[] keys =
            {
                "valItemInfo/skuList",
                "valItemInfo/skuMap"
            };
            var skuList = data.GetHashValue(keys);
            var details = skuList.GetDataEx <ArrayList>("skuList");
            var skuMaps = skuList.GetDataEx <HashObject>("skuMap");

            foreach (HashObject hash in details)
            {
                SkuMap skuMap = new SkuMap();
                skuMap.Title = hash.GetValue <string>("names");
                skuMap.SkuId = hash.GetValue <string>("skuId");
                skuMap.Key   = string.Format(";{0};", hash.GetValue <string>("pvs"));
                var map = (HashObject)skuMaps[skuMap.Key];
                skuMap.Stock         = map.GetValue <decimal>("stock");
                skuMap.OriginalPrice = map.GetValue <decimal>("price");
                list.Add(skuMap);
            }

            return(list);
        }