public string GetCode(int id, string source) { if (source.Trim().Length < 1) { return("未设置模板"); } if (id < 1) { return("未选择数据库表"); } Velocity.Init(); VelocityContext vc = new VelocityContext(); vc.Put("data", TemplateDT.CreateTemplateDT(id)); try { using (StringWriter sw = new StringWriter()) { string log = ""; bool result = Velocity.Evaluate(vc, sw, log, source); return(sw.GetStringBuilder().ToString()); } } catch (System.Exception ex) { return(ex.ToString()); } }
public void PrintAll() { DataView dv = DataMarket.GetUserTable(); List <TemplateDT> list = new List <TemplateDT>(); foreach (DataRowView drv in dv) { list.Add(TemplateDT.CreateTemplateDT(drv)); } foreach (TemplateDT detail in list) { PrintCode(detail); } }
/// <summary> /// 导出所有的类。 /// </summary> public static string PrinterAllClass() { DataView dv = DataMarket.GetUserTable(); List <TemplateDT> list = new List <TemplateDT>(); foreach (DataRowView drv in dv) { list.Add(TemplateDT.CreateTemplateDT(drv)); //Template.PrinterClassForTable(drv); } foreach (TemplateDT detail in list) { //Template.PrinterClassForTable(detail); foreach (CodeObject obj in s_CodeObjects.Values) { obj.PrintCode(detail); } } return("../../Code/Tables"); }
public void PrintCode(int id) { PrintCode(TemplateDT.CreateTemplateDT(id)); }
public string GetCode(int id) { return(GetCode(TemplateDT.CreateTemplateDT(id))); }