Esempio n. 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(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);
        }
Esempio n. 2
0
        /// <summary>
        /// 得到热门版块列表
        /// </summary>
        /// <returns></returns>
        public DataTable GetHotForumList(int topnumber)
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();

            DataTable __forumList = cache.RetrieveObject("/Aggregation/HotForumList") as DataTable;

            if (__forumList == null)
            {
                __forumList = DatabaseProvider.GetInstance().GetWebSiteAggHotForumList(topnumber <= 0 ? 10 : topnumber);

                //声明新的缓存策略接口
                Discuz.Cache.ICacheStrategy ics = new Discuz.Forum.ForumCacheStrategy();
                ics.TimeOut = 5;
                cache.LoadCacheStrategy(ics);
                cache.AddObject("/Aggregation/HotForumList", __forumList);
                cache.LoadDefaultCacheStrategy();
            }
            return(__forumList);
        }
Esempio n. 3
0
        /// <summary>
        /// 获得干扰码字符串
        /// </summary>
        /// <returns>干扰码字符串</returns>
        public static string GetJammer()
        {
            ///干扰码组成(10 位随机字符 + 网站域名 + 10位随机字符)
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            string str = cache.RetrieveObject("/UI/Jammer") as string;

            if (str == null)
            {
                Random        rdm1 = new Random(unchecked ((int)DateTime.Now.Ticks));
                StringBuilder sb   = new StringBuilder();
                for (int i = 0; i < 10; i++)
                {
                    sb.Append(Convert.ToChar(rdm1.Next(1, 256)));
                }
                sb.Append(HttpContext.Current.Request.Url.Authority);
                for (int i = 0; i < 10; i++)
                {
                    sb.Append(Convert.ToChar(rdm1.Next(1, 256)));
                }
                str = sb.ToString();
                str = Utils.HtmlEncode(str);

                if (sb.Length > 0)
                {
                    sb.Remove(0, sb.Length);
                }

                sb.Append("<span style=\"display:none;font-size:0px\">");
                sb.Append(str);
                sb.Append("</span>");
                str = sb.ToString();
                Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy();
                ics.TimeOut = 720;
                cache.LoadCacheStrategy(ics);
                cache.AddObject("/UI/Jammer", str);
                cache.LoadDefaultCacheStrategy();

                //cache.AddObject("/UI/Jammer", str);
            }

            return(str);
        }
Esempio n. 4
0
        /// <summary>
        /// 热门标签
        /// </summary>
        /// <param name="count">标签数</param>
        /// <returns>TagInfo</returns>
        public static TagInfo[] GetCachedHotForumTags(int count)
        {
            TagInfo[] tags;
            DNTCache  cache = DNTCache.GetCacheService();

            tags = cache.RetrieveObject("/Tag/Hot-" + count) as TagInfo[];
            if (tags != null)
            {
                return(tags);
            }

#if NET1
            System.Collections.ArrayList tagList = new System.Collections.ArrayList();
#else
            List <TagInfo> tagList = new List <TagInfo>();
#endif


            IDataReader reader = DatabaseProvider.GetInstance().GetHotTagsListForForum(count);

            while (reader.Read())
            {
                tagList.Add(Tags.LoadSingleTagInfo(reader));
            }
            reader.Close();
#if NET1
            tags = (TagInfo[])tagList.ToArray(typeof(TagInfo));
#else
            tags = tagList.ToArray();
#endif


            Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy();
            ics.TimeOut = 360;
            cache.LoadCacheStrategy(ics);
            cache.AddObject("/Tag/Hot-" + count, tags);
            cache.LoadDefaultCacheStrategy();

            return(tags);
        }
Esempio n. 5
0
 /// <summary>
 /// 热门标签
 /// </summary>
 /// <param name="count">标签数</param>
 /// <returns>TagInfo</returns>
 public static TagInfo[] GetCachedHotForumTags(int count)
 {
     TagInfo[] tags;
     DNTCache cache = DNTCache.GetCacheService();
     tags = cache.RetrieveObject("/Forum/Tag/Hot-" + count) as TagInfo[];
     if (tags == null)
     {
         tags = Discuz.Data.ForumTags.GetCachedHotForumTags(count);
         Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy();
         ics.TimeOut = 360;
         cache.LoadCacheStrategy(ics);
         cache.AddObject("/Forum/Tag/Hot-" + count, tags);
         cache.LoadDefaultCacheStrategy();
     }
     return tags;
 }
