Exemple #1
0
        /// <summary>
        /// 获得帖子列表
        /// </summary>
        /// <param name="count">数量</param>
        /// <param name="views">最小浏览量</param>
        /// <param name="fid">板块ID</param>
        /// <param name="timetype">期限类型,一天、一周、一月、不限制</param>
        /// <param name="ordertype">排序类型,时间倒序、浏览量倒序、最后回复倒序</param>
        /// <param name="isdigest">是否精华</param>
        /// <param name="cachetime">缓存的有效期(单位:分钟)</param>
        /// <returns></returns>
        public static DataTable GetTopicList(ForumHotItemInfo forumHotItemInfo)
        {
            //防止恶意行为
            forumHotItemInfo.Cachetimeout  = forumHotItemInfo.Cachetimeout == 0 ? 1 : forumHotItemInfo.Cachetimeout;
            forumHotItemInfo.Dataitemcount = forumHotItemInfo.Dataitemcount > 50 ? 50 : (forumHotItemInfo.Dataitemcount < 1 ? 1 : forumHotItemInfo.Dataitemcount);

            DataTable dt = new DataTable();

            if (forumHotItemInfo.Cachetimeout > 0)
            {
                dt = DNTCache.GetCacheService().RetrieveObject("/Forum/ForumHostList-" + forumHotItemInfo.Id) as DataTable;
            }

            if (dt == null)
            {
                //如果版块idlist设置为空,则默认读取所有可见板块的idlist
                string forumList      = string.IsNullOrEmpty(forumHotItemInfo.Forumlist) ? Forums.GetVisibleForum() : forumHotItemInfo.Forumlist;
                string orderFieldName = Focuses.GetFieldName((TopicOrderType)Enum.Parse(typeof(TopicOrderType), forumHotItemInfo.Sorttype));

                dt = Discuz.Data.Topics.GetTopicList(forumHotItemInfo.Dataitemcount, -1, 0, "",
                                                     Focuses.GetStartDate((TopicTimeType)Enum.Parse(typeof(TopicTimeType), forumHotItemInfo.Datatimetype)),
                                                     orderFieldName, forumList, orderFieldName == "digest", false);

                if (forumHotItemInfo.Cachetimeout > 0)
                {
                    DNTCache.GetCacheService().AddObject("/Forum/ForumHostList-" + forumHotItemInfo.Id, dt, forumHotItemInfo.Cachetimeout);
                }
            }
            return(dt);
        }
Exemple #2
0
        /// <summary>
        /// 获得帖子列表
        /// </summary>
        /// <param name="count">数量</param>
        /// <param name="views">最小浏览量</param>
        /// <param name="fid">板块ID</param>
        /// <param name="timetype">期限类型,一天、一周、一月、不限制</param>
        /// <param name="ordertype">排序类型,时间倒序、浏览量倒序、最后回复倒序</param>
        /// <param name="isdigest">是否精华</param>
        /// <param name="cachetime">缓存的有效期(单位:分钟)</param>
        /// <returns></returns>
        public static DataTable GetTopicList(int count, int fid, TopicOrderType ordertype, bool digest, int cachetime, bool onlyimg, string fidlist, int tabid, TopicTimeType timetype)
        {
            //防止恶意行为
            cachetime = cachetime == 0 ? 1 : cachetime;
            count     = count > 50 ? 50 : (count < 1 ? 1 : count);

            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            DataTable             dt    = cache.RetrieveObject("/Forum/ForumHostList-" + tabid) as DataTable;

            if (dt == null)
            {
                if (fidlist == "")
                {
                    fidlist = Forums.GetVisibleForum();
                }

                if (Focuses.GetFieldName(ordertype) == "digest")
                {
                    digest = true;
                }

                dt = Discuz.Data.Topics.GetTopicList(count, -1, fid, "", Focuses.GetStartDate(timetype), Focuses.GetFieldName(ordertype), fidlist, digest, onlyimg);

                cache.AddObject("/Forum/ForumHostList-" + tabid, dt, cachetime);
            }
            return(dt);
        }