/// <summary> /// 获取开始日期 /// </summary> /// <param name="type">日期类型</param> /// <returns></returns> public static string GetStartDate(TopicTimeType type) { DateTime dtnow = DateTime.Now; switch (type) { case TopicTimeType.Day: return(dtnow.AddDays(-1).ToString()); case TopicTimeType.ThreeDays: return(dtnow.AddDays(-3).ToString()); case TopicTimeType.FiveDays: return(dtnow.AddDays(-5).ToString()); case TopicTimeType.Week: return(dtnow.AddDays(-7).ToString()); case TopicTimeType.Month: return(dtnow.AddDays(-30).ToString()); case TopicTimeType.SixMonth: return(dtnow.AddMonths(-6).ToString()); case TopicTimeType.Year: return(dtnow.AddYears(-1).ToString()); default: return("1754-1-1"); } }
//public static DataTable GetUpdatedSpaces(int count, int cachetime) //{ // if (cachetime == 0) // { // cachetime = 1; // } // if (count > 50) // { // count = 50; // } // if (count < 1) // { // count = 1; // } // string xpath = "/Space/UpdatedSpace-" + count.ToString(); // var cacheService = DNTCache.Current; // DataTable dataTable = cacheService.RetrieveObject(xpath) as DataTable; // if (dataTable == null) // { // dataTable = SpacePluginProvider.GetInstance().GetWebSiteAggRecentUpdateSpaceList(count); // XCache.Add(xpath, dataTable, cachetime * 60); // } // return dataTable; //} //public static DataTable GetNewSpacePosts(int count, int cachetime) //{ // if (cachetime == 0) // { // cachetime = 1; // } // if (count > 50) // { // count = 50; // } // if (count < 1) // { // count = 1; // } // string xpath = "/Space/NewSpacePosts-" + count.ToString(); // var cacheService = DNTCache.Current; // DataTable dataTable = cacheService.RetrieveObject(xpath) as DataTable; // if (dataTable == null) // { // dataTable = SpacePluginProvider.GetInstance().GetWebSiteAggSpacePostList(count); // XCache.Add(xpath, dataTable, cachetime * 60); // } // return dataTable; //} public static DateTime GetStartDate(TopicTimeType type) { var now = DateTime.Now.Date; switch (type) { case TopicTimeType.Day: return(now.AddDays(-1.0)); case TopicTimeType.ThreeDays: return(now.AddDays(-3.0)); case TopicTimeType.FiveDays: return(now.AddDays(-5.0)); case TopicTimeType.Week: return(now.AddDays(-7.0)); case TopicTimeType.Month: return(now.AddDays(-30.0)); case TopicTimeType.SixMonth: return(now.AddMonths(-6)); case TopicTimeType.Year: return(now.AddYears(-1)); default: return(new DateTime(1754, 1, 1)); } }
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); }
private static void ReSetFocusTopicList(int count, int views, int fid, TopicTimeType timetype, String ordertype, bool isdigest) { string key = string.Format(CacheKeys.FORUM_TOPIC_LIST_FORMAT, new object[] { count, views, fid, timetype, ordertype, isdigest }); Caches.RemoveObject(key); }
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); }
//重新设置指定版块热帖主题列表[暂未调用] public static void ReSetHotTopicList(int count, int views, int fid, TopicTimeType timetype, TopicOrderType ordertype) { ReSetFocusTopicList(count, views, fid, timetype, ordertype, false); }
//重新设置指定版块精华主题列表[暂未调用] 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 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, ""); }
/// <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="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); }
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="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="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="type">日期类型</param> /// <returns></returns> public static string GetStartDate(TopicTimeType type) { DateTime dtnow = DateTime.Now; switch (type) { case TopicTimeType.Day: return dtnow.AddDays(-1).ToString(); case TopicTimeType.Week: return dtnow.AddDays(-7).ToString(); case TopicTimeType.Month: return dtnow.AddDays(-30).ToString(); case TopicTimeType.SixMonth: return dtnow.AddMonths(-6).ToString(); case TopicTimeType.Year: return dtnow.AddYears(-1).ToString(); default: return "1754-1-1"; } }
/// <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="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, "")); }
//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); }