Merge branch 'dev-PetaPoco'

This commit is contained in:
Argo Zhang 2019-07-12 12:38:06 +08:00
commit 4b199b5724
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
15 changed files with 16 additions and 39 deletions

View File

@ -12,12 +12,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.10" />
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.11" />
<PackageReference Include="Longbow.Configuration" Version="2.2.4" />
<PackageReference Include="Longbow.Tasks" Version="1.5.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.10" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" PrivateAssets="All" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Sentry.AspNetCore" Version="1.2.0" />

View File

@ -7,12 +7,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.10" />
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.11" />
<PackageReference Include="Longbow.Configuration" Version="2.2.4" />
<PackageReference Include="Longbow.Logging" Version="2.2.9" />
<PackageReference Include="Longbow.Web" Version="2.2.14" />
<PackageReference Include="Longbow.Web" Version="2.2.15" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.4" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.6" />
</ItemGroup>
</Project>

View File

@ -5,14 +5,14 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.6" />
<PackageReference Include="Longbow.Data" Version="2.3.2" />
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.7" />
<PackageReference Include="Longbow.Data" Version="2.3.3" />
<PackageReference Include="Longbow.Logging" Version="2.2.9" />
<PackageReference Include="Longbow.Security.Cryptography" Version="1.3.0" />
<PackageReference Include="Longbow.Web" Version="2.2.14" />
<PackageReference Include="Longbow.Web" Version="2.2.15" />
<PackageReference Include="Longbow.Cache" Version="2.2.12" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.4" />
<PackageReference Include="PetaPoco.Extensions" Version="1.0.5" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.6" />
<PackageReference Include="PetaPoco.Extensions" Version="1.0.7" />
</ItemGroup>
</Project>

View File

@ -18,13 +18,7 @@ namespace Bootstrap.DataAccess
/// <returns></returns>
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;

View File

@ -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<Dict>().Save(p);
if (ret) CacheCleanUtility.ClearCache(dictIds: new List<string>());
return ret;

View File

@ -51,7 +51,6 @@ namespace Bootstrap.DataAccess
/// <returns></returns>
public static bool Save(Group p)
{
if (p.Id == string.Empty) p.Id = null;
var ret = DbContextManager.Create<Group>().Save(p);
if (ret) CacheCleanUtility.ClearCache(groupIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string>() { p.Id });
return ret;

View File

@ -34,7 +34,6 @@ namespace Bootstrap.DataAccess
/// <returns></returns>
public static bool Save(Log log)
{
if (log.Id == string.Empty) log.Id = null;
log.LogTime = DateTime.Now;
return DbContextManager.Create<Log>().Save(log);
}

View File

@ -18,7 +18,6 @@ namespace Bootstrap.DataAccess
/// <returns></returns>
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<LoginUser>().Log(user);
}

View File

@ -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<Menu>().Save(p);
if (ret) CacheCleanUtility.ClearCache(menuIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string>() { p.Id });
return ret;

View File

@ -54,10 +54,6 @@ namespace Bootstrap.DataAccess
/// </summary>
/// <param name="msg"></param>
/// <returns></returns>
public static bool Save(Message msg)
{
if (string.IsNullOrEmpty(msg.Id)) msg.Id = null;
return DbContextManager.Create<Message>().Save(msg);
}
public static bool Save(Message msg) => DbContextManager.Create<Message>().Save(msg);
}
}

View File

@ -14,7 +14,6 @@ namespace Bootstrap.DataAccess
/// <returns></returns>
public static bool Save(ResetUser user)
{
if (user.Id == string.Empty) user.Id = null;
user.ResetTime = DateTime.Now;
return DbContextManager.Create<ResetUser>().Save(user);
}

View File

@ -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<Role>().Save(p);
if (ret) CacheCleanUtility.ClearCache(roleIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string> { p.Id });
return ret;

View File

@ -25,10 +25,6 @@ namespace Bootstrap.DataAccess
/// </summary>
/// <param name="task"></param>
/// <returns></returns>
public static bool Save(Task task)
{
if (string.IsNullOrEmpty(task.Id)) task.Id = null;
return DbContextManager.Create<Task>().Save(task);
}
public static bool Save(Task task) => DbContextManager.Create<Task>().Save(task);
}
}

View File

@ -28,7 +28,6 @@ namespace Bootstrap.DataAccess
v.DisplayName = user.DisplayName;
DbContextManager.Create<Trace>().Save(new Trace
{
Id = null,
Ip = v.Ip,
RequestUrl = v.RequestUrl,
LogTime = v.LastAccessTime,

View File

@ -8,14 +8,14 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.6.2">
<PackageReference Include="coverlet.msbuild" Version="2.6.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.2.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MySql.Data" Version="8.0.16" />
<PackageReference Include="Npgsql" Version="4.0.7" />
<PackageReference Include="xunit" Version="2.4.1" />