public ModuleField(Module parent, string title, string name, string codename) { this.Id = Guid.NewGuid(); this.Parent = parent; this.Title = title; this.FieldName = name; this.CodeName = codename; }
//private readonly string Temp_Query_Model = Comm.GetTemplete("Query.Model.cshtml"); //private readonly string Temp_Query_GetList = Comm.GetTemplete("Query.GetList.cshtml"); //private readonly string Temp_Query_GetOne = Comm.GetTemplete("Query.GetOne.cshtml"); //private readonly string Temp_Query_ExecuteNonQuery = Comm.GetTemplete("Query.ExecuteNonQuery.cshtml"); //private readonly string Temp_Query_ExecuteScalar = Comm.GetTemplete("Query.ExecuteScalar.cshtml"); //private readonly string Temp_Query_GetMultiList = Comm.GetTemplete("Query.GetMultiList.cshtml"); public string GenForQueryList(string query, Module module, string connstr) { DbQueryGetListModel gModel = new DbQueryGetListModel(); gModel.SQL = query; gModel.ConnectionString = connstr; gModel.Module = module; //if (ds != null && ds.Tables != null && ds.Tables.Count > 0) //{ // for (int i = 0; i < ds.Tables.Count; i++) // { // DataTable dt = ds.Tables[i]; // Module module = new Module(); // module.ModuleName = string.Format("Result{0}", i); // module.CodeName = string.Format("Result{0}", i); // foreach (DataColumn dc in dt.Columns) // { // ModuleField mf = new ModuleField(module, "", dc.ColumnName, dc.ColumnName); // mf.DataType = dc.DataType; // mf.Nullable = dc.AllowDBNull; // mf.LanguageType = LanguageConvert.GetCSharpType(dc.DataType, dc.AllowDBNull); // //Debug.WriteLine("{0} ---> {1}", mf.FieldName, mf.LanguageType); // module.Fields.Add(mf); // } // gModel.Module = module; // } //} string modelCode = GenModelCode(gModel.Module); StringBuilder sb = new StringBuilder(); sb.AppendLine(modelCode); string queryCode = codeGen.Gen(Comm.GetTemplete("Query.GetList.cshtml"), gModel); queryCode = queryCode.Replace("'conn_name'", "Program.TestConnection"); sb.AppendLine(queryCode); return sb.ToString(); }
private string GenModelCode(Module module) { return codeGen.Gen(Comm.GetTemplete("Query.Model.cshtml"), module); }
public DbQueryGetListModel() { this.Module = new Module(); }
public PageFormModel(ITableInfo tbInfo) { this.FormModule = new Module(tbInfo); }
public PageFormModel() { this.FormModule = new Module(); }
public StringField(Module parent, string title, string name, string codename) : base(parent, title, name, codename) { }
public CollectionField(Module parent, string title, Module entity, ModuleRelationship relationship) : base(parent, title, "", "") { this.RelationshipEntity = entity; this.Relationship = relationship; }
private void ResultSettingPage_Commit(object sender, AeroWizard.WizardPageConfirmEventArgs e) { if (ResultList == null || ResultList.Count == 0) return; DbQueryCodeGen gen = new DbQueryCodeGen(); string code = string.Empty; string connstr = App.Instance.DBLink.ConnectionString; if (ResultList.Count == 1) { var ctrl = ResultList[0]; Module module = new Module(); module.ModuleName = ctrl.RowClassName; module.CodeName = ctrl.RowClassName; if (ctrl.DataTable != null) { foreach (DataColumn dc in ctrl.DataTable.Columns) { ModuleField mf = new ModuleField(module, "", dc.ColumnName, dc.ColumnName); mf.DataType = dc.DataType; mf.Nullable = dc.AllowDBNull; mf.LanguageType = LanguageConvert.GetCSharpType(dc.DataType, dc.AllowDBNull); //Debug.WriteLine("{0} ---> {1}", mf.FieldName, mf.LanguageType); module.Fields.Add(mf); } } if (ctrl.QueryExecuteType == SQLQueryExecuteType.ReadRows) { code = gen.GenForQueryList(this.SQL, module, connstr); } else if (ctrl.QueryExecuteType == SQLQueryExecuteType.ReadOneRow) { code = gen.GenForQueryOne(this.SQL, module, connstr); } else if (ctrl.QueryExecuteType == SQLQueryExecuteType.ExecuteSclor) { if (ctrl.DataTable != null && ctrl.DataTable.Columns != null && ctrl.DataTable.Columns.Count > 0) { var dc = ctrl.DataTable.Columns[0]; Type t = dc.DataType; bool allowDBNull = dc.AllowDBNull; code = gen.GenForExecuteScalar(this.SQL, t, allowDBNull, connstr); } } else { code = gen.GenForExecuteNoQuery(this.SQL, connstr); } } else { List<Module> modules = new List<Module>(); foreach (var ctrl in this.ResultList) { Module module = new Module(); module.ModuleName = ctrl.RowClassName; module.CodeName = ctrl.RowClassName; if (ctrl.DataTable != null) { foreach (DataColumn dc in ctrl.DataTable.Columns) { ModuleField mf = new ModuleField(module, "", dc.ColumnName, dc.ColumnName); mf.DataType = dc.DataType; mf.Nullable = dc.AllowDBNull; mf.LanguageType = LanguageConvert.GetCSharpType(dc.DataType, dc.AllowDBNull); //Debug.WriteLine("{0} ---> {1}", mf.FieldName, mf.LanguageType); module.Fields.Add(mf); } } modules.Add(module); } code = gen.GenForMultiQuery(this.SQL, modules, connstr); } CodeView codeView = new CodeView(); codeView.Dock = DockStyle.Fill; ResultPage.Controls.Add(codeView); codeView.Show(code); }