Skip to content

Commit 0c53415

Browse files
authored
Merge pull request #4957 from marcduiker/add-dotnet-wf
Extend .NET SDK docs with info about DaprWorkflowClient
2 parents 747d541 + 48e5cf9 commit 0c53415

File tree

8 files changed

+160
-206
lines changed

8 files changed

+160
-206
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,9 @@ Continue with the [Run local server](#run-local-server) steps.
7676
git submodule update --init --recursive
7777
```
7878

79-
1. Navigate back to the repository root and install npm packages:
79+
1. Install the npm packages:
8080

8181
```sh
82-
cd ..
8382
npm install
8483
```
8584

sdkdocs/dotnet/content/en/dotnet-sdk-docs/_index.md

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,14 @@ Put the Dapr .NET SDK to the test. Walk through the .NET quickstarts and tutoria
6666
Learn more about local development options, best practices, or browse NuGet packages to add to your existing .NET
6767
applications.
6868

69-
<div class="card-deck">
70-
<div class="card">
71-
<div class="card-body">
72-
<h5 class="card-title"><b>Development</b></h5>
73-
<p class="card-text">Learn about local development integration options</p>
74-
<a href="{{% ref dotnet-integrations %}}" class="stretched-link"></a>
75-
</div>
76-
<div class="card">
77-
<div class="card-body">
78-
<h5 class="card-title"><b>Best Practices</b></h5>
79-
<p class="card-text">Learn about best practices for developing .NET Dapr applications</p>
80-
<a href="{{% ref dotnet-guidance %}}" class="stretched-link"></a>
81-
</div>
82-
</div>
83-
<div class="card">
84-
<div class="card-body">
85-
<h5 class="card-title"><b>NuGet packages</b></h5>
86-
<p class="card-text">NuGet packages for adding the Dapr to your .NET applications.</p>
87-
<a href="https://www.nuget.org/profiles/dapr.io" class="stretched-link"></a>
88-
</div>
89-
</div>
90-
</div>
91-
<br />
69+
{{% cardpane %}}
70+
{{% card title="**Development**"%}}
71+
[Learn about local development integration options]({{% ref dotnet-integrations %}})
72+
{{% /card %}}
73+
{{% card title="**Best Practices**"%}}
74+
[Learn about best practices for developing .NET Dapr applications]({{% ref dotnet-guidance %}})
75+
{{% /card %}}
76+
{{% card title="**Nuget Packages**"%}}
77+
[NuGet packages for adding the Dapr to your .NET applications](https://www.nuget.org/profiles/dapr.io)
78+
{{% /card %}}
79+
{{% /cardpane %}}

sdkdocs/dotnet/content/en/dotnet-sdk-docs/dotnet-actors/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
type: docs
33
title: "Dapr actors .NET SDK"
44
linkTitle: "Actors"
5-
weight: 30000
5+
weight: 40000
66
description: Get up and running with the Dapr actors .NET SDK
77
---
88

sdkdocs/dotnet/content/en/dotnet-sdk-docs/dotnet-workflow/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
type: docs
33
title: "Dapr Workflow .NET SDK"
44
linkTitle: "Workflow"
5-
weight: 40000
5+
weight: 30000
66
description: Get up and running with Dapr Workflow and the Dapr .NET SDK
77
---
88

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
type: docs
3+
title: ".NET Workflow Examples"
4+
linkTitle: "Workflow examples on GitHub"
5+
weight: 3000
6+
description: Explore Dapr Workflow code examples on GitHub
7+
---
8+
9+
## Workflow tutorials in the Dapr Quickstarts repository
10+
11+
The Dapr Quickstarts repository on GitHub includes many workflow tutorials that showcase the various workflow patterns and how to use the workflow management operations. You can find these tutorials in the [quickstarts/tutorials/workflow/csharp](https://github.com/dapr/quickstarts/tree/master/tutorials/workflow/csharp) folder.
12+
13+
## Workflow examples in the .NET SDK repository
14+
15+
The Dapr .NET SDK repository on GitHub contains several examples demonstrating how to use Dapr Workflows with .NET. You can find these examples in the [examples/Workflow](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow) folder.
16+
17+
## Next steps
18+
19+
- [Try the Dapr University Workflow track](https://www.diagrid.io/dapr-university#dapr-workflow)

sdkdocs/dotnet/content/en/dotnet-sdk-docs/dotnet-workflow/dotnet-workflow-howto.md

Lines changed: 0 additions & 172 deletions
This file was deleted.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
type: docs
3+
title: "Workflow management operations with DaprWorkflowClient"
4+
linkTitle: "Workflow management operations"
5+
weight: 2000
6+
description: Learn how to use the `DaprWorkflowClient` to manage workflows
7+
---
8+
9+
## Workflow management operations with `DaprWorkflowClient`
10+
11+
The `DaprWorkflowClient` class provides methods to manage workflow instances. Below are the operations you can perform using the `DaprWorkflowClient`.
12+
13+
### Schedule a new workflow instance
14+
15+
To start a new workflow instance, use the `ScheduleNewWorkflowAsync` method. This method requires the workflow type name and an input required by the workflow. The workflow `instancedId` is an optional argument; if not provided, a new GUID is generated by the `DaprWorkflowClient`. The final optional argument is a `startTime` of type `DateTimeOffset` which can be used to define when the workflow instance should start. The method returns the `instanceId` of the scheduled workflow which is used for other workflow management operations.
16+
17+
```csharp
18+
var instanceId = $"order-workflow-{Guid.NewGuid().ToString()[..8]}";
19+
var input = new Order("Paperclips", 1000, 9.95);
20+
await daprWorkflowClient.ScheduleNewWorkflowAsync(
21+
nameof(OrderProcessingWorkflow),
22+
instanceId,
23+
input);
24+
```
25+
26+
### Retrieve the status of a workflow instance
27+
28+
To get the current status of a workflow instance, use the `GetWorkflowStateAsync` method. This method requires the instance ID of the workflow and returns a `WorkflowStatus` object containing details about the workflow's current state.
29+
30+
```csharp
31+
var workflowStatus = await daprWorkflowClient.GetWorkflowStateAsync(instanceId);
32+
```
33+
34+
### Raise an event to a running workflow instance
35+
36+
To send an event to a running workflow instance that is waiting for an external event, use the `RaiseEventAsync` method. This method requires the instance ID of the workflow, the name of the event, and optionally the event payload.
37+
38+
```csharp
39+
await daprWorkflowClient.RaiseEventAsync(instanceId, "Approval", true);
40+
```
41+
42+
### Suspend a running workflow instance
43+
44+
A running workflow instance can be paused using the `SuspendWorkflowAsync` method. This method requires the instance ID of the workflow. You can optionally provide a reason for suspending the workflow.
45+
46+
```csharp
47+
await daprWorkflowClient.SuspendWorkflowAsync(instanceId);
48+
```
49+
50+
### Resume a suspended workflow instance
51+
52+
A suspended workflow instance can be resumed using the `ResumeWorkflowAsync` method. This method requires the instance ID of the workflow. You can optionally provide a reason for resuming the workflow.
53+
54+
```csharp
55+
await daprWorkflowClient.ResumeWorkflowAsync(instanceId);
56+
```
57+
58+
### Terminate a workflow instance
59+
60+
To terminate a workflow instance, use the `TerminateWorkflowAsync` method. This method requires the instance ID of the workflow. You can optionally provide an `output` argument of type `string`. Terminating a workflow instance will also terminal all child workflow instances but it has no impact on in-flight activity executions.
61+
62+
```csharp
63+
await daprWorkflowClient.TerminateWorkflowAsync(instanceId);
64+
```
65+
66+
### Purge a workflow instance
67+
68+
To remove the workflow instance history from the Dapr Workflow state store, use the `PurgeWorkflowAsync` method. This method requires the instance ID of the workflow. Only completed, failed, or terminated workflow instances can be purged.
69+
70+
```csharp
71+
await daprWorkflowClient.PurgeWorkflowAsync(instanceId);
72+
```
73+
74+
## Next steps
75+
76+
- [Learn how to author workflows and activities]({{% ref howto-author-workflow.md %}})
77+
- [Try the Dapr Workflow quickstart]({{% ref workflow-quickstart.md %}})

0 commit comments

Comments
 (0)