-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ae5c64
commit 1328d3c
Showing
27 changed files
with
1,577 additions
and
128 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,6 @@ | ||
--- | ||
description: This section covers all built-in control flow activities. | ||
--- | ||
|
||
# Control Flow | ||
|
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,71 @@ | ||
# Decision | ||
|
||
The **Decision** activity models a decision that yields a `true` or a `false` outcome, and is analogous to C#'s `if` statement. | ||
|
||
## Inputs | ||
|
||
| Name | Type | Description | | ||
| ----------- | ------------- | ----------------------------------------------- | | ||
| `Condition` | `Input<bool>` | An expression that evaluates to a boolean value | | ||
|
||
## Outcomes | ||
|
||
| Name | Description | | ||
| ----- | ------------------------------------------------- | | ||
| True | Triggered when the condition evaluates to `true` | | ||
| False | Triggered when the condition evaluates to `false` | | ||
|
||
## Usage | ||
|
||
The following workflow shows an example of how the `Decision` activity can be used inside a `Flowchart` activity. | ||
|
||
{% code fullWidth="false" %} | ||
```csharp | ||
using Elsa.Workflows; | ||
using Elsa.Workflows.Activities; | ||
using Elsa.Workflows.Activities.Flowchart.Activities; | ||
using Elsa.Workflows.Contracts; | ||
using Endpoint = Elsa.Workflows.Activities.Flowchart.Models.Endpoint; | ||
|
||
namespace ElsaServer.Workflows; | ||
|
||
public class FlowDecisionWorkflow : WorkflowBase | ||
{ | ||
protected override void Build(IWorkflowBuilder builder) | ||
{ | ||
builder.Name = "Flow Decision Workflow"; | ||
|
||
var age = builder.WithVariable<int>(); | ||
var promptWriteLine = new WriteLine("What is your age?"); | ||
var readLine = new ReadLine(age); | ||
var isAdult = new FlowDecision(context => age.Get(context) >= 18); | ||
var adult = new WriteLine("You are an adult."); | ||
var minor = new WriteLine("You are a minor."); | ||
var finish = new Finish(); | ||
|
||
builder.Root = new Flowchart | ||
{ | ||
Activities = | ||
{ | ||
promptWriteLine, | ||
readLine, | ||
isAdult, | ||
adult, | ||
minor, | ||
finish | ||
}, | ||
Connections = | ||
{ | ||
new(promptWriteLine, readLine), | ||
new(readLine, isAdult), | ||
new(new Endpoint(isAdult, "True"), new Endpoint(adult)), | ||
new(new Endpoint(isAdult, "False"), new Endpoint(minor)), | ||
new(new Endpoint(adult), new Endpoint(finish)), | ||
new(new Endpoint(minor), new Endpoint(finish)) | ||
} | ||
}; | ||
} | ||
} | ||
``` | ||
{% endcode %} | ||
|
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,18 @@ | ||
# MassTransit | ||
|
||
MassTransit is an open-source distributed application framework for .NET that provides a consistent abstraction on top of the supported message transports. | ||
|
||
It enables .NET developers to model messages as C# types, which can then be sent & received. To receive messages, one would typically write a Consumer. | ||
|
||
When using the MassTransit module with Elsa, there is an additional method of sending & handling messages; through workflow activities. | ||
|
||
## Messages as Activities | ||
|
||
Elsa makes it easy to send and receive messages that are modeled as .NET type. All you need to do is define your type and then register it with the MassTransit feature. | ||
|
||
When a message type is registered, two new activities will be automatically available for use: | ||
|
||
* Publish {activity type} | ||
* {activity type} | ||
|
||
The first activity will _publish_ your message. The second activity acts as a trigger and will start or resume your workflow when a message of this type is received. |
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,30 @@ | ||
# Tutorial | ||
|
||
The following example highlights creating and registering a fictive message type called `OrderCreated`. | ||
|
||
{% code title="OrderCreated.cs" %} | ||
```csharp | ||
public record OrderCreated(string Id, string ProductId, int Quantity); | ||
``` | ||
{% endcode %} | ||
|
||
{% code title="Program.cs" %} | ||
```csharp | ||
services.AddElsa(elsa => | ||
{ | ||
// Enable and configure MassTransit | ||
elsa.AddMassTransit(massTransit => | ||
{ | ||
// Register our message type. | ||
massTransit.AddMessageType<OrderCreated>(); | ||
}; | ||
}); | ||
``` | ||
{% endcode %} | ||
|
||
With the above setup, your workflow server will now add two activities that allow you to send and receive messages of type \`OrderCreated\`: | ||
|
||
* Order Created | ||
* Publish Order Created | ||
|
||
The **Order Created** activity acts as a trigger, which means that it will automatically start the workflow it is a part of when a message is received of this type. The **Publish Order Created** activity will publish a message of this type. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.