Merge pull request #851 from paulyuk/patch/workflow-dotnet

Patch/workflow -- fixes #831
This commit is contained in:
Paul Yuknewicz 2023-05-27 09:44:39 -07:00 committed by GitHub
commit b199c5631a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -33,14 +33,18 @@ host.Start();
using var daprClient = new DaprClientBuilder().Build();
// Populate the store with items
RestockInventory();
// NOTE: WorkflowEngineClient will be replaced with a richer version of DaprClient
// in a subsequent SDK release. This is a temporary workaround.
WorkflowEngineClient workflowClient = host.Services.GetRequiredService<WorkflowEngineClient>();
// Generate a unique ID for the workflow
string orderId = Guid.NewGuid().ToString()[..8];
string itemToPurchase = "Cars";
int ammountToPurchase = 10;
// Populate the store with items
RestockInventory(itemToPurchase);
// Construct the order
OrderPayload orderInfo = new OrderPayload(itemToPurchase, 15000, ammountToPurchase);
@ -67,7 +71,7 @@ state = await daprClient.WaitForWorkflowCompletionAsync(
Console.WriteLine("Workflow Status: {0}", state.RuntimeStatus);
void RestockInventory()
void RestockInventory(string itemToPurchase)
{
daprClient.SaveStateAsync<OrderPayload>(StoreName, itemToPurchase, new OrderPayload(Name: itemToPurchase, TotalCost: 15000, Quantity: 100));
return;