Browse Source

feat: Add workflow/activity event handler

pull/1568/head
colin 3 weeks ago
parent
commit
b4f63897a3
  1. 3
      aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/appsettings.Development.json
  2. 3
      aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Notifications/LINGYUN/Abp/ElsaNext/Notifications/AbpElsaNextNotificationsModule.cs
  3. 42
      aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Notifications/LINGYUN/Abp/ElsaNext/Notifications/Handlers/ActivityNotificationHandler.cs
  4. 53
      aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Notifications/LINGYUN/Abp/ElsaNext/Notifications/Handlers/WorkflowNotificationHandler.cs

3
aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/appsettings.Development.json

@ -180,7 +180,8 @@
"Override": { "Override": {
"System": "Warning", "System": "Warning",
"Microsoft": "Warning", "Microsoft": "Warning",
"DotNetCore": "Warning" "DotNetCore": "Warning",
"LINGYUN.Abp.ElsaNext.Notifications": "Debug"
} }
}, },
"WriteTo": [ "WriteTo": [

3
aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Notifications/LINGYUN/Abp/ElsaNext/Notifications/AbpElsaNextNotificationsModule.cs

@ -2,6 +2,7 @@
using LINGYUN.Abp.ElsaNext.Localization; using LINGYUN.Abp.ElsaNext.Localization;
using LINGYUN.Abp.ElsaNext.Notifications.Extensions; using LINGYUN.Abp.ElsaNext.Notifications.Extensions;
using LINGYUN.Abp.Notifications; using LINGYUN.Abp.Notifications;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
@ -34,5 +35,7 @@ public class AbpElsaNextNotificationsModule : AbpModule
.Get<ElsaNextResource>() .Get<ElsaNextResource>()
.AddVirtualJson("/LINGYUN/Abp/ElsaNext/Notifications/Localization/Resources"); .AddVirtualJson("/LINGYUN/Abp/ElsaNext/Notifications/Localization/Resources");
}); });
context.Services.AddNotificationHandlersFrom<AbpElsaNextNotificationsModule>();
} }
} }

42
aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Notifications/LINGYUN/Abp/ElsaNext/Notifications/Handlers/ActivityNotificationHandler.cs

@ -0,0 +1,42 @@
using Elsa.Mediator.Contracts;
using Elsa.Workflows.Notifications;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace LINGYUN.Abp.ElsaNext.Notifications.Handlers;
public class ActivityNotificationHandler :
INotificationHandler<ActivityExecuting>,
INotificationHandler<ActivityExecuted>,
INotificationHandler<ActivityCancelled>,
INotificationHandler<ActivityCompleted>
{
public ILogger<ActivityNotificationHandler> Logger { protected get; set; }
public ActivityNotificationHandler()
{
Logger = NullLogger<ActivityNotificationHandler>.Instance;
}
public async virtual Task HandleAsync(ActivityExecuting notification, CancellationToken cancellationToken)
{
Logger.LogDebug("The activity notification: {notification} has been triggered.", notification.ToString());
}
public async virtual Task HandleAsync(ActivityExecuted notification, CancellationToken cancellationToken)
{
Logger.LogDebug("The activity notification: {notification} has been triggered.", notification.ToString());
}
public async virtual Task HandleAsync(ActivityCancelled notification, CancellationToken cancellationToken)
{
Logger.LogDebug("The activity notification: {notification} has been triggered.", notification.ToString());
}
public async virtual Task HandleAsync(ActivityCompleted notification, CancellationToken cancellationToken)
{
Logger.LogDebug("The activity notification: {notification} has been triggered.", notification.ToString());
}
}

53
aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Notifications/LINGYUN/Abp/ElsaNext/Notifications/Handlers/WorkflowNotificationHandler.cs

@ -0,0 +1,53 @@
using Elsa.Mediator.Contracts;
using Elsa.Workflows.Notifications;
using Elsa.Workflows.Runtime.Notifications;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using System.Threading;
using System.Threading.Tasks;
namespace LINGYUN.Abp.ElsaNext.Notifications.Handlers;
public class WorkflowNotificationHandler :
INotificationHandler<WorkflowExecuting>,
INotificationHandler<WorkflowStarted>,
INotificationHandler<WorkflowFinished>,
INotificationHandler<WorkflowExecuted>,
INotificationHandler<WorkflowCancelling>,
INotificationHandler<WorkflowCancelled>
{
public ILogger<WorkflowNotificationHandler> Logger { protected get; set; }
public WorkflowNotificationHandler()
{
Logger = NullLogger<WorkflowNotificationHandler>.Instance;
}
public async virtual Task HandleAsync(WorkflowExecuting notification, CancellationToken cancellationToken)
{
Logger.LogDebug("The workflow notification: {notification} has been triggered.", notification.ToString());
}
public async virtual Task HandleAsync(WorkflowStarted notification, CancellationToken cancellationToken)
{
Logger.LogDebug("The workflow notification: {notification} has been triggered.", notification.ToString());
}
public async virtual Task HandleAsync(WorkflowFinished notification, CancellationToken cancellationToken)
{
Logger.LogDebug("The workflow notification: {notification} has been triggered.", notification.ToString());
}
public async virtual Task HandleAsync(WorkflowExecuted notification, CancellationToken cancellationToken)
{
Logger.LogDebug("The workflow notification: {notification} has been triggered.", notification.ToString());
}
public async virtual Task HandleAsync(WorkflowCancelling notification, CancellationToken cancellationToken)
{
Logger.LogDebug("The workflow notification: {notification} has been triggered.", notification.ToString());
}
public async virtual Task HandleAsync(WorkflowCancelled notification, CancellationToken cancellationToken)
{
Logger.LogDebug("The workflow notification: {notification} has been triggered.", notification.ToString());
}
}
Loading…
Cancel
Save