forked from elsa-workflows/elsa-core
-
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
Showing
36 changed files
with
508 additions
and
113 deletions.
There are no files selected for viewing
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,27 @@ | ||
using Elsa.Abstractions; | ||
using Elsa.Workflows.Runtime.Contracts; | ||
|
||
namespace Elsa.Server.Web; | ||
|
||
public class MyEndpoint : ElsaEndpointWithoutRequest | ||
{ | ||
private readonly IEventPublisher _eventPublisher; | ||
|
||
public MyEndpoint(IEventPublisher eventPublisher) | ||
{ | ||
_eventPublisher = eventPublisher; | ||
} | ||
|
||
public override void Configure() | ||
{ | ||
Get("/my-event-workflow"); | ||
AllowAnonymous(); | ||
} | ||
|
||
public override async Task HandleAsync(CancellationToken ct) | ||
{ | ||
Console.WriteLine("Publishing MyEvent"); | ||
var results = await _eventPublisher.PublishAsync("MyEvent", cancellationToken: ct); | ||
Console.WriteLine($"Affected workflows: {results.Count}"); | ||
} | ||
} |
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,39 @@ | ||
using Elsa.Workflows; | ||
using Elsa.Workflows.Activities; | ||
using Elsa.Workflows.Contracts; | ||
using Elsa.Workflows.Runtime.Activities; | ||
|
||
namespace Elsa.Server.Web; | ||
|
||
public class OnMyEventWorkflow : WorkflowBase | ||
{ | ||
protected override void Build(IWorkflowBuilder builder) | ||
{ | ||
builder.Version = 1; | ||
builder.Id = "OnMyEventWorkflow"; | ||
builder.Root = new Sequence | ||
{ | ||
Activities = | ||
{ | ||
new Event("MyEvent") | ||
{ | ||
CanStartWorkflow = true | ||
}, | ||
new Inline(async () => | ||
{ | ||
// IEventPublisher.PublishAsync returns before this executes | ||
await SomeCallAsync(); | ||
}), | ||
new WriteLine("End of workflow"), | ||
new Finish() | ||
} | ||
}; | ||
} | ||
|
||
private async Task SomeCallAsync() | ||
{ | ||
Console.WriteLine("Hello from OnMyEventWorkflow"); | ||
await Task.Delay(1000); | ||
Console.WriteLine("Goodbye from OnMyEventWorkflow"); | ||
} | ||
} |
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
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
32 changes: 32 additions & 0 deletions
32
src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Contracts/IExecuteWorkflowApi.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,32 @@ | ||
using Elsa.Api.Client.Resources.WorkflowDefinitions.Requests; | ||
using JetBrains.Annotations; | ||
using Refit; | ||
|
||
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Contracts; | ||
|
||
/// <summary> | ||
/// Represents a client for the workflow definitions API. | ||
/// </summary> | ||
[PublicAPI] | ||
public interface IExecuteWorkflowApi | ||
{ | ||
/// <summary> | ||
/// Executes a workflow definition. | ||
/// </summary> | ||
/// <param name="definitionId">The definition ID of the workflow definition to execute.</param> | ||
/// <param name="request">An optional request containing options for executing the workflow definition.</param> | ||
/// <param name="cancellationToken">An optional cancellation token.</param> | ||
/// <returns>A response containing information about the workflow instance that was created.</returns> | ||
[Post("/workflow-definitions/{definitionId}/execute")] | ||
Task<HttpResponseMessage> ExecuteAsync(string definitionId, ExecuteWorkflowDefinitionRequest? request, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Dispatches a request to execute the specified workflow definition. | ||
/// </summary> | ||
/// <param name="definitionId">The definition ID of the workflow definition to dispatch request.</param> | ||
/// <param name="request">An optional request containing options for dispatching a request to execute the specified workflow definition.</param> | ||
/// <param name="cancellationToken">An optional cancellation token.</param> | ||
/// <returns>A response containing information about the workflow instance that was created.</returns> | ||
[Post("/workflow-definitions/{definitionId}/dispatch")] | ||
Task<HttpResponseMessage> DispatchAsync(string definitionId, DispatchWorkflowDefinitionRequest? request, CancellationToken cancellationToken = default); | ||
} |
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
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
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
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
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
Oops, something went wrong.