public static Schema CreateFromConnection(ConnectionInfo conInfo) { Schema schema = new Schema(); schema.CatalogName = conInfo.Catalog; schema.Name = conInfo.Schema; IConnectionFactory fac = null; ISqlConf sqlConf = null; if (conInfo.Type == ConnectionType.SqlServer) { fac = new SqlServerConnectionFactory(); sqlConf = new SQLServerDefaultConf(); schema.Platform = "SQLSERVER"; } else if (conInfo.Type == ConnectionType.MySql) { fac = new MySqlConnectionFactory(); sqlConf = new MySqlDefaultConf(); schema.Platform = "MYSQL"; } using (IDbConnection conn = fac.CreateConnection(conInfo)) { conn.Open(); IDatabaseExplorer dbExplorer = new DatabaseExplorer(conn, sqlConf); schema.Tables = dbExplorer.GetTables(schema).ToList<Table>(); schema.StoredProcedures = dbExplorer.GetStoredProcedures(schema).ToList<StoredProcedure>(); } return schema; }
public override void Execute(IDictionary<string, object> scope) { try { this.Status = OperationStatus.RUNNING; SqlConnection conn = scope["CONNECTION"] as SqlConnection; DatabaseExplorer exp = new DatabaseExplorer(conn, new SQLServerDefaultConf()); Schema schema = new Schema(); schema.Name = this.schemaName; schema.Tables = exp.GetTables(schema).ToList<Table>(); schema.StoredProcedures = exp.GetStoredProcedures(schema).ToList<StoredProcedure>(); scope["SCHEMA"] = schema; this.Status = OperationStatus.COMPLETED; } catch (Exception ex) { this.Exception = ex; this.Status = OperationStatus.FAILED; throw ex; } }