public Dictionary <string, string> Create(List <string> LstTbName, CreateData cd) { StringBuilder sb = new StringBuilder(); Dictionary <string, string> dic = new Dictionary <string, string>(); for (int i = 0; i < LstTbName.Count; i++) { sb.Clear(); string tbName = LstTbName[i]; sb.AppendLine("using System;").AppendLine("using System.Collections.Generic;").AppendLine("using System.Data.SqlClient;").AppendLine($"using {Creator.Instance.Config.ModelName};").AppendLine($"using {Creator.Instance.Config.ProjName}.Common;").AppendLine($"namespace {Creator.Instance.Config.DALName}").AppendLine("{"); sb.AppendLine($"public class {tbName}{cd.DalSuffix}").AppendLine("{"); if (cd.IsPage) { sb.AppendLine($"public PageData PageData = new PageData({cd.PageSize});"); } //CRUD sb.AppendLine(CreateInsertMethod(tbName)); sb.AppendLine(CreateDelMethod(tbName)); sb.AppendLine(CreateUpdateMethod(tbName)); sb.AppendLine(CreateGetMethod(tbName)); sb.AppendLine(CreateReadMethod(tbName)); if (cd.IsPage) { sb.AppendLine(CreatePageMethod(tbName)); } if (cd.IsExistedName) { sb.AppendLine(CreateIsExistedName(tbName)); } sb.AppendLine("}").AppendLine("}"); dic.Add(tbName, sb.ToString()); } return(dic); }
public void Create(string path, List <string> LstTbName) { //保存Model CreateData cd = new CreateData() { IsPage = this.IsPage, PageSize = this.PageSize, IsExistedName = this.IsExistedName, DalSuffix = this.DALSuffix, BllSuffix = this.BLLSuffix }; Dictionary <string, string> dicM = Mc.Create(LstTbName); if (!Directory.Exists(path + "\\Models")) { Directory.CreateDirectory(path + "\\Models"); } SaveFile(path + "\\Models\\", string.Empty, dicM); //save DAL Dictionary <string, string> dicD = Dc.Create(LstTbName, cd); if (!Directory.Exists(path + "\\DAL")) { Directory.CreateDirectory(path + "\\DAL"); } SaveFile(path + "\\DAL\\", DALSuffix, dicD); //save BLL Dictionary <string, string> dicB = Bc.Create(LstTbName, cd); if (!Directory.Exists(path + "\\BLL")) { Directory.CreateDirectory(path + "\\BLL"); } SaveFile(path + "\\BLL\\", BLLSuffix, dicB); }