Esempio n. 1
0
        public static void ImportJuTuan(string path)
        {
            JuTuan t        = new JuTuan();
            var    list     = TaoBaoImport.Import(t, path);
            var    tempList = new List <JuTuan>(500);

            foreach (var item in list)
            {
                item.Id          = Guid.NewGuid();
                item.CreatedTime = DateTime.Now;
                item.Tags        = item.TypeName.Replace("/", ",");
                tempList.Add(item);
                if (tempList.Count == 500)
                {
                    BLL.JuTuanBLL.BatchInsert(tempList);
                    tempList.Clear();
                }
            }

            if (tempList.Count > 0)
            {
                BLL.JuTuanBLL.BatchInsert(tempList);
            }

            Console.WriteLine("ImportJuTuan done, total count:" + list.Count.ToString());
        }
Esempio n. 2
0
        public static void ImportItems(string path)
        {
            Items t        = new Items();
            var   list     = TaoBaoImport.Import(t, path);
            var   tempList = new List <Items>(500);

            foreach (var item in list)
            {
                item.TypeId      = 1;
                item.CateId      = 1;
                item.OrdId       = 1;
                item.IsShow      = 1;
                item.AliId       = "1";
                item.CateId      = 1;
                item.Status      = 1;
                item.ProductUrl += string.IsNullOrEmpty(item.ProductUrl) ? "" : pid;
                item.FinalPrice  = item.Price;
                if (!string.IsNullOrEmpty(item.ItemInfo))
                {
                    if (item.ItemInfo.Contains("无条件"))
                    {
                        var temp = item.ItemInfo.Split("元");
                        item.YouhuiPrice = temp[0].TryToDecimal();
                    }
                    else if (item.ItemInfo.Contains("减"))
                    {
                        var temp = item.ItemInfo.Split("减");
                        item.YouhuiPrice = temp[1].Replace("元", "").TryToDecimal();
                    }

                    item.FinalPrice -= item.YouhuiPrice;
                }
                item.Tags = item.TypeName.Replace("/", ",");
                tempList.Add(item);
                if (tempList.Count == 500)
                {
                    BLL.ItemsBLL.BatchInsert(tempList);
                    tempList.Clear();
                }
            }

            if (tempList.Count > 0)
            {
                BLL.ItemsBLL.BatchInsert(tempList);
            }
            FileHelper.AppendSuffix(path, "done");
            Console.WriteLine("ImportItems done, total count:" + list.Count.ToString());
        }