Exemplo n.º 1
0
        public static void Build(string outputdir, string projName)
        {
            if (string.IsNullOrEmpty(outputdir) || string.IsNullOrEmpty(projName))
            {
                throw new ArgumentNullException("outputdir 和 projName", "不能为空");
            }
            outputDir   = outputdir;
            projectName = projName;

            CreateDir();
            CreateCsproj();
            EnumsDal.Generate(Path.Combine(outputdir, projName + ".db"), modelPath, GeneralFactory.projectName);

            List <string> schemaList = SchemaDal.Get_List();

            foreach (var schemaName in schemaList)
            {
                Console.WriteLine("正在生成模式:{0}", schemaName);
                List <TableViewModel> tableList = GetTables(schemaName);
                foreach (var item in tableList)
                {
                    Console.WriteLine("{0}:{1}", item.type, item.name);
                    TablesDal td = new TablesDal(GeneralFactory.projectName, modelPath, dalPath, schemaName, item);
                    td.Generate();
                }
            }
        }
Exemplo n.º 2
0
        public void LoadTablesAsync(Server server)
        {
            _currentServer = server;
            tv.Nodes.Clear();
            Task.Factory.StartNew(() =>
            {
                try
                {
                    using (var db = new AppDb(server.GetInformation_chemaConnectString()))
                    {
                        db.Open();

                        TablesDal dal = new TablesDal(db);
                        List <TableModel> modelList = dal.GetListBySchemaName(server.DbName);
                        this.Invoke(new Action(() =>
                        {
                            SetUI(server, modelList);
                            this.TabText = "数据库";
                        }));
                    }
                }
                catch (Exception ex)
                {
                    this.Invoke(new Action(() =>
                    {
                        this.TabText = "数据库";
                        MsgBox.Error(string.Format("[{0}]:加载表异常!\n{1}", server.DbName, ex.Message));
                    }));
                }
            });
            this.TabText = "loading...";
        }
Exemplo n.º 3
0
 private void CreateModels(List <SchemaViewModel> schemas)
 {
     foreach (var item in schemas)
     {
         Console.WriteLine("building:{0}", item.Name);
         foreach (var table in item.Tables)
         {
             Console.WriteLine("{0}:{1}", table.Type, table.Name);
             TablesDal td = new TablesDal(projectName, modelPath, schemaPath, dalPath, item.Name, table);
             td.Create();
         }
     }
 }