Пример #1
0
 public virtual DataPage <ForumPost> GetPageList(int topicId, int pageSize, int memberId)
 {
     if (memberId > 0)
     {
         return(db.findPage <ForumPost>("TopicId=" + topicId + " and Creator.Id=" + memberId + " and " + TopicStatus.GetShowCondition() + " order by Id asc", pageSize));
     }
     return(db.findPage <ForumPost>("TopicId=" + topicId + " and " + TopicStatus.GetShowCondition() + " order by Id asc", pageSize));
 }
Пример #2
0
        public virtual int GetPageCount(int topicId, int pageSize)
        {
            String strCondition = "TopicId=" + topicId + " and " + TopicStatus.GetShowCondition();
            int    count        = ForumPost.count(strCondition);
            int    page         = count / pageSize;
            int    imod         = count % pageSize;

            return(imod > 0 ? page + 1 : page);
        }
Пример #3
0
        public virtual List <ForumTopic> GetByAppAndReplies(int appId, int count, int days)
        {
            EntityInfo ei = Entity.GetInfo(typeof(User));

            String   t   = ei.Dialect.GetTimeQuote();
            String   fs  = " and Created between " + t + "{0}" + t + " and " + t + "{1}" + t + " ";
            DateTime now = DateTime.Now;
            String   dc  = string.Format(fs, now.AddDays(-days + 1).ToShortDateString(), now.AddDays(1).ToShortDateString());    // 加1表示包含今天

            return(ForumTopic.find("AppId=" + appId + " and " + TopicStatus.GetShowCondition() + dc + " order by Replies desc, Id desc").list(count));
        }
Пример #4
0
        private List <IBinderValue> getNewTopic(int count, Type ownerType)
        {
            if (count <= 0)
            {
                count = 10;
            }

            List <ForumTopic> list = db.find <ForumTopic>(TopicStatus.GetShowCondition() + " and OwnerType=:otype order by Id desc")
                                     .set("otype", ownerType.FullName)
                                     .list(count);

            return(SysForumTopicService.populateBinderValue(list));
        }
Пример #5
0
        private List <IBinderValue> getNewPost(int boardId, int count, Type ownerType)
        {
            if (count <= 0)
            {
                count = 10;
            }

            String bd = boardId > 0 ? " and ForumBoardId=" + boardId : "";

            List <ForumPost> list = db.find <ForumPost>(TopicStatus.GetShowCondition() + bd + " and OwnerType=:otype order by Id desc")
                                    .set("otype", ownerType.FullName)
                                    .list(count);

            return(populateBinderValue(list));
        }
Пример #6
0
        public virtual List <IBinderValue> GetNewBoardTopic(String ids, int count)
        {
            if (count <= 0)
            {
                count = 10;
            }

            String sids = checkIds(ids);

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

            String bd = " and ForumBoardId in ( " + sids + " )";

            List <ForumTopic> list = db.find <ForumTopic>(TopicStatus.GetShowCondition() + bd + " and OwnerType=:otype order by Id desc")
                                     .set("otype", typeof(Site).FullName)
                                     .list(count);

            return(SysForumTopicService.populateBinderValue(list));
        }
Пример #7
0
        public virtual void UpdateLastInfo(ForumBoard fb)
        {
            ForumTopic topic = ForumTopic
                               .find("ForumBoardId=" + fb.Id + " and " + TopicStatus.GetShowCondition() + " order by Id desc")
                               .first();

            LastUpdateInfo info = new LastUpdateInfo();

            info.PostId    = topic.Id;
            info.PostType  = typeof(ForumTopic).Name;
            info.PostTitle = topic.Title;

            User user = topic.Creator;

            info.CreatorName = user.Name;
            info.CreatorUrl  = user.Url;
            info.UpdateTime  = topic.Created;

            fb.LastUpdateInfo = info;
            fb.Updated        = info.UpdateTime;

            db.update(fb);
        }
