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); }
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(); }
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); }
internal DatabaseInfo(ServerInfo server) { this._server = server; this.loader = server.Loader; }
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); } }
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(); }
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); }
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); }
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); }
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); } }