fix issue #I7WEZP

This commit is contained in:
yubaolee 2023-08-28 12:33:45 +08:00
parent 6826eecc92
commit 8e3e2f9f45

View File

@ -16,6 +16,7 @@ using OpenAuth.App;
using OpenAuth.App.HostedService;
using OpenAuth.Mvc.Models;
using OpenAuth.Repository;
using SqlSugar;
namespace OpenAuth.Mvc
{
@ -100,6 +101,70 @@ namespace OpenAuth.Mvc
services.AddDataProtection().PersistKeysToFileSystem(new DirectoryInfo(Configuration["DataProtection"]));
services.AddScoped<ISqlSugarClient>(s =>
{
SqlSugarClient sqlSugar;
if(dbtypes.ContainsValue(Define.DBTYPE_SQLSERVER))
{
sqlSugar = new SqlSugarClient (new ConnectionConfig()
{
DbType = SqlSugar.DbType.SqlServer,
ConnectionString = connectionString,
IsAutoCloseConnection = true,
},db=>{
db.Aop.OnLogExecuting = (sql, pars) =>
{
logger.LogInformation(sql);
};
});
}
else if(dbtypes.ContainsValue(Define.DBTYPE_MYSQL)) //mysql
{
sqlSugar = new SqlSugarClient (new ConnectionConfig()
{
DbType = SqlSugar.DbType.MySql,
ConnectionString = connectionString,
IsAutoCloseConnection = true,
},db=>{
db.Aop.OnLogExecuting = (sql, pars) =>
{
logger.LogInformation(sql);
};
});
}
else if(dbtypes.ContainsValue(Define.DBTYPE_PostgreSQL)) //PostgreSQL
{
sqlSugar = new SqlSugarClient (new ConnectionConfig()
{
DbType = SqlSugar.DbType.PostgreSQL,
ConnectionString = connectionString,
IsAutoCloseConnection = true,
},db=>{
db.Aop.OnLogExecuting = (sql, pars) =>
{
logger.LogInformation(sql);
};
});
}
else
{
sqlSugar = new SqlSugarClient (new ConnectionConfig()
{
DbType = SqlSugar.DbType.Oracle,
ConnectionString = connectionString,
IsAutoCloseConnection = true,
},db=>{
db.Aop.OnLogExecuting = (sql, pars) =>
{
logger.LogInformation(sql);
};
});
}
return sqlSugar;
});
//设置定时启动的任务
services.AddHostedService<QuartzService>();