Пример #8
0
 public virtual DataPage <ForumTopic> GetPickedByApp(int appId, int pageSize)
 {
     return(ForumTopic.findPage("AppId=" + appId + " and IsPicked=1 and " + TopicStatus.GetShowCondition(), pageSize));
 }
Пример #9
0
 public virtual DataPage <ForumTopic> GetByUser(int userId, int pageSize)
 {
     if (userId <= 0)
     {
         return(DataPage <ForumTopic> .GetEmpty());
     }
     return(ForumTopic.findPage("CreatorId=" + userId + " and OwnerType='" + typeof(Site).FullName + "' and " + TopicStatus.GetShowCondition(), pageSize));
 }
Пример #10
0
 public virtual DataPage <ForumTopic> GetByUserAndApp(int appId, int userId, int pageSize)
 {
     if (userId <= 0 || appId <= 0)
     {
         return(DataPage <ForumTopic> .GetEmpty());
     }
     return(ForumTopic.findPage("AppId=" + appId + " and CreatorId=" + userId + " and " + TopicStatus.GetShowCondition(), pageSize));
 }
Пример #11
0
 public virtual List <ForumTopic> GetByApp(int appId, int count)
 {
     return(ForumTopic.find("AppId=" + appId + " and " + TopicStatus.GetShowCondition()).list(count));
 }
Пример #12
0
        public virtual int GetPostPage(int postId, int topicId, int pageSize)
        {
            int count = ForumPost.count("Id<=" + postId + " and TopicId=" + topicId + " and " + TopicStatus.GetShowCondition());

            return(getPage(count, pageSize));
        }
Пример #13
0
 public virtual DataPage <ForumPost> GetByAppAndUser(long appId, long userId, int pageSize)
 {
     if (userId <= 0 || appId <= 0)
     {
         return(DataPage <ForumPost> .GetEmpty());
     }
     return(ForumPost.findPage("AppId=" + appId + " and CreatorId=" + userId + " and " + TopicStatus.GetShowCondition(), pageSize));
 }
Пример #14
0
 public virtual int CountPost(long forumBoardId)
 {
     return(db.find <ForumPost>("ForumBoardId=" + forumBoardId + " and " + TopicStatus.GetShowCondition()).count());
 }
Пример #15
0
 public virtual DataPage <ForumPost> GetPageByApp(int appId, int pageSize)
 {
     return(db.findPage <ForumPost>("AppId=" + appId + " and " + TopicStatus.GetShowCondition(), pageSize));
 }
Пример #16
0
 public virtual int CountTopic(int forumBoardId)
 {
     return(db.find <ForumTopic>("ForumBoardId=" + forumBoardId + " and " + TopicStatus.GetShowCondition()).count());
 }
Пример #17
0
 public virtual List <ForumTopic> GetByAppAndViews(int appId, int count)
 {
     return(ForumTopic.find("AppId=" + appId + " and " + TopicStatus.GetShowCondition() + " order by Hits desc, Id desc").list(count));
 }
Пример #18
0
        //--------------------------------------------------------------------------------

        public virtual DataPage <ForumTopic> Search(int appId, string key, int pageSize)
        {
            if (strUtil.IsNullOrEmpty(key))
            {
                return(DataPage <ForumTopic> .GetEmpty());
            }
            String q = strUtil.SqlClean(key, 10);

            return(ForumTopic.findPage("AppId=" + appId + " and Title like '%" + q + "%' and " + TopicStatus.GetShowCondition(), pageSize));
        }
Пример #19
0
        public virtual int GetBoardPage(int topicId, int boardId, int pageSize)
        {
            int count = ForumTopic.count("Id>=" + topicId + " and ForumBoardId=" + boardId + " and " + TopicStatus.GetShowCondition());

            return(getPage(count, pageSize));
        }
Пример #20
0
 public virtual List <ForumPost> GetRecentByApp(long appId, int count)
 {
     return(ForumPost.find("AppId=" + appId + " and " + TopicStatus.GetShowCondition()).list(count));
 }