mirror of https://github.com/dapr/quickstarts.git
Merge branch 'master' of github.com:dapr/quickstarts into patch/workflow-dotnet
Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan>
This commit is contained in:
commit
590162ba61
|
|
@ -7,7 +7,8 @@ using WorkflowConsoleApp.Activities;
|
|||
using WorkflowConsoleApp.Models;
|
||||
using WorkflowConsoleApp.Workflows;
|
||||
|
||||
const string storeName = "statestore";
|
||||
const string StoreName = "statestore";
|
||||
const string DaprWorkflowComponent = "dapr";
|
||||
|
||||
// The workflow host is a background service that connects to the sidecar over gRPC
|
||||
var builder = Host.CreateDefaultBuilder(args).ConfigureServices(services =>
|
||||
|
|
@ -50,31 +51,28 @@ OrderPayload orderInfo = new OrderPayload(itemToPurchase, 15000, ammountToPurcha
|
|||
// Start the workflow
|
||||
Console.WriteLine("Starting workflow {0} purchasing {1} {2}", orderId, ammountToPurchase, itemToPurchase);
|
||||
|
||||
await workflowClient.ScheduleNewWorkflowAsync(
|
||||
name: nameof(OrderProcessingWorkflow),
|
||||
instanceId: orderId,
|
||||
input: orderInfo);
|
||||
await daprClient.StartWorkflowAsync(
|
||||
workflowComponent: DaprWorkflowComponent,
|
||||
workflowName: nameof(OrderProcessingWorkflow),
|
||||
input: orderInfo,
|
||||
instanceId: orderId);
|
||||
|
||||
// Wait a second to allow workflow to start
|
||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||
|
||||
WorkflowState state = await workflowClient.GetWorkflowStateAsync(
|
||||
// Wait for the workflow to start and confirm the input
|
||||
GetWorkflowResponse state = await daprClient.WaitForWorkflowStartAsync(
|
||||
instanceId: orderId,
|
||||
getInputsAndOutputs: true);
|
||||
workflowComponent: DaprWorkflowComponent);
|
||||
|
||||
Console.WriteLine("Your workflow has started. Here is the status of the workflow: {0}", state.RuntimeStatus);
|
||||
while (!state.IsWorkflowCompleted)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||
state = await workflowClient.GetWorkflowStateAsync(
|
||||
instanceId: orderId,
|
||||
getInputsAndOutputs: true);
|
||||
}
|
||||
|
||||
// Wait for the workflow to complete
|
||||
state = await daprClient.WaitForWorkflowCompletionAsync(
|
||||
instanceId: orderId,
|
||||
workflowComponent: DaprWorkflowComponent);
|
||||
|
||||
Console.WriteLine("Workflow Status: {0}", state.RuntimeStatus);
|
||||
|
||||
void RestockInventory(string itemToPurchase)
|
||||
{
|
||||
daprClient.SaveStateAsync<OrderPayload>(storeName, itemToPurchase, new OrderPayload(Name: itemToPurchase, TotalCost: 15000, Quantity: 100));
|
||||
daprClient.SaveStateAsync<OrderPayload>(StoreName, itemToPurchase, new OrderPayload(Name: itemToPurchase, TotalCost: 15000, Quantity: 100));
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapr.AspNetCore" Version="1.10.0-rc02" />
|
||||
<PackageReference Include="Dapr.Workflow" Version="1.10.0-rc02" />
|
||||
<PackageReference Include="Dapr.AspNetCore" Version="1.11.*-*" />
|
||||
<PackageReference Include="Dapr.Workflow" Version="1.11.*-*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
Loading…
Reference in New Issue