Exemplo n.º 1
0
        protected void DefaultModule(HttpContext context, HttpResponse response, String path, String directory, String file, String skinname, String templatefile)
        {
            string requestFile = Path.GetFileNameWithoutExtension(path);
            string requestPath = Path.GetDirectoryName(path);
            string html        = string.Empty;
            string htmlpath    = string.Empty;
            string rowurl      = context.Request.RawUrl;

            if (HTMLCache)
            {
                if (string.IsNullOrEmpty(rowurl) || rowurl.IndexOf('.') < 0)
                {
                    htmlpath = PathHelper.Map(string.Format("{0}{1}{2}/{3}{4}", cfgHelper.FrameworkRoot, "htmlcache", rowurl, "default", System.TemplateEngine.TeConfig.Instance.PageSuffix));
                }
                else
                {
                    htmlpath = PathHelper.Map(cfgHelper.FrameworkRoot + "htmlcache/" + rowurl.Replace('?', '_'));
                }
                if (File.Exists(htmlpath))   //启用页面缓存
                {
                    html = FileEx.Read(htmlpath);
                }
            }
            if (string.IsNullOrEmpty(html))
            {
                if (string.IsNullOrEmpty(templatefile))
                {
                    templatefile = System.IO.PathTool.ServerMap(string.Format(@"{0}{1}\{2}\{3}{4}", cfgHelper.FrameworkRoot, System.TemplateEngine.TeConfig.Instance.TemplateFolder, requestPath, System.IO.Path.GetFileNameWithoutExtension(file), System.TemplateEngine.TeConfig.Instance.TemplatePageSuffix));
                }
                //页面文件不存在,根据模板生成网页文件
                if (File.Exists(templatefile))
                {
                    foreach (string key in context.Request.QueryString.AllKeys)
                    {
                        parameters.Add(KeyValue.Create(key, context.Request.QueryString[key]));
                    }
                    foreach (string key in context.Request.Form.AllKeys)
                    {
                        parameters.Add(KeyValue.Create(key, context.Request.Form[key]));
                    }
                    System.TemplateEngine.PageBase pagebase = new System.TemplateEngine.PageBase();
                    pagebase.ThisContext = context;
                    pagebase.Params      = parameters.ToArray();
                    pagebase.SkinName    = skinname;
                    html = pagebase.GetHtml(templatefile);
                    if (HTMLCache)
                    {
                        FileEx.Write(htmlpath, html, true);
                    }
                }
                else
                {
                    context.RewritePath(cfgHelper.WebRoot + "404.htm");
                }
            }
            response.Write(html);
            response.End();
        }
Exemplo n.º 2
0
 protected void DefaultModule(HttpContext context, HttpResponse response, String path, String directory, String file, String skinname, String templatefile)
 {
     string requestFile = Path.GetFileNameWithoutExtension(path);
     string requestPath = Path.GetDirectoryName(path);
     string html = string.Empty;
     string htmlpath = string.Empty;
     string rowurl = context.Request.RawUrl;
     if (HTMLCache)
     {
         if (string.IsNullOrEmpty(rowurl) || rowurl.IndexOf('.') < 0)
         {
             htmlpath = PathHelper.Map(string.Format("{0}{1}{2}/{3}{4}", cfgHelper.FrameworkRoot, "htmlcache", rowurl, "default", System.TemplateEngine.TeConfig.Instance.PageSuffix));
         }
         else
         {
             htmlpath = PathHelper.Map(cfgHelper.FrameworkRoot + "htmlcache/" + rowurl.Replace('?', '_'));
         }
         if (File.Exists(htmlpath))   //启用页面缓存
         {
             html = FileEx.Read(htmlpath);
         }
     }
     if (string.IsNullOrEmpty(html))
     {
         if (string.IsNullOrEmpty(templatefile))
         {
             templatefile = System.IO.PathTool.ServerMap(string.Format(@"{0}{1}\{2}\{3}{4}", cfgHelper.FrameworkRoot, System.TemplateEngine.TeConfig.Instance.TemplateFolder, requestPath, System.IO.Path.GetFileNameWithoutExtension(file), System.TemplateEngine.TeConfig.Instance.TemplatePageSuffix));
         }
         //页面文件不存在,根据模板生成网页文件
         if (File.Exists(templatefile))
         {
             foreach (string key in context.Request.QueryString.AllKeys)
                 parameters.Add(KeyValue.Create(key, context.Request.QueryString[key]));
             foreach (string key in context.Request.Form.AllKeys)
                 parameters.Add(KeyValue.Create(key, context.Request.Form[key]));
             System.TemplateEngine.PageBase pagebase = new System.TemplateEngine.PageBase();
             pagebase.ThisContext = context;
             pagebase.Params = parameters.ToArray();
             pagebase.SkinName = skinname;
             html = pagebase.GetHtml(templatefile);
             if (HTMLCache)
             {
                 FileEx.Write(htmlpath, html, true);
             }
         }
         else
             context.RewritePath(cfgHelper.WebRoot + "404.htm");
     }
     response.Write(html);
     response.End();
 }
