diff --git a/SoEasyPlatform/Apis/ProjectApp/ProjectController_Common.cs b/SoEasyPlatform/Apis/ProjectApp/ProjectController_Common.cs index f9ab431f4c2a993dbbc9cfa53c1b6cb64ffedf62..154777dc98d9845280b6c51ee5fe2b60e60818ac 100644 --- a/SoEasyPlatform/Apis/ProjectApp/ProjectController_Common.cs +++ b/SoEasyPlatform/Apis/ProjectApp/ProjectController_Common.cs @@ -35,69 +35,75 @@ namespace SoEasyPlatform for (int i = 0; i < idsArray.Count(); i++) { ExpandoObject jsonItem = GetJsonItem(obj[i]); - var fileId = ids[i].ToString(); - var fileInfo = DbScoped.Sugar.Queryable().InSingle(idsArray[i]); - if (dbid > 0&&fileInfo.Content.Contains("[请设置ConStr]")) - { - var db = DbScoped.Sugar.Queryable().InSingle(dbid); - fileInfo.Content = fileInfo.Content.Replace("[请设置DbType]","SqlSugar.DbType."+db.DbType+"").Replace("[请设置ConStr]", "@@\""+db.Connection.Replace("@","@@")+"\""); - } - var context = fileInfo.Content; - if (!string.IsNullOrEmpty(project.Reference)) + + if ((jsonItem as IDictionary).ContainsKey("nuget")) { - StringBuilder sb = new StringBuilder(); - sb.AppendLine(""); - //< ProjectReference Include = "..\Entites\WebFirst.Entities.csproj" /> - foreach (var item in project.Reference.Split(',')) + var fileId = ids[i].ToString(); + var fileInfo = DbScoped.Sugar.Queryable().InSingle(idsArray[i]); + if (dbid > 0 && fileInfo.Content.Contains("[请设置ConStr]")) { - var data = DbScoped.Sugar.Queryable().InSingle(item); - var itemName = (dynamic)Newtonsoft.Json.JsonConvert.DeserializeObject(data.FileModel); - sb.AppendLine(""); + var db = DbScoped.Sugar.Queryable().InSingle(dbid); + fileInfo.Content = fileInfo.Content.Replace("[请设置DbType]", "SqlSugar.DbType." + db.DbType + "").Replace("[请设置ConStr]", "@@\"" + db.Connection.Replace("@", "@@") + "\""); } - sb.AppendLine(""); - (jsonItem as IDictionary).Add("reference", sb.ToString()); - } - else - { - (jsonItem as IDictionary).Add("reference", null); - } - var html = TemplateHelper.GetTemplateValue(context, context, jsonItem); - var name = (jsonItem as IDictionary)["name"]; - var fileName = FileSugar.MergeUrl(project.Path, name + "." + fileInfo.Suffix.TrimStart('.')); - if (!FileSugar.IsExistFile(fileName)) - FileSugar.CreateFile(fileName, html); - if (fileName.EndsWith(".csproj")) - { - var root= new DirectoryInfo(fileName).Parent.Parent.FullName; - var files=FileSugar.GetFileNames(root).Where(it=>it.EndsWith(".sln")).ToList(); - var directory =FileSugar.MergeUrl( Directory.GetCurrentDirectory(),"wwwroot\\template\\sln.txt"); - if (files.Count == 0) + var context = fileInfo.Content; + if (!string.IsNullOrEmpty(project.Reference)) { - var text = FileSugar.FileToString(directory); - text=text.Replace("{0}", name+""); - text=text.Replace("{1}", new DirectoryInfo(project.Path).Name+"\\"+name+".csproj" ); - FileSugar.CreateFile(root+"\\WebFirst.sln", text); + StringBuilder sb = new StringBuilder(); + sb.AppendLine(""); + //< ProjectReference Include = "..\Entites\WebFirst.Entities.csproj" /> + foreach (var item in project.Reference.Split(',')) + { + var data = DbScoped.Sugar.Queryable().InSingle(item); + var itemName = (dynamic)Newtonsoft.Json.JsonConvert.DeserializeObject(data.FileModel); + sb.AppendLine(""); + } + sb.AppendLine(""); + (jsonItem as IDictionary).Add("reference", sb.ToString()); + } + else + { + (jsonItem as IDictionary).Add("reference", null); } - else if (files.Count > 0) + var html = TemplateHelper.GetTemplateValue(context, context, jsonItem); + var name = (jsonItem as IDictionary)["name"]; + var fileName = FileSugar.MergeUrl(project.Path, name + "." + fileInfo.Suffix.TrimStart('.')); + if (!FileSugar.IsExistFile(fileName)) + FileSugar.CreateFile(fileName, html); + if (fileName.EndsWith(".csproj")) { - foreach (var item in files) + var root = new DirectoryInfo(fileName).Parent.Parent.FullName; + var files = FileSugar.GetFileNames(root).Where(it => it.EndsWith(".sln")).ToList(); + var directory = FileSugar.MergeUrl(Directory.GetCurrentDirectory(), "wwwroot\\template\\sln.txt"); + if (files.Count == 0) { - var text = FileSugar.FileToString(item); - if (!text.ToLower().Contains(name.ToString().ToLower())) + var text = FileSugar.FileToString(directory); + text = text.Replace("{0}", name + ""); + text = text.Replace("{1}", new DirectoryInfo(project.Path).Name + "\\" + name + ".csproj"); + FileSugar.CreateFile(root + "\\WebFirst.sln", text); + } + else if (files.Count > 0) + { + foreach (var item in files) { - StringBuilder sb = new StringBuilder(); - sb.AppendLine("EndProject"); - sb.AppendLine("Project(\"{9A19103F-16F7-4668-BE54-9A1E7A4F7556}\") = \""+name+"\", \""+ new DirectoryInfo(project.Path).Name + "\\" + name + ".csproj" + "\", \"{"+Guid.NewGuid()+"}\""); - sb.AppendLine(@"EndProject + var text = FileSugar.FileToString(item); + if (!text.ToLower().Contains(name.ToString().ToLower())) + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine("EndProject"); + sb.AppendLine("Project(\"{9A19103F-16F7-4668-BE54-9A1E7A4F7556}\") = \"" + name + "\", \"" + new DirectoryInfo(project.Path).Name + "\\" + name + ".csproj" + "\", \"{" + Guid.NewGuid() + "}\""); + sb.AppendLine(@"EndProject Global"); - text = text.Replace(@"EndProject + text = text.Replace(@"EndProject Global", sb.ToString()); - FileSugar.DeleteFile(item); - FileSugar.CreateFile(item, text); + FileSugar.DeleteFile(item); + FileSugar.CreateFile(item, text); + } } } } } + + } } else