예제 #1
0
        public IContainerStepBuilder <TData, When, OutcomeSwitch> When(Expression <Func <TData, object> > outcomeValue, string label = null)
        {
            var newStep = new WorkflowStep <When>();
            Expression <Func <When, object> > inputExpr = (x => x.ExpectedOutcome);

            newStep.Inputs.Add(new MemberMapParameter(outcomeValue, inputExpr));

            IStepBuilder <TData, OutcomeSwitch> switchBuilder;

            if (Step.BodyType != typeof(OutcomeSwitch))
            {
                var switchStep = new WorkflowStep <OutcomeSwitch>();
                WorkflowBuilder.AddStep(switchStep);
                Step.Outcomes.Add(new StepOutcome()
                {
                    NextStep = switchStep.Id,
                    Label    = label
                });
                switchBuilder = new StepBuilder <TData, OutcomeSwitch>(WorkflowBuilder, switchStep);
            }
            else
            {
                switchBuilder = (this as IStepBuilder <TData, OutcomeSwitch>);
            }

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new ReturnStepBuilder <TData, When, OutcomeSwitch>(WorkflowBuilder, newStep, switchBuilder);

            switchBuilder.Step.Children.Add(newStep.Id);

            return(stepBuilder);
        }
예제 #2
0
        public IStepBuilder <TData, Activity> Activity(string activityName, Expression <Func <TData, object> > parameters = null, Expression <Func <TData, DateTime> > effectiveDate = null, Expression <Func <TData, bool> > cancelCondition = null)
        {
            var newStep = new WorkflowStep <Activity>();

            newStep.CancelCondition = cancelCondition;

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, Activity>(WorkflowBuilder, newStep);

            stepBuilder.Input((step) => step.ActivityName, (data) => activityName);

            if (parameters != null)
            {
                stepBuilder.Input((step) => step.Parameters, parameters);
            }

            if (effectiveDate != null)
            {
                stepBuilder.Input((step) => step.EffectiveDate, effectiveDate);
            }

            Step.Outcomes.Add(new StepOutcome()
            {
                NextStep = newStep.Id
            });
            return(stepBuilder);
        }
예제 #3
0
        public IStepBuilder <TData, WaitFor> WaitFor(string eventName, Expression <Func <TData, IStepExecutionContext, string> > eventKey, Expression <Func <TData, DateTime> > effectiveDate = null, Expression <Func <TData, bool> > cancelCondition = null)
        {
            WorkflowStep <WaitFor> newStep;

            if (cancelCondition != null)
            {
                newStep = new CancellableStep <WaitFor, TData>(cancelCondition);
            }
            else
            {
                newStep = new WorkflowStep <WaitFor>();
            }

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, WaitFor>(WorkflowBuilder, newStep);

            stepBuilder.Input((step) => step.EventName, (data) => eventName);
            stepBuilder.Input((step) => step.EventKey, eventKey);

            if (effectiveDate != null)
            {
                stepBuilder.Input((step) => step.EffectiveDate, effectiveDate);
            }

            Step.Outcomes.Add(new StepOutcome()
            {
                NextStep = newStep.Id
            });
            return(stepBuilder);
        }
예제 #4
0
        public IStepBuilder <TData, TStep> Then <TStep>(IStepBuilder <TData, TStep> step)
            where TStep : IStepBody
        {
            Outcome.NextStep = step.Step.Id;
            var stepBuilder = new StepBuilder <TData, TStep>(WorkflowBuilder, step.Step);

            return(stepBuilder);
        }
예제 #5
0
        public IStepBuilder <TData, TStep> Then <TStep>(IStepBuilder <TData, TStep> newStep)
            where TStep : IStepBody
        {
            Step.Outcomes.Add(new ValueOutcome {
                NextStep = newStep.Step.Id
            });
            var stepBuilder = new StepBuilder <TData, TStep>(WorkflowBuilder, newStep.Step);

            return(stepBuilder);
        }
