예제 #1
0
        /// <summary>
        /// 将新抓取的分类 siteClass 保存到 慢慢买 shop_class_info
        /// </summary>
        public void UpdatemmbsiteClass(int siteid)
        {
            var site = new SiteClassInfoDB();
            var knowList = site.getmmbSiteClass(siteid);
            var oldList = site.getAllSiteCatInfo(siteid);
            if (siteid == 190)
            {
                UpdatemmbsiteClass(siteid, "50514008");
                oldList = _tempcatList;
            }

            var mmbSite = new mmbSiteClassInfoDB();

            List<SiteClassInfo> tempList = new List<SiteClassInfo>();

            for (int i = 0; i < oldList.Count; i++)
            {
                //if (oldList[i].UpdateTime.AddDays(3) < System.DateTime.Now)
                //    continue;
                //int classid;
                //if (siteid != 13&&!int.TryParse(oldList[i].ClassId, out classid))
                //    continue;
                if (siteid == 11 && !string.IsNullOrEmpty(oldList[i].ParentClass))
                    oldList[i].ClassId = oldList[i].ParentClass + "t" + oldList[i].ClassId;
                else if (siteid == 8)
                {
                    oldList[i].ClassId = oldList[i].ClassId.Replace("cat", "");
                    if (!string.IsNullOrEmpty(oldList[i].ParentClass))
                        oldList[i].ParentClass = oldList[i].ParentClass.Replace("cat", "");
                }
                //else if (siteid == 13)
                //{
                //    string tempcatid = oldList[i].ClassId.Substring(0, oldList[i].ClassId.IndexOf('-'));
                //    if (knowList.Exists(p => p.ClassId == tempcatid))
                //        continue;
                //}
                else if (siteid == 42)
                {

                    if (knowList.Exists(p => p.ClassId == "0-" + oldList[i].ClassId))
                        continue;
                    oldList[i].ClassId = "100-" + oldList[i].ClassId;
                    if (!string.IsNullOrEmpty(oldList[i].ParentClass))
                    {
                        oldList[i].ParentClass = "100-" + oldList[i].ParentClass;
                    }
                    if (knowList.Exists(p => p.ClassId == oldList[i].ClassId))
                        continue;
                }
                else if (siteid == 43)
                {
                    if (oldList[i].ClassId.Contains('_'))
                    {
                        oldList[i].ClassId = oldList[i].ClassId.Substring(oldList[i].ClassId.IndexOf('_') + 1);
                    }
                    if (oldList[i].ParentClass.Contains('_'))
                    {
                        oldList[i].ParentClass = oldList[i].ParentClass.Substring(oldList[i].ParentClass.IndexOf('_') + 1);
                    }
                }

                else if (siteid == 1)
                {
                    //if (!oldList[i].ClassId.Contains(',') && !oldList[i].ClassId.Contains('-'))
                    //    continue;
                    oldList[i].ClassId = oldList[i].ClassId.Replace(',', '-');
                    if (!string.IsNullOrEmpty(oldList[i].ParentClass))
                        oldList[i].ParentClass = oldList[i].ParentClass.Replace(',', '-');
                }

                if (knowList.Exists(p => p.ClassId == oldList[i].ClassId))
                    continue;
                tempList.Add(oldList[i]);
                if (tempList.Count >= 100)
                {
                    mmbSite.addmmbSIteClass(tempList);
                    tempList.Clear();
                }
            }
            if (tempList.Count > 0)
                mmbSite.addmmbSIteClass(tempList);
        }
예제 #2
0
        /// <summary>
        /// 将shop_class_info数据导入到 SiteClass
        /// </summary>
        public void SaveTommbData()
        {
            var site =new SiteClassInfoDB();
            var knowList = site.getAllSiteCatInfo(3);
            var oldList = site.getmmbSiteClass(3);

            var mmbSite = new mmbSiteClassInfoDB();

            List<SiteClassInfo> tempList = new List<SiteClassInfo>();

            for (int i = 0; i < oldList.Count; i++)
            {
                if (knowList.Exists(p => p.ClassId == oldList[i].ClassId))
                    continue;
                tempList.Add(oldList[i]);
                if (tempList.Count >= 100)
                {
                    mmbSite.AddSiteClass(tempList);
                    tempList.Clear();
                }
            }

            mmbSite.AddSiteClass(tempList);
        }