コード例 #1
0
        public virtual string GetSectionIdsByPost(long postId)
        {
            List <ContentPostSection> list = ContentPostSection.find("PostId=" + postId).list();

            if (list.Count == 0)
            {
                ContentPost post = ContentPost.findById(postId);
                if (post == null)
                {
                    return("");
                }
                if (post.PageSection == null)
                {
                    return("");
                }
                return(post.PageSection.Id.ToString());
            }

            String ids = "";

            foreach (ContentPostSection ps in list)
            {
                ids += ps.Section.Id + ",";
            }

            return(ids.TrimEnd(','));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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();
        }
コード例 #6
0
ファイル: ListMaker.cs プロジェクト: zuhuizou/wojilu
        public virtual int Process(ContentPost post)
        {
            if (post == null)
            {
                return(0);
            }

            int totalCount = 0;

            List <ContentPostSection> psList = ContentPostSection.find("PostId=" + post.Id).list();

            foreach (ContentPostSection x in psList)
            {
                int recordCount = postService.CountBySection(x.Section.Id);

                totalCount += this.ProcessAll(x.Section.Id, recordCount);
            }

            return(totalCount);
        }
コード例 #7
0
        public virtual void Update(ContentPost post, String sectionIds, String tagList)
        {
            if (db.update(post).IsValid)
            {
                post.Tag.Save(tagList);
            }

            List <ContentPostSection> oldPsList = ContentPostSection.find("PostId=" + post.Id).list();

            // 多对多处理
            ContentPostSection.deleteBatch("PostId=" + post.Id);

            ContentPostSection ps = new ContentPostSection();

            int[] ids = cvt.ToIntArray(sectionIds);
            foreach (int sectionId in ids)
            {
                ContentSection section = new ContentSection();
                section.Id = sectionId;

                ps.Post    = post;
                ps.Section = section;
                ps.insert();
            }

            post.PageSection    = new ContentSection(); // 不再使用旧版一对多关系
            post.PageSection.Id = ids[0];
            post.update();


            // 更新旧的section关系
            foreach (ContentPostSection p in oldPsList)
            {
                updateCachePostIds(p.Section.Id);
            }
            // 更新新的section关系
            foreach (int sectionId in ids)
            {
                updateCachePostIds(sectionId);
            }
        }
コード例 #8
0
        public virtual List <IBinderValue> GetBySectionIds(String ids, int count)
        {
            String sids = checkIds(ids);

            if (strUtil.IsNullOrEmpty(sids))
            {
                return(new List <IBinderValue>());
            }

            if (count <= 0)
            {
                count = 10;
            }

            List <ContentPostSection> psList = ContentPostSection
                                               .find("SectionId in (" + sids + ") and SaveStatus=" + SaveStatus.Normal)
                                               .list(count);

            List <ContentPost> list = populatePost(psList);

            return(populateBinder(list));
        }
コード例 #9
0
 public List <ContentPostSection> GetByPost(int postId)
 {
     return(ContentPostSection.find("PostId=" + postId).list());
 }
コード例 #10
0
 private ContentPostSection hasTrans(ContentPost x, int sectionId)
 {
     return(ContentPostSection.find("SectionId=" + sectionId + " and PostId=" + x.Id).first());
 }
コード例 #11
0
 public virtual List <ContentPostSection> GetByPost(long postId)
 {
     return(ContentPostSection.find("PostId=" + postId).list());
 }