Esempio n. 1
0
            resultAction = new ResultActionConfig()
            {
                Name  = Constants.Events.ExpiredEventName,
                Label = "Expiration",
                Delay = delay,
                Kind  = Constants.PushActionName
            };

            rule = new ResultRuleConfig()
            {
            };
            rule.Actions.Add(resultAction);
            resultActions.Add(("in", rule));

            #endregion

            #region action to add to 'On Exit State' (remove expiration event)

            resultAction = new ResultActionConfig()
            {
                Name  = Constants.Events.CancelReminderAction,
                Label = "Cancel Expiration",
                Kind  = Constants.PushActionName,
            };

            rule = new ResultRuleConfig()
            {
                WhenRuleText = $"@IncomingEvent.Name != '{Constants.Events.ExpiredEventName}'",
                WhenRule     = (ctx) => ctx.IncomingEvent.Name != Constants.Events.ExpiredEventName,
            };
            rule.Actions.Add(resultAction);
            resultActions.Add(("out", rule));

            #endregion
        }
        public static TransitionConfig AddAction(this TransitionConfig self, Func <RunContext, bool> func, params ResultActionConfig[] actions)
        {
            var r = self.RuleActions.FirstOrDefault(c => c.WhenRule == func);

            if (r == null)
            {
                r = new ResultRuleConfig()
                {
                    WhenRule = func,
                };
                self.RuleActions.Add(r);
            }
            r.Actions.AddRange(actions);
            return(self);
        }
        public static IncomingEventConfig AddAction(this IncomingEventConfig self, Func <RunContext, bool> func, ResultActionConfig act)
        {
            var r = self.Rules.FirstOrDefault(c => c.WhenRule == func);

            if (r == null)
            {
                r = new ResultRuleConfig()
                {
                    WhenRule = func,
                };
                self.Rules.Add(r);
            }
            r.Actions.Add(act);
            return(self);
        }
Esempio n. 4
0
        /// <summary>
        /// execute2 :
        ///     (WHEN rule_conditions)?
        ///     (WAITING delay BEFORE)?
        ///     execute3+
        ///     ;
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override object VisitExecute2([NotNull] WorkflowParser.Execute2Context context)
        {
            ResultRuleConfig rule = new ResultRuleConfig()
            {
            };

            int delay = 0;

            if (context.WAITING() != null)
            {
                delay = (int)VisitDelay(context.delay());
            }


            if (context.WHEN() != null)
            {
                var condition = context.rule_conditions();
                rule.WhenRuleText     = condition.GetText();
                rule.WhenRulePosition = new RuleSpan()
                {
                    StartLine   = condition.Start.Line,
                    StartColumn = condition.Start.Column,
                    StartIndex  = condition.Start.StartIndex,

                    StopLine   = condition.Stop.Line,
                    StopColumn = condition.Stop.Column,
                    StopIndex  = condition.Stop.StopIndex,
                };

                var compilation = ((Func <RunContext, bool>, string))Compile((ExpressionModel)VisitRule_conditions(condition));
                rule.WhenRule     = compilation.Item1;
                rule.WhenRuleCode = compilation.Item2;
            }

            var a = context.execute3();

            foreach (var item1 in a)
            {
                var _a = (List <ResultActionConfig>)VisitExecute3(item1);
                foreach (var item2 in _a)
                {
                    item2.Delay = delay;
                    rule.Actions.Add(item2);
                }
            }

            return(rule);
        }