private static void beginImportPrivate(ImportState ts) { int id = ts.TemplateId; SpiderImport item = SpiderImport.findById(id); List <SpiderArticle> articles = SpiderArticle .find("SpiderTemplateId in (" + item.DataSourceIds + ") and Id>" + item.LastImportId + " order by Id") .list(); List <ContentSection> sections = ContentSection.find("Id in (" + item.SectionIds + ")").list(); if (sections.Count == 0) { throw new Exception("导入的目标section不存在"); } ContentSection section = null; for (int i = 0; i < articles.Count; i++) { if (articleExist(articles[i])) { ts.Log.AppendLine("pass..." + articles[i].Title); continue; } section = getNextSection(sections, section); // 均匀分散到各目标section中 ContentApp app = getApp(section); if (item.IsApprove == 1) { importToTemp(articles[i], item, section, app); } else { importDirect(articles[i], item, section, app); } ts.Log.AppendLine("导入:" + articles[i].Title); } if (articles.Count > 0) { item.LastImportId = articles[articles.Count - 1].Id; item.update("LastImportId"); ts.Log.AppendLine("导入完毕(操作结束)"); } else { ts.Log.AppendLine("没有新条目可导入(操作结束)"); } }
public void DoRefresh(int id) { set("processLink", to(Process, id)); StringBuilder sb = LogCacher.GetNewImportLog("log" + ctx.viewer.Id); ImportState ts = new ImportState(); ts.TemplateId = id; ts.Log = sb; new Thread(ImportUtil.BeginImport).Start(ts); }
public static void BeginImport(object param) { ImportState ts = param as ImportState; try { beginImportPrivate(ts); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); ts.Log.AppendLine(ex.Message); ts.Log.AppendLine(ex.StackTrace); DbContext.closeConnectionAll(); } }
public void Execute() { List<SpiderImport> items = SpiderImport.find( "IsDelete=0" ).list(); DbContext.closeConnectionAll(); logger.Info( "begin ImportJob=" + items.Count ); StringBuilder log = new StringBuilder(); foreach (SpiderImport item in items) { ImportState ts = new ImportState(); ts.TemplateId = item.Id; ts.Log = log; ImportUtil.BeginImport( ts ); DbContext.closeConnectionAll(); } }
private static void beginImportPrivate( ImportState ts ) { int id = ts.TemplateId; SpiderImport item = SpiderImport.findById( id ); List<SpiderArticle> articles = SpiderArticle .find( "SpiderTemplateId in (" + item.DataSourceIds + ") and Id>" + item.LastImportId + " order by Id" ) .list(); List<ContentSection> sections = ContentSection.find( "Id in (" + item.SectionIds + ")" ).list(); if (sections.Count == 0) throw new Exception( "导入的目标section不存在" ); ContentSection section = null; for (int i = 0; i < articles.Count; i++) { if (articleExist( articles[i] )) { ts.Log.AppendLine( "pass..." + articles[i].Title ); continue; } section = getNextSection( sections, section ); // 均匀分散到各目标section中 ContentApp app = getApp( section ); if (item.IsApprove == 1) importToTemp( articles[i], item, section, app ); else importDirect( articles[i], item, section, app ); ts.Log.AppendLine( "导入:" + articles[i].Title ); } if (articles.Count > 0) { item.LastImportId = articles[articles.Count - 1].Id; item.update( "LastImportId" ); ts.Log.AppendLine( "导入完毕(操作结束)" ); } else { ts.Log.AppendLine( "没有新条目可导入(操作结束)" ); } }
public void Execute() { List <SpiderImport> items = SpiderImport.find("IsDelete=0").list(); DbContext.closeConnectionAll(); logger.Info("begin ImportJob=" + items.Count); StringBuilder log = new StringBuilder(); foreach (SpiderImport item in items) { ImportState ts = new ImportState(); ts.TemplateId = item.Id; ts.Log = log; ImportUtil.BeginImport(ts); DbContext.closeConnectionAll(); } }
public void DoRefresh( int id ) { set( "processLink", to( Process, id ) ); StringBuilder sb = LogCacher.GetNewImportLog( "log" + ctx.viewer.Id ); ImportState ts = new ImportState(); ts.TemplateId = id; ts.Log = sb; new Thread( ImportUtil.BeginImport ).Start( ts ); }