public object assemblyPage(string projName, List <Grids> grids, List <DataGrids> datas) { List <string> vs = new List <string>(); int[] ids = new int[10]; int count = 0; foreach (var ds in grids) { int t = 0; int ts = 0; Strings strings = new Strings(); string xaml = strings.borderLevel(t++, Buttons.CreateButton(ds.strs));//整个界面 string tmp = ""; int j = 0; for (; j < ds.grids.Count; j++) { var rs = ds.grids[j]; if (rs.CONTROL_NAME == "btn") { var res = Buttons.CreateButton_new(rs.NAME, rs.CODE); tmp += res; } else if (rs.CONTROL_NAME == "NEXT_LINE") { var borders = strings.borderLevel(t++, tmp); tmp = ""; xaml += borders; } else if (rs.CONTROL_NAME == "DATAGRID") { dynamic res = strings.DataGrid(datas[ts].ItemsSource, datas[ts].SelectedItem, datas[ts].PageSize, datas[ts].TotalCount, datas[ts].PageIndex, datas[ts].IsSelectedAll, ds.grids, j); ts++; tmp += res.str; j = res.count - 1; } else if (rs.CONTROL_NAME == "FOOTER") { dynamic res = MyControls.AddFooter(); tmp += res; } else if (rs.CONTROL_NAME == "CustomControl") { var control = NewPage.NewPage.CCDic[rs.NAME]; var list = NewPage.NewPage.PropertiesDic[rs.NAME]; tmp += Strings.formatString(control, list); } else { dynamic res = MyControls.CreateContents_new(ds.grids, j); tmp += res.str; j = res.count - 1; } } ids[count++] = ts; string xamlCode = ""; if (ds.Identity == "主页") { xamlCode = strings.PageXaml(projName, ds.PageCode, xaml); } else { xaml = xaml.Replace("RelativeSource={RelativeSource AncestorType=common:PagePlugin, Mode=FindAncestor}", "RelativeSource={RelativeSource AncestorType=common:WindowPlugin, Mode=FindAncestor}");//全选替换 否则不能全选 xamlCode = strings.WindowXaml(projName, ds.PageCode, xaml); } vs.Add(xamlCode); } return(new { vs, ids }); }
/// <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); } }