33 lines
858 B
C#
33 lines
858 B
C#
using Jaina;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System.Threading.Tasks;
|
|
using HT.Cloud.Code;
|
|
using HT.Cloud.Domain.SystemSecurity;
|
|
using HT.Cloud.Service.SystemSecurity;
|
|
|
|
namespace HT.Cloud.Service.Event
|
|
{
|
|
// 实现 IEventSubscriber 接口
|
|
public class LogEventSubscriber : IEventSubscriber
|
|
{
|
|
|
|
public LogEventSubscriber()
|
|
{
|
|
}
|
|
|
|
[EventSubscribe("Log:create")]
|
|
public async Task SendMessages(EventHandlerExecutingContext context)
|
|
{
|
|
var todo = (BaseEventSource)context.Source;
|
|
var input = (LogEntity)todo.Payload;
|
|
var user = todo.User;
|
|
using (var serviceProvider = GlobalContext.RootServices.CreateScope())
|
|
{
|
|
var logService = serviceProvider.ServiceProvider.GetService<LogService>();
|
|
await logService.WriteDbLog(input, user);
|
|
}
|
|
await Task.CompletedTask;
|
|
}
|
|
}
|
|
}
|