예제 #1
0
        public static Int32[] GetMaxAndMinTidByFid(int fid)
        {
            var arr  = new Int32[2];
            var list = FindAll(_.Fid.In(XForum.FindByID(fid).AllChildKeys), null, _.ID.Max() & _.ID.Min(__.PosterID), 0, 0);

            if (list.Count > 0)
            {
                arr[0] = list[0].ID;
                arr[1] = list[0].PosterID;
            }
            return(arr);
        }
예제 #2
0
        void UpdateStatistic(Int32 count)
        {
            // 更新各地统计信息
            var st = Statistic.Current;

            st.TotalPost += count;
            st.Save();

            // 更新论坛统计
            var fi = XForum.FindByID(Fid);

            if (fi == null)
            {
                throw new ArgumentNullException("Fid", "找不到ID=" + Fid + "的论坛");
            }

            // 所有上级论坛帖子数增加
            while (fi != null && fi.ID != 0)
            {
                fi.Posts += count;
                if (fi.LastPost.Date == DateTime.Now.Date)
                {
                    fi.TodayPosts += count;
                }
                else
                {
                    fi.TodayPosts = 1;
                }

                fi.LastTID      = Tid;
                fi.LastTitle    = TopicTitle;
                fi.LastPost     = PostDateTime;
                fi.LastPoster   = Poster;
                fi.LastPosterID = PosterID;

                fi.Save();

                fi = fi.Parent;
            }

            // 更新用户统计
            var user = User.FindByID(PosterID);

            if (user == null)
            {
                throw new ArgumentNullException("PosterID", "找不到ID=" + PosterID + "的发帖者");
            }
            {
                user.LastPost      = PostDateTime;
                user.LastPostID    = ID;
                user.LastPostTitle = TopicTitle;
                user.Posts        += count;
                user.LastActivity  = DateTime.Now;

                user.Save();
            }

            var tp = Topic.FindByID(Tid);

            if (Invisible == 0 && Layer > 0)
            {
                tp.Replies += count;
            }
            else if (Layer <= 0)
            {
                tp.Replies = 0;
            }

            tp.LastPost     = PostDateTime;
            tp.LastPoster   = Poster;
            tp.LastPosterID = PosterID;
            tp.LastPostID   = ID;
            tp.Save();
        }