using NetAdmin.Domain.Events.Sys; using NetAdmin.SysComponent.Application.Services.Sys.Dependency; namespace NetAdmin.SysComponent.Host.Subscribers; /// /// 操作日志记录 /// public sealed class OperationLogger : IEventSubscriber { /// /// 保存请求日志到数据库 /// [EventSubscribe(nameof(RequestLogEvent))] public async Task OperationEventDbRecordAsync(EventHandlerExecutingContext context) { if (context.Source is not RequestLogEvent operationEvent) { return; } operationEvent.Data.TruncateStrings(); _ = await App.GetService().CreateAsync(operationEvent.Data).ConfigureAwait(false); } }