示例#1
0
文件: App.cs 项目: zhh007/CKGen
        public void LoadDatabaseSchema(DatabaseLink dbLink, ServerInfo srvInfo)
        {
            this.DBLink = dbLink;
            this.SrvInfo = srvInfo;
            this.DBName = dbLink.DatabaseName;
            this.Database = srvInfo.GetDatabase(this.DBName);

            LoadDbSchema(false);
        }
示例#2
0
文件: Program.cs 项目: zhh007/CKGen
        private static void BuildDBDoc()
        {
            //string dbConnStr = @"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=pass@word1;Initial Catalog=ENTERPRISES_SUPERWORKFLOW;Data Source=.\SQL2008R2";
            string dbname = "ENTERPRISES_SUPERWORKFLOW";
            DatabaseLink link = new DatabaseLink(DatabaseType.MSSQLServer, @".\SQL2008R2", dbname, "sa", "pass@word1");
            ServerInfo serverInfo = new ServerInfo(link);
            IDatabaseInfo database = serverInfo.GetDatabase(dbname);

            DBDocBuilder builder = new DBDocBuilder(database);
            builder.Build();
        }
示例#3
0
文件: App.cs 项目: zhh007/CKGen
        public void RefreshDbSchema()
        {
            if(this.DBLink == null)
            {
                return;
            }

            var srvInfo = new DBLoader.ServerInfo(this.DBLink);
            srvInfo.Connect();
            this.SrvInfo = srvInfo;
            this.Database = srvInfo.GetDatabase(this.DBName);

            LoadDbSchema(true);
        }
示例#4
0
 internal DatabaseInfo(ServerInfo server)
 {
     this._server = server;
     this.loader = server.Loader;
 }
示例#5
0
文件: FrmLogin.cs 项目: zhh007/CKGen
 void worker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         this.SrvInfo = new ServerInfo(this.DBLink);
         connected = this.SrvInfo.Connect();
         if (!connected)
         {
             if (this.SrvInfo.LastConnectionException != null)
             {
                 MessageBox.Show(this.SrvInfo.LastConnectionException.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 MessageBox.Show("数据库连接失败。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             return;
         }
         this.SrvInfo.LoadDatabases();
     }
     catch (Exception ex)
     {
         LogHelper.Error(ex);
         MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK);
     }
 }
示例#6
0
文件: Program.cs 项目: zhh007/CKGen
        private static void BuildDBAccess()
        {
            //Console.WriteLine("正在生成...");

            var watch1 = Stopwatch.StartNew();

            //string dbConnStr = @"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=pass@word1;Initial Catalog=ENTERPRISES_SUPERWORKFLOW;Data Source=.\SQL2008R2";

            string solutionName = "CK";
            string dbname = "ENTERPRISES_SUPERWORKFLOW";
            DatabaseLink link = new DatabaseLink(DatabaseType.MSSQLServer, @".\SQL2008R2", dbname, "sa", "pass@word1");
            ServerInfo serverInfo = new ServerInfo(link);
            IDatabaseInfo database = serverInfo.GetDatabase(dbname);

            SolutionBuilder sb = new SolutionBuilder(database, solutionName, dbname, link.ConnectionString);
            string errorStr = "";
            if (!sb.Build(ref errorStr))
            {
                Console.Write(errorStr);
            }

            Console.WriteLine("over!");

            Console.WriteLine("{0} ", watch1.Elapsed);
            Console.ReadKey();
        }
示例#7
0
文件: Program.cs 项目: zhh007/CKGen
        private static void TestAspnetForm(string tableName)
        {
            //string dbConnStr = @"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=pass@word1;Initial Catalog=DBTest;Data Source=.\SQL2008R2";
            string dbname = "DBTest";
            //string tableName = "SampleInt";
            //string connStr2 = @"Data Source=.\SQL2008R2;Initial Catalog=DBTest;User ID=sa;Password=pass@word1;Persist Security Info=False;";
            DatabaseLink link = new DatabaseLink(DatabaseType.MSSQLServer, @".\SQL2008R2", dbname, "sa", "pass@word1");
            ServerInfo serverInfo = new ServerInfo(link);
            IDatabaseInfo database = serverInfo.GetDatabase(dbname);

            ITableInfo tbInfo = null;

            foreach (ITableInfo tInfo in database.Tables)
            {
                if (tInfo.LowerName == tableName.ToLower())
                {
                    tbInfo = tInfo;
                    break;
                }
            }

            PageFormCodeGen builder = new PageFormCodeGen();
            PageFormModel model = new PageFormModel(tbInfo);
            string folder = builder.Build(model);
            Process.Start(folder);
        }
示例#8
0
文件: Program.cs 项目: zhh007/CKGen
        private static void BuildProj()
        {
            //string dbConnStr = @"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=pass@word1;Initial Catalog=NGB_ONLINE;Data Source=192.168.0.98";
            string dbname = "NGB_ONLINE";
            string tableName = "CoursePlan";
            //string connStr2 = @"Data Source=192.168.0.98;Initial Catalog=NGB_ONLINE;User ID=sa;Password=pass@word1;Persist Security Info=False;";
            DatabaseLink link = new DatabaseLink(DatabaseType.MSSQLServer, @"192.168.0.98", dbname, "sa", "pass@word1");
            ServerInfo serverInfo = new ServerInfo(link);
            IDatabaseInfo database = serverInfo.GetDatabase(dbname);

            List<ITableInfo> selTables = new List<ITableInfo>();
            foreach (ITableInfo tInfo in database.Tables)
            {
                if (tInfo.LowerName == tableName.ToLower())
                {
                    selTables.Add(tInfo);
                    break;
                }
            }
            List<IViewInfo> selViews = new List<IViewInfo>();

            DbConsoleProjectBuilder builder = new DbConsoleProjectBuilder();
            string folder = builder.Build(selTables, selViews, link.ConnectionString, "TestApp");
            Process.Start(folder);
        }
示例#9
0
文件: Program.cs 项目: zhh007/CKGen
        private static void BuildTableAccess()
        {
            //string dbConnStr = @"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=pass@word1;Initial Catalog=DBTest;Data Source=.\SQL2008R2";
            string dbname = "DBTest";
            string tableName = "df_TestUser";
            DatabaseLink link = new DatabaseLink(DatabaseType.MSSQLServer, @".\SQL2008R2", dbname, "sa", "pass@word1");
            ServerInfo serverInfo = new ServerInfo(link);
            IDatabaseInfo database = serverInfo.GetDatabase(dbname);

            ITableInfo tbInfo = null;

            foreach (ITableInfo tInfo in database.Tables)
            {
                if (tInfo.LowerName == tableName.ToLower())
                {
                    tbInfo = tInfo;
                    break;
                }
            }

            DbTableCodeGen gen = new DbTableCodeGen();

            //string code = CodeGen.GenForTable("Model.cshtml", tbInfo);

            string code = gen.GenDataAccessCode("TestApp", tbInfo);

            string fileName = System.IO.Path.GetTempFileName();

            System.IO.File.WriteAllText(fileName, code);

            Process.Start("notepad.exe", fileName);
        }
示例#10
0
 void worker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         ServerInfo serverInfo = new ServerInfo(this.DBLink);
         serverInfo.LoadDatabases();
         this.SrvInfo = serverInfo;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK);
     }
 }