/// <summary>
/// 登录日志
/// </summary>
private IUserLogProvider _userLogProvider;
/// <summary>
/// 注入服务
/// </summary>
/// <param name="responseLoginRepository"></param>
/// <param name="cache"></param>
/// <param name="des"></param>
public LoginController(IUserLogProvider userLogProvider)
{
_userLogProvider = userLogProvider;
}
bo_operation_userlog bo_operation_behavior.i_log_system
operation:systemLogDbType
bo_operation_userlog.xml
IConfiguration _configDev = _configurationBuilderService.GetConfigurationApp(pf.OwnerId, pf.SysId);
////操作日志存储的数据库类别 mysql sqlserver oracle sqlite
string dataBaseType = _configDev.GetValue<string>("operation:systemLogDbType");
if (pf.OwnerId == null)
{
}
else if (string.IsNullOrEmpty(dataBaseType) && (usl == null || pf == null))
{
}
else if (string.IsNullOrEmpty(dataBaseType))
{
_db.Execute(pf, "bo_operation_behavior.i_log_system", usl);
_subscribePublish.PushBiz(pf, _configDev, $"user-log-{pf.OwnerId}-mkey-{pf.ModuleKey}", $"user-log-{pf.OwnerId}-mkey");
}
else
{
//判断表是否存在,如果不存在添加
var mapper = _mapper.GetMapper(new PFGlobalParameter { OwnerId = pf.OwnerId, SysId = pf.SysId, DatabaseType = dataBaseType.ToString() }, "bo_operation_userlog.i_table");
StringBuilder sbSql = new StringBuilder(mapper.Sql);
sbSql
.Replace("_@suffixYM", DateTime.Now.ToString("_yyyyMM"))
.Replace("_@suffixY", DateTime.Now.ToString("_yyyy"))
.Replace("_@suffixM", DateTime.Now.ToString("_MM"))
.Replace("_@suffix", DateTime.Now.ToString("_yyyyMMdd"));
string sql = sbSql.ToString();
//动态创建表
var result = _db.Execute(pf, mapper.ConnName, sql, new object { });
//插入数据
var mapperD = _mapper.GetMapper(new PFGlobalParameter { OwnerId = pf.OwnerId, SysId = pf.SysId, DatabaseType = dataBaseType.ToString() }, "bo_operation_userlog.i_data");
StringBuilder sbSqld = new StringBuilder(mapperD.Sql);
sbSqld
.Replace("_@suffixYM", DateTime.Now.ToString("_yyyyMM"))
.Replace("_@suffixY", DateTime.Now.ToString("_yyyy"))
.Replace("_@suffixM", DateTime.Now.ToString("_MM"))
.Replace("_@suffix", DateTime.Now.ToString("_yyyyMMdd"));
string sqlD = sbSqld.ToString();
result = _db.Execute(pf, mapper.ConnName, sqlD, usl);
_subscribePublish.PushBiz(pf, _configDev, $"user-log-{pf.OwnerId}-mkey-{pf.ModuleKey}", $"user-log-{pf.OwnerId}-mkey");
}
文档更新时间: 2021-08-25 08:00 作者:admin