public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; VelocityHelper vh = new VelocityHelper(); vh.Init("~/template/front"); //模板路径 #region 获取head.html中菜单项 vh.Put("menu", this.Menu); vh.Put("submenu", this.SubMenu); vh.Put("parentmenu", this.ParentMenu); #endregion #region 工程中心简介 string ec_title; string ec_content; string ec_date; Front_DataHandlerBLL.GetIntroBLL(out ec_title, out ec_content, out ec_date); vh.Put("ec_content",ec_content); #endregion #region 科研成果 vh.Put("productlist", Front_DataHandlerBLL.GetIndexProductListBLL()); #endregion vh.Display("index.html"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; VelocityHelper vh = new VelocityHelper(); vh.Init("~/template/front"); //模板路径 #region 获取head.html中菜单项 vh.Put("menu", this.Menu); vh.Put("submenu", this.SubMenu); vh.Put("parentmenu", this.ParentMenu); #endregion #region 工程中心简介 string ec_title; string ec_content; string ec_date; Front_DataHandlerBLL.GetIntroBLL(out ec_title, out ec_content, out ec_date); vh.Put("ec_content", ec_content); #endregion #region 科研成果 vh.Put("productlist", Front_DataHandlerBLL.GetIndexProductListBLL()); #endregion vh.Display("index.html"); }
public override void Execute(RequestContext context) { var velocity = new VelocityHelper(string.Format("~/Views/{0}/", context.RouteData["controller"].ToString())); // 绑定实体model velocity.Put("model", this.model); // 显示具体html velocity.Display(string.Format("{0}.html", context.RouteData["action"].ToString())); // 设置响应头类型 context.HttpContext.Response.ContentType = "text/html"; }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; string template = context.Server.MapPath("/Template"); string imageDataPath = context.Server.MapPath("~/imagedata.txt"); VelocityHelper helper = new VelocityHelper(template); if (context.Session["password"] != null) { if (context.Session["password"].ToString() == ConfigHelper.Password) { List <FBImageInfo> ls = FBCommon.LoadFBImage(imageDataPath); helper.PutSet("imagelist", ls); helper.Display("imageview.html"); } } else { helper.Display("password.html"); } }
public override void ExecuteResult(RouteData routeData) { //var filepath = AppDomain.CurrentDomain.BaseDirectory + @"Views\" + routeData.RouteValue["controller"]; //这里必须是虚拟路径 var velocity = new VelocityHelper(string.Format("~/Views/{0}/", routeData.RouteValue["controller"])); // 绑定实体model velocity.Put("model", Data); // 显示具体html HttpResponse response = HttpContext.Current.Response; response.ContentType = "text/html"; velocity.Display(string.Format("{0}.cshtml", routeData.RouteValue["action"].ToString())); }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { Model.contents.article_category model = new BLL.channels.category().GetModel(this.category_id); if (model != null) { string _name = model.call_index; string _class_list = model.class_list; string _key = BasePage.pageUrl(model.model_id); string _where = "status=0 and category_id=" + this.category_id; DataRowCollection list = new BasePage().get_article_list(_name, page, _where, out totalcount, out pagelist, _key, this.category_id, "__id__").Rows; vh.Put("channel_id", category_id); vh.Put("list", list); vh.Put("page", pagelist); vh.Display("../Template/newList.html"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; VelocityHelper vh = new VelocityHelper(); vh.Init("~/template/front"); //模板路径 #region 科研成果列表 vh.Put("pl",Front_DataHandlerBLL.GetIndexProductListBLL()); #endregion #region 获取head.html中菜单项 vh.Put("menu", this.Menu); vh.Put("submenu", this.SubMenu); vh.Put("parentmenu", this.ParentMenu); #endregion vh.Display("products.html"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; VelocityHelper vh = new VelocityHelper(); vh.Init("~/template/front"); int pid = 0; try { pid = Convert.ToInt32(context.Request["id"].ToString()); } catch (Exception) { } string ptitle; string pinfo; string pdes; string pimage; string psort; Front_DataHandlerBLL.GetProductInfoBLL(pid, out ptitle, out pinfo, out pdes, out pimage, out psort); vh.Put("title", ptitle); vh.Put("info", pinfo); vh.Put("des", pdes); vh.Put("image", pimage); vh.Put("sort", psort); #region 获取head.html中菜单项 vh.Put("menu", this.Menu); vh.Put("submenu", this.SubMenu); vh.Put("parentmenu", this.ParentMenu); #endregion vh.Display("product_detail.html"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; VelocityHelper vh = new VelocityHelper(); vh.Init("~/template/front"); //模板路径 #region 科研成果列表 vh.Put("pl", Front_DataHandlerBLL.GetIndexProductListBLL()); #endregion #region 获取head.html中菜单项 vh.Put("menu", this.Menu); vh.Put("submenu", this.SubMenu); vh.Put("parentmenu", this.ParentMenu); #endregion vh.Display("products.html"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; VelocityHelper vh = new VelocityHelper(); vh.Init("~/template/front"); int pid=0; try { pid = Convert.ToInt32(context.Request["id"].ToString()); } catch (Exception) { } string ptitle; string pinfo; string pdes; string pimage; string psort; Front_DataHandlerBLL.GetProductInfoBLL(pid, out ptitle, out pinfo, out pdes, out pimage, out psort); vh.Put("title", ptitle); vh.Put("info", pinfo); vh.Put("des", pdes); vh.Put("image", pimage); vh.Put("sort", psort); #region 获取head.html中菜单项 vh.Put("menu", this.Menu); vh.Put("submenu", this.SubMenu); vh.Put("parentmenu", this.ParentMenu); #endregion vh.Display("product_detail.html"); }
public static string GetTableStructCode(Config config, string tableName, string projectName, out string factoryCode, out string sqlCode, bool isView) { string title = string.Empty; list = GetTableStructure(tableName, out title); VelocityHelper entity = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName)); entity.Put("Project", projectName); entity.Put("ProjectStartDate", config.ProjectStartDate); entity.Put("CopyRight", config.CopyRight); entity.Put("TableName", tableName); entity.Put("TableNameCN", title); entity.Put("Now", DateTime.Now.ToString("yyyy-MM-dd")); entity.Put("Fields", list); entity.Put("helper", new helper()); string code = entity.Display("entity.tmp"); factoryCode = string.Empty; sqlCode = string.Empty; var pkInfo = list.Where(p => p.IsPK && p.IsIdentity).FirstOrDefault(); var currTableOP = config.OPList.Where(p => p.Table == tableName).FirstOrDefault(); if (!currTableOP.Insert && !currTableOP.Update && !currTableOP.DeleteByID && !currTableOP.SelectByID && !currTableOP.IsExistByID && !currTableOP.SelectListByAll && !currTableOP.SelectListByFK && !currTableOP.SelectPageList && !currTableOP.UpdateAndInsert) return code; VelocityHelper factory = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName)); factory.Put("Project", projectName); factory.Put("ProjectStartDate", config.ProjectStartDate); factory.Put("CacheTime", config.CacheTime); factory.Put("DesignPatternExtName", config.DesignPatternExtName); factory.Put("CopyRight", config.CopyRight); factory.Put("TableName", tableName); factory.Put("TableNameCN", title); factory.Put("Now", DateTime.Now.ToString("yyyy-MM-dd")); factory.Put("Fields", list); factory.Put("NoPKFields", list.Where(p => !p.IsPK).ToList()); factory.Put("PKFields", list.Where(p => p.IsPK).ToList()); factory.Put("FKFields", list.Where(p => p.IsFK).ToList()); factory.Put("helper", new helper()); factory.Put("currTableOP", currTableOP); factory.Put("PKInfo", pkInfo); factory.Put("isView", isView); factoryCode = factory.Display("helper.tmp"); //MessageBox.Show(list.Where(p => p.IsPK && p.IsIdentity).Count().ToString()); string dbfile = "".GetMapPath() + "\\templates\\{0}\\db.tmp".FormatWith(config.TemplateName); if (FileDirectory.FileExists(dbfile)) { VelocityHelper db = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName)); db.Put("Project", projectName); db.Put("ProjectStartDate", config.ProjectStartDate); db.Put("CacheTime", config.CacheTime); db.Put("DesignPatternExtName", config.DesignPatternExtName); db.Put("CopyRight", config.CopyRight); db.Put("TableName", tableName); db.Put("TableNameCN", title); db.Put("Now", DateTime.Now.ToString("yyyy-MM-dd")); db.Put("Fields", list); db.Put("NoPKFields", list.Where(p => !p.IsPK).ToList()); db.Put("PKFields", list.Where(p => p.IsPK).ToList()); db.Put("FKFields", list.Where(p => p.IsFK).ToList()); db.Put("helper", new helper()); db.Put("currTableOP", currTableOP); db.Put("PKInfo", pkInfo); db.Put("isView", isView); sqlCode = factory.Display("db.tmp"); } if (!string.IsNullOrEmpty(config.AdminPath)) { //AdminCode(tableName, tableName.LowerFirstChar2(), projectName, pkInfo.IsNull() || pkInfo.ColumnName.IsNullEmpty() ? false : true, isView, pkInfo.IsNull() || pkInfo.ColumnName.IsNullEmpty() ? string.Empty : pkInfo.ColumnType); StringBuilder dbCode = new StringBuilder(); bool isOnePage = false; int addTotalCount = 0; int pks = 0; int idspks = 0; bool max200 = false; int max200Count = 0; string csCode = string.Empty; string aspxCode = string.Empty, entityName = tableName.LowerFirstChar2(); string folder = (tableName.IndexOf("_") >= 0 ? tableName.Substring(0, tableName.IndexOf("_")) : tableName).ToLower(); string aspxPath = config.AdminPath + "\\admin\\" + folder + "\\"; foreach (TableStructureEntity entity2 in list) { if (entity2.IsPK) { pks++; }; if (!max200 && (entity2.Length > 200 || entity2.DBType == "ntext" || entity2.DBType == "text" || entity2.Length <= 0)) max200 = true; if (entity2.IsPK && entity2.IsIdentity) { idspks++; }; if (!entity2.IsIdentity && entity2.IsPK) addTotalCount++; if (!entity2.IsIdentity && !entity2.IsPK) addTotalCount++; if (entity2.Length > 200 || entity2.DBType == "ntext" || entity2.DBType == "text" || entity2.Length <= 0) max200Count++; } if (addTotalCount < 6 && !max200) isOnePage = true; if (pks > 1) isOnePage = true; int height = addTotalCount < 10 ? addTotalCount * 31 + 65 + (110 * max200Count) : ((addTotalCount / 2) + (addTotalCount % 2)) * 31 + 65; VelocityHelper manage = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName)); manage.Put("Project", projectName); manage.Put("ProjectStartDate", config.ProjectStartDate); manage.Put("CopyRight", config.CopyRight); manage.Put("TableName", tableName); manage.Put("TableNameCN", title); manage.Put("Fields", list); manage.Put("NoPKFields", list.Where(p => !p.IsPK).ToList()); manage.Put("PKFields", list.Where(p => p.IsPK).ToList()); manage.Put("FKFields", list.Where(p => p.IsFK).ToList()); manage.Put("helper", new helper()); manage.Put("PKInfo", pkInfo); manage.Put("isOnePage", isOnePage); manage.Put("PagerSqlEnum", config.PagerSqlEnum); manage.Put("PageSize", config.PageSize); manage.Put("WinHeight", height); aspxCode = manage.Display("manage.tmp"); VelocityHelper managecs = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName)); managecs.Put("Project", projectName); managecs.Put("ProjectStartDate", config.ProjectStartDate); managecs.Put("CopyRight", config.CopyRight); managecs.Put("TableName", tableName); managecs.Put("TableNameCN", title); managecs.Put("Fields", list); managecs.Put("NoPKFields", list.Where(p => !p.IsPK).ToList()); managecs.Put("PKFields", list.Where(p => p.IsPK).ToList()); managecs.Put("FKFields", list.Where(p => p.IsFK).ToList()); managecs.Put("helper", new helper()); managecs.Put("PKInfo", pkInfo); managecs.Put("isOnePage", isOnePage); managecs.Put("PagerSqlEnum", config.PagerSqlEnum); managecs.Put("PageSizes", config.PageSize); csCode = managecs.Display("manage.cs.tmp"); FileDirectory.DirectoryCreate(aspxPath); FileDirectory.FileDelete(aspxPath + entityName + "Manage.aspx"); FileDirectory.FileWrite(aspxPath + entityName + "Manage.aspx", aspxCode.ToString()); FileDirectory.FileDelete(aspxPath + entityName + "Manage.aspx.cs"); FileDirectory.FileWrite(aspxPath + entityName + "Manage.aspx.cs", csCode.ToString()); if (!string.IsNullOrEmpty(config.AdminPath) && config.IsAll) { dbCode.AppendFormat(string.Format(" <table cellspacing='0' cellpadding='0' style='width: 100%;'><tbody><tr class='MenuItemRow'><td style='width: 7px;' /><td align='RIGHT' style='width: 10px; vertical-align: top;'><div class='IconContainer' style='width: 10px;'></div></td><td style='padding: 0px 9px 0px 5px;'><font class='MenuItemLabel'><a href='#' onclick=\"parent.window.frames[1].location.href='{0}'\" style='text-decoration:none; color:#428eff'>{1}</a></font></td></tr></tbody></table>", "../" + folder + "/" + entityName + "Manage.aspx", (string.IsNullOrEmpty(title) ? tableName : title) + "管理")); FileDirectory.FileWrite(config.AdminPath + "\\xml\\db.aspx", dbCode.ToString()); } if (!isOnePage) { VelocityHelper add = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName)); add.Put("Project", projectName); add.Put("ProjectStartDate", config.ProjectStartDate); add.Put("CopyRight", config.CopyRight); add.Put("TableName", tableName); add.Put("TableNameCN", title); add.Put("Fields", list); add.Put("NoPKFields", list.Where(p => !p.IsPK).ToList()); add.Put("PKFields", list.Where(p => p.IsPK).ToList()); add.Put("FKFields", list.Where(p => p.IsFK).ToList()); add.Put("helper", new helper()); add.Put("currTableOP", currTableOP); add.Put("PKInfo", pkInfo); aspxCode = add.Display("add.tmp"); VelocityHelper addcs = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName)); addcs.Put("Project", projectName); addcs.Put("ProjectStartDate", config.ProjectStartDate); addcs.Put("CopyRight", config.CopyRight); addcs.Put("TableName", tableName); addcs.Put("TableNameCN", title); addcs.Put("Fields", list); addcs.Put("NoPKFields", list.Where(p => !p.IsPK).ToList()); addcs.Put("PKFields", list.Where(p => p.IsPK).ToList()); addcs.Put("FKFields", list.Where(p => p.IsFK).ToList()); addcs.Put("helper", new helper()); addcs.Put("currTableOP", currTableOP); addcs.Put("PKInfo", pkInfo); csCode = addcs.Display("add.cs.tmp"); FileDirectory.FileDelete(aspxPath + entityName + "Add.aspx"); FileDirectory.FileWrite(aspxPath + entityName + "Add.aspx", aspxCode.ToString()); FileDirectory.FileDelete(aspxPath + entityName + "Add.aspx.cs"); FileDirectory.FileWrite(aspxPath + entityName + "Add.aspx.cs", csCode.ToString()); } } return code; //return sb.ToString(); }