Ejemplo n.º 1
0
        /// <summary>
        /// Determines the workflow status browsing the related life-cycle event entries.
        /// </summary>
        public WorkflowItemState GetStatus(long eventId, IEnumerable<HistoryEvent> history)
        {
            if (history.IsWorkflowCompleted(eventId))
            {
                return WorkflowItemState.Completed;
            }

            if (history.IsWorkflowFailed(eventId))
            {
                return WorkflowItemState.Failed;
            }

            if (history.IsWorkflowCanceled(eventId))
            {
                return WorkflowItemState.Canceled;
            }

            if (history.IsWorkflowTerminated(eventId))
            {
                return WorkflowItemState.Terminated;
            }

            if (history.IsWorkflowStarted(eventId))
            {
                return WorkflowItemState.Started;
            }

            throw new InvalidOperationException("Cannot determine the workflow status.");
        }