11using CaseManagement . CMMN . Domains ;
22using CaseManagement . CMMN . Infrastructure . ExternalEvts ;
3- using CaseManagement . Common . Processors ;
43using System ;
54using System . Threading ;
65using System . Threading . Tasks ;
@@ -11,10 +10,11 @@ public abstract class BaseTaskOrStageProcessor<T> : BaseCasePlanItemProcessor<T>
1110 {
1211 public BaseTaskOrStageProcessor ( ISubscriberRepository subscriberRepository ) : base ( subscriberRepository ) { }
1312
14- protected override async Task Process ( CMMNExecutionContext executionContext , T elt , CancellationToken cancellationToken )
13+ protected override async Task < bool > Process ( CMMNExecutionContext executionContext , T elt , CancellationToken cancellationToken )
1514 {
1615 var terminate = await TrySubscribe ( executionContext , elt , CMMNConstants . ExternalTransitionNames . Terminate , cancellationToken ) ;
1716 var manualStart = await TrySubscribe ( executionContext , elt , CMMNConstants . ExternalTransitionNames . ManualStart , cancellationToken ) ;
17+ var disable = await TrySubscribe ( executionContext , elt , CMMNConstants . ExternalTransitionNames . Disable , cancellationToken ) ;
1818 if ( elt . State == null )
1919 {
2020 executionContext . Instance . MakeTransition ( elt , CMMNTransitions . Create ) ;
@@ -25,17 +25,23 @@ protected override async Task Process(CMMNExecutionContext executionContext, T e
2525 if ( elt . ManualActivationRule != null && elt . IsManualActivationRuleSatisfied ( executionContext . Instance . ExecutionContext ) )
2626 {
2727 executionContext . Instance . MakeTransition ( elt , CMMNTransitions . Enable ) ;
28- return ;
28+ return false ;
2929 }
3030
3131 executionContext . Instance . MakeTransition ( elt , CMMNTransitions . Start ) ;
3232 }
3333
3434 if ( elt . State == TaskStageStates . Enabled )
3535 {
36+ if ( disable . IsCaptured )
37+ {
38+ executionContext . Instance . MakeTransition ( elt , CMMNTransitions . Disable ) ;
39+ return false ;
40+ }
41+
3642 if ( ! manualStart . IsCaptured )
3743 {
38- return ;
44+ return false ;
3945 }
4046
4147 executionContext . Instance . MakeTransition ( elt , CMMNTransitions . ManualStart ) ;
@@ -45,22 +51,24 @@ protected override async Task Process(CMMNExecutionContext executionContext, T e
4551 {
4652 try
4753 {
48- await ProtectedProcess ( executionContext , elt , cancellationToken ) ;
54+ if ( terminate . IsCaptured )
55+ {
56+ executionContext . Instance . MakeTransition ( elt , CMMNTransitions . Terminate ) ;
57+ return true ;
58+ }
59+
60+ return await ProtectedProcess ( executionContext , elt , cancellationToken ) ;
4961 }
5062 catch ( Exception ex )
5163 {
5264 executionContext . Instance . MakeTransition ( elt , CMMNTransitions . Fault , ex . ToString ( ) ) ;
53- return ;
54- }
55-
56- if ( terminate . IsCaptured )
57- {
58- executionContext . Instance . MakeTransition ( elt , CMMNTransitions . Terminate ) ;
59- return ;
65+ return false ;
6066 }
6167 }
68+
69+ return false ;
6270 }
6371
64- protected abstract Task ProtectedProcess ( CMMNExecutionContext executionContext , T elt , CancellationToken cancellationToken ) ;
72+ protected abstract Task < bool > ProtectedProcess ( CMMNExecutionContext executionContext , T elt , CancellationToken cancellationToken ) ;
6573 }
6674}
0 commit comments