| | | 1 | | using Elsa.Extensions; |
| | | 2 | | using Elsa.Workflows; |
| | | 3 | | using Elsa.Workflows.Attributes; |
| | | 4 | | using JetBrains.Annotations; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Server.Web.ActivityHosts; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// A sample activity host that represents a penguin. |
| | | 10 | | /// Each of its public methods is an activity that can be executed. |
| | | 11 | | /// Method arguments are interpreted as input values, except for ActivityExecutionContext and CancellationToken. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <param name="logger"></param> |
| | | 14 | | [UsedImplicitly] |
| | 0 | 15 | | public class Penguin(ILogger<Penguin> logger) |
| | | 16 | | { |
| | | 17 | | [Activity(Description = "Wag the penguin")] |
| | | 18 | | public void Wag() |
| | | 19 | | { |
| | 0 | 20 | | logger.LogInformation("The penguin is wagging!"); |
| | 0 | 21 | | } |
| | | 22 | | |
| | | 23 | | public void Jump() |
| | | 24 | | { |
| | 0 | 25 | | logger.LogInformation("The penguin is jumping!"); |
| | 0 | 26 | | } |
| | | 27 | | |
| | | 28 | | public void Swim() |
| | | 29 | | { |
| | 0 | 30 | | logger.LogInformation("The penguin is swimming!"); |
| | 0 | 31 | | } |
| | | 32 | | |
| | | 33 | | public void Eat(string food) |
| | | 34 | | { |
| | 0 | 35 | | logger.LogInformation($"The penguin is eating {food}!"); |
| | 0 | 36 | | } |
| | | 37 | | |
| | | 38 | | public string Sleep(ActivityExecutionContext context) |
| | | 39 | | { |
| | 0 | 40 | | logger.LogInformation("The penguin is sleeping!"); |
| | 0 | 41 | | var bookmark = context.CreateBookmark(Wake); |
| | 0 | 42 | | return context.GenerateBookmarkTriggerToken(bookmark.Id); |
| | | 43 | | } |
| | | 44 | | |
| | | 45 | | private ValueTask Wake(ActivityExecutionContext context) |
| | | 46 | | { |
| | 0 | 47 | | logger.LogInformation("The penguin woke up!"); |
| | 0 | 48 | | return ValueTask.CompletedTask; |
| | | 49 | | } |
| | | 50 | | } |