/// <summary> /// Propagate transition to children. /// </summary> /// <param name="elementId"></param> /// <param name="transition"></param> private void PropagateTransition(BaseCaseEltInstance elt, CMMNTransitions transition) { CMMNTransitions?newTransition = null; if (transition == CMMNTransitions.Terminate || transition == CMMNTransitions.ParentTerminate) { newTransition = CMMNTransitions.ParentTerminate; } if (newTransition == null) { return; } var stage = elt as StageElementInstance; if (stage == null) { return; } foreach (var child in stage.Children) { MakeTransition(child, newTransition.Value); } }
public void MakeTransition(CMMNTransitions transition, DateTime executionDateTime) { UpdateTransition(transition, executionDateTime); TransitionHistories.Add(new CasePlanElementInstanceTransitionHistory { ExecutionDateTime = executionDateTime, Transition = transition }); }
public CaseElementTransitionRaisedEvent(string id, string aggregateId, int version, string elementId, CMMNTransitions transition, string message, Dictionary <string, string> incomingTokens, DateTime updateDateTime) : base(id, aggregateId, version) { ElementId = elementId; Transition = transition; Message = message; IncomingTokens = incomingTokens; UpdateDateTime = updateDateTime; }
public CriteriaBuilder AddFileItemOnPart(string sourceRef, CMMNTransitions transition) { _fileItems.Add(new CaseFileItemOnPart { SourceRef = sourceRef, StandardEvent = transition }); return(this); }
protected override void UpdateTransition(CMMNTransitions transition, DateTime executionDateTime) { var newState = GetMilestoneOrEventListenerState(State, transition); if (newState != null) { State = newState; } }
public void MakeTransition(CMMNTransitions transition, bool isEvtPropagate = true) { var evt = new CaseTransitionRaisedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, transition, DateTime.UtcNow); Handle(evt); DomainEvents.Add(evt); if (isEvtPropagate) { PropagateTransition(StageContent, transition); } }
protected override void UpdateTransition(CMMNTransitions transition, DateTime executionDateTime) { if (transition == CMMNTransitions.ParentTerminate) { if (State != TaskStageStates.Completed && State != TaskStageStates.Terminated) { State = TaskStageStates.Terminated; } } else { State = GetTaskStageState(State, transition); } }
protected CaseFileItemStates?GetCaseFileItemState(CaseFileItemStates?state, CMMNTransitions transition) { CaseFileItemStates?result = null; switch (transition) { case CMMNTransitions.Create: if (state != null) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "already initialized") }); } result = CaseFileItemStates.Available; break; case CMMNTransitions.Update: case CMMNTransitions.Replace: case CMMNTransitions.RemoveChild: case CMMNTransitions.AddChild: case CMMNTransitions.AddReference: case CMMNTransitions.RemoveReference: if (state != CaseFileItemStates.Available) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "case file item is not available") }); } result = CaseFileItemStates.Available; break; case CMMNTransitions.Delete: if (state != CaseFileItemStates.Available) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "case file item is not available") }); } result = CaseFileItemStates.Discarded; break; } return(result); }
public void MakeTransition(CMMNTransitions transition, string message, DateTime executionDateTime) { switch (Type) { case CasePlanElementInstanceTypes.MILESTONE: case CasePlanElementInstanceTypes.TIMER: { var newState = GetMilestoneOrEventListenerState(MilestoneState, transition); if (newState != null) { MilestoneState = newState; } } break; case CasePlanElementInstanceTypes.EMPTYTASK: case CasePlanElementInstanceTypes.HUMANTASK: case CasePlanElementInstanceTypes.PROCESSTASK: case CasePlanElementInstanceTypes.STAGE: { if (transition == CMMNTransitions.ParentTerminate) { if (TakeStageState != TaskStageStates.Completed && TakeStageState != TaskStageStates.Terminated) { TakeStageState = TaskStageStates.Terminated; } } else { TakeStageState = GetTaskStageState(TakeStageState, transition); } } break; case CasePlanElementInstanceTypes.FILEITEM: { var newState = GetCaseFileItemState(FileState, transition); if (newState != null) { FileState = newState; } } break; } TransitionHistories.Add(new CaseEltInstanceTransitionHistory { Message = message, ExecutionDateTime = executionDateTime, Transition = transition }); }
public void MakeTransition(BaseCaseEltInstance element, CMMNTransitions transition, bool isEvtPropagate = true) { var evt = new CaseElementTransitionRaisedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, element.Id, transition, DateTime.UtcNow); Handle(evt); DomainEvents.Add(evt); var caseWorkerTask = WorkerTasks.FirstOrDefault(_ => _.CasePlanElementInstanceId == element.Id); if (caseWorkerTask != null && (transition == CMMNTransitions.Complete || transition == CMMNTransitions.Terminate || transition == CMMNTransitions.ParentTerminate)) { var removeCWT = new CaseInstanceWorkerTaskRemovedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, element.Id, DateTime.UtcNow); Handle(removeCWT); DomainEvents.Add(removeCWT); } if (isEvtPropagate) { PropagateTransition(element, transition); } }
/// <summary> /// Propagate transition to children. /// </summary> /// <param name="elementId"></param> /// <param name="transition"></param> private void PropagateTransition(CaseEltInstance elt, CMMNTransitions transition) { CMMNTransitions?newTransition = null; if (transition == CMMNTransitions.Terminate || transition == CMMNTransitions.ParentTerminate) { newTransition = CMMNTransitions.ParentTerminate; } if (newTransition == null) { return; } if (elt.Type != CasePlanElementInstanceTypes.STAGE) { return; } foreach (var child in elt.Children) { MakeTransition(child, newTransition.Value); } }
protected TaskStageStates?GetTaskStageState(TaskStageStates?state, CMMNTransitions transition) { TaskStageStates?result = null; switch (transition) { case CMMNTransitions.Create: if (state != null) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "already initialized") }); } result = TaskStageStates.Available; break; case CMMNTransitions.Enable: if (state != TaskStageStates.Available) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "planitem instance is not available") }); } result = TaskStageStates.Enabled; break; case CMMNTransitions.Disable: if (state != TaskStageStates.Enabled) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "planitem instance is not enabled") }); } result = TaskStageStates.Disabled; break; case CMMNTransitions.Reenable: if (state != TaskStageStates.Enabled) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "planitem instance is not disabled") }); } result = TaskStageStates.Disabled; break; case CMMNTransitions.Fault: if (state != TaskStageStates.Active) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "planitem instance is not active") }); } result = TaskStageStates.Failed; break; case CMMNTransitions.Reactivate: if (state != TaskStageStates.Failed) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "planitem instance is not failed") }); } result = TaskStageStates.Active; break; case CMMNTransitions.ManualStart: if (state != TaskStageStates.Enabled) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "planitem instance is not enabled") }); } result = TaskStageStates.Active; break; case CMMNTransitions.Start: if (state != TaskStageStates.Available) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "planitem instance is not available") }); } result = TaskStageStates.Active; break; case CMMNTransitions.Terminate: if (state != TaskStageStates.Active) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "planitem instance is not active") }); } result = TaskStageStates.Terminated; break; case CMMNTransitions.Suspend: if (state != TaskStageStates.Active) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "planitem instance is not active") }); } result = TaskStageStates.Suspended; break; case CMMNTransitions.Resume: if (state != TaskStageStates.Suspended) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "planitem instance is not suspended") }); } result = TaskStageStates.Active; break; case CMMNTransitions.Complete: if (state != TaskStageStates.Active) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "planitem instance is not active") }); } result = TaskStageStates.Completed; break; } return(result); }
protected abstract void UpdateTransition(CMMNTransitions transition, DateTime executionDateTime);
public CaseElementTransitionRaisedEvent(string id, string aggregateId, int version, string elementId, CMMNTransitions transition, DateTime updateDateTime) : base(id, aggregateId, version) { ElementId = elementId; Transition = transition; UpdateDateTime = updateDateTime; }
protected MilestoneEventStates?GetMilestoneOrEventListenerState(MilestoneEventStates?state, CMMNTransitions transition) { MilestoneEventStates?result = null; switch (transition) { case CMMNTransitions.Create: if (state != null) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "already initialized") }); } result = MilestoneEventStates.Available; break; case CMMNTransitions.Occur: if (state != MilestoneEventStates.Available) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "milestone instance is not available") }); } result = MilestoneEventStates.Completed; break; case CMMNTransitions.Suspend: if (state != MilestoneEventStates.Available) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "milestone instance is not available") }); } result = MilestoneEventStates.Suspended; break; case CMMNTransitions.Terminate: if (state != MilestoneEventStates.Available) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "milestone instance is not available") }); } result = MilestoneEventStates.Terminated; break; case CMMNTransitions.Resume: if (state != MilestoneEventStates.Suspended) { throw new AggregateValidationException(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transition", "milestone instance is not suspended") }); } result = MilestoneEventStates.Available; break; } return(result); }
public IncomingTransition(CMMNTransitions transition, Dictionary <string, string> incomingTokens) { Transition = transition; IncomingTokens = incomingTokens; }
public CaseTransitionRaisedEvent(string id, string aggregateId, int version, CMMNTransitions transition, DateTime updateDateTime) : base(id, aggregateId, version) { Transition = transition; UpdateDateTime = updateDateTime; }