예제 #6
0
        public IStepBuilder <TData, InlineStepBody> Then(Func <IStepExecutionContext, ExecutionResult> body)
        {
            WorkflowStepInline newStep = new WorkflowStepInline();

            newStep.Body = body;
            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, InlineStepBody>(WorkflowBuilder, newStep);

            Outcome.NextStep = newStep.Id;
            return(stepBuilder);
        }
예제 #7
0
        public IStepBuilder <TData, TStepBody> CompensateWith(Func <IStepExecutionContext, ExecutionResult> body)
        {
            WorkflowStepInline newStep = new WorkflowStepInline();

            newStep.Body = body;
            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, InlineStepBody>(WorkflowBuilder, newStep);

            Step.CompensationStepId = newStep.Id;
            return(this);
        }
예제 #8
0
        public IStepBuilder <TData, TStepBody> CompensateWith(Action <IStepExecutionContext> body)
        {
            var newStep = new WorkflowStep <ActionStepBody>();

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, ActionStepBody>(WorkflowBuilder, newStep);

            stepBuilder.Input(x => x.Body, x => body);
            Step.CompensationStepId = newStep.Id;
            return(this);
        }
예제 #9
0
        public IStepBuilder <TData, ActionStepBody> Then(Action <IStepExecutionContext> body)
        {
            var newStep = new WorkflowStep <ActionStepBody>();

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, ActionStepBody>(WorkflowBuilder, newStep);

            stepBuilder.Input(x => x.Body, x => body);
            Step.Outcomes.Add(new ValueOutcome {
                NextStep = newStep.Id
            });
            return(stepBuilder);
        }
예제 #10
0
        public IStepBuilder <TData, TStepBody> CompensateWithSequence(Action <IWorkflowBuilder <TData> > builder)
        {
            var newStep = new WorkflowStep <Sequence>();

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, Sequence>(WorkflowBuilder, newStep);

            Step.CompensationStepId = newStep.Id;
            builder.Invoke(WorkflowBuilder);
            stepBuilder.Step.Children.Add(stepBuilder.Step.Id + 1); //TODO: make more elegant

            return(this);
        }
예제 #11
0
        public IParallelStepBuilder <TData, Sequence> Parallel()
        {
            var newStep    = new WorkflowStep <Sequence>();
            var newBuilder = new StepBuilder <TData, Sequence>(WorkflowBuilder, newStep);

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new ParallelStepBuilder <TData, Sequence>(WorkflowBuilder, newBuilder, newBuilder);

            Step.Outcomes.Add(new ValueOutcome {
                NextStep = newStep.Id
            });

            return(stepBuilder);
        }
예제 #12
0
        public IStepBuilder <TData, Sequence> Saga(Action <IWorkflowBuilder <TData> > builder)
        {
            var newStep = new SagaContainer <Sequence>();

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, Sequence>(WorkflowBuilder, newStep);

            Step.Outcomes.Add(new ValueOutcome {
                NextStep = newStep.Id
            });
            builder.Invoke(WorkflowBuilder);
            stepBuilder.Step.Children.Add(stepBuilder.Step.Id + 1); //TODO: make more elegant

            return(stepBuilder);
        }
예제 #13
0
        public IStepBuilder <TData, SubscriptionStepBody> WaitFor(string eventName, Expression <Func <TData, string> > eventKey)
        {
            var newStep = new SubscriptionStep <SubscriptionStepBody>();

            newStep.EventName = eventName;
            newStep.EventKey  = eventKey;
            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, SubscriptionStepBody>(WorkflowBuilder, newStep);

            Step.Outcomes.Add(new StepOutcome()
            {
                NextStep = newStep.Id
            });
            return(stepBuilder);
        }
