namespace Admin.NET.Core; /// /// 日志事件订阅 /// public class LogEventSubscriber : IEventSubscriber { public IServiceProvider Services { get; } public LogEventSubscriber(IServiceProvider services) { Services = services; } /// /// 增加操作日志 /// /// /// [EventSubscribe("Add:OpLog")] public async Task CreateOpLog(EventHandlerExecutingContext context) { using var scope = Services.CreateScope(); var _rep = scope.ServiceProvider.GetRequiredService>(); await _rep.InsertAsync((SysLogOp)context.Source.Payload); } /// /// 增加异常日志 /// /// /// [EventSubscribe("Add:ExLog")] public async Task CreateExLog(EventHandlerExecutingContext context) { using var scope = Services.CreateScope(); var _rep = scope.ServiceProvider.GetRequiredService>(); await _rep.InsertAsync((SysLogEx)context.Source.Payload); } /// /// 增加访问日志 /// /// /// [EventSubscribe("Add:VisLog")] public async Task CreateVisLog(EventHandlerExecutingContext context) { using var scope = Services.CreateScope(); var _rep = scope.ServiceProvider.GetRequiredService>(); await _rep.InsertAsync((SysLogVis)context.Source.Payload); } }