Esempio n. 6
0
        /// <summary>
        /// 获取指定条件的帖子DataSet
        /// </summary>
        /// <param name="_postpramsinfo">参数列表</param>
        /// <returns>指定条件的帖子DataSet</returns>
        public static List<ShowtopicPagePostInfo> GetPostList(PostpramsInfo postpramsInfo, out List<ShowtopicPageAttachmentInfo> attachList, bool isModer)
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            List<ShowtopicPagePostInfo> postList = null;

            MemCachedConfigInfo mcci = MemCachedConfigs.GetConfig();

            //只有在应用memcached的情况下才可以使用主题缓存
            if (mcci != null && mcci.ApplyMemCached && postpramsInfo.Pageindex <= cachedPageNumber)
            {
                postList = cache.RetrieveObject("/Forum/ShowTopic_" + postpramsInfo.Tid + "/Page_" + postpramsInfo.Pageindex) as List<ShowtopicPagePostInfo>;
                postpramsInfo.Pagesize = GeneralConfigs.GetConfig().Ppp;//如果开启时,则不再使用用户自己的帖子分页设置
            }

            attachList = new List<ShowtopicPageAttachmentInfo>();
            if (postList == null || postList.Count == 0)
            {
                postList = Data.Posts.GetPostList(postpramsInfo);
                int adCount = Advertisements.GetInPostAdCount("", postpramsInfo.Fid);

                foreach (ShowtopicPagePostInfo postInfo in postList)
                {
                    LoadExtraPostInfo(postInfo, adCount);
                }

                if (postList.Count == 0)
                    return postList;

                //当存在帖子信息时则缓存相应数据
                if (mcci != null && mcci.ApplyMemCached && postpramsInfo.Pageindex <= cachedPageNumber)
                {
                    Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy();
                    ics.TimeOut = 60;
                    cache.LoadCacheStrategy(ics);
                    cache.AddObject("/Forum/ShowTopic_" + postpramsInfo.Tid + "/Page_" + postpramsInfo.Pageindex, postList);
                    cache.LoadDefaultCacheStrategy();
                }
            }
            //进行相应帖子信息设置
            string pidList = GetPidListWithAttach(postList);
            attachList = Attachments.GetAttachmentList(postpramsInfo, pidList);
            ParsePostListExtraInfo(postpramsInfo, attachList, isModer, postList);

            return postList;
        }
Esempio n. 7
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 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;
        }
Esempio n. 8
0
        public static DataTable GetNewSpacePosts(int count, int cachetime)
        {
            //防止恶意行为
            if (cachetime == 0)
                cachetime = 1;

            if (count > 50)
                count = 50;

            if (count < 1)
                count = 1;

            string cacheKey = "/Space/NewSpacePosts-" + count.ToString();
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            DataTable dt = cache.RetrieveObject(cacheKey) as DataTable;

            if (dt == null)
            {
                dt = SpacePluginProvider.GetInstance().GetWebSiteAggSpacePostList(count);

                //声明新的缓存策略接口
                Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy();
                ics.TimeOut = cachetime * 60;
                cache.LoadCacheStrategy(ics);
                cache.AddObject(cacheKey, dt);
                cache.LoadDefaultCacheStrategy();
            }
            return dt;
        }
Esempio n. 9
0
        /// <summary>
        /// 得到热门版块列表
        /// </summary>
        /// <returns></returns>
        public DataTable GetHotForumList(int topNumber)
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();

            DataTable forumList = cache.RetrieveObject("/Aggregation/HotForumList") as DataTable;
            if (forumList == null)
            {
                forumList = Discuz.Data.DatabaseProvider.GetInstance().GetWebSiteAggHotForumList(topNumber <= 0 ? 10 : topNumber);

                //声明新的缓存策略接口
                Discuz.Cache.ICacheStrategy ics = new Discuz.Forum.ForumCacheStrategy();
                ics.TimeOut = 5;
                cache.LoadCacheStrategy(ics);
                cache.AddObject("/Aggregation/HotForumList", forumList);
                cache.LoadDefaultCacheStrategy();
            }
            return forumList;
        }
