public void SaveAllSiteClass() { HasBindClasslist = new SiteClassInfoDB().getAllSiteCatInfo(Baseinfo.SiteId); string url = "http://3c.tmall.com/"; //电器 for (int i = 1; i < 16; i++) { url = string.Format("http://www.tmall.com/tmall-fp/3.0/mods/load.php?path=tmall-fp%2F3-0%2Fcategory-{0}.php",i); Thread.Sleep(new Random().Next(10, 60) * 1000); string directoryHtml = HtmlAnalysis.Gethtmlcode(url); var catList = RegGroupCollection(directoryHtml, "cat=(?<x>\\d+)"); if (catList == null) return; foreach (Match item in catList) { SaveCat(item.Groups["x"].Value); } if (shopClasslist.Count > 0) { new SiteClassInfoDB().AddSiteClass(shopClasslist); shopClasslist.Clear(); } } }
public void LoadBand() { HasBindClasslist = new SiteClassInfoDB().getAllSiteCatInfo(Baseinfo.SiteId).OrderBy(p => p.UpdateTime).ToList(); HasBindBandlist = new SiteClassBandDb().FindBySiteId(Baseinfo.SiteId); HasSiteBandlist = new SiteBandDb().FindBySiteId(Baseinfo.SiteId); for (int i = 0; i < HasBindClasslist.Count; i++) { if (string.IsNullOrEmpty(HasBindClasslist[i].ClassId)) continue; SaveBand(HasBindClasslist[i]); Thread.Sleep(1000 * 10); } }
public void UpdateSiteCat() { HasBindClasslist = new SiteClassInfoDB().getAllSiteCatInfo(Baseinfo.SiteId).OrderBy(p => p.UpdateTime).ToList(); for (int i = 0; i < HasBindClasslist.Count; i++) { if (string.IsNullOrEmpty(HasBindClasslist[i].ClassId)) continue; try { UpdateTmallNode(HasBindClasslist[i]); //Thread.Sleep(1000*10); } catch (Exception ex) { LogServer.WriteLog(ex); } } }
public void delClass(SiteClassInfo siteclass) { SiteClassInfoDB db = new SiteClassInfoDB(); siteclass.IsDel = true; db.SetIsDel(siteclass); }
public string BingCat(int id,int catid) { var siteCat = GetCatById(id); if (siteCat == null) return "没找到商城分类 id:" + id; var cat = new ClassInfoBll().getCat(catid); if (cat == null) return "没找到分类 catid:" + catid; siteCat.BindClassId = catid; siteCat.BindClassName = cat.CatName; siteCat.IsBind = true; var flag = new SiteClassInfoDB().BingCatInfo(siteCat); if (flag) return "绑定成功"; return "绑定失败"; }
private void UpdatemmbsiteClass(int siteid, string catid) { if (_catList == null) { var site = new SiteClassInfoDB(); _catList = site.getAllSiteCatInfo(10); } if (_tempcatList == null) _tempcatList = new List<SiteClassInfo>(); foreach (SiteClassInfo siteClassInfo in _catList.Where(c => c.ParentClass == catid)) { siteClassInfo.SiteId = siteid; _tempcatList.Add(siteClassInfo); if (_catList.Exists(c => c.ParentClass == siteClassInfo.ClassId)) { UpdatemmbsiteClass(siteid, siteClassInfo.ClassId); } } }
/// <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); }
/// <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); }