Пример #1
0
 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;
 }
Пример #2
0
        //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();
        }
Пример #3
0
 private string GenModelCode(Module module)
 {
     return codeGen.Gen(Comm.GetTemplete("Query.Model.cshtml"), module);
 }
Пример #4
0
 public DbQueryGetListModel()
 {
     this.Module = new Module();
 }
Пример #5
0
 public PageFormModel(ITableInfo tbInfo)
 {
     this.FormModule = new Module(tbInfo);
 }
Пример #6
0
 public PageFormModel()
 {
     this.FormModule = new Module();
 }
Пример #7
0
 public StringField(Module parent, string title, string name, string codename)
     : base(parent, title, name, codename)
 {
 }
Пример #8
0
 public CollectionField(Module parent, string title, Module entity, ModuleRelationship relationship)
     : base(parent, title, "", "")
 {
     this.RelationshipEntity = entity;
     this.Relationship = relationship;
 }
Пример #9
0
        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);
        }