@@ -10,11 +10,15 @@ namespace WorkflowEngine.Core.Actions
1010{
1111 public interface IArrayContext
1212 {
13- public string JobId { get ; set ; }
13+ string JobId { get ; set ; }
14+ string Queue { get ; set ; }
15+ bool HasMore { get ; set ; }
1416 }
1517 public class ArrayContext : IArrayContext
1618 {
1719 public string JobId { get ; set ; }
20+ public string Queue { get ; set ; }
21+ public bool HasMore { get ; set ; }
1822 }
1923
2024 public class ForeachAction : IActionImplementation
@@ -35,7 +39,9 @@ public async ValueTask<object> ExecuteAsync(IRunContext context, IWorkflow workf
3539 {
3640
3741 var loop = workflow . Manifest . Actions . FindAction ( action . Key ) as ForLoopActionMetadata ;
38-
42+
43+ arrayContext . HasMore = true ;
44+
3945 if ( loop . ForEach is string str && str . Contains ( "@" ) )
4046 {
4147 var items = await expressionEngine . ParseToValueContainer ( str ) ;
@@ -64,6 +70,7 @@ public async ValueTask<object> ExecuteAsync(IRunContext context, IWorkflow workf
6470 }
6571 else if ( action . Index < itemsToRunover . Count )
6672 {
73+
6774 // var nextAction = new Action { Type = action.Type, Key=action.Key, ScheduledTime = DateTimeOffset.UtcNow, RunId = context.RunId, Index = action.Index+1 };
6875
6976 var nextactionmetadata = loop . Actions . SingleOrDefault ( c => c . Value . RunAfter ? . Count == 0 ) ;
@@ -73,17 +80,18 @@ public async ValueTask<object> ExecuteAsync(IRunContext context, IWorkflow workf
7380 var nextaction = context . CopyTo ( new Action { Type = nextactionmetadata . Value . Type , Key = $ "{ action . Key } .{ nextactionmetadata . Key } ", ScheduledTime = DateTimeOffset . UtcNow , Index = action . Index + 1 } ) ;
7481
7582
76- var a = backgroundJobClient . ContinueJobWith < IHangfireActionExecutor > ( arrayContext . JobId ,
83+ var a = backgroundJobClient . ContinueJobWith < IHangfireActionExecutor > ( arrayContext . JobId , arrayContext . Queue ,
7784 ( executor ) => executor . ExecuteAsync ( context , workflow , nextaction , null ) ) ;
7885
7986 return new { item = itemsToRunover [ action . Index ] } ;
80- }
87+ }
8188
8289 }
8390 }
8491
8592
8693
94+ arrayContext . HasMore = false ;
8795
8896 return new { } ;
8997 }
0 commit comments