Esempio n. 10
0
        /// <summary>
        /// 返回全部版块列表并缓存
        /// </summary>
        /// <returns>板块信息数组</returns>
        public static ForumInfo[] GetForumList()
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();

            ForumInfo[] forumlist = cache.RetrieveObject("/ForumList") as ForumInfo[];
            if (forumlist == null)
            {
                DataTable dt = DatabaseProvider.GetInstance().GetForumsTable();
                if (dt.Rows.Count > 0)
                {
                    forumlist = new ForumInfo[dt.Rows.Count];
                    int i = 0;
                    foreach (DataRow dr in dt.Rows)
                    {
                        forumlist[i] = new ForumInfo();
                        forumlist[i].Fid = Int32.Parse(dr["fid"].ToString());
                        forumlist[i].Parentid = Int16.Parse(dr["parentid"].ToString());
                        forumlist[i].Layer = Int16.Parse(dr["layer"].ToString());
                        forumlist[i].Name = dr["name"].ToString();
                        forumlist[i].Pathlist = dr["pathlist"].ToString();
                        forumlist[i].Parentidlist = dr["parentidlist"].ToString();
                        forumlist[i].Subforumcount = Int32.Parse(dr["subforumcount"].ToString());
                        forumlist[i].Status = Int32.Parse(dr["status"].ToString());
                        forumlist[i].Colcount = Int16.Parse(dr["colcount"].ToString());
                        forumlist[i].Displayorder = Int32.Parse(dr["displayorder"].ToString());
                        forumlist[i].Templateid = Int16.Parse(dr["templateid"].ToString());
                        forumlist[i].Topics = Int32.Parse(dr["topics"].ToString());
                        forumlist[i].CurrentTopics = Int32.Parse(dr["curtopics"].ToString());
                        forumlist[i].Posts = Int32.Parse(dr["posts"].ToString());

                        //当前版块的最后发帖日期为空,则表示今日发帖数为0 
                        if (dr["lastpost"].ToString().Equals(""))
                        {
                            dr["todayposts"] = 0;
                        }
                        else
                        {
                            //当系统日期与最发发帖日期不同时,则表示今日发帖数为0 
                            if (Convert.ToDateTime(dr["lastpost"]).ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd"))
                            {
                                dr["todayposts"] = 0;
                            }
                        }

                        forumlist[i].Todayposts = Int32.Parse(dr["todayposts"].ToString());
                        forumlist[i].Lastpost = dr["lastpost"].ToString();
                        forumlist[i].Lastposter = dr["lastposter"].ToString();
                        forumlist[i].Lastposterid = Int32.Parse(dr["lastposterid"].ToString());
                        forumlist[i].Lasttitle = dr["lasttitle"].ToString();
                        forumlist[i].Allowsmilies = Int32.Parse(dr["allowsmilies"].ToString());
                        forumlist[i].Allowrss = Int32.Parse(dr["allowrss"].ToString());
                        forumlist[i].Allowhtml = Int32.Parse(dr["allowhtml"].ToString());
                        forumlist[i].Allowbbcode = Int32.Parse(dr["allowbbcode"].ToString());
                        forumlist[i].Allowimgcode = Int32.Parse(dr["allowimgcode"].ToString());
                        forumlist[i].Allowblog = Int32.Parse(dr["allowblog"].ToString());
                        forumlist[i].Istrade = Int32.Parse(dr["istrade"].ToString());
                        forumlist[i].Allowpostspecial = Int32.Parse(dr["allowpostspecial"].ToString());
                        forumlist[i].Allowspecialonly = Int32.Parse(dr["allowspecialonly"].ToString());
                        forumlist[i].Alloweditrules = Int32.Parse(dr["alloweditrules"].ToString());
                        forumlist[i].Allowthumbnail = Int32.Parse(dr["allowthumbnail"].ToString());
                        forumlist[i].Allowtag = Int32.Parse(dr["allowtag"].ToString());
                        forumlist[i].Recyclebin = Int32.Parse(dr["recyclebin"].ToString());
                        forumlist[i].Modnewposts = Int32.Parse(dr["modnewposts"].ToString());
                        forumlist[i].Jammer = Int32.Parse(dr["jammer"].ToString());
                        forumlist[i].Disablewatermark = Int32.Parse(dr["disablewatermark"].ToString());
                        forumlist[i].Inheritedmod = Int32.Parse(dr["inheritedmod"].ToString());
                        forumlist[i].Autoclose = Int16.Parse(dr["autoclose"].ToString());

                        forumlist[i].Description = dr["description"].ToString();
                        forumlist[i].Password = dr["password"].ToString();
                        forumlist[i].Icon = dr["icon"].ToString();
                        forumlist[i].Postcredits = dr["postcredits"].ToString();
                        forumlist[i].Replycredits = dr["replycredits"].ToString();
                        forumlist[i].Redirect = dr["redirect"].ToString();
                        forumlist[i].Attachextensions = dr["attachextensions"].ToString();
                        forumlist[i].Moderators = dr["moderators"].ToString();
                        forumlist[i].Rules = dr["rules"].ToString();
                        forumlist[i].Topictypes = dr["topictypes"].ToString();
                        forumlist[i].Viewperm = dr["viewperm"].ToString();
                        forumlist[i].Postperm = dr["postperm"].ToString();
                        forumlist[i].Replyperm = dr["replyperm"].ToString();
                        forumlist[i].Getattachperm = dr["getattachperm"].ToString();
                        forumlist[i].Postattachperm = dr["postattachperm"].ToString();
                        forumlist[i].Applytopictype = Int16.Parse(dr["applytopictype"] == DBNull.Value ? "0" : dr["applytopictype"].ToString());
                        forumlist[i].Postbytopictype = Int16.Parse(dr["postbytopictype"] == DBNull.Value ? "0" : dr["postbytopictype"].ToString());
                        forumlist[i].Viewbytopictype = Int16.Parse(dr["viewbytopictype"] == DBNull.Value ? "0" : dr["viewbytopictype"].ToString());
                        forumlist[i].Topictypeprefix = Int16.Parse(dr["topictypeprefix"] == DBNull.Value ? "0" : dr["topictypeprefix"].ToString());
                        forumlist[i].Permuserlist = dr["permuserlist"].ToString();
                        i++;
                    }

                    //声明新的缓存策略接口
                    Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy();
                    ics.TimeOut = 5;
                    cache.LoadCacheStrategy(ics);
                    cache.AddObject("/ForumList", forumlist);
                    cache.LoadDefaultCacheStrategy();
                }
            }

            return forumlist;
        }
