public virtual void Delete(long id) { SpiderImport s = SpiderImport.findById(id); s.IsDelete = 1; s.update("IsDelete"); }
public virtual void Delete(long id) { SpiderImport item = importService.GetById(id); item.delete(); redirect(List); }
private static int importDirect(SpiderArticle art, SpiderImport item, ContentSection section, ContentApp app) { ContentPost post = new ContentPost(); post.Title = art.Title; post.Content = art.Body; if (art.IsPic == 1) { post.CategoryId = PostCategory.Img; post.ImgLink = art.PicUrl; } post.SourceLink = art.Url; post.Creator = item.Creator; post.CreatorUrl = item.Creator.Url; post.PageSection = section; post.OwnerId = app.OwnerId; post.OwnerType = app.OwnerType; post.OwnerUrl = app.OwnerUrl; post.AppId = app.Id; post.insert(); return(post.Id); }
public void Delete(int id) { SpiderImport item = importService.GetById(id); item.delete(); redirect(List); }
public void Delete(int id) { SpiderImport s = SpiderImport.findById(id); s.IsDelete = 1; s.update("IsDelete"); }
public void Stop(int id) { SpiderImport item = importService.GetById(id); item.IsDelete = 1; item.update("IsDelete"); echoAjaxOk(); }
private string getImportDescription( SpiderImport it, List<SpiderTemplate> dataSrc ) { StringBuilder sb = getDataSrcInfo( it, dataSrc ); sb.Append( " --> " ); sb.Append( getTargetInfo( it ) ); return sb.ToString(); }
public virtual void Start(long id) { SpiderImport item = importService.GetById(id); item.IsDelete = 0; item.update("IsDelete"); echoAjaxOk(); }
private static List <long> beginImportPrivate(ImportState ts) { long 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; List <long> results = new List <long>(); 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 { long newArticleId = importDirect(articles[i], item, section, app); results.Add(newArticleId); } 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("没有新条目可导入(操作结束)"); } return(results); }
private string getImportDescription(SpiderImport it, List <SpiderTemplate> dataSrc) { StringBuilder sb = getDataSrcInfo(it, dataSrc); sb.Append(" --> "); sb.Append(getTargetInfo(it)); return(sb.ToString()); }
public ImportJson( SpiderImport it ) { this.Id = it.Id; this.Name = it.Name; this.DataSrcIds = cvtToString( it.DataSourceIds ); this.TargetIds = cvtToString( it.SectionIds ); this.Creator = it.Creator.Name; this.IsApprove = it.IsApprove == 1; }
public ImportJson(SpiderImport it) { this.Id = it.Id; this.Name = it.Name; this.DataSrcIds = cvtToString(it.DataSourceIds); this.TargetIds = cvtToString(it.SectionIds); this.Creator = it.Creator.Name; this.IsApprove = it.IsApprove == 1; }
public void Save() { int id = ctx.PostInt("Id"); int isApprove = ctx.PostInt("isApprove"); String name = ctx.Post("name"); String srcIds = ctx.PostIdList("srcIds"); String targetIds = ctx.PostIdList("targetIds"); String userName = ctx.Post("userName"); if (strUtil.IsNullOrEmpty(name)) { errors.Add("请填写名称"); } if (strUtil.IsNullOrEmpty(srcIds)) { errors.Add("请选择数据源"); } if (strUtil.IsNullOrEmpty(targetIds)) { errors.Add("请选择目标区块"); } User user = userService.GetByName(userName); if (user == null) { errors.Add("用户不存在"); } if (ctx.HasErrors) { echoError(); return; } SpiderImport it = id > 0 ? importService.GetById(id) : new SpiderImport(); it.Name = name; it.DataSourceIds = srcIds; it.SectionIds = targetIds; it.IsApprove = isApprove; it.Creator = user; if (id > 0) { it.update(); } else { it.insert(); } echoJsonMsg("操作成功", true, null); }
public void Show(int id) { SpiderImport item = importService.GetById(id); List <SpiderTemplate> dataSrc = templateService.GetAll(); set("item.ApproveInfo", item.IsApprove == 1 ? "需要审核" : "不需要"); bind("item", item); set("item.DataSourceInfo", getDataSrcInfo(item, dataSrc)); set("item.TargetInfo", getTargetInfo(item)); set("editUrl", to(Add, id)); }
private StringBuilder getTargetInfo(SpiderImport it) { StringBuilder sb = new StringBuilder(); List <ContentSection> sections = ContentSection.find("Id in (" + it.SectionIds + ")").list(); for (int i = 0; i < sections.Count; i++) { sb.Append(sections[i].Title); if (i < sections.Count - 1) { sb.Append(","); } } return(sb); }
private StringBuilder getDataSrcInfo(SpiderImport it, List <SpiderTemplate> dataSrc) { StringBuilder sb = new StringBuilder(); int[] arrSrc = cvt.ToIntArray(it.DataSourceIds); for (int i = 0; i < arrSrc.Length; i++) { sb.Append(getTemplateName(arrSrc[i], dataSrc)); if (i < arrSrc.Length - 1) { sb.Append(","); } } return(sb); }
private static int importToTemp(SpiderArticle art, SpiderImport item, ContentSection section, ContentApp app) { ContentTempPost post = new ContentTempPost(); post.Creator = item.Creator; post.OwnerId = app.OwnerId; post.OwnerType = app.OwnerType; post.AppId = app.Id; post.SectionId = section.Id; post.Title = art.Title; post.SourceLink = art.Url; post.Content = art.Body; post.insert(); return(post.Id); }
public void Add(int id) { if (id > 0) { SpiderImport item = importService.GetById(id); if (item == null) { echoRedirect(lang("exDataNotFound")); return; } set("itemJson", Json.ToString(new ImportJson(item))); } else { set("itemJson", "{Id:0}"); } set("step3Action", to(Save)); set("returnUrl", to(List)); List <SpiderTemplate> list = templateService.GetAll(); checkboxList("dataSrc", list, "SiteName=Id", null); //dataTarget List <ContentApp> apps = ContentApp.find("OwnerType=:otype").set("otype", typeof(Site).FullName).list(); IBlock block = getBlock("apps"); foreach (ContentApp app in apps) { block.Set("appId", app.Id); IMemberApp ma = appService.GetByApp(app); if (ma == null) { continue; } block.Set("appName", ma.Name); List <ContentSection> sections = ContentSection.find("AppId=" + app.Id).list(); block.Set("dataTarget", Html.CheckBoxList(sections, "dataTarget", "Title", "Id", null)); block.Next(); } }
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 virtual void SaveSort() { int id = ctx.PostInt("id"); String cmd = ctx.Post("cmd"); SpiderImport s = importService.GetById(id); List <SpiderImport> list = importService.GetAll(); if (cmd == "up") { new SortUtil <SpiderImport>(s, list).MoveUp(); echoJsonOk(); } else if (cmd == "down") { new SortUtil <SpiderImport>(s, list).MoveDown(); echoJsonOk(); } else { echoError(lang("exUnknowCmd")); } }
public virtual SpiderImport GetById(long id) { return(SpiderImport.findById(id)); }
private StringBuilder getDataSrcInfo( SpiderImport it, List<SpiderTemplate> dataSrc ) { StringBuilder sb = new StringBuilder(); int[] arrSrc = cvt.ToIntArray( it.DataSourceIds ); for (int i = 0; i < arrSrc.Length; i++) { sb.Append( getTemplateName( arrSrc[i], dataSrc ) ); if (i < arrSrc.Length - 1) sb.Append( "," ); } return sb; }
private StringBuilder getTargetInfo( SpiderImport it ) { StringBuilder sb = new StringBuilder(); List<ContentSection> sections = ContentSection.find( "Id in (" + it.SectionIds + ")" ).list(); for (int i = 0; i < sections.Count; i++) { sb.Append( sections[i].Title ); if (i < sections.Count - 1) sb.Append( "," ); } return sb; }
public void Update( SpiderImport s ) { s.update(); }
public void Insert( SpiderImport s ) { s.insert(); }
private static int importToTemp( SpiderArticle art, SpiderImport item, ContentSection section, ContentApp app ) { ContentTempPost post = new ContentTempPost(); post.Creator = item.Creator; post.OwnerId = app.OwnerId; post.OwnerType = app.OwnerType; post.AppId = app.Id; post.SectionId = section.Id; post.Title = art.Title; post.SourceLink = art.Url; post.Content = art.Body; post.insert(); return post.Id; }
private static int importDirect( SpiderArticle art, SpiderImport item, ContentSection section, ContentApp app ) { ContentPost post = new ContentPost(); post.Title = art.Title; post.Content = art.Body; if (art.IsPic == 1) { post.CategoryId = PostCategory.Img; post.ImgLink = art.PicUrl; } post.SourceLink = art.Url; post.Creator = item.Creator; post.CreatorUrl = item.Creator.Url; post.PageSection = section; post.OwnerId = app.OwnerId; post.OwnerType = app.OwnerType; post.OwnerUrl = app.OwnerUrl; post.AppId = app.Id; post.insert(); return post.Id; }
public List <SpiderImport> GetAll() { return(SpiderImport.find("order by OrderId desc, Id asc").list()); }
public void Update(SpiderImport s) { s.update(); }
public void Insert(SpiderImport s) { s.insert(); }
public SpiderImport GetById(int id) { return(SpiderImport.findById(id)); }