Add PersistWorkflow setting to Activity (#239)
This commit is contained in:
parent
7e040aca51
commit
fd1cfb4756
|
|
@ -1,6 +1,6 @@
|
|||
using Elsa.Models;
|
||||
|
||||
namespace Elsa.Messages.Distributed
|
||||
namespace Elsa.Messaging.Distributed
|
||||
{
|
||||
public class RunWorkflow
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Messages.Domain
|
||||
namespace Elsa.Messaging.Domain
|
||||
{
|
||||
public class ActivityExecuted : ActivityNotification
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Messages.Domain
|
||||
namespace Elsa.Messaging.Domain
|
||||
{
|
||||
public class ActivityExecuting : ActivityNotification
|
||||
{
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
using Elsa.Services.Models;
|
||||
using MediatR;
|
||||
|
||||
namespace Elsa.Messages.Domain
|
||||
namespace Elsa.Messaging.Domain
|
||||
{
|
||||
public abstract class ActivityNotification : INotification
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Messages.Domain
|
||||
namespace Elsa.Messaging.Domain
|
||||
{
|
||||
public class ExecutingWorkflow : WorkflowNotification
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Messages.Domain
|
||||
namespace Elsa.Messaging.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// Published when a workflow transitioned into the Cancelled state.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Messages.Domain
|
||||
namespace Elsa.Messaging.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// Published when a workflow transitioned into the Completed state.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using MediatR;
|
||||
|
||||
namespace Elsa.Messages.Domain
|
||||
namespace Elsa.Messaging.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// Published when the workflow definition store is updated.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Messages.Domain
|
||||
namespace Elsa.Messaging.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// Published when a burst of execution finished.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Messages.Domain
|
||||
namespace Elsa.Messaging.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// Published when a workflow transitioned into the Faulted state.
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using Elsa.Services.Models;
|
||||
using MediatR;
|
||||
|
||||
namespace Elsa.Messages.Domain
|
||||
namespace Elsa.Messaging.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// Common base for workflow-related events.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Messages.Domain
|
||||
namespace Elsa.Messaging.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// Published when a workflow transitioned into the Suspended state.
|
||||
|
|
@ -21,6 +21,7 @@ namespace Elsa.Services
|
|||
public string? Name { get; set; }
|
||||
public string? DisplayName{ get; set; }
|
||||
public string? Description{ get; set; }
|
||||
public bool PersistWorkflow { get; set; }
|
||||
|
||||
public Task<bool> CanExecuteAsync(ActivityExecutionContext context, CancellationToken cancellationToken) => OnCanExecuteAsync(context, cancellationToken);
|
||||
public Task<IActivityExecutionResult> ExecuteAsync(ActivityExecutionContext context, CancellationToken cancellationToken) => OnExecuteAsync(context, cancellationToken);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ namespace Elsa.Services
|
|||
/// Description of this activity.
|
||||
/// </summary>
|
||||
string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A value indicating whether the workflow instance will be persisted automatically upon executing this activity.
|
||||
/// </summary>
|
||||
bool PersistWorkflow { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Activity output.
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ using System.Threading.Tasks;
|
|||
using Elsa.Attributes;
|
||||
using Elsa.Design;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Messages;
|
||||
using Elsa.Messages.Domain;
|
||||
using Elsa.Messaging.Domain;
|
||||
using Elsa.Results;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Messages\Domain" />
|
||||
<Folder Include="Messaging\Domain" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -10,9 +10,9 @@ using Elsa.Caching;
|
|||
using Elsa.Converters;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Mapping;
|
||||
using Elsa.Messages;
|
||||
using Elsa.Messages.Distributed;
|
||||
using Elsa.Messages.Distributed.Handlers;
|
||||
using Elsa.Messaging;
|
||||
using Elsa.Messaging.Distributed;
|
||||
using Elsa.Messaging.Distributed.Handlers;
|
||||
using Elsa.Persistence;
|
||||
using Elsa.Persistence.Memory;
|
||||
using Elsa.Runtime;
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
// using Elsa.Models;
|
||||
// using Elsa.Services;
|
||||
// using Elsa.Services.Models;
|
||||
// using NodaTime;
|
||||
//
|
||||
// namespace Elsa.Messages.Handlers
|
||||
// {
|
||||
// public class ActivityLoggingWorkflowEventHandler : WorkflowEventHandlerBase
|
||||
// {
|
||||
// private readonly IClock clock;
|
||||
//
|
||||
// public ActivityLoggingWorkflowEventHandler(IClock clock)
|
||||
// {
|
||||
// this.clock = clock;
|
||||
// }
|
||||
//
|
||||
// protected override void ActivityExecuted(ProcessExecutionContext processExecutionContext, IActivity activity)
|
||||
// {
|
||||
// var timeStamp = clock.GetCurrentInstant();
|
||||
// processExecutionContext.ProcessInstance.ExecutionLog.Add(
|
||||
// new LogEntry(activity.Id, timeStamp, $"Successfully executed at {timeStamp}"));
|
||||
// }
|
||||
//
|
||||
// protected override void ActivityFaulted(
|
||||
// ProcessExecutionContext processExecutionContext,
|
||||
// IActivity activity,
|
||||
// string message)
|
||||
// {
|
||||
// processExecutionContext.ProcessInstance.ExecutionLog.Add(
|
||||
// new LogEntry(activity.Id, clock.GetCurrentInstant(), message, true));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
@ -2,7 +2,7 @@ using System.Threading.Tasks;
|
|||
using Elsa.Services;
|
||||
using Rebus.Handlers;
|
||||
|
||||
namespace Elsa.Messages.Distributed.Handlers
|
||||
namespace Elsa.Messaging.Distributed.Handlers
|
||||
{
|
||||
public class RunWorkflowHandler : IHandleMessages<RunWorkflow>
|
||||
{
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Extensions;
|
||||
|
|
@ -8,7 +7,7 @@ using Elsa.Services.Models;
|
|||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Elsa.Messages.Domain.Handlers
|
||||
namespace Elsa.Messaging.Domain.Handlers
|
||||
{
|
||||
public class PersistenceWorkflowEventHandler :
|
||||
INotificationHandler<WorkflowExecuted>,
|
||||
|
|
@ -39,7 +38,7 @@ namespace Elsa.Messages.Domain.Handlers
|
|||
|
||||
public async Task Handle(ActivityExecuted notification, CancellationToken cancellationToken)
|
||||
{
|
||||
if (notification.WorkflowExecutionContext.PersistenceBehavior == WorkflowPersistenceBehavior.ActivityExecuted)
|
||||
if (notification.WorkflowExecutionContext.PersistenceBehavior == WorkflowPersistenceBehavior.ActivityExecuted || notification.Activity.PersistWorkflow)
|
||||
await SaveWorkflowAsync(notification.WorkflowExecutionContext, cancellationToken);
|
||||
}
|
||||
|
||||
|
|
@ -4,7 +4,7 @@ using Elsa.Services.Models;
|
|||
using MediatR;
|
||||
using NodaTime;
|
||||
|
||||
namespace Elsa.Messages.Domain.Handlers
|
||||
namespace Elsa.Messaging.Domain.Handlers
|
||||
{
|
||||
public class WorkflowExecutionLogEventHandler : INotificationHandler<ActivityExecuted>
|
||||
{
|
||||
|
|
@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
using Rebus.Config;
|
||||
using Rebus.ServiceProvider;
|
||||
|
||||
namespace Elsa.Messages
|
||||
namespace Elsa.Messaging
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Messages;
|
||||
using Elsa.Messages.Domain;
|
||||
using Elsa.Messaging.Domain;
|
||||
using Elsa.Models;
|
||||
using MediatR;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ using System.Threading.Tasks;
|
|||
using Elsa.Comparers;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Messages;
|
||||
using Elsa.Messages.Domain;
|
||||
using Elsa.Messaging.Domain;
|
||||
using Elsa.Models;
|
||||
using Elsa.Persistence;
|
||||
using Elsa.Results;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ using System.Threading.Tasks;
|
|||
using Elsa.Comparers;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Messages.Distributed;
|
||||
using Elsa.Messages.Domain;
|
||||
using Elsa.Messaging.Distributed;
|
||||
using Elsa.Messaging.Domain;
|
||||
using Elsa.Models;
|
||||
using Elsa.Persistence;
|
||||
using Elsa.Services.Models;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Messages.Distributed;
|
||||
using Elsa.Messaging.Distributed;
|
||||
using Elsa.Runtime;
|
||||
using Rebus.Bus;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using Elsa.Activities.Http.Extensions;
|
||||
using Elsa.Runtime;
|
||||
using Elsa.Server.GraphQL.Extensions;
|
||||
using Elsa.StartupTasks;
|
||||
|
|
|
|||
Loading…
Reference in a new issue