Esempio n. 11
0
        /// <summary>
        /// 获得干扰码字符串
        /// </summary>
        /// <returns>干扰码字符串</returns>
        public static string GetJammer()
        {

            ///干扰码组成(10 位随机字符 + 网站域名 + 10位随机字符)
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            string str = cache.RetrieveObject("/UI/Jammer") as string;

            if (str == null)
            {
                Random rdm1 = new Random(unchecked((int)DateTime.Now.Ticks));
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < 10; i++)
                {
                    sb.Append(Convert.ToChar(rdm1.Next(1, 256)));
                }
                sb.Append(HttpContext.Current.Request.Url.Authority);
                for (int i = 0; i < 10; i++)
                {
                    sb.Append(Convert.ToChar(rdm1.Next(1, 256)));
                }
                str = sb.ToString();
                str = Utils.HtmlEncode(str);

                if (sb.Length > 0)
                {
                    sb.Remove(0, sb.Length);
                }

                sb.Append("<span style=\"display:none;font-size:0px\">");
                sb.Append(str);
                sb.Append("</span>");
                str = sb.ToString();
                Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy();
                ics.TimeOut = 720;
                cache.LoadCacheStrategy(ics);
                cache.AddObject("/UI/Jammer", str);
                cache.LoadDefaultCacheStrategy();

                //cache.AddObject("/UI/Jammer", str);
            }
         
            return str;
        }
Esempio n. 12
0
        /// <summary>
        /// OnUnload事件处理
        /// </summary>
        /// <param name="e"></param>
        protected override void OnUnload(EventArgs e)
        {

            if (isguestcachepage == 1)
            {
                switch (pagename)
                {
                    case "index.aspx":
                        Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
                        Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy();
                        ics.TimeOut = config.Guestcachepagetimeout;
                        cache.LoadCacheStrategy(ics);
                        string str = cache.RetrieveObject("/GuestCachePage/" + pagename) as string;
                        if (str == null && templateBuilder.Length > 1 && templateid == config.Templateid)
                        {
                            templateBuilder.Append("\r\n\r\n<!-- Discuz!NT CachedPage (Created: " + Utils.GetDateTime() + ") -->");
                            cache.AddObject("/GuestCachePage/" + pagename, templateBuilder.ToString());
                        }
                        cache.LoadDefaultCacheStrategy();

                        break;

                    case "showtopic.aspx":
                        int topicid = DNTRequest.GetQueryInt("topicid", 0);
                        int pageid = DNTRequest.GetQueryInt("page", 1);
                        if (pageid == 1 && DNTRequest.GetParamCount() == 2 && topicid > 0 && templateid == config.Templateid)
                        {
                            templateBuilder.Append("\r\n\r\n<!-- Discuz!NT CachedPage (Created: " + Utils.GetDateTime() + ") -->");
                            ForumUtils.CreateTopicCacheFile(topicid, templateBuilder.ToString());
                        }
                        break;
                    default:
                        //
                        break;
                }
            }

            base.OnUnload(e);
        }
