From acebe33cad0664a4b0532fc4cc08698700098208 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 1 Oct 2019 22:50:57 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat(#I12XDG):=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=BB=BA=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #Comment comment #I12XDG #Issue link #I12XDG --- db/SqlServer/install.ps1 | 6 +- .../AutoGenerateDatabaseExtensions.cs | 24 ++++ .../Bootstrap.Admin/Bootstrap.Admin.csproj | 1 + src/admin/Bootstrap.Admin/Startup.cs | 1 + .../appsettings.Development.json | 4 + src/admin/Bootstrap.DataAccess/AutoDB.cs | 114 ++++++++++++++++++ .../Helper/AutoDbHelper.cs | 13 ++ 7 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 src/admin/Bootstrap.Admin/AutoGenerateDatabaseExtensions.cs create mode 100644 src/admin/Bootstrap.DataAccess/AutoDB.cs create mode 100644 src/admin/Bootstrap.DataAccess/Helper/AutoDbHelper.cs diff --git a/db/SqlServer/install.ps1 b/db/SqlServer/install.ps1 index 78b0b25b..22b7246f 100644 --- a/db/SqlServer/install.ps1 +++ b/db/SqlServer/install.ps1 @@ -1,5 +1,9 @@ # init sqlserver database -$startPath = "Z:\src\Longbow\BootstrapAdmin\DatabaseScripts\SqlServer" +$startPath = $args[0] +if ($startPath -eq $null) { + $startPath = "Z:\src\Longbow\BootstrapAdmin\db\SqlServer" +} + $sqlInstance = "localhost" $outFile = join-path $startPath "output.log" $sqlFile = join-path $startPath "Install.sql" diff --git a/src/admin/Bootstrap.Admin/AutoGenerateDatabaseExtensions.cs b/src/admin/Bootstrap.Admin/AutoGenerateDatabaseExtensions.cs new file mode 100644 index 00000000..bca33660 --- /dev/null +++ b/src/admin/Bootstrap.Admin/AutoGenerateDatabaseExtensions.cs @@ -0,0 +1,24 @@ +using Bootstrap.DataAccess.Helper; + +namespace Microsoft.AspNetCore.Builder +{ + /// + /// 自动生成数据库扩展操作类 + /// + public static class AutoGenerateDatabaseExtensions + { + /// + /// 自动生成数据库中间件 + /// + /// + public static IApplicationBuilder UseAutoGenerateDatabase(this IApplicationBuilder app) + { + app.Use(async (context, next) => + { + AutoDbHelper.CheckDB(); + await next(); + }); + return app; + } + } +} diff --git a/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj b/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj index 841aa89a..f85dbc62 100644 --- a/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -23,6 +23,7 @@ + diff --git a/src/admin/Bootstrap.Admin/Startup.cs b/src/admin/Bootstrap.Admin/Startup.cs index ce258b32..05ed94a3 100644 --- a/src/admin/Bootstrap.Admin/Startup.cs +++ b/src/admin/Bootstrap.Admin/Startup.cs @@ -115,6 +115,7 @@ namespace Bootstrap.Admin app.UseHttpsRedirection(); app.UseResponseCompression(); app.UseStaticFiles(); + app.UseAutoGenerateDatabase(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); diff --git a/src/admin/Bootstrap.Admin/appsettings.Development.json b/src/admin/Bootstrap.Admin/appsettings.Development.json index 0ebdc609..fd88f310 100644 --- a/src/admin/Bootstrap.Admin/appsettings.Development.json +++ b/src/admin/Bootstrap.Admin/appsettings.Development.json @@ -19,6 +19,7 @@ { "Enabled": false, "ProviderName": "SqlServer", + "SqlFolder": "Z:\\src\\Longbow\\BootstrapAdmin\\db\\SqlServer", "ConnectionStrings": { "ba": "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa" } @@ -26,6 +27,7 @@ { "Enabled": true, "ProviderName": "Sqlite", + "SqlFolder": "Z:\\src\\Longbow\\BootstrapAdmin\\db\\SQLite", "ConnectionStrings": { "ba": "Data Source=BootstrapAdmin.db;" } @@ -33,6 +35,7 @@ { "Enabled": false, "ProviderName": "MySql", + "SqlFolder": "Z:\\src\\Longbow\\BootstrapAdmin\\db\\MySQL", "ConnectionStrings": { "ba": "Server=localhost;Database=BA;Uid=argozhang;Pwd=argo@163.com;SslMode=none;" } @@ -48,6 +51,7 @@ "Enabled": false, "Widget": "Bootstrap.DataAccess.MongoDB", "ProviderName": "MongoDB", + "SqlFolder": "Z:\\src\\Longbow\\BootstrapAdmin\\db\\MongoDB", "ConnectionStrings": { "ba": "mongodb://localhost:27017/BootstrapAdmin" } diff --git a/src/admin/Bootstrap.DataAccess/AutoDB.cs b/src/admin/Bootstrap.DataAccess/AutoDB.cs new file mode 100644 index 00000000..a2d82097 --- /dev/null +++ b/src/admin/Bootstrap.DataAccess/AutoDB.cs @@ -0,0 +1,114 @@ +using Longbow.Configuration; +using Microsoft.Extensions.Configuration; +using PetaPoco; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; + +namespace Bootstrap.DataAccess +{ + /// + /// 数据库自动生成实体类 + /// + public class AutoDB + { + private static bool _init = false; + private static object _locker = new object(); + + /// + /// 数据库检查方法 + /// + public void CheckDB() + { + if (_init) return; + + // 阻止所有线程继续往下运行,等待数据库检查 + lock (_locker) + { + if (_init) return; + + // 数据检查 + Check(); + } + } + + private void Check() + { + var dbSection = ConfigurationManager.GetSection("DB").GetChildren().FirstOrDefault(c => c.GetValue("Enabled", false)); + if (dbSection == null) + { + _init = true; + return; + } + var folder = dbSection["SqlFolder"]; + if (folder.IsNullOrEmpty()) + { + _init = true; + return; + } + + var db = Longbow.Data.DbManager.Create(); + CheckDbExists(db, folder); + _init = true; + } + + private void CheckDbExists(IDatabase db, string folder) + { + db.CommandTimeout = 5000; + switch (db.Provider.GetType().Name) + { + case "SQLiteDatabaseProvider": + if (db.ExecuteScalar("SELECT count(*) FROM sqlite_master WHERE type='table' AND name='Users'") == 0) GenerateSQLiteDB(db, folder); + break; + case "SqlServerDatabaseProvider": + var newDB = ModifyConnectionString(db); + if (newDB.ExecuteScalar("select COUNT(1) from sys.databases where name = N'BootstrapAdmin'") == 0) GenerateSqlServer(folder); + break; + case "MySqlDatabaseProvider": + case "MariaDbDatabaseProvider": + if (db.ExecuteScalar("select count(*) from information_schema.tables where table_name ='Users' and Table_Schema = 'BootstrapAdmin'") == 0) GenerateMySql(folder); + break; + } + } + + private IDatabase ModifyConnectionString(IDatabase db) + { + var conn = db.ConnectionString; + var newsegs = new List(); + var segs = conn.SpanSplit(";"); + segs.ForEach(s => + { + if (s.StartsWith("Initial Catalog", StringComparison.OrdinalIgnoreCase)) newsegs.Add("Initial Catalog=master"); + else newsegs.Add(s); + }); + var provider = db.Provider; + db.Dispose(); + return new Database(string.Join(";", newsegs), provider); + } + + private void GenerateSQLiteDB(IDatabase db, string folder) + { + var initFile = Path.Combine(folder, "Install.sql"); + var sql = File.ReadAllText(initFile); + db.Execute(sql); + + initFile = Path.Combine(folder, "InitData.sql"); + sql = File.ReadAllText(initFile); + db.Execute(sql); + } + + private void GenerateSqlServer(string folder) + { + var psi = new ProcessStartInfo("powershell", Path.Combine(folder, $"install.ps1 \"{folder}\"")); + var p = Process.Start(psi); + p.WaitForExit(); + } + + private void GenerateMySql(string folder) + { + // 没有环境暂时未写代码 + } + } +} diff --git a/src/admin/Bootstrap.DataAccess/Helper/AutoDbHelper.cs b/src/admin/Bootstrap.DataAccess/Helper/AutoDbHelper.cs new file mode 100644 index 00000000..94cf2157 --- /dev/null +++ b/src/admin/Bootstrap.DataAccess/Helper/AutoDbHelper.cs @@ -0,0 +1,13 @@ +namespace Bootstrap.DataAccess.Helper +{ + /// + /// 数据库自动生成帮助类 + /// + public static class AutoDbHelper + { + /// + /// 数据库检查方法 + /// + public static void CheckDB() => DbContextManager.Create()?.CheckDB(); + } +} From c45d0b0198262229495bdb75998c22cd94a75092 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 2 Oct 2019 10:57:37 +0800 Subject: [PATCH 2/4] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E4=BD=BF=E7=94=A8=E7=9B=B8=E5=AF=B9?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoGenerateDatabaseExtensions.cs | 42 ++++++- .../Bootstrap.Admin/Bootstrap.Admin.csproj | 4 +- .../Properties/launchSettings.json | 10 +- .../appsettings.Development.json | 8 +- .../Bootstrap.DataAccess.MongoDB/AutoDB.cs | 17 +++ src/admin/Bootstrap.DataAccess/AutoDB.cs | 111 +++++++----------- .../Bootstrap.DataAccess.csproj | 3 +- .../Helper/AutoDbHelper.cs | 2 +- 8 files changed, 118 insertions(+), 79 deletions(-) create mode 100644 src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs diff --git a/src/admin/Bootstrap.Admin/AutoGenerateDatabaseExtensions.cs b/src/admin/Bootstrap.Admin/AutoGenerateDatabaseExtensions.cs index bca33660..09de0b2d 100644 --- a/src/admin/Bootstrap.Admin/AutoGenerateDatabaseExtensions.cs +++ b/src/admin/Bootstrap.Admin/AutoGenerateDatabaseExtensions.cs @@ -1,4 +1,10 @@ using Bootstrap.DataAccess.Helper; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using System.IO; +using System.Linq; +using System; namespace Microsoft.AspNetCore.Builder { @@ -7,6 +13,9 @@ namespace Microsoft.AspNetCore.Builder /// public static class AutoGenerateDatabaseExtensions { + private static bool _init; + private static object _locker = new object(); + /// /// 自动生成数据库中间件 /// @@ -15,7 +24,38 @@ namespace Microsoft.AspNetCore.Builder { app.Use(async (context, next) => { - AutoDbHelper.CheckDB(); + if (!_init) + { + // 阻止所有线程继续往下运行,等待数据库检查 + lock (_locker) + { + if (!_init) + { + // 数据检查 + var config = context.RequestServices.GetRequiredService(); + var dbSection = config.GetSection("DB").GetChildren().FirstOrDefault(c => c.GetValue("Enabled", false)); + if (dbSection != null) + { + var folder = dbSection["SqlFolder"].ReplaceOSPlatformPath(); + if (!string.IsNullOrEmpty(folder)) + { + // 判断文件夹是否存在 + var env = context.RequestServices.GetRequiredService(); + var fullFolder = Path.Combine(env.ContentRootPath, folder); + if (Directory.Exists(fullFolder)) + { + try + { + AutoDbHelper.CheckDB(fullFolder); + } + catch { } + } + } + } + } + _init = true; + } + } await next(); }); return app; diff --git a/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj b/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj index f85dbc62..a00ac7b0 100644 --- a/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -13,16 +13,18 @@ + + - + diff --git a/src/admin/Bootstrap.Admin/Properties/launchSettings.json b/src/admin/Bootstrap.Admin/Properties/launchSettings.json index 818a0181..7d62f9f0 100644 --- a/src/admin/Bootstrap.Admin/Properties/launchSettings.json +++ b/src/admin/Bootstrap.Admin/Properties/launchSettings.json @@ -16,6 +16,11 @@ "ASPNETCORE_ENVIRONMENT": "Development" } }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}" + }, "Bootstrap.Admin": { "commandName": "Project", "launchBrowser": true, @@ -23,11 +28,6 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "applicationUrl": "http://localhost:50852/" - }, - "Docker": { - "commandName": "Docker", - "launchBrowser": true, - "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}" } } } \ No newline at end of file diff --git a/src/admin/Bootstrap.Admin/appsettings.Development.json b/src/admin/Bootstrap.Admin/appsettings.Development.json index fd88f310..9cd8411c 100644 --- a/src/admin/Bootstrap.Admin/appsettings.Development.json +++ b/src/admin/Bootstrap.Admin/appsettings.Development.json @@ -19,7 +19,7 @@ { "Enabled": false, "ProviderName": "SqlServer", - "SqlFolder": "Z:\\src\\Longbow\\BootstrapAdmin\\db\\SqlServer", + "SqlFolder": "..\\..\\..\\db\\SqlServer", "ConnectionStrings": { "ba": "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa" } @@ -27,7 +27,7 @@ { "Enabled": true, "ProviderName": "Sqlite", - "SqlFolder": "Z:\\src\\Longbow\\BootstrapAdmin\\db\\SQLite", + "SqlFolder": "..\\..\\..\\db\\SQLite", "ConnectionStrings": { "ba": "Data Source=BootstrapAdmin.db;" } @@ -35,7 +35,7 @@ { "Enabled": false, "ProviderName": "MySql", - "SqlFolder": "Z:\\src\\Longbow\\BootstrapAdmin\\db\\MySQL", + "SqlFolder": "..\\..\\..\\db\\MySQL", "ConnectionStrings": { "ba": "Server=localhost;Database=BA;Uid=argozhang;Pwd=argo@163.com;SslMode=none;" } @@ -51,7 +51,7 @@ "Enabled": false, "Widget": "Bootstrap.DataAccess.MongoDB", "ProviderName": "MongoDB", - "SqlFolder": "Z:\\src\\Longbow\\BootstrapAdmin\\db\\MongoDB", + "SqlFolder": "..\\..\\..\\db\\MongoDB", "ConnectionStrings": { "ba": "mongodb://localhost:27017/BootstrapAdmin" } diff --git a/src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs b/src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs new file mode 100644 index 00000000..56a30681 --- /dev/null +++ b/src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs @@ -0,0 +1,17 @@ +namespace Bootstrap.DataAccess.MongoDB +{ + /// + /// 自动建库实体操作类 + /// + public class AutoDB : DataAccess.AutoDB + { + /// + /// 数据库检查方法 + /// + /// + public override void CheckDB(string folder) + { + + } + } +} diff --git a/src/admin/Bootstrap.DataAccess/AutoDB.cs b/src/admin/Bootstrap.DataAccess/AutoDB.cs index a2d82097..2de345bb 100644 --- a/src/admin/Bootstrap.DataAccess/AutoDB.cs +++ b/src/admin/Bootstrap.DataAccess/AutoDB.cs @@ -1,11 +1,8 @@ -using Longbow.Configuration; -using Microsoft.Extensions.Configuration; -using PetaPoco; +using PetaPoco; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; namespace Bootstrap.DataAccess { @@ -14,62 +11,33 @@ namespace Bootstrap.DataAccess /// public class AutoDB { - private static bool _init = false; - private static object _locker = new object(); + private string _folder; /// /// 数据库检查方法 /// - public void CheckDB() + public virtual void CheckDB(string folder) { - if (_init) return; - - // 阻止所有线程继续往下运行,等待数据库检查 - lock (_locker) + _folder = folder; + using (var db = Longbow.Data.DbManager.Create()) { - if (_init) return; - - // 数据检查 - Check(); - } - } - - private void Check() - { - var dbSection = ConfigurationManager.GetSection("DB").GetChildren().FirstOrDefault(c => c.GetValue("Enabled", false)); - if (dbSection == null) - { - _init = true; - return; - } - var folder = dbSection["SqlFolder"]; - if (folder.IsNullOrEmpty()) - { - _init = true; - return; - } - - var db = Longbow.Data.DbManager.Create(); - CheckDbExists(db, folder); - _init = true; - } - - private void CheckDbExists(IDatabase db, string folder) - { - db.CommandTimeout = 5000; - switch (db.Provider.GetType().Name) - { - case "SQLiteDatabaseProvider": - if (db.ExecuteScalar("SELECT count(*) FROM sqlite_master WHERE type='table' AND name='Users'") == 0) GenerateSQLiteDB(db, folder); - break; - case "SqlServerDatabaseProvider": - var newDB = ModifyConnectionString(db); - if (newDB.ExecuteScalar("select COUNT(1) from sys.databases where name = N'BootstrapAdmin'") == 0) GenerateSqlServer(folder); - break; - case "MySqlDatabaseProvider": - case "MariaDbDatabaseProvider": - if (db.ExecuteScalar("select count(*) from information_schema.tables where table_name ='Users' and Table_Schema = 'BootstrapAdmin'") == 0) GenerateMySql(folder); - break; + db.CommandTimeout = 5000; + switch (db.Provider.GetType().Name) + { + case "SQLiteDatabaseProvider": + if (db.ExecuteScalar("SELECT count(*) FROM sqlite_master WHERE type='table' AND name='Users'") == 0) GenerateSQLiteDB(db); + break; + case "SqlServerDatabaseProvider": + using (var newDB = ModifyConnectionString(db)) + { + if (newDB.ExecuteScalar("select COUNT(1) from sys.databases where name = N'BootstrapAdmin'") == 0) GenerateSqlServer(); + } + break; + case "MySqlDatabaseProvider": + case "MariaDbDatabaseProvider": + if (db.ExecuteScalar("select count(*) from information_schema.tables where table_name ='Users' and Table_Schema = 'BootstrapAdmin'") == 0) GenerateMySql(); + break; + } } } @@ -84,29 +52,40 @@ namespace Bootstrap.DataAccess else newsegs.Add(s); }); var provider = db.Provider; - db.Dispose(); return new Database(string.Join(";", newsegs), provider); } - private void GenerateSQLiteDB(IDatabase db, string folder) + private void GenerateSQLiteDB(IDatabase db) { + var folder = _folder; var initFile = Path.Combine(folder, "Install.sql"); - var sql = File.ReadAllText(initFile); - db.Execute(sql); + if (File.Exists(initFile)) + { + var sql = File.ReadAllText(initFile); + db.Execute(sql); - initFile = Path.Combine(folder, "InitData.sql"); - sql = File.ReadAllText(initFile); - db.Execute(sql); + initFile = Path.Combine(folder, "InitData.sql"); + if (File.Exists(initFile)) + { + sql = File.ReadAllText(initFile); + db.Execute(sql); + } + } } - private void GenerateSqlServer(string folder) + private void GenerateSqlServer() { - var psi = new ProcessStartInfo("powershell", Path.Combine(folder, $"install.ps1 \"{folder}\"")); - var p = Process.Start(psi); - p.WaitForExit(); + // 检查 install.ps1 脚本 + var file = Path.Combine(_folder, $"install.ps1"); + if (File.Exists(file)) + { + var psi = new ProcessStartInfo("powershell", $"{file} \"{_folder}\""); + var p = Process.Start(psi); + p.WaitForExit(); + } } - private void GenerateMySql(string folder) + private void GenerateMySql() { // 没有环境暂时未写代码 } diff --git a/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj b/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj index 13d4e880..13a7775b 100644 --- a/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj +++ b/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj @@ -6,6 +6,7 @@ + @@ -14,7 +15,7 @@ - + diff --git a/src/admin/Bootstrap.DataAccess/Helper/AutoDbHelper.cs b/src/admin/Bootstrap.DataAccess/Helper/AutoDbHelper.cs index 94cf2157..f99416db 100644 --- a/src/admin/Bootstrap.DataAccess/Helper/AutoDbHelper.cs +++ b/src/admin/Bootstrap.DataAccess/Helper/AutoDbHelper.cs @@ -8,6 +8,6 @@ /// /// 数据库检查方法 /// - public static void CheckDB() => DbContextManager.Create()?.CheckDB(); + public static void CheckDB(string folder) => DbContextManager.Create()?.CheckDB(folder); } } From 36f9e1cd70ab626bed33318e4ee5fee60fb3f86d Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 2 Oct 2019 12:54:15 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20MongoDB=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=BB=BA=E5=BA=93=E7=9B=B8=E5=85=B3=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BootstrapAdmin.sln | 1 + db/MongoDB/install.cmd | 5 +++++ src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 db/MongoDB/install.cmd diff --git a/BootstrapAdmin.sln b/BootstrapAdmin.sln index 11a708d1..3e928488 100644 --- a/BootstrapAdmin.sln +++ b/BootstrapAdmin.sln @@ -33,6 +33,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MongoDB", "MongoDB", "{A06A db\MongoDB\Dicts.js = db\MongoDB\Dicts.js db\MongoDB\Groups.js = db\MongoDB\Groups.js db\MongoDB\init.js = db\MongoDB\init.js + db\MongoDB\install.cmd = db\MongoDB\install.cmd db\MongoDB\install.sh = db\MongoDB\install.sh db\MongoDB\Navigations.js = db\MongoDB\Navigations.js db\MongoDB\Roles.js = db\MongoDB\Roles.js diff --git a/db/MongoDB/install.cmd b/db/MongoDB/install.cmd new file mode 100644 index 00000000..e5f8ef0b --- /dev/null +++ b/db/MongoDB/install.cmd @@ -0,0 +1,5 @@ +# init mongodb data +@echo off + +mongo ./init.js +mongo BootstrapAdmin --eval "printjson(db.getCollectionNames())" diff --git a/src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs b/src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs index 56a30681..8a7f79f8 100644 --- a/src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs +++ b/src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs @@ -11,7 +11,7 @@ /// public override void CheckDB(string folder) { - + // 没有环境暂时未写代码 } } } From 509de4ddaf2157a16015ba31e6011406782882c0 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 2 Oct 2019 18:29:43 +0800 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20MySql=20=E4=B8=8E=20MongoDB=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20UNDONE=20=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #Comment 没有环境暂时未写相关代码 --- src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs | 2 +- src/admin/Bootstrap.DataAccess/AutoDB.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs b/src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs index 8a7f79f8..e633392b 100644 --- a/src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs +++ b/src/admin/Bootstrap.DataAccess.MongoDB/AutoDB.cs @@ -11,7 +11,7 @@ /// public override void CheckDB(string folder) { - // 没有环境暂时未写代码 + // UNDONE: 没有环境暂时未写代码 } } } diff --git a/src/admin/Bootstrap.DataAccess/AutoDB.cs b/src/admin/Bootstrap.DataAccess/AutoDB.cs index 2de345bb..a1992a60 100644 --- a/src/admin/Bootstrap.DataAccess/AutoDB.cs +++ b/src/admin/Bootstrap.DataAccess/AutoDB.cs @@ -35,6 +35,7 @@ namespace Bootstrap.DataAccess break; case "MySqlDatabaseProvider": case "MariaDbDatabaseProvider": + // UNDONE: 本地没有环境此处代码未测试 if (db.ExecuteScalar("select count(*) from information_schema.tables where table_name ='Users' and Table_Schema = 'BootstrapAdmin'") == 0) GenerateMySql(); break; } @@ -87,7 +88,7 @@ namespace Bootstrap.DataAccess private void GenerateMySql() { - // 没有环境暂时未写代码 + // UNDONE: 没有环境暂时未写代码 } } }