diff --git a/SmartSQL/SmartSQL.Framework/Exporter/OracleExporter.cs b/SmartSQL/SmartSQL.Framework/Exporter/OracleExporter.cs index 0590e5a8dbd5ac23824743d7881ed5f8f2415cd0..0a4e36208535cb798b146db1011fe0749b82b4c6 100644 --- a/SmartSQL/SmartSQL.Framework/Exporter/OracleExporter.cs +++ b/SmartSQL/SmartSQL.Framework/Exporter/OracleExporter.cs @@ -28,9 +28,9 @@ namespace SmartSQL.Framework.Exporter var model = new Model { Database = "MySql" }; try { - //model.Tables = this.GetTables(); - //model.Views = this.GetViews(); - //model.Procedures = this.GetProcedures(); + model.Tables = this.GetTables(); + model.Views = this.GetViews(); + model.Procedures = this.GetProcedures(); return model; } catch (Exception ex) @@ -38,7 +38,90 @@ namespace SmartSQL.Framework.Exporter throw ex; } } + #region Private + private Tables GetTables() + { + #region MyRegion + var tables = new Tables(); + var dbMaintenance = SugarFactory.GetDbMaintenance(DbType.Oracle, DbConnectString); + var tableList = dbMaintenance.GetTableInfoList(false); + tableList.ForEach(tb => + { + if (tables.ContainsKey(tb.Name)) + { + return; + } + var table = new Table + { + Id = tb.Name, + Name = tb.Name, + DisplayName = tb.Name, + Comment = tb.Description, + CreateDate = tb.CreateDate, + ModifyDate = tb.ModifyDate + }; + tables.Add(tb.Name, table); + }); + return tables; + #endregion + } + + private Views GetViews() + { + #region MyRegion + var views = new Views(); + var dbMaintenance = SugarFactory.GetDbMaintenance(DbType.Oracle, DbConnectString); + var viewList = dbMaintenance.GetViewInfoList(false); + viewList.ForEach(v => + { + if (views.ContainsKey(v.Name)) + { + return; + } + var view = new View() + { + Id = v.Name, + Name = v.Name, + DisplayName = v.Name, + Comment = v.Description, + CreateDate = v.CreateDate, + ModifyDate = v.ModifyDate + }; + views.Add(v.Name, view); + }); + return views; + #endregion + } + private Procedures GetProcedures() + { + #region MyRegion + var procDic = new Procedures(); + var dbMaintenance = SugarFactory.GetDbMaintenance(DbType.Oracle, DbConnectString); + var procInfoList = dbMaintenance.GetProcInfoList(false); + var dbName = dbMaintenance.Context.Ado.Connection.Database; + var procList = procInfoList.Where(x => x.Schema == dbName).ToList(); + procList.ForEach(p => + { + if (procDic.ContainsKey(p.Name)) + { + return; + } + var proc = new Procedure() + { + Id = p.Name, + Name = p.Name, + DisplayName = p.Name, + Comment = p.Description, + CreateDate = p.CreateDate, + ModifyDate = p.ModifyDate + }; + procDic.Add(p.Name, proc); + }); + return procDic; + #endregion + } + #endregion public override List GetDatabases() { #region MyRegion diff --git a/SmartSQL/SmartSQL.Framework/ExporterFactory.cs b/SmartSQL/SmartSQL.Framework/ExporterFactory.cs index db6e7e2b56e014a770a4807ece8033a5fd2e5996..f022c1e57069ce72a6f56ebfa2d0c2fe6a0d5698 100644 --- a/SmartSQL/SmartSQL.Framework/ExporterFactory.cs +++ b/SmartSQL/SmartSQL.Framework/ExporterFactory.cs @@ -22,6 +22,7 @@ namespace SmartSQL.Framework case DbType.MySql: return new MySqlExporter(dbConnectionString); case DbType.PostgreSQL: return new PostgreSqlExporter(dbConnectionString); case DbType.Sqlite: return new SqliteExporter(dbConnectionString); + case DbType.Oracle: return new OracleExporter(dbConnectionString); default: return new SqlServerExporter(dbConnectionString); } } @@ -33,6 +34,7 @@ namespace SmartSQL.Framework case DbType.MySql: return new MySqlExporter(tableName, columns); case DbType.PostgreSQL: return new PostgreSqlExporter(tableName, columns); case DbType.Sqlite: return new SqliteExporter(tableName, columns); + case DbType.Oracle: return new OracleExporter(tableName, columns); default: return new SqlServerExporter(tableName, columns); } } diff --git a/SmartSQL/SmartSQL/SmartSQL.csproj b/SmartSQL/SmartSQL/SmartSQL.csproj index 05e24a98a16410eaae364e646067c3ec95dd1523..8b022d46951e012712e8635bf159545767e8f302 100644 --- a/SmartSQL/SmartSQL/SmartSQL.csproj +++ b/SmartSQL/SmartSQL/SmartSQL.csproj @@ -85,6 +85,9 @@ ..\..\Lib\AduSkin.dll + + ..\..\..\..\Oracle.ManagedDataAccess.dll + diff --git a/SmartSQL/SmartSQL/UserControl/Connect/ConnectMainUC.xaml b/SmartSQL/SmartSQL/UserControl/Connect/ConnectMainUC.xaml index 62f87fcb3fb190afd1e92f7e1343899869c166d2..de70fbf6031794b1cddbb5975db0d142b46219e8 100644 --- a/SmartSQL/SmartSQL/UserControl/Connect/ConnectMainUC.xaml +++ b/SmartSQL/SmartSQL/UserControl/Connect/ConnectMainUC.xaml @@ -58,7 +58,7 @@ ClickCard="ConnectType_OnClickCard" DataBaseIcon="pack://application:,,,/Resources/svg/oracle@64.svg" DataBaseName="Oracle" - IsEnabled="False" /> + IsEnabled="True" />