public WorkflowItem BuildItem(HistoryEvent historyEvent, IEnumerable<HistoryEvent> history)
        {
            var eventId = historyEvent.GetInitialEventId();
            var state = GetStatus(eventId, history);

            var item = new WorkflowItem
            {
                EventId = historyEvent.EventId,
                Kind = WorkflowItemKind.ActivityCancellation,
                State = state,
                Result = state == WorkflowItemState.Completed ? history.GetActivityResult(eventId) : null,
                Reason = state == WorkflowItemState.Failed ? history.GetActivityReason(eventId) : null,
                Details =
                    state == WorkflowItemState.Failed ||
                    state == WorkflowItemState.Canceled ? history.GetActivityDetails(eventId) : null
            };

            if (state == WorkflowItemState.CancelRequested)
            {
                var attributes = historyEvent.ActivityTaskCancelRequestedEventAttributes;
                var decisionId = historyEvent.ActivityTaskCancelRequestedEventAttributes.DecisionTaskCompletedEventId;

                item.Order = decisionId;
                item.Id = attributes.ActivityId;
            }
            else if (state == WorkflowItemState.CancelFailed)
            {
                var attributes = historyEvent.RequestCancelActivityTaskFailedEventAttributes;
                var decisionId = historyEvent.RequestCancelActivityTaskFailedEventAttributes.DecisionTaskCompletedEventId;

                item.Order = decisionId;
                item.Id = attributes.ActivityId;
                item.Reason = attributes.Cause;
            }

            return item;
        }
Example #2
0
        public WorkflowItem BuildItem(HistoryEvent historyEvent, IEnumerable<HistoryEvent> history)
        {
            var eventId = historyEvent.GetInitialEventId();
            var attributes = historyEvent.ActivityTaskScheduledEventAttributes;
            var state = GetStatus(eventId, history);
            var decisionId = historyEvent.ActivityTaskScheduledEventAttributes.DecisionTaskCompletedEventId;

            return new WorkflowItem
            {
                Id = attributes.ActivityId,
                EventId = historyEvent.EventId,
                Name = attributes.ActivityType.Name,
                Input = attributes.Input,
                Kind = WorkflowItemKind.Activity,
                Version = attributes.ActivityType.Version,
                Order = decisionId,
                State = state,
                Result = state == WorkflowItemState.Completed ? history.GetActivityResult(eventId) : null,
                Reason = state == WorkflowItemState.Failed ? history.GetActivityReason(eventId) : null,
                Details =
                    state == WorkflowItemState.Failed ||
                    state == WorkflowItemState.Canceled ? history.GetActivityDetails(eventId) : null
            };
        }