예제 #14
0
        public IStepBuilder <TData, InlineStepBody> Then(Func <IStepExecutionContext, ExecutionResult> body)
        {
            WorkflowStepInline newStep = new WorkflowStepInline
            {
                Body = body
            };

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, InlineStepBody>(WorkflowBuilder, newStep);

            Step.Outcomes.Add(new StepOutcome()
            {
                NextStep = newStep.Id
            });
            return(stepBuilder);
        }
예제 #15
0
        public IStepBuilder <TData, Delay> Delay(Expression <Func <TData, TimeSpan> > period)
        {
            var newStep = new WorkflowStep <Delay>();

            Expression <Func <Delay, TimeSpan> > inputExpr = (x => x.Period);

            newStep.Inputs.Add(new MemberMapParameter(period, inputExpr));

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, Delay>(WorkflowBuilder, newStep);

            Step.Outcomes.Add(new ValueOutcome {
                NextStep = newStep.Id
            });

            return(stepBuilder);
        }
예제 #16
0
        public IStepBuilder <TData, Decide> Decide(Expression <Func <TData, object> > expression)
        {
            var newStep = new WorkflowStep <Decide>();

            Expression <Func <Decide, object> > inputExpr = (x => x.Expression);

            newStep.Inputs.Add(new MemberMapParameter(expression, inputExpr));

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, Decide>(WorkflowBuilder, newStep);

            Step.Outcomes.Add(new ValueOutcome {
                NextStep = newStep.Id
            });

            return(stepBuilder);
        }
예제 #17
0
        public IStepBuilder <TData, TStepBody> CompensateWith <TStep>(Action <IStepBuilder <TData, TStep> > stepSetup = null) where TStep : IStepBody
        {
            WorkflowStep <TStep> newStep = new WorkflowStep <TStep>();

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, TStep>(WorkflowBuilder, newStep);

            if (stepSetup != null)
            {
                stepSetup.Invoke(stepBuilder);
            }

            newStep.Name            = newStep.Name ?? typeof(TStep).Name;
            Step.CompensationStepId = newStep.Id;

            return(this);
        }
예제 #18
0
        public IContainerStepBuilder <TData, If, If> If(Expression <Func <TData, bool> > condition)
        {
            var newStep = new WorkflowStep <If>();

            Expression <Func <If, bool> > inputExpr = (x => x.Condition);

            newStep.Inputs.Add(new MemberMapParameter(condition, inputExpr));

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, If>(WorkflowBuilder, newStep);

            Step.Outcomes.Add(new ValueOutcome {
                NextStep = newStep.Id
            });

            return(stepBuilder);
        }
예제 #19
0
        public IContainerStepBuilder <TData, Foreach, Foreach> ForEach(Expression <Func <TData, IEnumerable> > collection)
        {
            var newStep = new WorkflowStep <Foreach>();

            Expression <Func <Foreach, IEnumerable> > inputExpr = (x => x.Collection);

            newStep.Inputs.Add(new MemberMapParameter(collection, inputExpr));

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, Foreach>(WorkflowBuilder, newStep);

            Step.Outcomes.Add(new ValueOutcome {
                NextStep = newStep.Id
            });

            return(stepBuilder);
        }
예제 #20
0
        public IStepBuilder <TData, TStep> Then <TStep>(Action <IStepBuilder <TData, TStep> > stepSetup = null)
            where TStep : IStepBody
        {
            WorkflowStep <TStep> step = new WorkflowStep <TStep>();

            WorkflowBuilder.AddStep(step);
            var stepBuilder = new StepBuilder <TData, TStep>(WorkflowBuilder, step);

            if (stepSetup != null)
            {
                stepSetup.Invoke(stepBuilder);
            }

            step.Name        = step.Name ?? typeof(TStep).Name;
            Outcome.NextStep = step.Id;

            return(stepBuilder);
        }
