You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

29 lines
826 B

using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;
using Wood.Data.Repository;
using Wood.Entity;
using Wood.Entity.SystemManage;
using Wood.EventBus;
using Wood.EventBus.Events;
using Wood.Util;
namespace Wood.Service.Events
{
/// <summary>
/// 异常日志保存事件
/// </summary>
public class LogExceptionEventHandler : IntegrationEventHandler<LogExceptionEvent>, ISingleton
{
/// <summary>
/// 保存异常信息
/// </summary>
/// <param name="event"></param>
/// <param name="scope"></param>
/// <returns></returns>
public override async Task Run(LogExceptionEvent @event,IServiceScope scope)
{
await scope.ServiceProvider.GetRequiredService<SqlSugarRepository<LogExceptionEntity>>().InsertAsync(@event.GetPayload<LogExceptionEntity>()!);
}
}
}