⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 category.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.WebSite
{
    using PowerEasy.AccessManage;
    using PowerEasy.Components;
    using PowerEasy.Contents;
    using PowerEasy.Enumerations;
    using PowerEasy.Model.Contents;
    using PowerEasy.Model.TemplateProc;
    using PowerEasy.Templates;
    using PowerEasy.Web.UI;
    using System;
    using System.Collections.Specialized;
    using System.Text;
    using System.Web;
    using System.Web.UI;

    public class Category : DynamicPage
    {
        private NodeInfo nodeInfo;

        private void CheckIsAuthenticated()
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                DynamicPage.WriteErrMsg("该页需要登录才能查看!", base.BasePath + "User/Login.aspx");
            }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            int nodeId = BasePage.RequestInt32("id");
            if (nodeId > 0)
            {
                this.nodeInfo = Nodes.GetCacheNodeById(nodeId);
                if (!this.nodeInfo.IsNull)
                {
                    switch (this.nodeInfo.PurviewType)
                    {
                        case 0:
                            return;

                        case 1:
                            this.CheckIsAuthenticated();
                            return;

                        case 2:
                            this.CheckIsAuthenticated();
                            if (!UserPermissions.AccessCheck(OperateCode.NodeContentPreview, nodeId))
                            {
                                DynamicPage.WriteErrMsg("您没有查看该页的权限,请与网站管理员联系");
                            }
                            return;
                    }
                }
            }
            else
            {
                DynamicPage.WriteErrMsg("您访问的栏目不存在");
            }
        }

        protected override void Render(HtmlTextWriter writer)
        {
            if (!this.nodeInfo.IsNull)
            {
                int num = BasePage.RequestInt32("page", 0);
                string containChildTemplateFile = "";
                if (num >= 1)
                {
                    containChildTemplateFile = this.nodeInfo.ContainChildTemplateFile;
                }
                else if (string.IsNullOrEmpty(this.nodeInfo.DefaultTemplateFile))
                {
                    containChildTemplateFile = this.nodeInfo.ContainChildTemplateFile;
                }
                else
                {
                    containChildTemplateFile = this.nodeInfo.DefaultTemplateFile;
                }
                if (!string.IsNullOrEmpty(containChildTemplateFile))
                {
                    string templateContent;
                    NameValueCollection queryString = base.Request.QueryString;
                    StringBuilder builder = new StringBuilder();
                    if (queryString.Count > 3)
                    {
                        for (int i = 2; i < queryString.Count; i++)
                        {
                            builder.Append(queryString[i]);
                            builder.Append("&");
                        }
                    }
                    string key = "CK_Page_Category_" + queryString["id"];
                    int seconds = 12 * Nodes.GetCacheNodeById(int.Parse(queryString["id"])).Settings.CacheTime;
                    if ((seconds > 0) && (SiteCache.Get(key) != null))
                    {
                        templateContent = (string) SiteCache.Get(key);
                    }
                    else
                    {
                        TemplateInfo templateInfo = new TemplateInfo();
                        templateInfo.QueryList = base.Request.QueryString;
                        templateInfo.PageName = "index_{$pageid/}.aspx";
                        if (!string.IsNullOrEmpty(builder.ToString()))
                        {
                            templateInfo.PageName = templateInfo.PageName + "?" + builder.ToString();
                        }
                        templateInfo.TemplateContent = Template.GetTemplateContent(containChildTemplateFile);
                        templateInfo.RootPath = HttpContext.Current.Request.PhysicalApplicationPath;
                        templateInfo.CurrentPage = num;
                        templateInfo.IsDynamicPage = false;
                        templateInfo.PageType = 1;
                        templateContent = TemplateTransform.GetHtml(templateInfo).TemplateContent;
                        if (seconds > 0)
                        {
                            SiteCache.Insert(key, templateContent, seconds);
                        }
                    }
                    writer.Write(templateContent);
                }
                else
                {
                    DynamicPage.WriteErrMsg("您查看的栏目未设置模板!");
                }
            }
            else
            {
                DynamicPage.WriteErrMsg("您查看的栏目不存在!");
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -