添加项目文件。
This commit is contained in:
32
HT.Cloud.Service/Event/LogEventSubscriber.cs
Normal file
32
HT.Cloud.Service/Event/LogEventSubscriber.cs
Normal file
@ -0,0 +1,32 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user