From 50644583d92e1e04b22670a7953f4be176dbf6ed Mon Sep 17 00:00:00 2001 From: BaoZhen Long <398187372@qq.com> Date: Wed, 17 Aug 2022 11:11:20 +0800 Subject: [PATCH] =?UTF-8?q?#Oracles=E6=95=B0=E6=8D=AE=E5=BA=93=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Exporter/OracleExporter.cs | 89 ++++++++++++++++++- .../SmartSQL.Framework/ExporterFactory.cs | 2 + SmartSQL/SmartSQL/SmartSQL.csproj | 3 + .../UserControl/Connect/ConnectMainUC.xaml | 2 +- SmartSQL/SmartSQL/Views/ConnectManage.xaml.cs | 6 ++ 5 files changed, 98 insertions(+), 4 deletions(-) diff --git a/SmartSQL/SmartSQL.Framework/Exporter/OracleExporter.cs b/SmartSQL/SmartSQL.Framework/Exporter/OracleExporter.cs index 0590e5a..0a4e362 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 db6e7e2..f022c1e 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 05e24a9..8b022d4 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 62f87fc..de70fbf 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" />