Add PersistWorkflow setting to Activity (#239)

This commit is contained in:
Sipke Schoorstra 2020-01-18 21:37:26 +01:00 committed by GitHub
parent 7e040aca51
commit fd1cfb4756
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 34 additions and 64 deletions

View file

@ -1,6 +1,6 @@
using Elsa.Models;
namespace Elsa.Messages.Distributed
namespace Elsa.Messaging.Distributed
{
public class RunWorkflow
{

View file

@ -1,6 +1,6 @@
using Elsa.Services.Models;
namespace Elsa.Messages.Domain
namespace Elsa.Messaging.Domain
{
public class ActivityExecuted : ActivityNotification
{

View file

@ -1,6 +1,6 @@
using Elsa.Services.Models;
namespace Elsa.Messages.Domain
namespace Elsa.Messaging.Domain
{
public class ActivityExecuting : ActivityNotification
{

View file

@ -2,7 +2,7 @@
using Elsa.Services.Models;
using MediatR;
namespace Elsa.Messages.Domain
namespace Elsa.Messaging.Domain
{
public abstract class ActivityNotification : INotification
{

View file

@ -1,6 +1,6 @@
using Elsa.Services.Models;
namespace Elsa.Messages.Domain
namespace Elsa.Messaging.Domain
{
public class ExecutingWorkflow : WorkflowNotification
{

View file

@ -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.

View file

@ -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.

View file

@ -1,6 +1,6 @@
using MediatR;
namespace Elsa.Messages.Domain
namespace Elsa.Messaging.Domain
{
/// <summary>
/// Published when the workflow definition store is updated.

View file

@ -1,6 +1,6 @@
using Elsa.Services.Models;
namespace Elsa.Messages.Domain
namespace Elsa.Messaging.Domain
{
/// <summary>
/// Published when a burst of execution finished.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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);

View file

@ -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.

View file

@ -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;

View file

@ -54,7 +54,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Messages\Domain" />
<Folder Include="Messaging\Domain" />
</ItemGroup>
</Project>

View file

@ -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;

View file

@ -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));
// }
// }
// }

View file

@ -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>
{

View file

@ -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);
}

View file

@ -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>
{

View file

@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
using Rebus.Config;
using Rebus.ServiceProvider;
namespace Elsa.Messages
namespace Elsa.Messaging
{
public static class ServiceCollectionExtensions
{

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -1,3 +1,4 @@
using Elsa.Activities.Http.Extensions;
using Elsa.Runtime;
using Elsa.Server.GraphQL.Extensions;
using Elsa.StartupTasks;