public virtual List <ContentPost> GetRelatedPosts(ContentPost post) { List <Tag> tags = post.Tag.List; List <int> ids = new List <int>(); foreach (Tag t in tags) { List <DataTagShip> list = DataTagShip.find("TagId=" + t.Id + " and TypeFullName=:tname") .set("tname", typeof(ContentPost).FullName) .list(); getPostIds(ids, list, post); } if (ids.Count == 0) { return(new List <ContentPost>()); } String strIds = ""; for (int i = 0; i < ids.Count; i++) { strIds += ids[i]; if (i < ids.Count - 1) { strIds += ","; } } List <ContentPost> posts = ContentPost.find("Id in (" + strIds + ") and SaveStatus=" + SaveStatus.Normal).list(); return(posts); }
public virtual List <ContentPost> GetTopBySectionAndCategory(int sectionId, int categoryId, int appId, int count) { List <ContentPost> list; // 兼容旧版 ContentSection s = ContentSection.findById(sectionId); if (strUtil.IsNullOrEmpty(s.CachePostIds)) { list = ContentPost.find("AppId=" + appId + " and PageSection.Id=" + sectionId + " and CategoryId=" + categoryId + " and SaveStatus=" + SaveStatus.Normal + " order by Id desc").list(count); } else { //list = ContentPost.findBySql( "select top " + count + " from ContentPost a, ContentSection b where a.AppId=" + appId + " and a.SectionId=" + sectionId + " and a.CategoryId=" + categoryId + " and a.SaveStatus=" + SaveStatus.Normal + " and b.SectionId=" + sectionId ); list = new List <ContentPost>(); List <ContentPost> posts = ContentPost.find("Id in (" + s.CachePostIds + ") and SaveStatus=" + SaveStatus.Normal).list(); foreach (ContentPost p in posts) { if (p.CategoryId == categoryId) { list.Add(p); } } } list.Sort(); return(list); }
public List <ContentPost> GetPicked(String ids, int count) { String sids = checkIds(ids); if (strUtil.IsNullOrEmpty(sids)) { return(new List <ContentPost>()); } if (count <= 0) { count = 10; } List <ContentPost> list = ContentPost.find("AppId in (" + sids + ") and PickStatus<" + PickStatus.Focus + " order by PickStatus desc, Id desc").list(count); list.Sort(); ContentPost post = ContentPost.find("AppId in (" + sids + ") and PickStatus=" + PickStatus.Focus).first(); List <ContentPost> results = new List <ContentPost>(); addFocusFirst(list, post, results); foreach (ContentPost a in list) { results.Add(a); } return(results); }
public virtual List <ContentPost> GetByCategory(long sectionId, long categoryId, long appId, int count) { List <ContentPost> list = ContentPost.find("AppId=" + appId + " and PageSection.Id=" + sectionId + " and CategoryId=" + categoryId + " and SaveStatus=" + SaveStatus.Normal + " order by Id desc").list(count); list.Sort(); return(list); }
public virtual List <ContentPost> GetByIds(string ids) { if (strUtil.IsNullOrEmpty(ids)) { return(new List <ContentPost>()); } List <ContentPost> posts = ContentPost.find("Id in (" + ids + ") and SaveStatus=" + SaveStatus.Normal).list(); return(posts); }
//---------------------------------------------------------------------------------------------------------- public virtual void Trans(String postIds, String targetSectionIds) { List <ContentPost> posts = ContentPost.find("Id in (" + postIds + ") ").list(); List <ContentSection> sections = ContentSection.find("Id in (" + targetSectionIds + ") ").list(); foreach (ContentPost x in posts) { transOne(x, sections); } }
private static bool articleExist(SpiderArticle spiderArticle) { logger.Info("articleExist=" + spiderArticle.Url); ContentPost post = ContentPost.find("OutUrl=:url").set("url", spiderArticle.Url).first(); if (post != null) { return(true); } return(ContentTempPost.find("SourceLink=:url").set("url", spiderArticle.Url).first() != null); }
public ContentPoll GetRecentPoll(int appId, int sectionId) { List <ContentPost> list = ContentPost.find("AppId=" + appId + " and PageSection.Id=" + sectionId + " and SaveStatus=" + SaveStatus.Normal + " order by Id desc").list(); if (list.Count == 0) { return(null); } return(db.find <ContentPoll>("TopicId=" + list[0].Id).first()); }
public void TransSection() { // 获取所有Post List <ContentPost> list = ContentPost.find("AppId=" + ctx.app.Id).list(); foreach (ContentPost x in list) { transSectionOne(x); } echoRedirect(lang("opok")); }
public virtual List <ContentPost> GetBySection(int sectionId, int count) { List <ContentPostSection> psList = ContentPostSection .find("SectionId=" + sectionId + " and SaveStatus=" + SaveStatus.Normal + " order by PostId desc") .list(count); if (psList.Count == 0) { // 兼容旧版 return(ContentPost.find("SectionId=" + sectionId + " and SaveStatus=" + SaveStatus.Normal).list(count)); } return(populatePost(psList)); }
public virtual List <ContentPost> GetAllBySection(int sectionId) { List <ContentPost> xResult = ContentPostSection .find("SectionId=" + sectionId + " and SaveStatus=" + SaveStatus.Normal + " order by PostId desc") .listChildren <ContentPost>("Post"); if (xResult.Count == 0) { // 兼容旧版 return(ContentPost.find("SectionId=" + sectionId + " and SaveStatus=" + SaveStatus.Normal).list()); } else { return(xResult); } }
private void updateCachePostIds(int sectionId) { ContentSection section = ContentSection.findById(sectionId); if (section == null) { throw new NullReferenceException(); } // 为了兼容旧版,section和post一对多关系下的数据也要抓取 List <ContentPostSection> list = ContentPostSection.find("SectionId=" + sectionId).list(section.ListCount); List <ContentPost> posts = ContentPost.find("SectionId=" + sectionId).list(section.ListCount); List <int> idList = getRecentIds(list, posts); section.CachePostIds = getCacheIds(idList, section.ListCount); section.update(); }
public virtual ContentPost GetFirstPost(int appId, int sectionId) { ContentPostSection xResult = ContentPostSection .find("SectionId=" + sectionId + " and SaveStatus=" + SaveStatus.Normal + " order by PostId desc") .first(); if (xResult == null) { // 兼容旧版 return(ContentPost.find("SectionId=" + sectionId + " and SaveStatus=" + SaveStatus.Normal).first()); } if (xResult.Post.AppId != appId) { return(null); } return(xResult.Post); }
//--------------------- service ------------------------------------------------------------------------ public virtual List <IBinderValue> GetByAppIds(String ids, int count) { String sids = checkIds(ids); if (strUtil.IsNullOrEmpty(sids)) { return(new List <IBinderValue>()); } if (count <= 0) { count = 10; } List <ContentPost> list = ContentPost.find("AppId in (" + sids + ") and SaveStatus=" + SaveStatus.Normal).list(count); return(populateBinder(list)); }
public void TransSection() { runsql("update ContentPostSection set SaveStatus=0"); runsql("update microblog set SaveStatus=0"); List <ContentApp> apps = ContentApp.find("").list(); foreach (ContentApp app in apps) { // 获取所有Post List <ContentPost> list = ContentPost.find("AppId=" + app.Id).list(); foreach (ContentPost x in list) { transSectionOne(x); } } echoRedirect(lang("opok")); }
public virtual List <IBinderValue> GetRepliesRankByAppIds(String ids, int count) { String sids = checkIds(ids); if (strUtil.IsNullOrEmpty(sids)) { return(new List <IBinderValue>()); } if (count <= 0) { count = 10; } String strSort = " order by Replies desc, Id desc"; List <ContentPost> list = ContentPost.find("AppId in (" + sids + ") and SaveStatus=" + SaveStatus.Normal + strSort).list(count); return(populatePosts(list)); }
public virtual List <ContentPost> GetBySection(int appId, int sectionId, int count) { List <ContentPost> list; // 兼容旧版 ContentSection s = ContentSection.findById(sectionId); if (strUtil.IsNullOrEmpty(s.CachePostIds)) { list = ContentPost.find("AppId=" + appId + " and PageSection.Id=" + sectionId + " and SaveStatus=" + SaveStatus.Normal + " order by Id desc").list(count); } else { list = ContentPost.find("Id in (" + s.CachePostIds + ") and SaveStatus=" + SaveStatus.Normal).list(); } list.Sort(); return(list); }
public void MovePostList(String ids, int targeSectionId) { // 首页缓存移除 removeCacheSingle(controller.to(new ContentController().Index)); List <ContentPost> posts = ContentPost.find("Id in (" + ids + ")").list(); foreach (ContentPost post in posts) { // 列表页标记过期 String listKey = "content_list_" + post.PageSection.Id; cacheHelper.SetTimestamp(listKey, DateTime.Now); // 详细页标记过期(包括分页) String detailKey = "content_post_" + post.Id; cacheHelper.SetTimestamp(detailKey, DateTime.Now); } // 目标列表页标记过期 String tagetListKey = "content_list_" + targeSectionId; cacheHelper.SetTimestamp(tagetListKey, DateTime.Now); }
public virtual List <ContentPost> GetByApp(int appId) { return(ContentPost.find("AppId=" + appId + " and SaveStatus=" + SaveStatus.Normal + " order by Id desc").list()); }
public virtual List <ContentPost> GetRankPost(int appId, int count, int typeId) { return(ContentPost.find("AppId=" + appId + " and CategoryId=" + typeId + " and SaveStatus=" + SaveStatus.Normal + " order by Hits desc, Replies desc, Id desc").list(count)); }
public virtual List <ContentPost> GetRecentPost(int appId, int count, int typeId) { return(ContentPost.find("AppId=" + appId + " and CategoryId=" + typeId + " and SaveStatus=" + SaveStatus.Normal).list(count)); }
public virtual ContentPost GetTopImg(long sectionId, long categoryId, long appId) { return(ContentPost.find("AppId=" + appId + " and PageSection.Id=" + sectionId + " and CategoryId=" + categoryId + " and SaveStatus=" + SaveStatus.Normal + " order by Id desc").first()); }
public virtual ContentPost GetNextPost(ContentPost post) { return(ContentPost.find("Id>" + post.Id + " and AppId=" + post.AppId + " and SaveStatus=" + SaveStatus.Normal + " order by Id asc").first()); }