Esempio n. 1
0
        /// <summary>获取帖子列表,带缓存</summary>
        /// <param name="inf"></param>
        /// <returns></returns>
        public static EntityList <Topic> GetTopicList(ForumHotItemInfo inf)
        {
            if (inf.Cachetimeout < 60)
            {
                inf.Cachetimeout = 60;
            }
            if (inf.Dataitemcount > 50)
            {
                inf.Dataitemcount = 50;
            }
            else if (inf.Dataitemcount < 1)
            {
                inf.Dataitemcount = 1;
            }

            var list = XCache.Current.RetrieveObject("/Forum/ForumHostList-" + inf.Id) as EntityList <Topic>;

            if (list == null)
            {
                string visibleFidList = string.IsNullOrEmpty(inf.Forumlist) ? Forums.GetVisibleForum() : inf.Forumlist;
                //string fieldName = Focuses.GetFieldName((TopicOrderType)Enum.Parse(typeof(TopicOrderType), inf.Sorttype));
                var type = Focuses.GetStartDate((TopicTimeType)Enum.Parse(typeof(TopicTimeType), inf.Datatimetype));
                list = Topic.GetFocusTopicList(inf.Dataitemcount, -1, 0, "", type, inf.Sorttype, visibleFidList, inf.Sorttype == "digest", false);
                if (inf.Cachetimeout > 0)
                {
                    XCache.Add("/Forum/ForumHostList-" + inf.Id, list, inf.Cachetimeout);
                }
            }
            return(list);
        }
Esempio n. 2
0
        //public static EntityList<Topic> GetDigestTopicList(int count)
        //{
        //	return Focuses.GetTopicList(count, -1, 0, "", TopicTimeType.All, TopicOrderType.ID, true, 20, false, "");
        //}
        //public static EntityList<Topic> GetDigestTopicList(int count, int fid, TopicTimeType timetype, TopicOrderType ordertype)
        //{
        //	return Focuses.GetTopicList(count, -1, fid, "", timetype, ordertype, true, 20, false, "");
        //}
        //public static EntityList<Topic> GetHotTopicList(int count, int views)
        //{
        //	return Focuses.GetTopicList(count, views, 0, "", TopicTimeType.All, TopicOrderType.ID, false, 20, false, "");
        //}
        //public static EntityList<Topic> GetHotTopicList(int count, int views, int fid, TopicTimeType timetype, TopicOrderType ordertype)
        //{
        //	return Focuses.GetTopicList(count, views, fid, "", timetype, ordertype, false, 20, false, "");
        //}
        //public static EntityList<Topic> GetRecentTopicList(int count)
        //{
        //	return Focuses.GetTopicList(count, -1, 0, "", TopicTimeType.All, TopicOrderType.ID, false, 20, false, "");
        //}
        //public static EntityList<Topic> GetTopicList(int count, int views, int fid, string typeIdList, TopicTimeType timetype, TopicOrderType ordertype, bool isdigest, int cachetime, bool onlyimg)
        //{
        //	return Focuses.GetTopicList(count, views, fid, typeIdList, timetype, ordertype, isdigest, cachetime, onlyimg, "");
        //}

        public static EntityList <Topic> GetTopicList(int count, int views, int fid, string typeIdList, TopicTimeType timetype, Int32 ordertype, bool isdigest, int cachetime, bool onlyimg, string fidlist)
        {
            if (cachetime == 0)
            {
                cachetime = 1;
            }
            if (count > 50)
            {
                count = 50;
            }
            if (count < 1)
            {
                count = 1;
            }
            var order = Topic._FocusOrder[ordertype];

            string xpath        = string.Format("/Forum/TopicList-{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}", count, views, fid, timetype, order, isdigest, onlyimg, typeIdList.Replace(',', 'd'));
            var    cacheService = XCache.Current;

            var dataTable = cacheService.RetrieveObject(xpath) as EntityList <Topic>;

            if (dataTable == null)
            {
                if (String.IsNullOrEmpty(fidlist))
                {
                    fidlist = Forums.GetVisibleForum();
                }

                dataTable = Topic.GetFocusTopicList(count, views, fid, typeIdList, Focuses.GetStartDate(timetype), order, fidlist, isdigest, onlyimg);
                XCache.Add(xpath, dataTable, cachetime * 60);
            }
            return(dataTable);
        }