public void ModelCodeGenerationTest() { string resultMsg = string.Empty; var gen = new CodeGenerators(); //var code = gen.ModelCodeGeneration(out resultMsg, "Models", "SHIP_INFO", BaseDict.OracleData); var criteria = new GeneratorCriteria(); criteria.ModelsNamespace = "Models"; criteria.ModelClassNamePrefix = "Model"; criteria.DalNamespace = "Logic"; criteria.DalClassNamePrefix = "Logic"; criteria.TableName = "TUSER"; criteria.DataBaseType = BaseDict.OracleData; var code = gen.ModelCodeGeneration(out resultMsg, criteria.TableName, criteria.DataBaseType, criteria.DataBaseName, criteria.ModelsNamespace, criteria.ModelClassNamePrefix); var code1 = string.Empty; Assert.AreNotEqual(code, code1); }
//C# Model 层代码生成按钮事件 private void btnGenerate_Click(object sender, EventArgs e) { string resultMsg = string.Empty; string strDataAccess = ConfigurationManager.AppSettings["DataAccess"]; CodeGenerators gen = new CodeGenerators(); try { if (cboSqlDataBase.Text == "Please select" || (string.IsNullOrWhiteSpace(cboSqlDataBase.Text) && strDataAccess.Equals(BaseDict.SqlServerData))) { MessageBox.Show("请选择数据库!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cboSqlDataTable.Text == "Please select" || string.IsNullOrWhiteSpace(cboSqlDataTable.Text)) { MessageBox.Show("请选择数据表!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } rtxtCont.Text = gen.ModelCodeGeneration(out resultMsg, cboSqlDataTable.Text.Trim(), strDataAccess, cboSqlDataBase.Text.Trim(), txtModelsNamespace.Text.Trim(), txtModelClassNamePrefix.Text.Trim()); SetStyle(); } catch (Exception ex) { MessageBox.Show("Error:" + ex.ToString()); } }