Beispiel #1
0
        public static V1WorkflowActivityCollectionState OnAddV1WorkflowInstance(V1WorkflowActivityCollectionState state, AddV1WorkflowInstance action)
        {
            var activities  = (action.WorkflowInstance.Activities ?? new Collection <V1WorkflowActivity>()).AsEnumerable();
            var activityIds = activities.Select(activity => activity.Id).ToList();

            activities = activities.Concat(state.Where(activity => !activityIds.Contains(activity.Id)));
            return(new(activities));
        }
Beispiel #2
0
        public static V1WorkflowActivityCollectionState OnRemoveV1WorkflowActivity(V1WorkflowActivityCollectionState state, RemoveV1WorkflowActivity action)
        {
            var activity = state.FirstOrDefault(a => a.Id == action.Id);

            if (activity != null)
            {
                state.Remove(activity);
            }
            return(state);
        }
Beispiel #3
0
        public static V1WorkflowActivityCollectionState OnMarkV1WorkflowActivityAsExecuted(V1WorkflowActivityCollectionState state, MarkV1WorkflowActivityAsExecuted action)
        {
            var activity = state.FirstOrDefault(a => a.Id == action.Id);

            if (activity != null)
            {
                activity.LastModified = action.ExecutedAt;
                activity.ExecutedAt   = action.ExecutedAt;
                activity.Error        = action.Error;
                activity.Output       = action.Output;
                activity.Status       = action.Status;
            }
            return(state);
        }
Beispiel #4
0
        public static V1WorkflowActivityCollectionState OnMarkV1WorkflowActivityAsCancelled(V1WorkflowActivityCollectionState state, MarkV1WorkflowActivityAsCancelled action)
        {
            var activity = state.FirstOrDefault(a => a.Id == action.Id);

            if (activity != null)
            {
                activity.LastModified = action.CancelledAt;
                activity.ExecutedAt   = action.CancelledAt;
                activity.Status       = V1WorkflowActivityStatus.Cancelled;
            }
            return(state);
        }
Beispiel #5
0
 public static V1WorkflowActivityCollectionState OnAddV1WorkflowActivity(V1WorkflowActivityCollectionState state, AddV1WorkflowActivity action)
 {
     state.Add(action.WorkflowActivity);
     return(state);
 }
Beispiel #6
0
        public static V1WorkflowActivityCollectionState OnGetWorkflowsFromApiSucceeded(V1WorkflowActivityCollectionState state, SetV1WorkflowInstanceCollection action)
        {
            var activities  = action.WorkflowInstances.SelectMany(instance => instance.Activities ?? new Collection <V1WorkflowActivity>());
            var activityIds = activities.Select(activity => activity.Id).ToList();

            activities = activities.Concat(state.Where(activity => !activityIds.Contains(activity.Id)));
            return(new(activities));
        }