From 62b00389f9562bac0b9c18d08054212135377e90 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 11 Jul 2019 20:44:11 +0800 Subject: [PATCH 1/2] =?UTF-8?q?build:=20=E4=BE=9D=E8=B5=96=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=9B=B4=E6=96=B0=E5=88=B0=E6=9C=80=E6=96=B0=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Bootstrap.Admin.csproj | 5 ++--- Bootstrap.Client/Bootstrap.Client.csproj | 6 +++--- Bootstrap.DataAccess/Bootstrap.DataAccess.csproj | 10 +++++----- UnitTest/UnitTest.csproj | 6 +++--- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Bootstrap.Admin/Bootstrap.Admin.csproj b/Bootstrap.Admin/Bootstrap.Admin.csproj index 79ff93df..c299df0b 100644 --- a/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -12,12 +12,11 @@ - + - - + diff --git a/Bootstrap.Client/Bootstrap.Client.csproj b/Bootstrap.Client/Bootstrap.Client.csproj index cf759e92..1c56f196 100644 --- a/Bootstrap.Client/Bootstrap.Client.csproj +++ b/Bootstrap.Client/Bootstrap.Client.csproj @@ -7,12 +7,12 @@ - + - + - + diff --git a/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj b/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj index 5a31b733..d682885f 100644 --- a/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj +++ b/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj @@ -5,14 +5,14 @@ - - + + - + - - + + diff --git a/UnitTest/UnitTest.csproj b/UnitTest/UnitTest.csproj index 71124281..20fc4040 100644 --- a/UnitTest/UnitTest.csproj +++ b/UnitTest/UnitTest.csproj @@ -8,14 +8,14 @@ - + all runtime; build; native; contentfiles; analyzers - - + + From bbad37ce6ea189d14c061d5d2965176e42d3a29d Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 11 Jul 2019 21:46:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=20=E6=A0=B9=E6=8D=AE=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=9A=84PetaPoco=E7=A7=BB=E9=99=A4=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E4=B8=BB=E9=94=AE=E8=AE=BE=E7=BD=AE=E4=B8=BANull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.DataAccess/DbManager.cs | 8 +------- Bootstrap.DataAccess/Helper/DictHelper.cs | 1 - Bootstrap.DataAccess/Helper/GroupHelper.cs | 1 - Bootstrap.DataAccess/Helper/LogHelper.cs | 1 - Bootstrap.DataAccess/Helper/LoginHelper.cs | 1 - Bootstrap.DataAccess/Helper/MenuHelper.cs | 1 - Bootstrap.DataAccess/Helper/MessageHelper.cs | 6 +----- Bootstrap.DataAccess/Helper/ResetUserHelper.cs | 1 - Bootstrap.DataAccess/Helper/RoleHelper.cs | 1 - Bootstrap.DataAccess/Helper/TaskHelper.cs | 6 +----- Bootstrap.DataAccess/Helper/TraceHelper.cs | 1 - 11 files changed, 3 insertions(+), 25 deletions(-) diff --git a/Bootstrap.DataAccess/DbManager.cs b/Bootstrap.DataAccess/DbManager.cs index af473a18..1e9fb503 100644 --- a/Bootstrap.DataAccess/DbManager.cs +++ b/Bootstrap.DataAccess/DbManager.cs @@ -18,13 +18,7 @@ namespace Bootstrap.DataAccess /// public static IDatabase Create(string connectionName = null, bool keepAlive = false) { - if (Mappers.GetMapper(typeof(Exceptions), null) == null) - { - lock (_locker) - { - if (Mappers.GetMapper(typeof(Exceptions), null) == null) Mappers.Register(typeof(Exceptions).Assembly, new BootstrapDataAccessConventionMapper()); - } - } + if (Mappers.GetMapper(typeof(Exceptions), null) == null) Mappers.Register(typeof(Exceptions).Assembly, new BootstrapDataAccessConventionMapper()); var db = Longbow.Data.DbManager.Create(connectionName, keepAlive); db.ExceptionThrown += (sender, args) => args.Exception.Log(new NameValueCollection() { ["LastCmd"] = db.LastCommand }); return db; diff --git a/Bootstrap.DataAccess/Helper/DictHelper.cs b/Bootstrap.DataAccess/Helper/DictHelper.cs index e78f48ef..30e82fc0 100644 --- a/Bootstrap.DataAccess/Helper/DictHelper.cs +++ b/Bootstrap.DataAccess/Helper/DictHelper.cs @@ -60,7 +60,6 @@ namespace Bootstrap.DataAccess { if (RetrieveSystemModel() && !string.IsNullOrEmpty(p.Id) && RetrieveProtectedDicts().Any(m => m.Id == p.Id)) return true; - if (p.Id == string.Empty) p.Id = null; var ret = DbContextManager.Create().Save(p); if (ret) CacheCleanUtility.ClearCache(dictIds: new List()); return ret; diff --git a/Bootstrap.DataAccess/Helper/GroupHelper.cs b/Bootstrap.DataAccess/Helper/GroupHelper.cs index 1a0e88bc..807233b4 100644 --- a/Bootstrap.DataAccess/Helper/GroupHelper.cs +++ b/Bootstrap.DataAccess/Helper/GroupHelper.cs @@ -51,7 +51,6 @@ namespace Bootstrap.DataAccess /// public static bool Save(Group p) { - if (p.Id == string.Empty) p.Id = null; var ret = DbContextManager.Create().Save(p); if (ret) CacheCleanUtility.ClearCache(groupIds: string.IsNullOrEmpty(p.Id) ? new List() : new List() { p.Id }); return ret; diff --git a/Bootstrap.DataAccess/Helper/LogHelper.cs b/Bootstrap.DataAccess/Helper/LogHelper.cs index 394e16c7..1bef5919 100644 --- a/Bootstrap.DataAccess/Helper/LogHelper.cs +++ b/Bootstrap.DataAccess/Helper/LogHelper.cs @@ -34,7 +34,6 @@ namespace Bootstrap.DataAccess /// public static bool Save(Log log) { - if (log.Id == string.Empty) log.Id = null; log.LogTime = DateTime.Now; return DbContextManager.Create().Save(log); } diff --git a/Bootstrap.DataAccess/Helper/LoginHelper.cs b/Bootstrap.DataAccess/Helper/LoginHelper.cs index 430eafbb..bbd19c9d 100644 --- a/Bootstrap.DataAccess/Helper/LoginHelper.cs +++ b/Bootstrap.DataAccess/Helper/LoginHelper.cs @@ -18,7 +18,6 @@ namespace Bootstrap.DataAccess /// public static bool Log(LoginUser user) { - if (user.Id == string.Empty) user.Id = null; if (string.IsNullOrEmpty(user.UserName)) user.UserName = user.Ip; return DbContextManager.Create().Log(user); } diff --git a/Bootstrap.DataAccess/Helper/MenuHelper.cs b/Bootstrap.DataAccess/Helper/MenuHelper.cs index 22ceba03..aca1d932 100644 --- a/Bootstrap.DataAccess/Helper/MenuHelper.cs +++ b/Bootstrap.DataAccess/Helper/MenuHelper.cs @@ -32,7 +32,6 @@ namespace Bootstrap.DataAccess // 不允许保存系统菜单与前台演示系统的默认菜单 if (DictHelper.RetrieveSystemModel() && (p.Category == "0" || p.Application == "2")) return true; - if (p.Id == string.Empty) p.Id = null; var ret = DbContextManager.Create().Save(p); if (ret) CacheCleanUtility.ClearCache(menuIds: string.IsNullOrEmpty(p.Id) ? new List() : new List() { p.Id }); return ret; diff --git a/Bootstrap.DataAccess/Helper/MessageHelper.cs b/Bootstrap.DataAccess/Helper/MessageHelper.cs index 2e1a8a6e..12150daf 100644 --- a/Bootstrap.DataAccess/Helper/MessageHelper.cs +++ b/Bootstrap.DataAccess/Helper/MessageHelper.cs @@ -54,10 +54,6 @@ namespace Bootstrap.DataAccess /// /// /// - public static bool Save(Message msg) - { - if (string.IsNullOrEmpty(msg.Id)) msg.Id = null; - return DbContextManager.Create().Save(msg); - } + public static bool Save(Message msg) => DbContextManager.Create().Save(msg); } } diff --git a/Bootstrap.DataAccess/Helper/ResetUserHelper.cs b/Bootstrap.DataAccess/Helper/ResetUserHelper.cs index ca61c295..6b1e7d5a 100644 --- a/Bootstrap.DataAccess/Helper/ResetUserHelper.cs +++ b/Bootstrap.DataAccess/Helper/ResetUserHelper.cs @@ -14,7 +14,6 @@ namespace Bootstrap.DataAccess /// public static bool Save(ResetUser user) { - if (user.Id == string.Empty) user.Id = null; user.ResetTime = DateTime.Now; return DbContextManager.Create().Save(user); } diff --git a/Bootstrap.DataAccess/Helper/RoleHelper.cs b/Bootstrap.DataAccess/Helper/RoleHelper.cs index 49420ac7..c18ba877 100644 --- a/Bootstrap.DataAccess/Helper/RoleHelper.cs +++ b/Bootstrap.DataAccess/Helper/RoleHelper.cs @@ -78,7 +78,6 @@ namespace Bootstrap.DataAccess var roles = new string[] { "Administrators", "Default" }; var rs = Retrieves().Where(r => roles.Any(rl => rl.Equals(r.RoleName, StringComparison.OrdinalIgnoreCase))); if (rs.Any(r => r.Id == p.Id)) return true; - if (p.Id == string.Empty) p.Id = null; var ret = DbContextManager.Create().Save(p); if (ret) CacheCleanUtility.ClearCache(roleIds: string.IsNullOrEmpty(p.Id) ? new List() : new List { p.Id }); return ret; diff --git a/Bootstrap.DataAccess/Helper/TaskHelper.cs b/Bootstrap.DataAccess/Helper/TaskHelper.cs index b1f64d8d..c3ab69ba 100644 --- a/Bootstrap.DataAccess/Helper/TaskHelper.cs +++ b/Bootstrap.DataAccess/Helper/TaskHelper.cs @@ -25,10 +25,6 @@ namespace Bootstrap.DataAccess /// /// /// - public static bool Save(Task task) - { - if (string.IsNullOrEmpty(task.Id)) task.Id = null; - return DbContextManager.Create().Save(task); - } + public static bool Save(Task task) => DbContextManager.Create().Save(task); } } diff --git a/Bootstrap.DataAccess/Helper/TraceHelper.cs b/Bootstrap.DataAccess/Helper/TraceHelper.cs index e7c5ef55..f90efc84 100644 --- a/Bootstrap.DataAccess/Helper/TraceHelper.cs +++ b/Bootstrap.DataAccess/Helper/TraceHelper.cs @@ -28,7 +28,6 @@ namespace Bootstrap.DataAccess v.DisplayName = user.DisplayName; DbContextManager.Create().Save(new Trace { - Id = null, Ip = v.Ip, RequestUrl = v.RequestUrl, LogTime = v.LastAccessTime,