/// <summary> /// 生成文章类型前台控件 /// </summary> /// <param name="model"></param> static void CreateArticleListControl(ModelInfo model) { NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath); string path = CreateDirectory(model, "List", "ArticleModelListDataControl", "列表"); helper.Put("modelDesc", string.IsNullOrEmpty(model.Desc) ? model.Desc : model.ModelName); helper.Put("model", model); We7DataColumnCollection dcs = null; if (model.Layout.UCContrl.DetailFieldArray == null) { dcs = model.DataSet.Tables[0].Columns; } else { dcs = new We7DataColumnCollection(); foreach (We7DataColumn dc in model.DataSet.Tables[0].Columns) { if (Array.Exists(model.Layout.UCContrl.DetailFieldArray, s => s == dc.Name)) { dcs.Add(dc); } } } helper.Put("columns", dcs); helper.Put("CurrentDate", DateTime.Now.ToString()); if (ModelConfig.IsCreateArticleUC) { helper.Save("ArticleList.vm", path); } helper.Save("DbModelList.vm", CreateNewFilePath(path, "DB")); }
protected override void Render(System.Web.UI.HtmlTextWriter writer) { if (Design) { //可视化设计时 StringWriter output = new StringWriter(); HtmlTextWriter tw = new HtmlTextWriter(output); base.Render(tw); string ControlHtml = output.ToString(); //格式化代码 string formatControlHtml = FormatHtml(ControlHtml); NVelocityHelper helper = new NVelocityHelper(We7.CMS.Constants.VisualTemplatePhysicalTemplateDirectory); helper.Put("controlId", this.ID); helper.Put("controlContent", formatControlHtml); var rendHtml = helper.Save("We7LayoutDesign.vm"); //格式化 rendHtml = FormatHtml(rendHtml); //输出代码 writer.Write(rendHtml); } else { base.Render(writer); } }
/// <summary> /// 生成模型布局 /// </summary> /// <param name="model"></param> /// <returns>布局存放路径</returns> public static string CreateModelLayout(ModelInfo model) { NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath); //string path = CreateDirectory(model, "Edit", "ArticleModelEditDataControl", "录入"); //string path2 = CreateModelDirectory(model, "Edit", "ArticleModelEditDataControl", "录入"); string path = GetModelLayoutDirectory(model.ModelName) + "GenerateLayout.ascx"; FileInfo fi = new FileInfo(path); if (!fi.Directory.Exists) { fi.Directory.Create(); } helper.Put("model", model); helper.Put("controls", model.Layout.Panels["edit"].EditInfo.Controls); helper.Put("CurrentDate", DateTime.Now.ToString()); helper.Save("ArticleEditor.vm", path); path = String.Format("{0}/{1}/{2}/{3}", ModelConfig.ModelsDirectory, model.GroupName, model.Name, "GenerateLayout.ascx"); return(path); //helper.Save("ArticleEditor.vm", path); //helper.Save("ArticleEditor.vm", path2); }
protected override void Render(HtmlTextWriter writer) { if (Design) { //可视化设计时 StringWriter output = new StringWriter(); HtmlTextWriter tw = new HtmlTextWriter(output); base.Render(tw); string ControlHtml = output.ToString(); //格式化代码 string formatControlHtml = FormatHtml(ControlHtml); NVelocityHelper helper = new NVelocityHelper(We7.CMS.Constants.VisualTemplatePhysicalTemplateDirectory); helper.Put("controlId", this.ID); helper.Put("controlContent", formatControlHtml); helper.Put("controlData", BuildData()); var rendHtml = helper.Save("We7LayoutDesign.vm"); //格式化 rendHtml = FormatHtml(rendHtml); //输出代码 writer.Write(rendHtml); } else { writer.Write("<div id=\"" + this.ID + "\" class=\"sf_cols\">"); base.Render(writer); //writer.Write("<div style= \"clear:both; height:0;\"></div>"); writer.Write("<div style= \"clear:both;height:0;font-size:1px;\"></div>"); writer.Write("</div>"); } }
/// <summary> /// 生成文章类型前台控件 /// </summary> /// <param name="model"></param> static void CreateArticlePagedListWidget(ModelInfo model) { NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath); string path = CreateWidgetDirectory(model, "PagedList"); helper.Put("modelDesc", string.IsNullOrEmpty(model.Desc) ? model.Desc : model.ModelName); helper.Put("model", model); We7DataColumnCollection dcs = null; if (model.Layout.UCContrl.WidgetListFields == null) { dcs = model.DataSet.Tables[0].Columns; } else { dcs = new We7DataColumnCollection(); foreach (We7DataColumn dc in model.DataSet.Tables[0].Columns) { if (Array.Exists(model.Layout.UCContrl.WidgetListFieldArray, s => s == dc.Name)) { dcs.Add(dc); } } } helper.Put("columns", dcs); helper.Put("CurrentDate", DateTime.Now.ToString()); string[] tpls = GetWidgetModelPagedListTemplate(); CreateWidgets(helper, path, tpls); }
/// <summary> /// 生成反馈类型 前台控件 /// </summary> /// <param name="model"></param> static void CreateAdviceQueryListControl(ModelInfo model) { NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath); string path = CreateDirectory(model, "QueryList", "AdviceQueryListDataControl", "查询列表"); helper.Put("model", model); helper.Put("columns", model.DataSet.Tables[0].Columns); helper.Put("CurrentDate", DateTime.Now.ToString()); helper.Save("AdviceQueryList.vm", path); }
private static void CreateAdviceDetailsWidget(ModelInfo model) { NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath); string path = CreateWidgetDirectory(model, "View"); helper.Put("model", model); helper.Put("columns", model.DataSet.Tables[0].Columns); helper.Put("CurrentDate", DateTime.Now.ToString()); helper.Save("WidgetAdviceView.vm", path); }
/// <summary> /// 生成反馈类型 前台控件 /// </summary> /// <param name="model"></param> static void CreateAdviceEditControl(ModelInfo model) { NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath); string path = CreateDirectory(model, "Edit", "AdviceModelEditDataControl", "录入"); helper.Put("model", model); helper.Put("controls", model.Layout.Panels["edit"].EditInfo.Controls); helper.Put("CurrentDate", DateTime.Now.ToString()); helper.Save("Advice.vm", path); }
/// <summary> /// 显示模板 /// </summary> /// <param name="templatFileName">模板文件名</param> public static void Display(NVelocityHelper th, string templateFile) { //全局 th.Put("querycount", querycount); th.Put("processtime", DateTime.Now.Subtract(starttick).TotalMilliseconds / 1000); th.Put("sqlanalytical", SqlAnalytical); // HttpContext.Current.Response.Clear(); // HttpContext.Current.Response.Write(writer.ToString()); HttpContext.Current.Response.Write(th.BuildString(templateFile)); // HttpContext.Current.Response.End(); }
/// <summary> /// 反馈前台录入(自动布局) /// </summary> /// <param name="model"></param> private static void CreateAdviceEditWidget(ModelInfo model) { //Criteria c = new Criteria(CriteriaType.Equals, "ModelName", model.ModelName); //List<AdviceType> adviceList = Assistant.List<AdviceType>(c, null); NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath); string path = CreateWidgetDirectory(model, "Edit"); helper.Put("model", model); helper.Put("controls", model.Layout.Panels["edit"].EditInfo.Controls); helper.Put("CurrentDate", DateTime.Now.ToString()); //helper.Put("adviceType", adviceList); helper.Save("WidgetAdvice.vm", path); }
// // GET: /Home/ public ActionResult Index() { string configData = SysVisitor.Instance.CurrentUser.ConfigJson; string themePath = Server.MapPath("~/Content/theme/navtype/"); NVelocityHelper vel = new NVelocityHelper(themePath); vel.Put("username", SysVisitor.Instance.CurrentUser.TrueName); string navHTML = "Accordion.html"; if (!string.IsNullOrEmpty(configData)) { ConfigModel sysconfig = JSONhelper.ConvertToObject <ConfigModel>(configData); if (sysconfig != null) { switch (sysconfig.ShowType) { case "menubutton": navHTML = "menubutton.html"; break; case "tree": navHTML = "tree.html"; break; case "menuAccordion": case "menuAccordion2": case "menuAccordionTree": navHTML = "topandleft.html"; break; default: navHTML = "Accordion.html"; break; } } } ViewBag.NavContent = vel.FileToString(navHTML); //============APP用户总数================ ViewBag.AppCount = 0;// DriverUserDal.Instance.GetAppCount(); //============订单签收总数================ ViewBag.SignCount = 0;// SignDal.Instance.GetCount(""); //系统更新日志 int pdateLogCount; ViewBag.UpdateLogList = SYS_UPDATELOGBLL.Instance.GetPageWithRecordCount(1, 3, out pdateLogCount); ViewBag.UpdateLogCount = pdateLogCount; return(View()); }
public void Render(RenderChain renders, ref string content, RenderArguments args) { Design = !string.IsNullOrEmpty(args.Request["state"]); if (Design) { UserControl uc = null; Action = !string.IsNullOrEmpty(args.Request["action"]); if (Action) { WidgetParameter = new Dictionary <string, object>(); var param = RequestHelper.Get <string>("params"); if (!string.IsNullOrEmpty(param)) { param = Base64Helper.Decode(param); WidgetParameter = JsonConvert.DeserializeObject <Dictionary <string, object> >(param); } } else { uc = args.Control; FileName = args.Request["file"].ToString(); } //执行 //格式化代码 content = FormatHtml(content); NVelocityHelper helper = new NVelocityHelper(We7.CMS.Constants.VisualTemplatePhysicalTemplateDirectory); helper.Put("controlId", args.Control.ID); helper.Put("controlName", string.Empty); helper.Put("controlContent", content); helper.Put("controlData", AttributesJsonData(args.Control)); var rendHtml = helper.Save("We7ControlDesign.vm"); //格式化 content = FormatHtml(rendHtml); } renders.DoRender(ref content, args); }
/// <summary> /// 首页 /// </summary> public void Home() { var model = new PostListModel(); model.IsDefault = 1; model.ThemeName = _themeName; model.PostMessage = string.Empty; model.Url = ConfigHelper.SiteUrl + "page/{0}" + BlogConfig.GetSetting().RewriteExtension;; int recordCount = 0; model.PostList = PostService.GetPostList(BlogConfig.GetSetting().PageSizePostCount, pageindex, out recordCount, categoryId, tagId, userId, -1, 1, -1, 0, begindate, enddate, keyword); model.Pager = Pager.CreateHtml(BlogConfig.GetSetting().PageSizePostCount, recordCount, model.Url); th.Put("Model", model); Display(th, _listTemplate); }
/// <summary> /// 导出Model类 /// </summary> /// <param name="strDbName">数据库名称</param> /// <param name="table">数据库表</param> /// <param name="savePath">文件夹存储路径</param> public void ExportModel(string strDbName, List <Table> tables, string saveDirectoryPath) { nVelocity = new NVelocityHelper(AppDomain.CurrentDomain.BaseDirectory + "Template"); nVelocity.TemplateFileName = "ModelTpl.cstpl"; nVelocity.Put("ConnType", Config.ConnType.ToString()); nVelocity.Put("DatabaseName", Config.DatabaseName); nVelocity.Put("this", this); ExportEventArgs args = new ExportEventArgs(); args.IsFinished = false; args.Info = "开始生成Model类……"; if (null != OnExport) { this.OnExport(this, args); } if (!Directory.Exists(saveDirectoryPath + Config.DatabaseName)) { Directory.CreateDirectory(saveDirectoryPath + Config.DatabaseName); } args.TotalNum = tables.Count; foreach (Table table in tables) { nVelocity.Remove("Table"); nVelocity.Put("Table", table); nVelocity.Remove("Columns"); nVelocity.Put("Columns", table.Columns); int i = 0; nVelocity.Put("i", i); File.WriteAllText(Path.Combine(saveDirectoryPath, Config.DatabaseName + "/" + table.Name + ".cs"), nVelocity.Content, encoding); ++args.NowIndex; if (null != OnExport) { this.OnExport(this, args); } } args.IsFinished = true; args.Info = "Model类生成完成"; if (null != OnExport) { this.OnExport(this, args); } nVelocity.Dispose(); }
protected void Page_Load(object sender, EventArgs e) { string configData = SysVisitor.Instance.CurrentUser.ConfigJson; string themePath = Server.MapPath("theme/navtype/"); NVelocityHelper vel = new NVelocityHelper(themePath); vel.Put("username", UserName); string navHTML = "Accordion.html"; if (!string.IsNullOrEmpty(configData)) { ConfigModel sysconfig = JSONhelper.ConvertToObject <ConfigModel>(configData); if (sysconfig != null) { switch (sysconfig.ShowType) { case "menubutton": navHTML = "menubutton.html"; break; case "tree": navHTML = "tree.html"; break; case "menuAccordion": case "menuAccordion2": case "menuAccordionTree": navHTML = "topandleft.html"; break; default: navHTML = "Accordion.html"; break; } } } NavContent = vel.FileToString(navHTML); }
private string GetContent() { string content = ""; string configData = CurrentUser.ConfigJson; string themePath = Server.MapPath("~/content/theme/navtype/"); NVelocityHelper vel = new NVelocityHelper(themePath); vel.Put("welcome", Lang.welcome); vel.Put("username", CurrentUser.UserTrueName); vel.Put("update_pwd", Lang.update_pwd); vel.Put("logout", Lang.logout); vel.Put("system_name", Lang.system_name); vel.Put("nav_menu", Lang.nav_menu); string navHTML = "Accordion.html"; if (!string.IsNullOrEmpty(configData)) { ConfigModel sysconfig = Newtonsoft.Json.JsonConvert.DeserializeObject <ConfigModel>(configData); if (sysconfig != null) { switch (sysconfig.ShowType) { case "menubutton": navHTML = "menubutton.html"; break; case "tree": navHTML = "tree.html"; break; case "menuAccordion": case "menuAccordion2": case "menuAccordionTree": navHTML = "topandleft.html"; break; default: navHTML = "Accordion.html"; break; } } } content = vel.FileToString(navHTML); return(content); }
/// <summary> /// 导出数据字典 /// </summary> /// <param name="strDbName">数据库名称</param> /// <param name="table">数据库表</param> /// <param name="savePath">文件存储路径</param> public void ExportDbDic(string strDbName, List <Table> tables, string saveFilePath) { nVelocity = new NVelocityHelper(AppDomain.CurrentDomain.BaseDirectory + "Template"); nVelocity.TemplateFileName = "DbDicTpl.html"; nVelocity.Put("ConnType", Config.ConnType.ToString()); nVelocity.Put("DatabaseName", Config.DatabaseName); nVelocity.Put("this", this); int i = 1; nVelocity.Put("i", i); int j = 0; nVelocity.Put("j", j); ExportEventArgs args = new ExportEventArgs(); args.IsFinished = false; args.Info = "开始生成数据字典……"; if (null != OnExport) { this.OnExport(this, args); } args.TotalNum = tables.Count; args.NowIndex = 1; nVelocity.Remove("Tables"); nVelocity.Put("Tables", tables); File.WriteAllText(saveFilePath, nVelocity.Content, encoding); args.IsFinished = true; args.NowIndex = args.TotalNum; args.Info = "数据字典生成完成"; if (null != OnExport) { this.OnExport(this, args); } nVelocity.Dispose(); }
/// <summary> /// 重写Render方法 /// </summary> /// <param name="writer"></param> protected override void Render(HtmlTextWriter writer) { if (VisualDesign)//在可视化设计时生成辅助标签 { //可视化设计时 StringWriter output = new StringWriter(); HtmlTextWriter tw = new HtmlTextWriter(output); try { base.Render(tw); } catch (Exception ex) { tw.Write("<div class=\"vdControlError\">"); tw.Write(ex.Message); tw.Write("</div>"); }; string ControlHtml = output.ToString(); //格式化代码 string formatControlHtml = FormatHtml(ControlHtml); NVelocityHelper helper = new NVelocityHelper(We7.CMS.Constants.VisualTemplatePhysicalTemplateDirectory); helper.Put("controlId", this.ID); helper.Put("controlName", ""); helper.Put("controlContent", formatControlHtml); helper.Put("controlData", AttributesJsonData()); var rendHtml = helper.Save("We7ControlDesign.vm"); //格式化 rendHtml = FormatHtml(rendHtml); //输出代码 writer.Write(rendHtml); } else { if (CreateHtml) //生成静态过程中 { if (IsHtml) //需要生成静态 { StringWriter strWriter = new StringWriter(); HtmlTextWriter tempWriter = new HtmlTextWriter(strWriter); try { base.Render(tempWriter); } catch (Exception ex) { strWriter.Write(""); }; string content = strWriter.ToString(); //格式化代码 string formatControlHtml = FormatHtml(content); //输出html代码 writer.Write(formatControlHtml); } else { writer.Write(GetOriginalControl()); } } else { base.Render(writer); } } //Response.Write("<br />当前控件执行时间::" + DateTime.Now.Subtract(processStartTime).TotalMilliseconds / 1000); }
public static string Pay(string orderNumber, int totalFee, string openid) { //读取配置文件 var merchantId = string.Empty; var appId = string.Empty; var key = string.Empty; var appSecret = string.Empty; //接收微信支付异步通知回调地址 var notifyUrl = string.Empty; var payUrl = string.Empty; var xd = new XmlDocument(); xd.Load(HttpContext.Current.Server.MapPath("/app_data/xml/payment.xml")); var selectSingleNode = xd.SelectSingleNode("paymentMethod"); if (selectSingleNode != null) { var xnl = selectSingleNode.ChildNodes; foreach (XmlNode xn in xnl) { var xe = (XmlElement)xn; if (xe.GetAttribute("id") != "wechat") { continue; } merchantId = xe.GetAttribute("merchant_id"); appId = xe.GetAttribute("app_id"); appSecret = xe.GetAttribute("app_secret"); key = xe.GetAttribute("key"); notifyUrl = xe.GetAttribute("notify_url"); payUrl = xe.GetAttribute("pay_url") + orderNumber.ToString(); break; } } var timestamp = Senparc.Weixin.MP.TenPayLib.TenPayUtil.GetTimestamp(); var nonceStr = Senparc.Weixin.MP.TenPayLib.TenPayUtil.GetNoncestr(); JsApiTicketContainer.Register(appId, appSecret); var jsapiTicket = JsApiTicketContainer.GetJsApiTicket(appId); var signConfig = new Senparc.Weixin.MP.TenPayLib.RequestHandler(null); signConfig.SetParameter("jsapi_ticket", jsapiTicket); signConfig.SetParameter("noncestr", nonceStr); signConfig.SetParameter("timestamp", timestamp); signConfig.SetParameter("url", payUrl); var signature = signConfig.CreateSHA1Sign(); //支付 //商品或支付单简要描述 var body = "Billion智能仪表管理系统"; //商户系统内部的订单号,32个字符内,可包含字母,其他说明见商户订单号 //APP和网页支付提交用户端IP,Native支付填调用微信支付API的机器IP var spbillCreateIp = HttpContext.Current.Request.ServerVariables.Get("Remote_Addr"); //JSAPI,NATIVE,APP,WAP var trade_type = "JSAPI"; //创建支付应答对象 var panSigig = new RequestHandler(null); //初始化 panSigig.Init(); //设置package订单参数 panSigig.SetParameter("appid", appId); panSigig.SetParameter("mch_id", merchantId); panSigig.SetParameter("nonce_str", nonceStr); panSigig.SetParameter("body", body); panSigig.SetParameter("out_trade_no", orderNumber); panSigig.SetParameter("total_fee", totalFee.ToString()); panSigig.SetParameter("spbill_create_ip", spbillCreateIp); panSigig.SetParameter("notify_url", notifyUrl); panSigig.SetParameter("trade_type", trade_type); panSigig.SetParameter("openid", openid); var sign = panSigig.CreateMd5Sign("key", key); panSigig.SetParameter("sign", sign); var data = panSigig.ParseXML(); var result = TenPayV3.Unifiedorder(data); var res = System.Xml.Linq.XDocument.Parse(result); var xElement = res.Element("xml"); if (xElement == null) { return(""); } var element = xElement.Element("prepay_id"); if (element == null) { return(""); } var prepayId = element.Value; var paysignReqHandler = new RequestHandler(null); paysignReqHandler.Init(); //设置支付参数 paysignReqHandler.SetParameter("appId", appId); paysignReqHandler.SetParameter("timeStamp", timestamp); paysignReqHandler.SetParameter("nonceStr", nonceStr); paysignReqHandler.SetParameter("package", string.Format("prepay_id={0}", prepayId)); paysignReqHandler.SetParameter("signType", "MD5"); var paysign = paysignReqHandler.CreateMd5Sign("key", key); paysignReqHandler.SetParameter("paysign", paysign); NVelocityHelper nh = new NVelocityHelper(); nh.Put("app_id", appId); nh.Put("timestamp", timestamp); nh.Put("nonceStr", nonceStr); nh.Put("signature", signature); nh.Put("package", string.Format("prepay_id={0}", prepayId)); nh.Put("signType", "MD5"); nh.Put("paySign", paysign); nh.Put("orderid", orderNumber); return(nh.Write("app_data/template/wechat")); }