Exemplo n.º 3
0
        protected void HTMLFactory(HttpContext context)
        {
            String skinname     = System.TemplateEngine.TeConfig.Instance.CurrentSkin;
            String path         = context.Request.Path.ToLower();
            String directory    = System.IO.Path.GetDirectoryName(path);
            String file         = System.IO.Path.GetFileName(path);
            string requestFile  = Path.GetFileNameWithoutExtension(path);
            string requestPath  = Path.GetDirectoryName(path);
            string html         = string.Empty;
            string htmlpath     = string.Empty;
            string rowurl       = context.Request.RawUrl;
            string templatefile = GetTempletPath(path, skinname, context);

            if (HTMLCache)
            {
                if (string.IsNullOrEmpty(_HTMLResponsePath))
                {
                    if (string.IsNullOrEmpty(rowurl) || rowurl.IndexOf('.') < 0)
                    {
                        htmlpath = string.Format("{0}{1}{2}/{3}{4}", cfgHelper.FrameworkRoot, "htmlcache", rowurl, "default", System.TemplateEngine.TeConfig.Instance.PageSuffix);
                    }
                    else
                    {
                        htmlpath = cfgHelper.FrameworkRoot + "htmlcache/" + rowurl.Replace('?', '_');
                    }
                    html = System.Data.KvTableUtil.GetString("HTMLCACHE_" + htmlpath);
                }
                else
                {
                    if (string.IsNullOrEmpty(rowurl) || rowurl.IndexOf('.') < 0)
                    {
                        htmlpath = PathHelper.Map(string.Format("{0}{1}{2}/{3}{4}", cfgHelper.FrameworkRoot, "htmlcache", rowurl, "default", System.TemplateEngine.TeConfig.Instance.PageSuffix));
                    }
                    else
                    {
                        htmlpath = PathHelper.Map(cfgHelper.FrameworkRoot + "htmlcache/" + rowurl.Replace('?', '_'));
                    }
                    if (File.Exists(htmlpath))   //启用页面缓存
                    {
                        html = FileEx.Read(htmlpath);
                    }
                }
            }
            if (string.IsNullOrEmpty(html))
            {
                if (string.IsNullOrEmpty(templatefile))
                {
                    templatefile = System.IO.PathTool.ServerMap(string.Format(@"{0}{1}\{2}\{3}{4}", cfgHelper.FrameworkRoot, System.TemplateEngine.TeConfig.Instance.TemplateFolder, requestPath, System.IO.Path.GetFileNameWithoutExtension(file), System.TemplateEngine.TeConfig.Instance.TemplatePageSuffix));
                }
                //找到模板文件后,根据模板拼接网页HTML内容
                if (File.Exists(templatefile))
                {
                    foreach (string key in context.Request.QueryString.AllKeys)
                    {
                        parameters.Add(System.Data.KeyValueData.Create(key, context.Request.QueryString[key]));
                    }
                    foreach (string key in context.Request.Form.AllKeys)
                    {
                        parameters.Add(System.Data.KeyValueData.Create(key, context.Request.Form[key]));
                    }
                    System.TemplateEngine.PageBase pagebase = new System.TemplateEngine.PageBase();
                    pagebase.ThisContext = context;
                    pagebase.Params      = parameters.ToArray();
                    pagebase.SkinName    = skinname;
                    html = pagebase.GetHtml(templatefile);
                    if (HTMLCache)
                    {
                        if (string.IsNullOrEmpty(_HTMLResponsePath))
                        {
                            System.Data.KvTableUtil.Save("HTMLCACHE_" + htmlpath, html);
                        }
                        else
                        {
                            FileEx.Write(htmlpath, html, true);
                        }
                    }
                }
                else
                {
                    context.RewritePath(cfgHelper.WebRoot + "404.htm");
                }
            }
            context.Response.Write(html);
            context.Response.End();
        }
