elsa-core/src/samples/console/Elsa.Samples.EntityChanged/EntityChangedWorkflow.cs
Sipke Schoorstra 7cfe24ba94
Implement revival of faulted workflow (#595)
* Initial version of workflow reviver

* Fix DI things

* Rename workflow builder parameter to `builder`

* Update EF Core stores to use short-lived db contexts

* Update serializer to use new settings to reset ID seed

* Write fault details

* Add faulty workflows sample project

* Switch to free & open source Z.EntityFramework.Plus.EFCore

* Add content type header

* Fix call to virtual OnSaving/OnLoading

* Fix retry
2021-01-30 12:47:50 +01:00

25 lines
997 B
C#

using Elsa.Activities.Entity;
using Elsa.Activities.Console;
using Elsa.Builders;
using Elsa.Activities.Entity.Models;
namespace Elsa.Samples.EntityChanged
{
/// <summary>
/// This workflow gets invoked whenever an entity is added to the repository.
/// It then blocks execution until the entity is deleted.
/// </summary>
public class EntityChangedWorkflow : IWorkflow
{
public void Build(IWorkflowBuilder builder)
{
builder
.WithContextType<Entity>()
.EntityChanged<Entity>(EntityChangedAction.Added)
.WriteLine(context => $"Entity '{context.GetInput<EntityChangedContext>()!.EntityId}' was '{context.GetInput<EntityChangedContext>()!.Action}'")
.EntityChanged<Entity>(EntityChangedAction.Deleted)
.WriteLine(context => $"Entity '{context.GetInput<EntityChangedContext>()!.EntityId}' was '{context.GetInput<EntityChangedContext>()!.Action}'");
}
}
}