using Furion.DatabaseAccessor; using Furion.EventBus; using Microsoft.Extensions.DependencyInjection; using System; using System.Threading.Tasks; namespace YBEE.EQM.Core { public class LogEventSubscriber : IEventSubscriber { public IServiceProvider Services { get; } public LogEventSubscriber(IServiceProvider services) { Services = services; } [EventSubscribe("Create:OpLog")] public async Task CreateOpLog(EventHandlerExecutingContext context) { using var scope = Services.CreateScope(); var _repository = scope.ServiceProvider.GetRequiredService>(); var log = (SysLogOp)context.Source.Payload; await _repository.InsertNowAsync(log); } [EventSubscribe("Create:ExLog")] public async Task CreateExLog(EventHandlerExecutingContext context) { using var scope = Services.CreateScope(); var _repository = scope.ServiceProvider.GetRequiredService>(); var log = (SysLogEx)context.Source.Payload; await _repository.InsertNowAsync(log); } [EventSubscribe("Create:VisLog")] public async Task CreateVisLog(EventHandlerExecutingContext context) { using var scope = Services.CreateScope(); var _repository = scope.ServiceProvider.GetRequiredService>(); var log = (SysLogVis)context.Source.Payload; await _repository.InsertNowAsync(log); } } }