using System; using Dapr.Workflow; namespace WorkflowApp; internal sealed class NonDeterministicWorkflow : Workflow { public override async Task RunAsync(WorkflowContext context, string orderItem) { // Do not use non-deterministic operations in a workflow! // These operations will create a new value every time the // workflow is replayed. var orderId = Guid.NewGuid().ToString(); var orderDate = DateTime.UtcNow; var idResult = await context.CallActivityAsync( "SubmitId", orderId); await context.CallActivityAsync( "SubmitDate", orderDate); return idResult; } } internal sealed class DeterministicWorkflow : Workflow { public override async Task RunAsync(WorkflowContext context, string orderItem) { // Do use these deterministic methods and properties on the WorkflowContext instead. // These operations create the same value when the workflow is replayed. var orderId = context.NewGuid().ToString(); var orderDate = context.CurrentUtcDateTime; var idResult = await context.CallActivityAsync( "SubmitId", orderId); await context.CallActivityAsync( "SubmitDate", orderDate); return idResult; } }