예제 #21
0
        public IStepBuilder <TData, TStep> Then <TStep>(Action <IStepBuilder <TData, TStep> > stepSetup = null)
            where TStep : IStepBody
        {
            WorkflowStep <TStep> newStep = new WorkflowStep <TStep>();

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, TStep>(WorkflowBuilder, newStep);

            if (stepSetup != null)
            {
                stepSetup.Invoke(stepBuilder);
            }

            newStep.Name = newStep.Name ?? typeof(TStep).Name;
            Step.Outcomes.Add(new ValueOutcome {
                NextStep = newStep.Id
            });

            return(stepBuilder);
        }
예제 #22
0
        public IStepBuilder <TData, WaitFor> WaitFor(string eventName, Expression <Func <TData, IStepExecutionContext, string> > eventKey, Expression <Func <TData, DateTime> > effectiveDate = null)
        {
            var newStep = new WorkflowStep <WaitFor>();

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, WaitFor>(WorkflowBuilder, newStep);

            stepBuilder.Input((step) => step.EventName, (data) => eventName);
            stepBuilder.Input((step) => step.EventKey, eventKey);

            if (effectiveDate != null)
            {
                stepBuilder.Input((step) => step.EffectiveDate, effectiveDate);
            }

            Step.Outcomes.Add(new StepOutcome()
            {
                NextStep = newStep.Id
            });
            return(stepBuilder);
        }
예제 #23
0
        public IStepBuilder <TData, WaitFor> WaitFor(string eventName, Expression <Func <TData, string> > eventKey, Expression <Func <TData, DateTime> > effectiveDate = null, Expression <Func <TData, bool> > cancelCondition = null)
        {
            var newStep = new WorkflowStep <WaitFor>();

            newStep.CancelCondition = cancelCondition;

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, WaitFor>(WorkflowBuilder, newStep);

            stepBuilder.Input((step) => step.EventName, (data) => eventName);
            stepBuilder.Input((step) => step.EventKey, eventKey);

            if (effectiveDate != null)
            {
                stepBuilder.Input((step) => step.EffectiveDate, effectiveDate);
            }

            Step.Outcomes.Add(new ValueOutcome {
                NextStep = newStep.Id
            });
            return(stepBuilder);
        }
예제 #24
0
        public IStepBuilder <TData, Delay> Delay(Expression <Func <TData, TimeSpan> > period)
        {
            var newStep = new WorkflowStep <Delay>();

            Expression <Func <Delay, TimeSpan> > inputExpr = (x => x.Period);

            var mapping = new DataMapping()
            {
                Source = period,
                Target = inputExpr
            };

            newStep.Inputs.Add(mapping);

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, Delay>(WorkflowBuilder, newStep);

            Step.Outcomes.Add(new StepOutcome()
            {
                NextStep = newStep.Id
            });

            return(stepBuilder);
        }
예제 #25
0
        public IContainerStepBuilder <TData, If, If> If(Expression <Func <TData, bool> > condition)
        {
            var newStep = new WorkflowStep <If>();

            Expression <Func <If, bool> > inputExpr = (x => x.ConditionResult);

            var mapping = new DataMapping()
            {
                Source = condition,
                Target = inputExpr
            };

            newStep.Inputs.Add(mapping);

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, If>(WorkflowBuilder, newStep);

            Step.Outcomes.Add(new StepOutcome()
            {
                NextStep = newStep.Id
            });

            return(stepBuilder);
        }
예제 #26
0
        public IContainerStepBuilder <TData, Foreach, Foreach> ForEach(Expression <Func <TData, IEnumerable> > collection)
        {
            var newStep = new WorkflowStep <Foreach>();

            Expression <Func <Foreach, IEnumerable> > inputExpr = (x => x.Collection);

            var mapping = new DataMapping()
            {
                Source = collection,
                Target = inputExpr
            };

            newStep.Inputs.Add(mapping);

            WorkflowBuilder.AddStep(newStep);
            var stepBuilder = new StepBuilder <TData, Foreach>(WorkflowBuilder, newStep);

            Step.Outcomes.Add(new StepOutcome()
            {
                NextStep = newStep.Id
            });

            return(stepBuilder);
        }