Add logging to OrderBatchProcessor workflow
Added a sequence with WriteLine activity to log processing of each order. Also, ensured the activity execution context properly sets its Tag property when a completion callback is provided.
This commit is contained in:
parent
15518ba6db
commit
e0a20c2dfc
|
|
@ -4,6 +4,7 @@ using Elsa.Samples.AspNet.BatchProcessing.Models;
|
|||
using Elsa.Workflows;
|
||||
using Elsa.Workflows.Activities;
|
||||
using Elsa.Workflows.Contracts;
|
||||
using Elsa.Workflows.Memory;
|
||||
|
||||
namespace Elsa.Samples.AspNet.BatchProcessing.Workflows;
|
||||
|
||||
|
|
@ -27,7 +28,14 @@ public class OrderBatchProcessor : WorkflowBase
|
|||
},
|
||||
new ParallelForEach<Order>
|
||||
{
|
||||
Items = new(orders)
|
||||
Items = new(orders),
|
||||
Body = new Sequence
|
||||
{
|
||||
Activities =
|
||||
{
|
||||
new WriteLine(context => $"Processing order {context.GetVariable<Order>("CurrentValue")!.Id}"),
|
||||
}
|
||||
}
|
||||
},
|
||||
new WriteLine("Done!")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -278,6 +278,7 @@ public partial class ActivityExecutionContext : IExecutionContext
|
|||
{
|
||||
if (completionCallback != null)
|
||||
{
|
||||
Tag = options?.Tag;
|
||||
var completedContext = new ActivityCompletedContext(this, this);
|
||||
await completionCallback(completedContext);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue