2022-04-27 20:32:40 +00:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2022-05-26 10:47:31 +00:00
|
|
|
|
using Elsa.Http.Extensions;
|
|
|
|
|
|
using Elsa.Http.Services;
|
2022-04-27 20:32:40 +00:00
|
|
|
|
using Elsa.Mediator.Services;
|
2022-05-26 10:47:31 +00:00
|
|
|
|
using Elsa.Workflows.Runtime.Notifications;
|
2022-04-27 20:32:40 +00:00
|
|
|
|
|
2022-05-26 10:47:31 +00:00
|
|
|
|
namespace Elsa.Http.Handlers
|
2022-04-27 20:32:40 +00:00
|
|
|
|
{
|
|
|
|
|
|
public class UpdateRouteTable :
|
|
|
|
|
|
INotificationHandler<WorkflowTriggersIndexed>,
|
|
|
|
|
|
INotificationHandler<WorkflowBookmarksIndexed>
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IRouteTable _routeTable;
|
|
|
|
|
|
public UpdateRouteTable(IRouteTable routeTable) => _routeTable = routeTable;
|
|
|
|
|
|
|
|
|
|
|
|
public Task HandleAsync(WorkflowTriggersIndexed notification, CancellationToken cancellationToken)
|
|
|
|
|
|
{
|
|
|
|
|
|
_routeTable.RemoveRoutes(notification.IndexedWorkflowTriggers.RemovedTriggers);
|
|
|
|
|
|
_routeTable.AddRoutes(notification.IndexedWorkflowTriggers.AddedTriggers);
|
|
|
|
|
|
_routeTable.AddRoutes(notification.IndexedWorkflowTriggers.UnchangedTriggers);
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task HandleAsync(WorkflowBookmarksIndexed notification, CancellationToken cancellationToken)
|
|
|
|
|
|
{
|
|
|
|
|
|
_routeTable.RemoveRoutes(notification.IndexedWorkflowBookmarks.RemovedBookmarks);
|
|
|
|
|
|
_routeTable.AddRoutes(notification.IndexedWorkflowBookmarks.AddedBookmarks);
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|