mirror of
https://github.com/nsnail/NetAdmin.git
synced 2026-07-04 19:43:33 +08:00
1a28e8d5a6
[skip ci] Co-authored-by: tk <fiyne1a@dingtalk.com>
24 lines
748 B
C#
24 lines
748 B
C#
using NetAdmin.Domain.Events.Sys;
|
|
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
|
|
|
namespace NetAdmin.SysComponent.Host.Subscribers;
|
|
|
|
/// <summary>
|
|
/// 操作日志记录
|
|
/// </summary>
|
|
public sealed class OperationLogger : IEventSubscriber
|
|
{
|
|
/// <summary>
|
|
/// 保存请求日志到数据库
|
|
/// </summary>
|
|
[EventSubscribe(nameof(RequestLogEvent))]
|
|
public async Task OperationEventDbRecordAsync(EventHandlerExecutingContext context)
|
|
{
|
|
if (context.Source is not RequestLogEvent operationEvent) {
|
|
return;
|
|
}
|
|
|
|
operationEvent.Data.TruncateStrings();
|
|
_ = await App.GetService<IRequestLogService>().CreateAsync(operationEvent.Data).ConfigureAwait(false);
|
|
}
|
|
} |