Exemplo n.º 4
0
 protected void HTMLFactory(HttpContext context)
 {
     String skinname = System.TemplateEngine.TeConfig.Instance.CurrentSkin;
     String path = context.Request.Path.ToLower();
     String directory = System.IO.Path.GetDirectoryName(path);
     String file = System.IO.Path.GetFileName(path);
     string requestFile = Path.GetFileNameWithoutExtension(path);
     string requestPath = Path.GetDirectoryName(path);
     string html = string.Empty;
     string htmlpath = string.Empty;
     string rowurl = context.Request.RawUrl;
     string templatefile = GetTempletPath(path, skinname, context);
     if (HTMLCache)
     {
         if (string.IsNullOrEmpty(_HTMLResponsePath))
         {
             if (string.IsNullOrEmpty(rowurl) || rowurl.IndexOf('.') < 0)
             {
                 htmlpath = string.Format("{0}{1}{2}/{3}{4}", cfgHelper.FrameworkRoot, "htmlcache", rowurl, "default", System.TemplateEngine.TeConfig.Instance.PageSuffix);
             }
             else
             {
                 htmlpath = cfgHelper.FrameworkRoot + "htmlcache/" + rowurl.Replace('?', '_');
             }
             html = System.Data.KvTableUtil.GetString("HTMLCACHE_" + htmlpath);
         }
         else
         {
             if (string.IsNullOrEmpty(rowurl) || rowurl.IndexOf('.') < 0)
             {
                 htmlpath = PathHelper.Map(string.Format("{0}{1}{2}/{3}{4}", cfgHelper.FrameworkRoot, "htmlcache", rowurl, "default", System.TemplateEngine.TeConfig.Instance.PageSuffix));
             }
             else
             {
                 htmlpath = PathHelper.Map(cfgHelper.FrameworkRoot + "htmlcache/" + rowurl.Replace('?', '_'));
             }
             if (File.Exists(htmlpath))   //启用页面缓存
             {
                 html = FileEx.Read(htmlpath);
             }
         }
     }
     if (string.IsNullOrEmpty(html))
     {
         if (string.IsNullOrEmpty(templatefile))
         {
             templatefile = System.IO.PathTool.ServerMap(string.Format(@"{0}{1}\{2}\{3}{4}", cfgHelper.FrameworkRoot, System.TemplateEngine.TeConfig.Instance.TemplateFolder, requestPath, System.IO.Path.GetFileNameWithoutExtension(file), System.TemplateEngine.TeConfig.Instance.TemplatePageSuffix));
         }
         //找到模板文件后,根据模板拼接网页HTML内容
         if (File.Exists(templatefile))
         {
             foreach (string key in context.Request.QueryString.AllKeys)
                 parameters.Add(System.Data.KeyValueData.Create(key, context.Request.QueryString[key]));
             foreach (string key in context.Request.Form.AllKeys)
                 parameters.Add(System.Data.KeyValueData.Create(key, context.Request.Form[key]));
             System.TemplateEngine.PageBase pagebase = new System.TemplateEngine.PageBase();
             pagebase.ThisContext = context;
             pagebase.Params = parameters.ToArray();
             pagebase.SkinName = skinname;
             html = pagebase.GetHtml(templatefile);
             if (HTMLCache)
             {
                 if (string.IsNullOrEmpty(_HTMLResponsePath))
                 {
                     System.Data.KvTableUtil.Save("HTMLCACHE_"+htmlpath, html);
                 }
                 else
                 {
                     FileEx.Write(htmlpath, html, true);
                 }
             }
         }
         else
             context.RewritePath(cfgHelper.WebRoot + "404.htm");
     }
     context.Response.Write(html);
     context.Response.End();
 }