示例#1
0
    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());
        }
    }
示例#2
0
    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);
        }
    }
示例#3
0
    /// <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");
    }
示例#4
0
 public void PrintCode(int id)
 {
     PrintCode(TemplateDT.CreateTemplateDT(id));
 }
示例#5
0
 public string GetCode(int id)
 {
     return(GetCode(TemplateDT.CreateTemplateDT(id)));
 }