将定时任务改为,发布、订阅模式的消息队列执行任务
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Filters
|
||||
{
|
||||
public class NotifyFilterAttribute : ActionFilterAttribute
|
||||
{
|
||||
|
||||
public override async void OnActionExecuted(ActionExecutedContext context)
|
||||
{
|
||||
var actionName = context.ActionDescriptor.RouteValues["action"]!;
|
||||
var taskMessageNotify = context.HttpContext.RequestServices.GetRequiredService<ITaskMessageNotify>();
|
||||
if (taskMessageNotify != null)
|
||||
{
|
||||
NotifyMessage message = new() { TaskName = actionName };
|
||||
await taskMessageNotify.Writer.WriteAsync(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user