/// <summary> /// Cancel process instance /// Cancels all currently active transitions and removes all tokens /// from the process. /// TODO: implement /// </summary> public void CancelProcessInstance() { log.Info("Cancelling process"); lock (this) { foreach (string corrId in _activeTransitions.Keys) { TaskShell ts = GetActiveTransition(corrId); if (ts.Status == TransitionStatus.ENABLED || ts.Status == TransitionStatus.STARTED) { CancelTransition(corrId); } } _currentMarking = new Dictionary<string, int>(); _status = ProcessStatus.Cancelled; FinishDate = DateTime.Now; } log.Info("Process cancelled"); ProcessCancelled pc = new ProcessCancelled(); pc.CorrelationId = this.CorrelationId; pc.DefinitionId = this.ProcessDefinitionId; pc.InstanceId = this.InstanceId; NotifyProcessEvent(pc); }
/// <summary> /// Cancel process instance /// Cancels all currently active transitions and removes all tokens /// from the process. /// TODO: implement /// </summary> public void CancelProcessInstance() { log.Info("Cancelling process"); foreach (Place pl in this.Definition.Places) { IList<Token> tokensInPlace = GetTokensInPlace(pl.Id); foreach (Token tok in tokensInPlace) { if (tok.Status == TokenStatus.READY || tok.Status == TokenStatus.LOCKED_ENABLED || tok.Status == TokenStatus.LOCKED_ALLOCATED || tok.Status == TokenStatus.WAITING) { log.Debug("Cancelling token {0} in place {1}", tok.TokenId, pl.Id); CancelToken(tok); } } } _status = ProcessStatus.Cancelled; log.Info("Process cancelled"); ProcessCancelled pc = new ProcessCancelled(); pc.CorrelationId = this.CorrelationId; pc.DefinitionId = this.ProcessDefinitionId; pc.InstanceId = this.InstanceId; NotifyProcessEvent(pc); }