public void DoDetails(Table replaceClass, ref List <string> fileName) { StringBuilder stringBuilder = new StringBuilder(); string newValue = string.Empty; int num = 0; foreach (Column column in replaceClass.Columns) { ++num; if (!Common.IsPrimaryKey(replaceClass, column.Id) && !Common.IsStampType(column.DataType) && !Common.IsNotDisplay(column.Comment)) { if (!string.IsNullOrWhiteSpace(replaceClass.childTableColumnRef) && replaceClass.childTableColumnRef == column.Id) { newValue += this.m_DetailsRef.Replace(this.m_ReplaceAttribute, column.Code).Replace(this.m_ReplaceClassCode, replaceClass.Code + "2").Replace(this.m_Name, Common.GetShowColumnCode((TableView)replaceClass)).Replace('@', '"'); } else { RefIdName foreignKey = Common.GetForeignKey(replaceClass, column); if (foreignKey != null) { newValue += this.m_DetailsRef.Replace(this.m_ReplaceAttribute, column.Code).Replace(this.m_ReplaceClassCode, foreignKey.RefTableCode).Replace(this.m_Id, foreignKey.Id).Replace(this.m_Name, foreignKey.Name).Replace('@', '"'); } else if (!string.IsNullOrWhiteSpace(column.Code) && !string.IsNullOrWhiteSpace(column.DataType)) { newValue = !Common.IsStringType(column.DataType) ? newValue + this.m_DetailsString.Replace(this.m_ReplaceAttribute, column.Code).Replace('@', '"') : (string.IsNullOrWhiteSpace(column.Length) || Convert.ToInt32(column.Length) <= 200 ? newValue + this.m_DetailsString.Replace(this.m_ReplaceAttribute, column.Code).Replace('@', '"') : newValue + this.m_TextAreaForDetails.Replace(this.m_ReplaceAttribute, column.Code).Replace('\'', '"')); } } } } if (replaceClass.refNotId != null && Enumerable.Count <RefIdName>((IEnumerable <RefIdName>)replaceClass.refNotId) > 0) { foreach (RefIdName refIdName in replaceClass.refNotId) { ++num; newValue += this.m_DetailsNotRef.Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_Id, refIdName.Id).Replace(this.m_Name, refIdName.Name).Replace("ids", "ids" + num.ToString()).Replace("item", "item" + num.ToString()).Replace('@', '"'); } } string content = Common.Read(BaseClass.m_DempDirectory + "/Details.aspx").Replace("ViewPage<DAL.", "ViewPage<" + replaceClass.NameSpace + "DAL.").Replace(this.m_Details, newValue).Replace(this.m_DetailsmMster, this.m_DetailsSmall).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_ReplaceClassName, replaceClass.Name); string path = BaseClass.m_RootDirectory + "/" + this.m_App + this.m_Views + "/" + replaceClass.Code; Directory.CreateDirectory(path); Common.Write(path + "/Details.aspx", content); fileName.Add(replaceClass.Code + "/Details.aspx"); }
public void DoControllers(Table replaceClass, ref List<string> fileName) { string newValue1 = string.Empty; string str1 = string.Empty; string str2 = string.Empty; string newValue2 = string.Empty; string str3 = string.Empty; string oldValue = "entity.^m_Id^ = Result.GetNewId();"; string newValue3 = oldValue; string str4 = string.Empty; string str5 = string.Empty; string primaryKeyType = replaceClass.PrimaryKeyType; string nullPrimaryKeyType = Common.GetNullPrimaryKeyType(replaceClass.PrimaryKeyType); string newValue4; if (replaceClass.PrimaryKeyType == "int") { newValue3 = string.Empty; newValue4 = replaceClass.PrimaryKeyType + "[] deleteId = collection[@query@].GetString().Split(',').Select(s => Convert.ToInt32(s)).ToArray();".Replace('@', '"'); } else if (replaceClass.PrimaryKeyType == "Guid") { newValue3 = string.Empty; newValue4 = replaceClass.PrimaryKeyType + "[] deleteId = collection[@query@].GetString().Split(',').Select(s => new Guid(s)).ToArray();".Replace('@', '"'); } else if (replaceClass.PrimaryKeyType == "long") { newValue3 = string.Empty; newValue4 = replaceClass.PrimaryKeyType + "[] deleteId = collection[@query@].GetString().Split(',').Select(s => Convert.ToInt64(s)).ToArray();".Replace('@', '"'); } else if (replaceClass.PrimaryKeyType == "short") { newValue3 = string.Empty; newValue4 = replaceClass.PrimaryKeyType + "[] deleteId = collection[@query@].GetString().Split(',').Select(s => Convert.ToInt16(s)).ToArray();".Replace('@', '"'); } else newValue4 = "string[] deleteId = collection[@query@].GetString().Split(',');".Replace('@', '"'); string newValue5 = string.Empty; int num1 = 0; foreach (Column column in replaceClass.Columns) { Column it = column; ++num1; RefIdName refIdName = new RefIdName(); if (replaceClass.refId != null && Enumerable.Count<RefIdName>((IEnumerable<RefIdName>) replaceClass.refId) > 0) refIdName = Enumerable.FirstOrDefault<RefIdName>(Enumerable.Where<RefIdName>((IEnumerable<RefIdName>) replaceClass.refId, (Func<RefIdName, bool>) (s => s.Ref == it.Code))); if (num1 == 1) newValue5 = newValue5 + it.Code + " = s." + it.Code + "\n\t\t\t\t\t"; else if (refIdName != null && !string.IsNullOrWhiteSpace(refIdName.Id)) newValue5 = newValue5 + "," + it.Code + " = s." + it.Code + "Old\n\t\t\t\t\t"; else newValue5 = newValue5 + "," + it.Code + " = s." + it.Code + "\n\t\t\t\t\t"; } if (replaceClass.childTableColumnRef != null) { Column columnByKey = Common.GetColumnByKey(replaceClass, replaceClass.childTableColumnRef); string str6 = string.Empty; string str7 = !(replaceClass.PrimaryKeyType == "long") ? (!(replaceClass.PrimaryKeyType == "short") ? (!(replaceClass.PrimaryKeyType == "int") ? (!(replaceClass.PrimaryKeyType == "Guid") ? Common.Read(BaseClass.m_DempDirectory + this.m_TreeController).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace("^parentId^", "parentId") : Common.Read(BaseClass.m_DempDirectory + this.m_TreeController).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace("^parentId^", "new Guid(parentId)")) : Common.Read(BaseClass.m_DempDirectory + this.m_TreeController).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace("^parentId^", "Convert.ToInt32(parentId)")) : Common.Read(BaseClass.m_DempDirectory + this.m_TreeController).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace("^parentId^", "Convert.ToInt16(parentId)")) : Common.Read(BaseClass.m_DempDirectory + this.m_TreeController).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace("^parentId^", "Convert.ToInt64(parentId)"); Common.Write(BaseClass.m_RootDirectory + "/" + this.m_App + "/" + this.m_Controllers + "/" + replaceClass.Code + "TreeController.cs", str7.Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass))); fileName.Add("Controllers\\" + replaceClass.Code + "TreeController.cs"); string content1 = Common.Read(BaseClass.m_DempDirectory + this.m_TreeModel).Replace("ParentId", columnByKey.Code).Replace(this.m_String, nullPrimaryKeyType).Replace("Name", Common.GetShowColumnCode((TableView) replaceClass)).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_ReplaceAttribute, columnByKey.Code).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)); Common.Write(BaseClass.m_RootDirectory + "/" + this.m_App + "/" + this.m_Models + "/" + replaceClass.Code + "TreeModel.cs", content1); fileName.Add("Models\\" + replaceClass.Code + "TreeModel.cs"); string content2 = Common.Read(BaseClass.m_DempDirectory + this.m_TreeIndex).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code); string path = BaseClass.m_RootDirectory + "/" + this.m_App + this.m_Views + "/" + replaceClass.Code + "Tree"; Directory.CreateDirectory(path); Common.Write(path + "/Index.aspx", content2); fileName.Add("Views\\" + replaceClass.Code + "\\Index.aspx"); int num2 = 0; foreach (Column column in replaceClass.Columns) { Column it = column; ++num2; RefIdName refIdName = new RefIdName(); if (replaceClass.refId != null && Enumerable.Count<RefIdName>((IEnumerable<RefIdName>) replaceClass.refId) > 0) refIdName = Enumerable.FirstOrDefault<RefIdName>(Enumerable.Where<RefIdName>((IEnumerable<RefIdName>) replaceClass.refId, (Func<RefIdName, bool>) (s => s.Ref == it.Code))); if (num2 == 1) str3 = str3 + it.Code + " = s." + it.Code + "\n\t\t\t\t\t"; else if (it.Id == columnByKey.Id) str3 = str3 + ",_parentId = s." + it.Code + "\n\t\t\t\t\t,state = s." + replaceClass.Code + "1.Any(a => a." + it.Code + " == s." + Common.GetFirstPrimaryKeyCode(replaceClass) + ") ? @closed@ : null\n\t\t\t\t\t".Replace('@', '"'); else if (refIdName != null && !string.IsNullOrWhiteSpace(refIdName.Id)) str3 = str3 + "," + it.Code + "Old = s." + it.Code + "//自连接的表要注意,等号两边可能需要换位\n\t\t\t\t\t"; else if (it.Code.ToUpper() == "ICONIC") str3 = str3 + ",iconCls = s." + it.Code + "\n\t\t\t\t\t"; else str3 = str3 + "," + it.Code + " = s." + it.Code + "\n\t\t\t\t\t"; } newValue1 = newValue1 + "\r\n /// <summary>\r\n /// 获取树形列表的数据\r\n /// </summary>\r\n /// <returns></returns>\r\n [HttpPost]\r\n public ActionResult GetAllMetadata(^string^ id)\r\n {\r\n ^ReplaceClassCode^BLL m_BLL = new ^ReplaceClassCode^BLL();\r\n IQueryable<^ReplaceClassCode^> rows = m_BLL.GetAllMetadata(id);\r\n if (rows.Any())\r\n {//是否可以省\r\n return Json(new treegrid\r\n {\r\n rows = rows.Select(s =>\r\n new\r\n {\r\n ".Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_String, primaryKeyType) + str3 + "\r\n }\r\n ).OrderBy(o => o.^m_Id^)\r\n });\r\n }\r\n return Content(\"[]\");\r\n }"; } string content; if (replaceClass.refNotId != null && Enumerable.Count<RefIdName>((IEnumerable<RefIdName>) replaceClass.refNotId) > 0) { foreach (RefIdName refIdName in replaceClass.refNotId) { if (refIdName.IsRefSelf) { newValue2 = !(replaceClass.PrimaryKeyType == "int") ? (!(replaceClass.PrimaryKeyType == "Guid") ? newValue2 + this.m_Create.Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_ReplaceClassName, refIdName.RefTableCode).Replace("^Name^", refIdName.Name).Replace("^id^", "id") : newValue2 + this.m_Create.Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_ReplaceClassName, refIdName.RefTableCode).Replace("^Name^", refIdName.Name).Replace("^id^", "new Guid(id)")) : newValue2 + this.m_Create.Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_ReplaceClassName, refIdName.RefTableCode).Replace("^Name^", refIdName.Name).Replace("^id^", "Convert.ToInt32(id)"); newValue1 += this.m_GetTrees.Replace(this.m_ReplaceAttribute, refIdName.RefTableCode).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_ReplaceClassName, refIdName.RefTableName).Replace("^Name^", Common.GetShowColumnCode((TableView) replaceClass)).Replace(this.m_String, primaryKeyType).Replace('@', '"'); } } content = Common.Read(BaseClass.m_DempDirectory + this.m_DuoMoban).Replace("^clomus^", newValue5).Replace(this.m_TreeSef, newValue1).Replace(oldValue, newValue3).Replace(this.m_String, primaryKeyType).Replace(this.m_StringCreate, nullPrimaryKeyType).Replace("^query^", newValue4).Replace(this.m_CreateSef, newValue2).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace(this.m_Application, this.m_App); } else content = Common.Read(BaseClass.m_DempDirectory + this.m_DanMoban).Replace("^clomus^", newValue5).Replace(this.m_CreateSef, newValue2).Replace(oldValue, newValue3).Replace(this.m_String, primaryKeyType).Replace(this.m_StringCreate, nullPrimaryKeyType).Replace("^query^", newValue4).Replace(this.m_TreeSef, newValue1).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)); string str8 = BaseClass.m_RootDirectory + "/" + this.m_App + "/" + this.m_Controllers + "/"; foreach (Column column in replaceClass.Columns) { if (Common.IsCreatePerson(column)) content = content.Replace("//entity.CreatePerson = currentPerson;", "entity." + column.Code + " = currentPerson;"); else if (Common.IsCreateTime(column)) content = content.Replace("//entity.CreateTime = DateTime.Now;", "entity." + column.Code + " = DateTime.Now;"); else if (Common.IsUpdatePerson(column)) content = content.Replace("//entity.UpdatePerson = currentPerson;", "entity." + column.Code + " = currentPerson;"); else if (Common.IsUpdateTime(column)) content = content.Replace("//entity.UpdateTime = DateTime.Now;", "entity." + column.Code + " = DateTime.Now;"); } Common.Write(str8 + replaceClass.Code + "Controller.cs", content); fileName.Add("Controllers\\" + replaceClass.Code + "Controller.cs"); }
public void DoEdit(Table replaceClass, ref List <string> fileName) { StringBuilder stringBuilder = new StringBuilder(); string newValue1 = string.Empty; string newValue2 = string.Empty; int num = 0; string newValue3 = ""; string newValue4 = ""; bool flag = false; foreach (Column column in replaceClass.Columns) { ++num; if (Common.IsPrimaryKey(replaceClass, column.Id)) { newValue2 = newValue2 + "<%: Html.HiddenFor(model => model." + column.Code + " ) %>"; } else if (Common.IsStampType(column.DataType) || Common.IsCreatePerson(column) || Common.IsCreateTime(column)) { newValue2 = newValue2 + "<%: Html.HiddenFor(model => model." + column.Code + " ) %>"; } else if (!Common.IsUpdatePerson(column) && !Common.IsUpdateTime(column) && !Common.IsCreatePerson(column) && (!Common.IsCreateTime(column) && !Common.IsNotDisplay(column.Comment)) && !Common.IsWorkFlow(column.Comment)) { if (!string.IsNullOrWhiteSpace(replaceClass.childTableColumnRef) && replaceClass.childTableColumnRef == column.Id) { newValue2 += this.m_SelfEdit.Replace(this.m_Name, Common.GetShowColumnCode((TableView)replaceClass)).Replace(this.m_ReplaceAttribute, column.Code).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace('@', '"'); } else { RefIdName foreignKey = Common.GetForeignKey(replaceClass, column); if (foreignKey != null) { newValue2 += this.m_EditRef.Replace(this.m_Name, foreignKey.Name).Replace(this.m_ReplaceAttribute, foreignKey.Ref).Replace(this.m_ReplaceClassCode, foreignKey.RefTableCode).Replace('@', '"'); } else if (!string.IsNullOrWhiteSpace(column.Code) && !string.IsNullOrWhiteSpace(column.DataType)) { if (Common.IsIntType(column.DataType)) { newValue2 += this.m_EditorForInt.Replace(this.m_ReplaceAttribute, column.Code).Replace('*', '"'); } else if (Common.IsDateType(column.DataType)) { if (!flag) { flag = true; } newValue2 += this.m_EditorForDate.Replace(this.m_ReplaceAttribute, column.Code).Replace('*', '"'); } else if (Common.IsDecimalType(column.DataType)) { newValue2 += this.m_EditorFor.Replace(this.m_ReplaceAttribute, column.Code).Replace('@', '"'); } else if (Common.IsStringType(column.DataType)) { if (column.Comment.Contains("RadioButton")) { newValue2 = !(column.Mandatory == "1") ? newValue2 + this.m_CreateRadioButtonFor.Replace(this.m_ReplaceClassCode, column.TableCode).Replace(this.m_ReplaceAttribute, column.Code).Replace('@', '"').Replace(this.m_RadioButtonListChecked, "false") : newValue2 + this.m_CreateRadioButtonFor.Replace(this.m_ReplaceClassCode, column.TableCode).Replace(this.m_ReplaceAttribute, column.Code).Replace('@', '"').Replace(this.m_RadioButtonListChecked, "true"); } else if (column.Comment.Contains("DropDown")) { newValue2 += this.m_CreateEditorFor.Replace(this.m_ReplaceClassCode, column.TableCode).Replace(this.m_ReplaceAttribute, column.Code).Replace('@', '"'); } else if (column.Comment.Contains("Cascade")) { string newValue5 = column.Comment.Substring(0, column.Comment.IndexOf("Cascade")); newValue2 += this.m_LianDongEditorFor.Replace(this.m_ReplaceClassCode, column.TableCode).Replace(this.m_ReplaceAttribute, column.Code).Replace("^MyParent^", newValue5).Replace('@', '"'); newValue3 += "\r\n \r\n $(@#myparent@).change(function () { get^ReplaceAttribute^(@#^ReplaceAttribute^@); });\r\n".Replace(this.m_ReplaceAttribute, column.Code).Replace("myparent", newValue5).Replace('@', '"'); newValue4 += "\r\n function get^ReplaceAttribute^(^ReplaceAttribute^) {\r\n $(^ReplaceAttribute^).empty();\r\n $(@<option></option>@)\r\n .val(@@)\r\n .text(@请选择@)\r\n .appendTo($(^ReplaceAttribute^));\r\n bindDropDownList(^ReplaceAttribute^, @#myparent@);\r\n $(^ReplaceAttribute^).change();\r\n }\r\n".Replace(this.m_ReplaceAttribute, column.Code).Replace("myparent", newValue5).Replace('@', '"'); } else { newValue2 = string.IsNullOrWhiteSpace(column.Length) || Convert.ToInt32(column.Length) <= 200 ? newValue2 + this.m_EditorFor.Replace(this.m_ReplaceAttribute, column.Code).Replace('@', '"') : newValue2 + this.m_TextAreaFor.Replace(this.m_ReplaceAttribute, column.Code).Replace('\'', '"'); } } else { newValue2 += this.m_EditorFor.Replace(this.m_ReplaceAttribute, column.Code).Replace('@', '"'); } } } } } if (replaceClass.refNotId != null && Enumerable.Count <RefIdName>((IEnumerable <RefIdName>)replaceClass.refNotId) > 0) { foreach (RefIdName refIdName in replaceClass.refNotId) { ++num; if (!refIdName.IsRefSelf) { if (refIdName.RefTableCode.ToUpper() == "FILEUPLOADER") { newValue2 += this.m_EditNotRefUp.Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_Id, refIdName.Id).Replace(this.m_Name, refIdName.Name).Replace("ids", "ids" + num.ToString()).Replace("item", "item" + num.ToString()).Replace('@', '"'); newValue3 += this.m_UpLodeJs.Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace('@', '"'); newValue1 += this.m_UpLoaderScript.Replace('@', '"'); } else { newValue2 += this.m_EditNotRef.Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_Id, refIdName.Id).Replace(this.m_Name, refIdName.Name).Replace("ids", "ids" + num.ToString()).Replace("item", "item" + num.ToString()).Replace('@', '"'); } } } } string content = Common.Read(BaseClass.m_DempDirectory + "/Edit.aspx").Replace("ViewPage<DAL.", "ViewPage<" + replaceClass.NameSpace + "DAL.").Replace("App.", replaceClass.NameSpace + "App.").Replace("liandongchushihua", newValue3).Replace("liandonghanshu", newValue4).Replace(this.m_CreatePage, newValue2).Replace(this.m_PickTimeCrea, newValue1).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_ReplaceClassName, replaceClass.Name); string path = BaseClass.m_RootDirectory + "/" + this.m_App + this.m_Views + "/" + replaceClass.Code; Directory.CreateDirectory(path); Common.Write(path + "/Edit.aspx", content); fileName.Add(replaceClass.Code + "/Edit.aspx"); }
public string DoBLL(Table replaceClass, ref List<string> fileName) { string newValue1 = string.Empty; string newValue2 = string.Empty; string newValue3 = string.Empty; string str1 = string.Empty; string newValue4 = string.Empty; string primaryKeyType = replaceClass.PrimaryKeyType; string nullPrimaryKeyType = Common.GetNullPrimaryKeyType(replaceClass.PrimaryKeyType); if (replaceClass.childTableColumnRef != null) { Column columnByKey = Common.GetColumnByKey(replaceClass, replaceClass.childTableColumnRef); if (string.IsNullOrWhiteSpace(newValue3)) newValue3 += "\r\n foreach (var item in queryData)\r\n {"; newValue3 += this.m_FlexigridSelfRef.Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_ReplaceAttribute, columnByKey.Code).Replace(this.m_Name, Common.GetShowColumnCode((TableView) replaceClass)).Replace('@', '"'); int num = 0; foreach (Column column in replaceClass.Columns) { Column it = column; if (!Common.IsStampType(it.DataType)) { ++num; RefIdName refIdName = new RefIdName(); if (replaceClass.refId != null && Enumerable.Count<RefIdName>((IEnumerable<RefIdName>) replaceClass.refId) > 0) refIdName = Enumerable.FirstOrDefault<RefIdName>(Enumerable.Where<RefIdName>((IEnumerable<RefIdName>) replaceClass.refId, (Func<RefIdName, bool>) (s => s.Ref == it.Code))); } } newValue2 += "\r\n public IQueryable<^ReplaceClassCode^> GetAllMetadata(^string^ id)\r\n { \r\n if (id == null)\r\n {\r\n return db.^ReplaceClassCode^.Where(w => w.^ParentId^ == null).AsQueryable();\r\n }\r\n else\r\n {\r\n return db.^ReplaceClassCode^.Where(w => w.^ParentId^ == id).AsQueryable();\r\n }\r\n }\r\n".Replace("^ParentId^", columnByKey.Code).Replace(this.m_String, primaryKeyType); } if (replaceClass.refId != null && Enumerable.Count<RefIdName>((IEnumerable<RefIdName>) replaceClass.refId) > 0) { foreach (RefIdName refIdName in replaceClass.refId) { if (string.IsNullOrWhiteSpace(newValue3)) newValue3 += "\r\n foreach (var item in queryData)\r\n {"; newValue3 += this.m_FlexigridRef.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.Ref).Replace(this.m_Name, refIdName.Name).Replace('@', '"'); newValue4 += this.m_ByRefId.Replace(this.m_String, refIdName.RefType).Replace(this.m_ReplaceClassCode, refIdName.Ref).Replace(this.m_ReplaceAttribute, replaceClass.Name).Replace(this.m_ReplaceClassName, replaceClass.Code).Replace('@', '"'); } } string str2; if (replaceClass.refNotId != null && Enumerable.Count<RefIdName>((IEnumerable<RefIdName>) replaceClass.refNotId) > 0) { string newValue5 = string.Empty; string newValue6 = string.Empty; string newValue7 = string.Empty; foreach (RefIdName refIdName in replaceClass.refNotId) { if (string.IsNullOrWhiteSpace(newValue3)) newValue3 += "\r\n foreach (var item in queryData) \r\n {"; newValue3 += this.m_FlexigridNotRef.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Name, refIdName.Name).Replace('@', '"'); if (refIdName.RefType == "int") { newValue6 += this.m_CreateDown.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Id, refIdName.Id).Replace("^item^", "Convert.ToInt32(item)"); newValue5 += this.m_EditDown.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Id, refIdName.Id).Replace("^item^", "Convert.ToInt32(item)"); } else if (refIdName.RefType == "Guid") { newValue6 += this.m_CreateDown.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Id, refIdName.Id).Replace("^item^", "new Guid(item)"); newValue5 += this.m_EditDown.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Id, refIdName.Id).Replace("^item^", "new Guid(item)"); } else { newValue6 += this.m_CreateDown.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Id, refIdName.Id).Replace("^item^", "item"); newValue5 += this.m_EditDown.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Id, refIdName.Id).Replace("^item^", "item"); } if (refIdName.IsRefSelf) { newValue7 += this.m_ReplaceFlexigridSefContent.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace('@', '"'); newValue1 = !(refIdName.RefType == "int") ? (!(refIdName.RefType == "Guid") ? newValue1 + this.m_SetToMany.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_PickTimeCrea, replaceClass.Code).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_ReplaceClassName, refIdName.RefTableName).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace('@', '"').Replace("^item^", "item") : newValue1 + this.m_SetToMany.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_PickTimeCrea, replaceClass.Code).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_ReplaceClassName, refIdName.RefTableName).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace('@', '"').Replace("^item^", "new Guid(item)")) : newValue1 + this.m_SetToMany.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_PickTimeCrea, replaceClass.Code).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_ReplaceClassName, refIdName.RefTableName).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace('@', '"').Replace("^item^", "Convert.ToInt32(item)"); } newValue1 += this.m_RefGetSelectDuo.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace('@', '"'); } if (!string.IsNullOrWhiteSpace(newValue3)) newValue3 += "\r\n }\r\n"; str2 = Common.Read(BaseClass.m_DempDirectory + this.m_DuoMoban).Replace(this.m_RefGetSelectList, newValue1).Replace(this.m_ReplaceFlexigridSef, newValue7).Replace(this.m_CopyMetadata, string.IsNullOrWhiteSpace(newValue2) ? "" : this.m_CopyMetadata2.Replace(this.m_CopyMetadata, newValue2)).Replace(this.m_ReplaceFlexigrid, newValue3).Replace(this.m_DuoRefCreateDown, newValue6).Replace(this.m_DuoRefEditDown, newValue5).Replace(this.m_GetByRefId, newValue4).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace(this.m_String, primaryKeyType); } else { if (!string.IsNullOrWhiteSpace(newValue3)) newValue3 += "\r\n }\r\n"; str2 = Common.Read(BaseClass.m_DempDirectory + this.m_DanMoban).Replace(this.m_CopyMetadata, string.IsNullOrWhiteSpace(newValue2) ? "" : this.m_CopyMetadata2.Replace(this.m_CopyMetadata, newValue2)).Replace(this.m_ReplaceFlexigrid, newValue3).Replace(this.m_RefGetSelectList, newValue1).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_GetByRefId, newValue4).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace(this.m_String, primaryKeyType); } string newValue8 = string.Empty; foreach (Column column in replaceClass.Columns) { if (column.Comment.Contains("Sort")) { newValue8 = newValue8 + ".OrderBy(o => o." + column.Code + ")"; break; } } if (string.IsNullOrEmpty(newValue8)) { if (Common.GetFirstPrimaryKey(replaceClass) == null) return replaceClass.Name + ",表没有主键"; newValue8 = ".OrderBy(o => o." + Common.GetFirstPrimaryKey(replaceClass).Code + ")"; } string content = str2.Replace("^m_Sort^", newValue8).Replace(BaseClass.m_BLLnamespace, replaceClass.NameSpace + "BLL").Replace(this.m_StringCreate, nullPrimaryKeyType).Replace(BaseClass.m_DALnamespace, replaceClass.NameSpace + "DAL"); Common.Write(BaseClass.m_RootDirectory + "/" + this.m_BLL + "/" + replaceClass.Code + this.m_BLL + ".cs", content); fileName.Add(replaceClass.Code); this.m_Content.Clear(); return string.Empty; }
public void DoControllers(Table replaceClass, ref List <string> fileName) { string newValue1 = string.Empty; string str1 = string.Empty; string str2 = string.Empty; string newValue2 = string.Empty; string str3 = string.Empty; string oldValue = "entity.^m_Id^ = Result.GetNewId();"; string newValue3 = oldValue; string str4 = string.Empty; string str5 = string.Empty; string primaryKeyType = replaceClass.PrimaryKeyType; string nullPrimaryKeyType = Common.GetNullPrimaryKeyType(replaceClass.PrimaryKeyType); string newValue4; if (replaceClass.PrimaryKeyType == "int") { newValue3 = string.Empty; newValue4 = replaceClass.PrimaryKeyType + "[] deleteId = collection[@query@].GetString().Split(',').Select(s => Convert.ToInt32(s)).ToArray();".Replace('@', '"'); } else if (replaceClass.PrimaryKeyType == "Guid") { newValue3 = string.Empty; newValue4 = replaceClass.PrimaryKeyType + "[] deleteId = collection[@query@].GetString().Split(',').Select(s => new Guid(s)).ToArray();".Replace('@', '"'); } else if (replaceClass.PrimaryKeyType == "long") { newValue3 = string.Empty; newValue4 = replaceClass.PrimaryKeyType + "[] deleteId = collection[@query@].GetString().Split(',').Select(s => Convert.ToInt64(s)).ToArray();".Replace('@', '"'); } else if (replaceClass.PrimaryKeyType == "short") { newValue3 = string.Empty; newValue4 = replaceClass.PrimaryKeyType + "[] deleteId = collection[@query@].GetString().Split(',').Select(s => Convert.ToInt16(s)).ToArray();".Replace('@', '"'); } else { newValue4 = "string[] deleteId = collection[@query@].GetString().Split(',');".Replace('@', '"'); } string newValue5 = string.Empty; int num1 = 0; foreach (Column column in replaceClass.Columns) { Column it = column; ++num1; RefIdName refIdName = new RefIdName(); if (replaceClass.refId != null && Enumerable.Count <RefIdName>((IEnumerable <RefIdName>)replaceClass.refId) > 0) { refIdName = Enumerable.FirstOrDefault <RefIdName>(Enumerable.Where <RefIdName>((IEnumerable <RefIdName>)replaceClass.refId, (Func <RefIdName, bool>)(s => s.Ref == it.Code))); } if (num1 == 1) { newValue5 = newValue5 + it.Code + " = s." + it.Code + "\n\t\t\t\t\t"; } else if (refIdName != null && !string.IsNullOrWhiteSpace(refIdName.Id)) { newValue5 = newValue5 + "," + it.Code + " = s." + it.Code + "Old\n\t\t\t\t\t"; } else { newValue5 = newValue5 + "," + it.Code + " = s." + it.Code + "\n\t\t\t\t\t"; } } if (replaceClass.childTableColumnRef != null) { Column columnByKey = Common.GetColumnByKey(replaceClass, replaceClass.childTableColumnRef); string str6 = string.Empty; string str7 = !(replaceClass.PrimaryKeyType == "long") ? (!(replaceClass.PrimaryKeyType == "short") ? (!(replaceClass.PrimaryKeyType == "int") ? (!(replaceClass.PrimaryKeyType == "Guid") ? Common.Read(BaseClass.m_DempDirectory + this.m_TreeController).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace("^parentId^", "parentId") : Common.Read(BaseClass.m_DempDirectory + this.m_TreeController).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace("^parentId^", "new Guid(parentId)")) : Common.Read(BaseClass.m_DempDirectory + this.m_TreeController).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace("^parentId^", "Convert.ToInt32(parentId)")) : Common.Read(BaseClass.m_DempDirectory + this.m_TreeController).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace("^parentId^", "Convert.ToInt16(parentId)")) : Common.Read(BaseClass.m_DempDirectory + this.m_TreeController).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace("^parentId^", "Convert.ToInt64(parentId)"); Common.Write(BaseClass.m_RootDirectory + "/" + this.m_App + "/" + this.m_Controllers + "/" + replaceClass.Code + "TreeController.cs", str7.Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass))); fileName.Add("Controllers\\" + replaceClass.Code + "TreeController.cs"); string content1 = Common.Read(BaseClass.m_DempDirectory + this.m_TreeModel).Replace("ParentId", columnByKey.Code).Replace(this.m_String, nullPrimaryKeyType).Replace("Name", Common.GetShowColumnCode((TableView)replaceClass)).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_ReplaceAttribute, columnByKey.Code).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)); Common.Write(BaseClass.m_RootDirectory + "/" + this.m_App + "/" + this.m_Models + "/" + replaceClass.Code + "TreeModel.cs", content1); fileName.Add("Models\\" + replaceClass.Code + "TreeModel.cs"); string content2 = Common.Read(BaseClass.m_DempDirectory + this.m_TreeIndex).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassCode, replaceClass.Code); string path = BaseClass.m_RootDirectory + "/" + this.m_App + this.m_Views + "/" + replaceClass.Code + "Tree"; Directory.CreateDirectory(path); Common.Write(path + "/Index.aspx", content2); fileName.Add("Views\\" + replaceClass.Code + "\\Index.aspx"); int num2 = 0; foreach (Column column in replaceClass.Columns) { Column it = column; ++num2; RefIdName refIdName = new RefIdName(); if (replaceClass.refId != null && Enumerable.Count <RefIdName>((IEnumerable <RefIdName>)replaceClass.refId) > 0) { refIdName = Enumerable.FirstOrDefault <RefIdName>(Enumerable.Where <RefIdName>((IEnumerable <RefIdName>)replaceClass.refId, (Func <RefIdName, bool>)(s => s.Ref == it.Code))); } if (num2 == 1) { str3 = str3 + it.Code + " = s." + it.Code + "\n\t\t\t\t\t"; } else if (it.Id == columnByKey.Id) { str3 = str3 + ",_parentId = s." + it.Code + "\n\t\t\t\t\t,state = s." + replaceClass.Code + "1.Any(a => a." + it.Code + " == s." + Common.GetFirstPrimaryKeyCode(replaceClass) + ") ? @closed@ : null\n\t\t\t\t\t".Replace('@', '"'); } else if (refIdName != null && !string.IsNullOrWhiteSpace(refIdName.Id)) { str3 = str3 + "," + it.Code + "Old = s." + it.Code + "//自连接的表要注意,等号两边可能需要换位\n\t\t\t\t\t"; } else if (it.Code.ToUpper() == "ICONIC") { str3 = str3 + ",iconCls = s." + it.Code + "\n\t\t\t\t\t"; } else { str3 = str3 + "," + it.Code + " = s." + it.Code + "\n\t\t\t\t\t"; } } newValue1 = newValue1 + "\r\n /// <summary>\r\n /// 获取树形列表的数据\r\n /// </summary>\r\n /// <returns></returns>\r\n [HttpPost]\r\n public ActionResult GetAllMetadata(^string^ id)\r\n {\r\n ^ReplaceClassCode^BLL m_BLL = new ^ReplaceClassCode^BLL();\r\n IQueryable<^ReplaceClassCode^> rows = m_BLL.GetAllMetadata(id);\r\n if (rows.Any())\r\n {//是否可以省\r\n return Json(new treegrid\r\n {\r\n rows = rows.Select(s =>\r\n new\r\n {\r\n ".Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_String, primaryKeyType) + str3 + "\r\n }\r\n ).OrderBy(o => o.^m_Id^)\r\n });\r\n }\r\n return Content(\"[]\");\r\n }"; } string content; if (replaceClass.refNotId != null && Enumerable.Count <RefIdName>((IEnumerable <RefIdName>)replaceClass.refNotId) > 0) { foreach (RefIdName refIdName in replaceClass.refNotId) { if (refIdName.IsRefSelf) { newValue2 = !(replaceClass.PrimaryKeyType == "int") ? (!(replaceClass.PrimaryKeyType == "Guid") ? newValue2 + this.m_Create.Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_ReplaceClassName, refIdName.RefTableCode).Replace("^Name^", refIdName.Name).Replace("^id^", "id") : newValue2 + this.m_Create.Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_ReplaceClassName, refIdName.RefTableCode).Replace("^Name^", refIdName.Name).Replace("^id^", "new Guid(id)")) : newValue2 + this.m_Create.Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_ReplaceClassName, refIdName.RefTableCode).Replace("^Name^", refIdName.Name).Replace("^id^", "Convert.ToInt32(id)"); newValue1 += this.m_GetTrees.Replace(this.m_ReplaceAttribute, refIdName.RefTableCode).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_ReplaceClassName, refIdName.RefTableName).Replace("^Name^", Common.GetShowColumnCode((TableView)replaceClass)).Replace(this.m_String, primaryKeyType).Replace('@', '"'); } } content = Common.Read(BaseClass.m_DempDirectory + this.m_DuoMoban).Replace("^clomus^", newValue5).Replace(this.m_TreeSef, newValue1).Replace(oldValue, newValue3).Replace(this.m_String, primaryKeyType).Replace(this.m_StringCreate, nullPrimaryKeyType).Replace("^query^", newValue4).Replace(this.m_CreateSef, newValue2).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace(this.m_Application, this.m_App); } else { content = Common.Read(BaseClass.m_DempDirectory + this.m_DanMoban).Replace("^clomus^", newValue5).Replace(this.m_CreateSef, newValue2).Replace(oldValue, newValue3).Replace(this.m_String, primaryKeyType).Replace(this.m_StringCreate, nullPrimaryKeyType).Replace("^query^", newValue4).Replace(this.m_TreeSef, newValue1).Replace(this.m_Application, this.m_App).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)); } string str8 = BaseClass.m_RootDirectory + "/" + this.m_App + "/" + this.m_Controllers + "/"; foreach (Column column in replaceClass.Columns) { if (Common.IsCreatePerson(column)) { content = content.Replace("//entity.CreatePerson = currentPerson;", "entity." + column.Code + " = currentPerson;"); } else if (Common.IsCreateTime(column)) { content = content.Replace("//entity.CreateTime = DateTime.Now;", "entity." + column.Code + " = DateTime.Now;"); } else if (Common.IsUpdatePerson(column)) { content = content.Replace("//entity.UpdatePerson = currentPerson;", "entity." + column.Code + " = currentPerson;"); } else if (Common.IsUpdateTime(column)) { content = content.Replace("//entity.UpdateTime = DateTime.Now;", "entity." + column.Code + " = DateTime.Now;"); } } Common.Write(str8 + replaceClass.Code + "Controller.cs", content); fileName.Add("Controllers\\" + replaceClass.Code + "Controller.cs"); }
public string DoBLL(Table replaceClass, ref List <string> fileName) { string newValue1 = string.Empty; string newValue2 = string.Empty; string newValue3 = string.Empty; string str1 = string.Empty; string newValue4 = string.Empty; string primaryKeyType = replaceClass.PrimaryKeyType; string nullPrimaryKeyType = Common.GetNullPrimaryKeyType(replaceClass.PrimaryKeyType); if (replaceClass.childTableColumnRef != null) { Column columnByKey = Common.GetColumnByKey(replaceClass, replaceClass.childTableColumnRef); if (string.IsNullOrWhiteSpace(newValue3)) { newValue3 += "\r\n foreach (var item in queryData)\r\n {"; } newValue3 += this.m_FlexigridSelfRef.Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_ReplaceAttribute, columnByKey.Code).Replace(this.m_Name, Common.GetShowColumnCode((TableView)replaceClass)).Replace('@', '"'); int num = 0; foreach (Column column in replaceClass.Columns) { Column it = column; if (!Common.IsStampType(it.DataType)) { ++num; RefIdName refIdName = new RefIdName(); if (replaceClass.refId != null && Enumerable.Count <RefIdName>((IEnumerable <RefIdName>)replaceClass.refId) > 0) { refIdName = Enumerable.FirstOrDefault <RefIdName>(Enumerable.Where <RefIdName>((IEnumerable <RefIdName>)replaceClass.refId, (Func <RefIdName, bool>)(s => s.Ref == it.Code))); } } } newValue2 += "\r\n public IQueryable<^ReplaceClassCode^> GetAllMetadata(^string^ id)\r\n { \r\n if (id == null)\r\n {\r\n return db.^ReplaceClassCode^.Where(w => w.^ParentId^ == null).AsQueryable();\r\n }\r\n else\r\n {\r\n return db.^ReplaceClassCode^.Where(w => w.^ParentId^ == id).AsQueryable();\r\n }\r\n }\r\n".Replace("^ParentId^", columnByKey.Code).Replace(this.m_String, primaryKeyType); } if (replaceClass.refId != null && Enumerable.Count <RefIdName>((IEnumerable <RefIdName>)replaceClass.refId) > 0) { foreach (RefIdName refIdName in replaceClass.refId) { if (string.IsNullOrWhiteSpace(newValue3)) { newValue3 += "\r\n foreach (var item in queryData)\r\n {"; } newValue3 += this.m_FlexigridRef.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.Ref).Replace(this.m_Name, refIdName.Name).Replace('@', '"'); newValue4 += this.m_ByRefId.Replace(this.m_String, refIdName.RefType).Replace(this.m_ReplaceClassCode, refIdName.Ref).Replace(this.m_ReplaceAttribute, replaceClass.Name).Replace(this.m_ReplaceClassName, replaceClass.Code).Replace('@', '"'); } } string str2; if (replaceClass.refNotId != null && Enumerable.Count <RefIdName>((IEnumerable <RefIdName>)replaceClass.refNotId) > 0) { string newValue5 = string.Empty; string newValue6 = string.Empty; string newValue7 = string.Empty; foreach (RefIdName refIdName in replaceClass.refNotId) { if (string.IsNullOrWhiteSpace(newValue3)) { newValue3 += "\r\n foreach (var item in queryData) \r\n {"; } newValue3 += this.m_FlexigridNotRef.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Name, refIdName.Name).Replace('@', '"'); if (refIdName.RefType == "int") { newValue6 += this.m_CreateDown.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Id, refIdName.Id).Replace("^item^", "Convert.ToInt32(item)"); newValue5 += this.m_EditDown.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Id, refIdName.Id).Replace("^item^", "Convert.ToInt32(item)"); } else if (refIdName.RefType == "Guid") { newValue6 += this.m_CreateDown.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Id, refIdName.Id).Replace("^item^", "new Guid(item)"); newValue5 += this.m_EditDown.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Id, refIdName.Id).Replace("^item^", "new Guid(item)"); } else { newValue6 += this.m_CreateDown.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Id, refIdName.Id).Replace("^item^", "item"); newValue5 += this.m_EditDown.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_Id, refIdName.Id).Replace("^item^", "item"); } if (refIdName.IsRefSelf) { newValue7 += this.m_ReplaceFlexigridSefContent.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace('@', '"'); newValue1 = !(refIdName.RefType == "int") ? (!(refIdName.RefType == "Guid") ? newValue1 + this.m_SetToMany.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_PickTimeCrea, replaceClass.Code).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_ReplaceClassName, refIdName.RefTableName).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace('@', '"').Replace("^item^", "item") : newValue1 + this.m_SetToMany.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_PickTimeCrea, replaceClass.Code).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_ReplaceClassName, refIdName.RefTableName).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace('@', '"').Replace("^item^", "new Guid(item)")) : newValue1 + this.m_SetToMany.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_PickTimeCrea, replaceClass.Code).Replace(this.m_ReplaceAttribute, refIdName.RefTableCode + refIdName.Id).Replace(this.m_ReplaceClassName, refIdName.RefTableName).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace('@', '"').Replace("^item^", "Convert.ToInt32(item)"); } newValue1 += this.m_RefGetSelectDuo.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace('@', '"'); } if (!string.IsNullOrWhiteSpace(newValue3)) { newValue3 += "\r\n }\r\n"; } str2 = Common.Read(BaseClass.m_DempDirectory + this.m_DuoMoban).Replace(this.m_RefGetSelectList, newValue1).Replace(this.m_ReplaceFlexigridSef, newValue7).Replace(this.m_CopyMetadata, string.IsNullOrWhiteSpace(newValue2) ? "" : this.m_CopyMetadata2.Replace(this.m_CopyMetadata, newValue2)).Replace(this.m_ReplaceFlexigrid, newValue3).Replace(this.m_DuoRefCreateDown, newValue6).Replace(this.m_DuoRefEditDown, newValue5).Replace(this.m_GetByRefId, newValue4).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace(this.m_String, primaryKeyType); } else { if (!string.IsNullOrWhiteSpace(newValue3)) { newValue3 += "\r\n }\r\n"; } str2 = Common.Read(BaseClass.m_DempDirectory + this.m_DanMoban).Replace(this.m_CopyMetadata, string.IsNullOrWhiteSpace(newValue2) ? "" : this.m_CopyMetadata2.Replace(this.m_CopyMetadata, newValue2)).Replace(this.m_ReplaceFlexigrid, newValue3).Replace(this.m_RefGetSelectList, newValue1).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_GetByRefId, newValue4).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace(this.m_String, primaryKeyType); } string newValue8 = string.Empty; foreach (Column column in replaceClass.Columns) { if (column.Comment.Contains("Sort")) { newValue8 = newValue8 + ".OrderBy(o => o." + column.Code + ")"; break; } } if (string.IsNullOrEmpty(newValue8)) { if (Common.GetFirstPrimaryKey(replaceClass) == null) { return(replaceClass.Name + ",表没有主键"); } newValue8 = ".OrderBy(o => o." + Common.GetFirstPrimaryKey(replaceClass).Code + ")"; } string content = str2.Replace("^m_Sort^", newValue8).Replace(BaseClass.m_BLLnamespace, replaceClass.NameSpace + "BLL").Replace(this.m_StringCreate, nullPrimaryKeyType).Replace(BaseClass.m_DALnamespace, replaceClass.NameSpace + "DAL"); Common.Write(BaseClass.m_RootDirectory + "/" + this.m_BLL + "/" + replaceClass.Code + this.m_BLL + ".cs", content); fileName.Add(replaceClass.Code); this.m_Content.Clear(); return(string.Empty); }