/// <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); }
/// <summary> /// 获取字段名 /// </summary> /// <param name="type">排序类型</param> /// <returns></returns> public static string GetFieldName(TopicOrderType type) { switch (type) { case TopicOrderType.Views: return("views"); case TopicOrderType.LastPost: return("lastpost"); case TopicOrderType.PostDateTime: return("postdatetime"); case TopicOrderType.Digest: return("digest"); case TopicOrderType.Replies: return("replies"); case TopicOrderType.Rate: return("rate"); default: return("tid"); } }
//重新设置指定版块精华主题列表[暂未调用] public static void ReSetDigestTopicList(int count, int fid, TopicTimeType timetype, TopicOrderType ordertype) { ReSetFocusTopicList(count, -1, fid, timetype, ordertype, true); }
/// <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 views, int fid, string typeIdList, TopicTimeType timetype, TopicOrderType ordertype, bool isdigest, int cachetime, bool onlyimg) { //防止恶意行为 if (cachetime == 0) cachetime = 1; if (count > 50) count = 50; if (count < 1) count = 1; string cacheKey = string.Format("/Forum/TopicList-{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}", count, views, fid, timetype, ordertype, isdigest, onlyimg, typeIdList.Replace(',', 'd')); Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService(); DataTable dt = cache.RetrieveObject(cacheKey) as DataTable; if (dt == null) { dt = Discuz.Data.Topics.GetTopicList(count, views, fid, typeIdList, GetStartDate(timetype), GetFieldName(ordertype), Forums.GetVisibleForum(), isdigest, onlyimg); //声明新的缓存策略接口 Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy(); ics.TimeOut = cachetime * 60; cache.LoadCacheStrategy(ics); cache.AddObject(cacheKey, dt); cache.LoadDefaultCacheStrategy(); } return dt; }
/// <summary> /// 获得热门主题列表 /// </summary> /// <param name="count">获取数</param> /// <param name="views">查看数</param> /// <param name="fid">版块id</param> /// <param name="timetype">时间类型</param> /// <param name="ordertype">排序类型</param> /// <returns></returns> public static DataTable GetHotTopicList(int count, int views, int fid, TopicTimeType timetype, TopicOrderType ordertype) { return GetTopicList(count, views, fid, "", timetype, ordertype, false, 20, false); }
/// <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; }
/// <summary> /// 获得热门主题列表 /// </summary> /// <param name="count">获取数</param> /// <param name="views">查看数</param> /// <param name="fid">版块id</param> /// <param name="timetype">时间类型</param> /// <param name="ordertype">排序类型</param> /// <returns></returns> public static DataTable GetHotTopicList(int count, int views, int fid, TopicTimeType timetype, TopicOrderType ordertype) { return(GetTopicList(count, views, fid, "", timetype, ordertype, false, 20, false, "")); }
/// <summary> /// 获取论坛主题列表 /// </summary> /// <param name="count">主题数</param> /// <param name="views">浏览量</param> /// <param name="forumid">版块ID</param> /// <param name="timetype">时间类型</param> /// <param name="ordertype">排序字段</param> /// <param name="isdigest">是否精化</param> /// <param name="onlyimg">是否包含附件</param> /// <returns></returns> public DataTable GetForumTopicList(int count, int views, int forumid, TopicTimeType timeType, TopicOrderType orderType, bool isDigest, bool onlyImg) { return Focuses.GetTopicList(count, views, forumid, "", timeType, orderType, isDigest, 5, onlyImg,""); }
//重新设置指定版块热帖主题列表[暂未调用] public static void ReSetHotTopicList(int count, int views, int fid, TopicTimeType timetype, TopicOrderType ordertype) { ReSetFocusTopicList(count, views, fid, timetype, ordertype, false); }
/// <summary> /// 获取论坛主题列表 /// </summary> /// <param name="count">主题数</param> /// <param name="views">浏览量</param> /// <param name="forumid">版块ID</param> /// <param name="timetype">时间类型</param> /// <param name="ordertype">排序字段</param> /// <param name="isdigest">是否精化</param> /// <param name="onlyimg">是否包含附件</param> /// <returns></returns> public DataTable GetForumTopicList(int count, int views, int forumid, TopicTimeType timetype, TopicOrderType ordertype, bool isdigest, bool onlyimg) { return(Focuses.GetTopicList(count, views, forumid, timetype, ordertype, isdigest, 5, onlyimg)); }
/// <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 views, int fid, string typeIdList, TopicTimeType timetype, TopicOrderType ordertype, bool isdigest, int cachetime, bool onlyimg) { return GetTopicList(count, views, fid, typeIdList, timetype, ordertype, isdigest, cachetime, onlyimg, ""); }
private static void ReSetFocusTopicList(int count, int views, int fid, TopicTimeType timetype, TopicOrderType ordertype, bool isdigest) { string cacheKey = "/TopicList-{0}-{1}-{2}-{3}-{4}-{5}"; cacheKey = string.Format(cacheKey, count, views, fid, timetype, ordertype, isdigest ); Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService(); cache.RemoveObject(cacheKey); }
/// <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 views, int fid, TopicTimeType timetype, TopicOrderType ordertype, bool isdigest, int cachetime, bool onlyimg) { //防止恶意行为 if (cachetime == 0) { cachetime = 1; } if (count > 50) { count = 50; } if (count < 1) { count = 1; } string cacheKey = "/TopicList-{0}-{1}-{2}-{3}-{4}-{5}-{6}"; cacheKey = string.Format(cacheKey, count, views, fid, timetype, ordertype, isdigest, onlyimg ); Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService(); DataTable dt = cache.RetrieveObject(cacheKey) as DataTable; if (dt == null) { dt = DatabaseProvider.GetInstance().GetFocusTopicList(count, views, fid, GetStartDate(timetype), GetFieldName(ordertype), Forums.GetVisibleForum(), isdigest, onlyimg); //声明新的缓存策略接口 Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy(); ics.TimeOut = cachetime; cache.LoadCacheStrategy(ics); cache.AddObject(cacheKey, dt); cache.LoadDefaultCacheStrategy(); } return(dt); }
private static void ReSetFocusTopicList(int count, int views, int fid, TopicTimeType timetype, TopicOrderType ordertype, bool isdigest) { string cacheKey = string.Format(CacheKeys.FORUM_TOPIC_LIST_FORMAT, count, views, fid, timetype, ordertype, isdigest ); RemoveObject(cacheKey); }
public EntityList <Topic> GetForumTopicList(int count, int views, int forumid, TopicTimeType timeType, TopicOrderType orderType, bool isDigest, bool onlyImg) { return(Focuses.GetTopicList(count, views, forumid, "", timeType, orderType, isDigest, 5, onlyImg, "")); }
/// <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 views, int fid, string typeIdList, TopicTimeType timetype, TopicOrderType ordertype, bool isdigest, int cachetime, bool onlyimg, string fidlist) { //防止恶意行为 if (cachetime == 0) { cachetime = 1; } if (count > 50) { count = 50; } if (count < 1) { count = 1; } string cacheKey = string.Format("/Forum/TopicList-{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}", count, views, fid, timetype, ordertype, isdigest, onlyimg, typeIdList.Replace(',', 'd')); Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService(); DataTable dt = cache.RetrieveObject(cacheKey) as DataTable; if (dt == null) { if (fidlist == "") { fidlist = Forums.GetVisibleForum(); } //dt = Discuz.Data.Topics.GetTopicList(count, views, fid, typeIdList, GetStartDate(timetype), GetFieldName(ordertype), Forums.GetVisibleForum(), isdigest, onlyimg); dt = Discuz.Data.Topics.GetTopicList(count, views, fid, typeIdList, GetStartDate(timetype), GetFieldName(ordertype), fidlist, isdigest, onlyimg); //声明新的缓存策略接口 //Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy(); //ics.TimeOut = cachetime * 60; //cache.LoadCacheStrategy(ics); cache.AddObject(cacheKey, dt, cachetime * 60); //cache.LoadDefaultCacheStrategy(); } return(dt); }
/// <summary> /// 获取字段名 /// </summary> /// <param name="type">排序类型</param> /// <returns></returns> public static string GetFieldName(TopicOrderType type) { switch (type) { case TopicOrderType.Views: return "views"; case TopicOrderType.LastPost: return "lastpost"; case TopicOrderType.PostDateTime: return "postdatetime"; case TopicOrderType.Digest: return "digest"; case TopicOrderType.Replies: return "replies"; case TopicOrderType.Rate: return "rate"; default: return "tid"; } }
/// <summary> /// 获取精华主题列表 /// </summary> /// <param name="count">获取数</param> /// <param name="fid">版块id</param> /// <param name="timetype">时间类型</param> /// <param name="ordertype">排序类型</param> /// <returns></returns> public static DataTable GetDigestTopicList(int count, int fid, TopicTimeType timetype, TopicOrderType ordertype) { return(GetTopicList(count, -1, fid, "", timetype, ordertype, true, 20, false, "")); }
/// <summary> /// 获取精华主题列表 /// </summary> /// <param name="count">获取数</param> /// <param name="fid">版块id</param> /// <param name="timetype">时间类型</param> /// <param name="ordertype">排序类型</param> /// <returns></returns> public static DataTable GetDigestTopicList(int count, int fid, TopicTimeType timetype, TopicOrderType ordertype) { return GetTopicList(count, -1, fid, "", timetype, ordertype, true, 20, false); }
/// <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 views, int fid, string typeIdList, TopicTimeType timetype, TopicOrderType ordertype, bool isdigest, int cachetime, bool onlyimg) { return(GetTopicList(count, views, fid, typeIdList, timetype, ordertype, isdigest, cachetime, onlyimg, "")); }