/// <summary> /// /// </summary> /// <param name="csproj">项目名称</param> /// <param name="Model">模型</param> /// <param name="Extend">扩展内容</param> /// <returns></returns> private bool CreateProj(string csproj, string Model, string Extend = "") { try { #region if (String.IsNullOrEmpty(ProjectName)) { return(false); } string dir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); Directory.CreateDirectory(dir + "\\" + csproj); Directory.CreateDirectory(dir + "\\" + csproj + "\\Models"); Directory.CreateDirectory(dir + "\\" + csproj + "\\Properties"); Directory.CreateDirectory(dir + "\\" + csproj + "\\Resources"); Directory.CreateDirectory(dir + "\\" + csproj + "\\ViewModels"); Directory.CreateDirectory(dir + "\\" + csproj + "\\Views"); Strings.Write(Strings.GetAssembly(ProjectName), dir + "\\" + csproj + "\\Properties\\AssemblyInfo.cs"); //Write(Strings.resx, dir + "\\" + csproj + "\\Properties\\Resources.resx"); Strings.Write(CreateClass.LoadModel(IndexBodies, ProjectName), dir + "\\" + csproj + "\\Models\\Model.cs"); Strings.Write(CreateClass.LoadModel(ProjectName), dir + "\\" + csproj + "\\Models\\ComboxModel.cs"); Strings.Write(Strings.GetIndexPage(csproj, Buttons.CreateButton(Buttones), MyControls.CreateContents(IndexContents), MyControls.CreateDataGrid(IndexBodies)), dir + "\\" + csproj + "\\Views\\IndexPage.xaml"); //indexpage.xaml Strings.Write(Strings.GetIndexXamlCs(csproj), dir + "\\" + csproj + "\\Views\\IndexPage.xaml.cs"); //xaml.cs Strings.Write(Strings.GetIndexVM(csproj, MyControls.CreateWord(IndexContents) + CreateCommand(IndexContents, Buttones, boxes), Strings.CreateLoadData(IndexContents)), dir + "\\" + csproj + "\\ViewModels\\IndexPageVM.cs"); //indexVM string res = Strings.CreateGetallUrl(csproj, IndexContents, 1) + Strings.CreateDeleteUrl(csproj) + Strings.CreateUpdateUrl(csproj); string Include = ""; string Complie = ""; //Add if (AddChecked) { Strings.Write(Strings.GetAddPageXaml(csproj, MyControls.CreateAddContents(AddContents), "auto"), dir + "\\" + csproj + "\\Views\\Add.xaml"); //Add.xaml Strings.Write(Strings.GetAddPageXamlCs(csproj), dir + "\\" + csproj + "\\Views\\Add.xaml.cs"); //xaml.cs Strings.Write(Strings.GetAddVM(csproj, MyControls.CreateWord(AddContents) + CreateCommand(AddContents, new List <MyModel>() { }), Strings.PostData(AddContents), Strings.IsLegal(AddContents)), dir + "\\" + csproj + "\\ViewModels\\AddVM.cs"); //AddVM res += Strings.CreateAddUrl(csproj); Include += GetAddInclude; Complie += GetAddComplie; } if (EditChecked) { Strings.Write(Strings.GetEditPageXaml(csproj, MyControls.CreateAddContents(AddContents), "auto"), dir + "\\" + csproj + "\\Views\\Edit.xaml"); //Edit.xaml Strings.Write(Strings.GetEditPageXamlCs(csproj), dir + "\\" + csproj + "\\Views\\Edit.xaml.cs"); //xaml.cs Strings.Write(Strings.GetEditVM(csproj, MyControls.CreateWord(AddContents) + CreateCommand(AddContents, new List <MyModel>() { }), Strings.PostData(AddContents), Strings.IsLegal(AddContents), Strings.CreateEditLoadData(AddContents)), dir + "\\" + csproj + "\\ViewModels\\EditVM.cs"); //AddVM res += Strings.CreateEditUrl(csproj); Include += GetEditInclude; Complie += GetEditComplie; } //Import if (ImportChecked) { Strings.Write(Strings.GetImportXaml(csproj, MyControls.CreateDataGrid(ImportBidies)), dir + "\\" + csproj + "\\Views\\ImportPage.xaml"); //Import.xaml Strings.Write(Strings.GetImportXamlCs(csproj), dir + "\\" + csproj + "\\Views\\ImportPage.xaml.cs"); //xaml.cs Strings.Write(Strings.GetImprotVM(csproj, ImportBidies, Import.CreateXss(ImportBidies), Import.CreateNull(ImportBidies), Import.CreateRepeat(ImportBidies), Import.CreateRepeatFunction(ImportBidies), Import.CheckImportData(ImportBidies)), dir + "\\" + csproj + "\\ViewModels\\ImportPageVM.cs"); //ImportVM res += Import.CreateImportUrl(csproj, ImportBidies); Include += GetImportInclude; Complie += GetImportComplie; } if (boxes.Count > 0) { foreach (var ds in boxes) { Strings.Write(Strings.GetBoxesXaml(csproj, ds.BOX_CODE, MyControls.CreateDataGrid(ds.Body), ds.SEARCH_CODE), dir + "\\" + csproj + "\\Views\\" + ds.BOX_CODE + ".xaml"); //Add.xaml Strings.Write(Strings.GetBoxesXamlCs(csproj, ds.BOX_CODE), dir + "\\" + csproj + "\\Views\\" + ds.BOX_CODE + ".xaml.cs"); //xaml.cs Strings.Write(Strings.GetBoxesVM(csproj, ds.BOX_CODE, MyControls.CreateWord(ds.Body), Strings.CreateBoxUrl(csproj, ds.BOX_CODE, ds.SEARCH_CODE)), dir + "\\" + csproj + "\\ViewModels\\" + ds.BOX_CODE + "VM.cs"); //AddVM } Include += GetInclude(boxes); Complie += GetComplie(boxes); } Strings.Write(Strings.GetResource(ChineseName, Resources.CreateResorce(Resources.AllRes(IndexContents, IndexBodies, boxes))), dir + "\\" + csproj + "\\Resources\\Strings.zh-CN.xaml");//资源文件 Strings.Write(Strings.GetCsproj(csproj, Complie, Include), dir + "\\" + csproj + "\\" + csproj + ".csproj"); Strings.Write(Strings.GetServices(csproj, res), dir + "\\" + csproj + "\\Services.cs"); Domain = Strings.CreateGetallUrl(csproj, IndexContents).Replace("\r\n\t\t", ""); #endregion #region 生成后台 Directory.CreateDirectory(dir + "\\" + ServerName); Directory.CreateDirectory(dir + "\\" + ServerName + "\\Models"); Directory.CreateDirectory(dir + "\\" + ServerName + "\\Properties"); Directory.CreateDirectory(dir + "\\" + ServerName + "\\Domains"); Directory.CreateDirectory(dir + "\\" + ServerName + "\\Services"); var ls = ServerName.Split('.'); Strings.Write(Domains.GetAssembly(ServerName, ChineseName), dir + "\\" + ServerName + "\\Properties\\AssemblyInfo.cs"); Strings.Write(Domains.GetCsproj(ServerName, LoadTables()), dir + "\\" + ServerName + "\\" + ServerName + ".csproj"); Strings.Write(Domains.GetDomain(ServerName, Domains.GetAllUrlBody(IndexContents, 1), Domains.GetHasWordUrl(ImportBidies, 1), Domains.GetHasWrodFunction(ImportBidies), Domains.GetAllFunction(Tables, IndexContents)), dir + "\\" + ServerName + "\\Domains\\" + ls.Last() + "Domain.cs"); Strings.Write(Domains.GetService(ServerName, Domains.GetAllUrlHeader(ServerName, IndexContents), Domains.GetAllUrlBody(IndexContents, 1), Domains.GetAllUrlBody(IndexContents, 0), ChineseName, Domains.GetHasWordUrl(ImportBidies, 0), Domains.GetHasWordUrl(ImportBidies, 1), Domains.GetHasWordUrl(ImportBidies, 2)), dir + "\\" + ServerName + "\\Services\\" + ls.Last() + "Service.cs"); if (ModelChecked) { CreateDbModel(); } #endregion return(true); } catch (Exception) { return(false); } }