예제 #1
0
        /// <summary>
        /// 判断页面是否需要游客缓存页
        /// </summary>
        /// <param name="pagename"></param>
        /// <returns>不需要返回false</returns>
        private bool GetUserCachePage(string pagename)
        {
            switch (pagename)
            {
            case "website.aspx":
                isguestcachepage = GetCachePage(pagename);
                break;

            case "forumindex.aspx":
                isguestcachepage = GetCachePage(pagename);
                break;

            case "spaceindex.aspx":
                isguestcachepage = GetCachePage(pagename);
                break;

            case "albumindex.aspx":
                isguestcachepage = GetCachePage(pagename);
                break;

            case "showtopic.aspx":
            {
                int pageid  = DNTRequest.GetQueryInt("page", 1);
                int topicid = DNTRequest.GetQueryInt("topicid", 0);
                //参数数目为2或0表示当前页面可能为第一页帖子列表
                if ((DNTRequest.GetParamCount() == 2 || DNTRequest.GetParamCount() == 3) && topicid > 0 && ForumUtils.ResponseShowTopicCacheFile(topicid, pageid))
                {
                    TopicStats.Track(topicid, 1);
                    return(true);
                }
                break;
            }

            case "showforum.aspx":
            {
                int pageid  = DNTRequest.GetQueryInt("page", 1);
                int forumid = DNTRequest.GetQueryInt("forumid", 0);
                //参数数目为2或0表示当前页面可能为第一页帖子列表
                if ((DNTRequest.GetParamCount() == 2 || DNTRequest.GetParamCount() == 3) && forumid > 0 && ForumUtils.ResponseShowForumCacheFile(forumid, pageid))
                {
                    return(true);
                }

                break;
            }

            default:
                break;
            }
            return(false);
        }
예제 #2
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);
                    //参数数目为2或0表示当前页面可能为第一页帖子列表
                    if ((DNTRequest.GetParamCount() == 2 || DNTRequest.GetParamCount() == 3) && topicid > 0 && templateid == config.Templateid)
                    {
                        ForumUtils.CreateShowTopicCacheFile(topicid, pageid, templateBuilder.ToString());
                    }
                    break;
                }

                case "showforum.aspx":
                {
                    int forumid = DNTRequest.GetQueryInt("forumid", 0);
                    int pageid  = DNTRequest.GetQueryInt("page", 1);
                    //参数数目为2或0表示当前页面可能为第一页帖子列表
                    if ((DNTRequest.GetParamCount() == 2 || DNTRequest.GetParamCount() == 3) && forumid > 0 && templateid == config.Templateid)
                    {
                        ForumUtils.CreateShowForumCacheFile(forumid, pageid, 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);
        }
예제 #3
0
        /// <summary>
        /// OnUnload事件处理
        /// </summary>
        /// <param name="e"></param>
        protected override void OnActionExecuted(ActionExecutedContext filterContext)//viewbag只在OnActionExecuted/ing中才有效,所以不用resultExecuted了
        {
            ViewBag.Infloat        = infloat;
            ViewBag.Config         = config;
            ViewBag.pagename       = pagename;
            ViewBag.meta           = meta;
            ViewBag.isnarrowpage   = isnarrowpage;
            ViewBag.link           = link;
            ViewBag.forumpath      = forumpath;
            ViewBag.jsdir          = jsdir;
            ViewBag.imagedir       = imagedir;
            ViewBag.rooturl        = rooturl;
            ViewBag.cssdir         = cssdir;
            ViewBag.script         = script;
            ViewBag.headerad       = headerad;
            ViewBag.userid         = userid;
            ViewBag.isopenconnect  = isopenconnect;
            ViewBag.isLoginCode    = isLoginCode;
            ViewBag.isbindconnect  = isbindconnect;
            ViewBag.username       = username;
            ViewBag.oluserinfo     = oluserinfo;
            ViewBag.useradminid    = useradminid;
            ViewBag.userinfotips   = userinfotips;
            ViewBag.mainnavigation = mainnavigation;



            m_processtime = DateTime.Now.Subtract(m_starttick).TotalMilliseconds / 1000;
            querycount    = Discuz.Data.DbHelper.QueryCount;
            Discuz.Data.DbHelper.QueryCount = 0;

            ViewBag.Processtime = Processtime;
            ViewBag.Querycount  = querycount;

            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);
                    //参数数目为2或0表示当前页面可能为第一页帖子列表
                    if ((DNTRequest.GetParamCount() == 2 || DNTRequest.GetParamCount() == 3) && topicid > 0 && templateid == config.Templateid)
                    {
                        ForumUtils.CreateShowTopicCacheFile(topicid, pageid, templateBuilder.ToString());
                    }
                    break;
                }

                case "showforum.aspx":
                {
                    int forumid = DNTRequest.GetQueryInt("forumid", 0);
                    int pageid  = DNTRequest.GetQueryInt("page", 1);
                    //参数数目为2或0表示当前页面可能为第一页帖子列表
                    if ((DNTRequest.GetParamCount() == 2 || DNTRequest.GetParamCount() == 3) && forumid > 0 && templateid == config.Templateid)
                    {
                        ForumUtils.CreateShowForumCacheFile(forumid, pageid, templateBuilder.ToString());
                    }
                    break;
                }

                default:
                    //
                    break;
                }
            }
#if DEBUG
            else
            {
                querydetail = Discuz.Data.DbHelper.QueryDetail;
                Discuz.Data.DbHelper.QueryDetail = "";
                ViewBag.DebugHtml = "<div>注意: 以下为数据查询分析工具,正式站点使用请使用官方发布版本或自行Release编译。</div>" + querydetail;
            }
#endif
            base.OnActionExecuted(filterContext);
        }