Пример #1
0
    /// <summary>
    /// 生成数据仓库代码
    /// </summary>
    /// <param name="tables"></param>
    /// <returns></returns>
    public int GenerateBusinessRepositoryClasses(ViewSchemaCollection views)
    {
        if (views == null || views.Count <= 0)
        {
            return(0);
        }
        int          tempIntTableNum            = 0;
        CodeTemplate BusinessRepositoryTemplate = GetCodeTemplate("ViewBusinessRepository.cst");

        foreach (ViewSchema view in views)
        {
            BusinessRepositoryTemplate.SetProperty("TargetView", view);
            BusinessRepositoryTemplate.SetProperty("CommonNamespace", CommonNamespace);
            BusinessRepositoryTemplate.SetProperty("BusinessRepositoryNamespace", BusinessRepositoryNamespace);
            BusinessRepositoryTemplate.SetProperty("EntityNamespace", EntityNamespace);
            BusinessRepositoryTemplate.SetProperty("DBUtilityNamespace", DBUtilityNamespace);
            BusinessRepositoryTemplate.SetProperty("CreatePerson", CreatePerson);
            BusinessRepositoryTemplate.SetProperty("CompanyName", CompanyName);
            BusinessRepositoryTemplate.SetProperty("BusinessRepositorySuffix", BusinessRepositorySuffix);
            BusinessRepositoryTemplate.SetProperty("FileDesc", "表[" + view.Name + "]的 数据仓库代码");
            string tempFilePath = string.Format(@"{0}{1}\{2}", this.OutputDirectory, BusinessRepositoryNamespace, BusinessRepositoryTemplate.GetFileName());
            BusinessRepositoryTemplate.RenderToFile(tempFilePath, true);
            WriteInfo("成功在路径[" + this.OutputDirectory + BusinessRepositoryNamespace + "] 生成 BusinessReposity 层代码文件:" + BusinessRepositoryTemplate.GetFileName() + "");
            tempIntTableNum++;
        }
        WriteInfo("-----成功在路径[" + this.OutputDirectory + BusinessRepositoryNamespace + "] 生成:" + tempIntTableNum + " 个 BusinessReposity 层代码文件-----");
        return(tempIntTableNum);
    }
Пример #2
0
    /// <summary>
    /// 生成数据实体代码
    /// </summary>
    /// <param name="tables"></param>
    /// <returns></returns>
    public int GenerateEntityClasses(ViewSchemaCollection views)
    {
        if (views == null || views.Count <= 0)
        {
            return(0);
        }
        int          tempIntTableNum = 0;
        CodeTemplate EntityTemplate  = GetCodeTemplate("ViewEntity.cst");

        foreach (ViewSchema view in views)
        {
            EntityTemplate.SetProperty("TargetView", view);
            EntityTemplate.SetProperty("EntityNamespace", EntityNamespace);
            EntityTemplate.SetProperty("CreatePerson", CreatePerson);
            EntityTemplate.SetProperty("CompanyName", CompanyName);
            EntityTemplate.SetProperty("FileDesc", "表[" + view.Name + "] 数据库实体代码");
            string tempFilePath = string.Format(@"{0}{1}\{2}", this.OutputDirectory, EntityNamespace, EntityTemplate.GetFileName());
            EntityTemplate.RenderToFile(tempFilePath, true);
            WriteInfo("成功在路径[" + this.OutputDirectory + EntityNamespace + "] 生成 Entity 层代码文件:" + EntityTemplate.GetFileName() + "");
            tempIntTableNum++;
        }
        WriteInfo("-----成功在路径[" + this.OutputDirectory + EntityNamespace + "] 生成 " + tempIntTableNum + " 个 Entity 层代码文件-----");
        return(tempIntTableNum);
    }