• 装载当前页面的模板文档


            /// <summary>
            /// 装载当前页面的模板文档
            /// </summary>
            public virtual void LoadCurrentTemplate()
            {
                //是否是手机端网页
                string filePath = this.Request.Url.AbsolutePath;
                bool isMobi = isMobilePage(out filePath);     //处理后filePath为文件名(不含扩展名)  
                if (isMobi && LoginState.Accounts.IsLogin)
                    LoginState.Accounts.Refresh(LoginState.Accounts.CurrentUser);            
                //取模板对象
                this.TmBank = isMobi ?
                    WeiSha.Common.Template.ForMobile.SetCurrent(this.Organ.Org_TemplateMobi)
                    : WeiSha.Common.Template.ForWeb.SetCurrent(this.Organ.Org_Template);
                if (TmBank == null) throw new Exception("没有任何模板库可用!");
                //是否是公共页面
                if (TmBank.Config.Public == null) throw new Exception("未找到公共模板库!");
                bool isPublic = TmBank.Config.Public.PageExists(filePath);
                if (isPublic) TmBank = TmBank.Config.Public;
                //当前模板的所在路径
                string tmFile = TmBank.Path.Physics + filePath + ".htm";
                //装载模板
                this.Document = null;
                if (!System.IO.File.Exists(tmFile))
                {
                    tmFile = TmBank.Config.Default.Path.Physics + filePath + ".htm";
                    if (!System.IO.File.Exists(tmFile)) tmFile = TmBank.Config.Public.Path.Physics + "Notfound.htm";                             
                }
                this.Document = TemplateDocument.FromFileCache(tmFile, Encoding.UTF8, this.DocumentConfig);
                //this.Document = new TemplateDocument(tmFile, Encoding.UTF8, this.DocumentConfig);   //不采用缓存 
            }
  • 相关阅读:
    C#for循环——迭代法、穷举法
    C#循环语句
    C#算数运算符、关系运算符、逻辑运算符、语句
    C#visual2012基本操作、数据类型、类型转换
    C#进制转化
    Ajax用法
    《四》JAVA 字符输入输出流
    《三》Java IO 字节输入输出流
    《二》Java IO 流的分类介绍
    《一》File 类的介绍
  • 原文地址:https://www.cnblogs.com/Jeely/p/11346336.html
Copyright © 2020-2023  润新知