增加功能:日志记录数据库脚本最后命令 closed #IVGH4

#Issue
https://gitee.com/LongbowEnterprise/dashboard/issues?id=IVGH4
This commit is contained in:
Argo Zhang 2019-04-16 15:26:11 +08:00
parent 238a630648
commit 80f27b5cf3
3 changed files with 39 additions and 36 deletions

View File

@ -14,7 +14,6 @@
<ItemGroup>
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.4" />
<PackageReference Include="Longbow.Logging" Version="2.2.6" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" PrivateAssets="All" />

View File

@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.1.0" />
<PackageReference Include="Longbow.Data" Version="2.2.8" />
<PackageReference Include="Longbow.Logging" Version="2.2.6" />
<PackageReference Include="Longbow.Security.Cryptography" Version="1.3.0" />
<PackageReference Include="Longbow.Web" Version="2.2.10" />
<PackageReference Include="Longbow.Cache" Version="2.2.7" />

View File

@ -1,35 +1,38 @@
using PetaPoco;
namespace Bootstrap.DataAccess
{
/// <summary>
///
/// </summary>
public static class DbManager
{
/// <summary>
///
/// </summary>
/// <param name="connectionName"></param>
/// <returns></returns>
public static IDatabase Create(string connectionName = null, bool keepAlive = false)
{
var db = Longbow.Data.DbManager.Create(connectionName, keepAlive);
return db.AddMaps();
}
private static IDatabase AddMaps(this IDatabase database)
{
database.AddMap<Dict>("Dicts");
database.AddMap<User>("Users", new string[] { "Checked", "Period", "NewPassword", "UserStatus" });
database.AddMap<Exceptions>("Exceptions", new string[] { "Period" });
database.AddMap<Group>("Groups", new string[] { "Checked" });
database.AddMap<Log>("Logs");
database.AddMap<Menu>("Navigations", new string[] { "ParentName", "CategoryName", "Active", "Menus" });
database.AddMap<Role>("Roles", new string[] { "Checked" });
database.AddMap<Task>("Tasks");
database.AddMap<Trace>("Traces");
return database;
}
}
}
using PetaPoco;
using System;
using System.Collections.Specialized;
namespace Bootstrap.DataAccess
{
/// <summary>
///
/// </summary>
public static class DbManager
{
/// <summary>
///
/// </summary>
/// <param name="connectionName"></param>
/// <returns></returns>
public static IDatabase Create(string connectionName = null, bool keepAlive = false)
{
var db = Longbow.Data.DbManager.Create(connectionName, keepAlive);
db.ExceptionThrown += (sender, args) => args.Exception.Log(new NameValueCollection() { ["LastCmd"] = db.LastCommand });
return db.AddMaps();
}
private static IDatabase AddMaps(this IDatabase database)
{
database.AddMap<Dict>("Dicts");
database.AddMap<User>("Users", new string[] { "Checked", "Period", "NewPassword", "UserStatus" });
database.AddMap<Exceptions>("Exceptions", new string[] { "Period" });
database.AddMap<Group>("Groups", new string[] { "Checked" });
database.AddMap<Log>("Logs");
database.AddMap<Menu>("Navigations", new string[] { "ParentName", "CategoryName", "Active", "Menus" });
database.AddMap<Role>("Roles", new string[] { "Checked" });
database.AddMap<Task>("Tasks");
database.AddMap<Trace>("Traces");
return database;
}
}
}