public override void AfterAction(MvcContext ctx) { if (!HtmlHelper.CanHtml(ctx)) { return; } // 1)文章添加之后,app首页和侧边栏都要更新 HtmlMaker.GetHome().Process(ctx.app.Id); logger.Info("PostAddObserver make app home"); // 2)新创建的文章,需要通过 ctx 传递 ContentPost post = HtmlHelper.GetPostFromContext(ctx); if (post != null) { DetailMaker mk = HtmlMaker.GetDetail(); mk.Process(post); ContentPost prev = postService.GetPrevPost(post); if (prev != null) { mk.Process(prev); } } // 3) 侧边栏 HtmlMaker.GetSidebar().Process(post.AppId); // 4) 其他生成工作放到队列中 JobManager.PostAdd(post); }
public virtual void AfterPostUpdate(int postId) { ContentPost post = ContentPost.findById(postId); // 3) 列表页处理 HtmlMaker.GetList().Process(post); logger.Info("[AfterPostUpdate] make html list done. postId=" + postId); // 4) 最近列表页处理 HtmlMaker.GetRecent().ProcessAll(post.AppId); logger.Info("[AfterPostUpdate] make html recent done. postId=" + postId); // 5) 侧边栏 HtmlMaker.GetSidebar().Process(post.AppId); logger.Info("[AfterPostUpdate] make html sidebar done. postId=" + postId); }
public virtual void AfterImport(String ids) { if (strUtil.IsNullOrEmpty(ids)) { return; } int[] arrIds = cvt.ToIntArray(ids); if (arrIds.Length == 0) { return; } List <int> appIds = new List <int>(); List <int> sectionIds = new List <int>(); List <ContentPost> posts = new List <ContentPost>(); // 1) 逐一生成详细页 foreach (int id in arrIds) { ContentPost x = ContentPost.findById(id); if (x == null) { continue; } posts.Add(x); if (isAutoMakeHtml(x.AppId) == false) { continue; } if (appIds.Contains(x.AppId) == false) { appIds.Add(x.AppId); } if (sectionIds.Contains(x.SectionId) == false) { sectionIds.Add(x.SectionId); } HtmlMaker.GetDetail().Process(x); logger.Info("[AfterImport] make html detail done. postId=" + x); } // 2) 列表页 foreach (int x in sectionIds) { HtmlMaker.GetList().ProcessSection(x); logger.Info("[AfterImport] make html list done. sectionId=" + x); } foreach (int appId in appIds) { // 3) 生成首页 HtmlMaker.GetHome().Process(appId); logger.Info("[AfterImport] make html home done. appId=" + appId); // 4) 生成侧边栏 HtmlMaker.GetSidebar().Process(appId); logger.Info("[AfterImport] make html sidebar done. appId=" + appId); // 5) 最近列表页处理 HtmlMaker.GetRecent().ProcessAll(appId); logger.Info("[AfterImport] make html recent done. appId=" + appId); } }