protected void FeedCaseEltInstance(BaseCaseEltInstance elt) { elt.Id = Id; elt.Name = Name; elt.EltId = EltId; elt.TransitionHistories = new ConcurrentBag <CasePlanElementInstanceTransitionHistory>(TransitionHistories.Select(_ => (CasePlanElementInstanceTransitionHistory)_.Clone())); }
/// <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 ICollection <BaseCasePlanItemInstance> GetNextCasePlanItems(BaseCaseEltInstance elt) { var lst = new List <BaseCasePlanItemInstance>(); lst.AddRange(GetFlatListCasePlanItems()); var children = lst.Where(ch => ch.ExitCriterions.Any( ec => ec.SEntry != null && ec.SEntry.PlanItemOnParts != null && ((ec.SEntry.PlanItemOnParts.Any(pi => pi.SourceRef == elt.EltId)) || (ec.SEntry.FileItemOnParts.Any(pi => pi.SourceRef == elt.EltId))) ) || ch.EntryCriterions.Any( ec => ec.SEntry != null && ec.SEntry.PlanItemOnParts != null && ((ec.SEntry.PlanItemOnParts.Any(pi => pi.SourceRef == elt.EltId)) || (ec.SEntry.FileItemOnParts.Any(pi => pi.SourceRef == elt.EltId))) ) ).ToList(); return(children); }
public void ConsumeTransitionEvts(BaseCaseEltInstance node, string sourceElementId, ICollection <IncomingTransition> transitions) { var source = GetChild(sourceElementId); var target = GetCasePlanItem(node.Id); var onParts = new List <IOnPart>(); onParts.AddRange(GetOnParts(source.EltId, target.EntryCriterions, transitions)); onParts.AddRange(GetOnParts(source.EltId, target.ExitCriterions, transitions)); if (!onParts.Any()) { return; } var evt = new OnPartEvtConsumedEvent(Guid.NewGuid().ToString(), AggregateId, Version + 1, node.Id, sourceElementId, transitions); Handle(evt); DomainEvents.Add(evt); }
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); } }