12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <%@ WebHandler Language="C#" Class="Handler" %>
- using System;
- using System.Web;
- using System.IO;
- public class Handler : IHttpHandler {
-
- public void ProcessRequest (HttpContext context) {
- context.Response.ContentType = "text/plain";
- string html = "";//返回数据集
- //新版本Grid
- switch (context.Request.Params["DataType"])
- {
- case "LeftMenu":
- string val = context.Request.Params["Value"];
- val = val.Replace("&", "&")
- .Replace("<", "<")
- .Replace(">", ">")
- .Replace("'", "'")
- .Replace(""", "\"");
- html = LoadLeftMenu(val);
- break;
- case "huodong":
- string val2 = context.Request.Params["Value"];
- val2 = val2.Replace("&", "&")
- .Replace("<", "<")
- .Replace(">", ">")
- .Replace("'", "'")
- .Replace(""", "\"");
- html = LoadHuoDong(val2);
- break;
- }
- context.Response.Write(html);
- context.Response.End();
- }
- private string LoadLeftMenu(string Value)
- {
- //生成静态页面
- string[] Marking = { "#Content#" };
- string[] Content = { Value };
- string HTMLURL = ConfigExportHTML(Marking, Content, 1, "handWrite.html");
- return HTMLURL;
- }
- private string LoadHuoDong(string Value)
- {
- //生成静态页面
- string[] Marking = { "#Content#" };
- string[] Content = { Value };
- string HTMLURL = ConfigExportHTML(Marking, Content, 1, "huodong.html");
- return HTMLURL;
- }
- #region 生成静态页面
- //生成静态页面
- public static string ConfigExportHTML(string[] Marking, string[] Content, int TemplateParamCount, string TemplateFilePath)
- {
- string Year = DateTime.Now.ToString("yyyy");
- string Month = DateTime.Now.ToString("yyyyMM");
- string RelativelyPath = "~/tpl/formbuilder/HTML/" + Year + "/" + Month + "/";//相对路径,注意更改生成的这个路径
- string Path = HttpContext.Current.Server.MapPath(RelativelyPath);//绝对路径
- //生成HTML的路径
- if (System.IO.Directory.Exists(Path))
- {
- //文件夹已存在
- }
- else
- {
- DirectoryInfo folder = Directory.CreateDirectory(Path);
- }
- GenerateHTML _GenerateHTML = new GenerateHTML();
- _GenerateHTML.TemplateParamCount = TemplateParamCount;
- _GenerateHTML._htmlFilePath = RelativelyPath;// 转换后的html文件所存放的路径
- _GenerateHTML._templateFilePath = TemplateFilePath;// 模板文件所在的路径
- _GenerateHTML.setAspxFileparameter(Content);
- _GenerateHTML.setTemplateFileparameter(Marking);
- string HtmlFileName = _GenerateHTML.StartConvert();//开始转换
- return "HTML/" + Year + "/" + Month + "/" + HtmlFileName;//返回生成文件的路径
- }
- #endregion
- public bool IsReusable {
- get {
- return false;
- }
- }
- }
|