-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add chapters on Blocking Activities and Triggers
A comprehensive explanation of blocking activities and triggers has been provided. The blocking activity chapter explains their importance in workflow designs and gives an illustrative example. The trigger chapter elaborates their specialized conditioning role in starting workflows and gives an example of how they can be used.
- Loading branch information
1 parent
61a31b8
commit 0080667
Showing
8 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+51.1 KB
writerside/images/extensibility/custom-activities/my-event-workflow-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+196 KB
writerside/images/extensibility/custom-activities/my-event-workflow-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions
9
writerside/snippets/extensibility/custom-activities/MyEvent1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Elsa.Workflows; | ||
|
||
public class MyEvent : Activity | ||
{ | ||
protected override void Execute(ActivityExecutionContext context) | ||
{ | ||
context.CreateBookmark("MyEvent"); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
writerside/snippets/extensibility/custom-activities/MyEvent2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Elsa.Extensions; | ||
using Elsa.Workflows; | ||
|
||
namespace Elsa.Server.Web.Activities; | ||
|
||
public class MyEvent : Trigger | ||
{ | ||
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) | ||
{ | ||
if (context.IsTriggerOfWorkflow()) | ||
{ | ||
await context.CompleteActivityAsync(); | ||
return; | ||
} | ||
|
||
context.CreateBookmark("MyEvent"); | ||
} | ||
|
||
protected override object GetTriggerPayload(TriggerIndexingContext context) | ||
{ | ||
return "MyEvent"; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
writerside/snippets/extensibility/custom-activities/MyEventResumeSnippet1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var bookmarkPayload = "MyEvent"; | ||
var activityTypeName = ActivityTypeNameHelper.GenerateTypeName<MyEvent>(); | ||
await _workflowRuntime.TriggerWorkflowsAsync(activityTypeName, bookmarkPayload); |
15 changes: 15 additions & 0 deletions
15
writerside/snippets/extensibility/custom-activities/MyEventWorkflow1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
public class MyEventWorkflow : WorkflowBase | ||
{ | ||
protected override void Build(IWorkflowBuilder builder) | ||
{ | ||
builder.Root = new Sequence | ||
{ | ||
Activities = | ||
{ | ||
new WriteLine("Starting workflow..."), | ||
new MyEvent(), // This will block further execution until the MyEvent's bookmark is resumed. | ||
new WriteLine("Event occurred!") | ||
} | ||
}; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
writerside/snippets/extensibility/custom-activities/MyEventWorkflow2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
public class MyEventWorkflow : WorkflowBase | ||
{ | ||
protected override void Build(IWorkflowBuilder builder) | ||
{ | ||
builder.Root = new Sequence | ||
{ | ||
Activities = | ||
{ | ||
new MyEvent | ||
{ | ||
CanStartWorkflow = true // Enable this activity to start this workflow when triggered. | ||
}, | ||
new WriteLine("Event occurred!") | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters