@@ -199,6 +199,7 @@ private void ProcessAfterExecutionIteration(WorkflowInstance workflow, WorkflowD
199
199
200
200
private void DetermineNextExecutionTime ( WorkflowInstance workflow )
201
201
{
202
+ //TODO: move to own class
202
203
workflow . NextExecution = null ;
203
204
204
205
if ( workflow . Status == WorkflowStatus . Complete )
@@ -212,33 +213,33 @@ private void DetermineNextExecutionTime(WorkflowInstance workflow)
212
213
return ;
213
214
}
214
215
215
- long pointerSleep = pointer . SleepUntil . Value . ToUniversalTime ( ) . Ticks ;
216
+ var pointerSleep = pointer . SleepUntil . Value . ToUniversalTime ( ) . Ticks ;
216
217
workflow . NextExecution = Math . Min ( pointerSleep , workflow . NextExecution ?? pointerSleep ) ;
217
218
}
218
219
219
220
if ( workflow . NextExecution == null )
220
221
{
221
222
foreach ( var pointer in workflow . ExecutionPointers . Where ( x => x . Active && ( x . Children ?? new List < string > ( ) ) . Count > 0 ) )
222
223
{
223
- if ( workflow . ExecutionPointers . Where ( x => pointer . Children . Contains ( x . Id ) ) . All ( x => x . EndTime . HasValue ) )
224
+ if ( ! workflow . ExecutionPointers . Where ( x => x . Scope . Contains ( pointer . Id ) ) . All ( x => x . EndTime . HasValue ) )
225
+ continue ;
226
+
227
+ if ( ! pointer . SleepUntil . HasValue )
224
228
{
225
- if ( ! pointer . SleepUntil . HasValue )
226
- {
227
- workflow . NextExecution = 0 ;
228
- return ;
229
- }
230
-
231
- long pointerSleep = pointer . SleepUntil . Value . ToUniversalTime ( ) . Ticks ;
232
- workflow . NextExecution = Math . Min ( pointerSleep , workflow . NextExecution ?? pointerSleep ) ;
229
+ workflow . NextExecution = 0 ;
230
+ return ;
233
231
}
232
+
233
+ var pointerSleep = pointer . SleepUntil . Value . ToUniversalTime ( ) . Ticks ;
234
+ workflow . NextExecution = Math . Min ( pointerSleep , workflow . NextExecution ?? pointerSleep ) ;
234
235
}
235
236
}
236
237
237
- if ( ( workflow . NextExecution == null ) && ( workflow . ExecutionPointers . All ( x => x . EndTime != null ) ) )
238
- {
239
- workflow . Status = WorkflowStatus . Complete ;
240
- workflow . CompleteTime = _datetimeProvider . Now . ToUniversalTime ( ) ;
241
- }
238
+ if ( ( workflow . NextExecution != null ) || ( workflow . ExecutionPointers . Any ( x => x . EndTime == null ) ) )
239
+ return ;
240
+
241
+ workflow . Status = WorkflowStatus . Complete ;
242
+ workflow . CompleteTime = _datetimeProvider . Now . ToUniversalTime ( ) ;
242
243
}
243
244
244
245
}
0 commit comments