Esempio n. 13
0
        public bool isSynchronizeSessionID = false;              // 是否获取中心 SessionID


        /// <summary>
        /// 获得游客缓存
        /// </summary>
        /// <param name="pagename"></param>
        /// <returns></returns>
        private int GetCachePage(string pagename)
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy();
            ics.TimeOut = config.Guestcachepagetimeout;
            cache.LoadCacheStrategy(ics);
            string str = cache.RetrieveObject("/GuestCachePage/" + pagename) as string;
            cache.LoadDefaultCacheStrategy();
            if (str != null && str.Length > 1)
            {
                //isguestcachepage = 2;
                System.Web.HttpContext.Current.Response.Write(str);
                System.Web.HttpContext.Current.Response.End();
                return 2;
            }
            return 1;
        }
Esempio n. 14
0
        /// <summary>
        /// 热门标签
        /// </summary>
        /// <param name="count">标签数</param>
        /// <returns>TagInfo</returns>
        public static TagInfo[] GetCachedHotForumTags(int count)
        {
            TagInfo[] tags;
            DNTCache cache = DNTCache.GetCacheService();
            tags = cache.RetrieveObject("/Tag/Hot-" + count) as TagInfo[];
            if (tags != null)
            {
                return tags;
            }

#if NET1
            System.Collections.ArrayList tagList = new System.Collections.ArrayList();
#else
            List<TagInfo> tagList = new List<TagInfo>();
#endif
            

            IDataReader reader = DatabaseProvider.GetInstance().GetHotTagsListForForum(count);

            while (reader.Read())
            {
                tagList.Add(Tags.LoadSingleTagInfo(reader));
            }
            reader.Close();
#if NET1
            tags = (TagInfo[])tagList.ToArray(typeof(TagInfo));
#else
            tags = tagList.ToArray();
#endif


            Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy();
            ics.TimeOut = 360;
            cache.LoadCacheStrategy(ics);
            cache.AddObject("/Tag/Hot-" + count, tags);
            cache.LoadDefaultCacheStrategy();    

            return tags;
        }
Esempio n. 15
0
        /// <summary>
        /// OnUnload事件处理
        /// </summary>
        /// <param name="e"></param>
        protected override void OnUnload(EventArgs e)
        {
            if (isguestcachepage == 1)
            {
                switch (pagename)
                {
                    case "index.aspx":
                        Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
                        Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy();
                        ics.TimeOut = config.Guestcachepagetimeout * 60;
                        cache.LoadCacheStrategy(ics);
                        string str = cache.RetrieveObject("/Forum/GuestCachePage/" + pagename) as string;
                        if (str == null && templateBuilder.Length > 1 && templateid == config.Templateid)
                        {
                            templateBuilder.Append("\r\n\r\n<!-- Discuz!NT CachedPage (Created: " + Utils.GetDateTime() + ") -->");
                            cache.AddObject("/Forum/GuestCachePage/" + pagename, templateBuilder.ToString());
                        }
                        cache.LoadDefaultCacheStrategy();

                        break;

                    case "showtopic.aspx":
                        int topicid = DNTRequest.GetQueryInt("topicid", 0);
                        int pageid = DNTRequest.GetQueryInt("page", 1);
                        if (pageid == 1 && DNTRequest.GetParamCount() == 2 && topicid > 0 && templateid == config.Templateid)
                        {
                            templateBuilder.Append("\r\n\r\n<!-- Discuz!NT CachedPage (Created: " + Utils.GetDateTime() + ") -->");
                            ForumUtils.CreateTopicCacheFile(topicid, templateBuilder.ToString());
                        }
                        break;
                    default:
                        //
                        break;
                }
            }

#if DEBUG
            else
            {
                System.Web.HttpContext.Current.Response.Clear();
                System.Web.HttpContext.Current.Response.Write(templateBuilder.Replace("</body>", "<div>注意: 以下为数据查询分析工具,正式站点使用请使用官方发布版本或自行Release编译。</div>" + querydetail + "</body>").ToString());
                System.Web.HttpContext.Current.Response.End();
            }
#endif



            base.OnUnload(e);
        }
Esempio n. 16
0
        /// <summary>
        /// 返回全部版块列表并缓存
        /// </summary>
        /// <returns>板块信息数组</returns>
        public static List<ForumInfo> GetForumList()
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            List<ForumInfo> forumList = cache.RetrieveObject("/Forum/ForumList") as List<ForumInfo>;

            if (forumList == null)
            {
                forumList = Discuz.Data.Forums.GetForumList();
                //声明新的缓存策略接口
                Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy();
                ics.TimeOut = 5;
                cache.LoadCacheStrategy(ics);
                cache.AddObject("/Forum/ForumList", forumList);
                cache.LoadDefaultCacheStrategy();
            }
            return forumList;
        }