private void ThrowIfBlockingProcessesRegistered(BusinessProcess businessProcess) { var blockingProcesses = _processes.FindAll(p => p.EffectiveDate.Equals(businessProcess.EffectiveDate) && p.ShouldBlockProcessOf(businessProcess) && p.IsActive()); if (blockingProcesses.Count > 0) { throw new BlockingProcessRegisteredException(blockingProcesses.Select(p => p.ProcessId).ToList()); } }
public void Register(BusinessProcess businessProcess) { ThrowIfRegistered(businessProcess.ProcessId); ThrowIfBlockingProcessesRegistered(businessProcess); SuspendInterferingProcesses(businessProcess); _processes.Add(businessProcess); AddDomainEvent(new ProcessRegistered(businessProcess.ProcessId)); }
private void SuspendInterferingProcesses(BusinessProcess businessProcess) { _processes .FindAll(businessProcess.MustSuspendProcessOf) .ForEach(p => p.Suspend(businessProcess.ProcessId)); }
internal override bool ShouldBlockProcessOf(BusinessProcess businessProcess) { // TODO: Better handling of blocking processes return(businessProcess.GetType().Equals(typeof(ChangeOfSupplierProcess))); }
internal override bool MustSuspendProcessOf(BusinessProcess businessProcess) { // TODO: Better handling of suspendable processes return(businessProcess.GetType().Equals(typeof(ChangeOfSupplierProcess))); }
internal virtual bool ShouldBlockProcessOf(BusinessProcess businessProcess) { return(false); }
internal virtual bool MustSuspendProcessOf(BusinessProcess businessProcess) { return(false); }