public void CompileScriptExport(long?id) { var temp = _scriptNodeCase.FirstOrDefault(x => x.Id == id); ScriptNodeCaseModel model = new ScriptNodeCaseModel(); model.Id = temp.Id; model.CompileContent = temp.CompileContent; CompileScriptExports(model); }
/// <summary> /// 编译后脚本内容显示页面 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult CompileScript(long id) { //EM_SCRIPT_NODE_CASE表id //根据id查询脚本节点实例需要的数据是:COMPILE_CONTENT字段 //var model= _scriptNodeService.GetScriptNode(id); var temp = _scriptNodeCase.FirstOrDefault(x => x.Id == id); ScriptNodeCaseModel model = new ScriptNodeCaseModel(); model.Id = temp.Id; model.CompileContent = temp.CompileContent; return(View("Easyman.FwWeb.Views.ScriptNode.CompileScript", model)); }
/// <summary> /// 编译后脚本内容下载 /// </summary> /// <param name="id"></param> private static void CompileScriptExports(ScriptNodeCaseModel temp) { //var temp = _scriptNodeCase.FirstOrDefault(x => x.Id == id); System.IO.StringWriter sw = new System.IO.StringWriter(); sw.WriteLine(temp.CompileContent); System.Web.HttpContext.Current.Response.Clear(); System.Web.HttpContext.Current.Response.Buffer = true; System.Web.HttpContext.Current.Response.Charset = "GB2312"; System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=编译后脚本内容.txt"); System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); //设置输出流为简体中文 System.Web.HttpContext.Current.Response.ContentType = "text/plain"; //设置输出文件类型为txt文件。 System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true); System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad); System.Web.HttpContext.Current.Response.Write(sw.ToString()); System.Web.HttpContext.Current.Response.End(); }