public static Dictionary <string, object> getInputVariables(this IActionRule_Action actionRule_action, Dictionary <string, object> tempVars)
        {
            KeyValueString mapping = new KeyValueString(actionRule_action.InputVariablesMapping);

            mapping.Resolve(tempVars);
            mapping.result.AddRange(tempVars);
            return(mapping.result);
        }
Пример #2
0
        public override ActionResult run(Dictionary <string, object> vars, IActionRule_Action actionRule_action)
        {
            ActionResult results = new ActionResult();

            foreach (Action action in _sequence)
            {
                results.Join(action.run(vars, actionRule_action));
            }

            return(results);
        }
Пример #3
0
        public virtual ActionResult run(Dictionary <string, object> vars, IActionRule_Action actionRule_action)
        {
            Dictionary <string, object> outputVars = new Dictionary <string, object>();
            MessageType outputStatus = MessageType.Success;
            var         invertedVar  = new Dictionary <string, object>();
            Message     message      = new Message(COREobject.i);

            try
            {
                InnerRun(vars, outputVars, invertedVar, message);
            }
            catch (Exception ex)
            {
                outputStatus = MessageType.Error;
                message.Errors.Add(ex.Message);
                Logger.Log.Error(ex);
                COREobject core = (COREobject)vars["__CORE__"];
                OmniusApplicationException.Log(ex, OmniusLogSource.Tapestry, core.Application, actionRule_action.ActionRule.SourceBlock, actionRule_action, vars, core.User);
            }

            return(new ActionResult(outputStatus, outputVars, invertedVar, message));
        }
Пример #4
0
 public static void Log(Exception innerException, OmniusLogSource source = OmniusLogSource.none, Application application = null, Block block = null, IActionRule_Action actionRule = null, Dictionary <string, object> vars = null, User user = null)
 {
     new OmniusApplicationException(innerException)
     {
         Application      = application,
         Block            = block,
         ActionRuleAction = actionRule,
         Vars             = vars,
         User             = user,
         SourceModule     = source
     }.Save();
 }
Пример #5
0
        public static ActionResult RunForeach(Dictionary <string, object> vars, IActionRule_Action actionRule_action)
        {
            ActionResult results = new ActionResult();

            if (((IEnumerable <object>)vars["DataSource"]).Count() > 0)
            {
                COREobject core    = COREobject.i;
                DBEntities context = core.Context;

                //List<ActionRule_Action> actions = context.ActionRule_Action.Where(a => a.VirtualParentId == actionRule_action.VirtualItemId).OrderBy(a => a.Order).ToList();

                var startRule = context.ActionRules.Include("ActionRule_Actions").FirstOrDefault(a => a.ActionRule_Actions.Any(aa => aa.IsForeachStart == true && aa.VirtualParentId == actionRule_action.VirtualItemId));
                if (startRule == null)
                {
                    return(results);
                }

                foreach (object item in (IEnumerable <object>)vars["DataSource"])
                {
                    vars[vars.ContainsKey("ItemName") ? (string)vars["ItemName"] : "__item__"] = item;
                    results.OutputData = vars;

                    var nextRule = startRule;
                    while (nextRule != null)
                    {
                        foreach (var nextAction in nextRule.ActionRule_Actions.OrderBy(a => a.Order))
                        {
                            var remapedParams = nextAction.getInputVariables(results.OutputData);

                            ActionResult result = null;
                            if (nextAction.ActionId == -1 && nextAction.VirtualAction == "foreach")   // foreach
                            {
                                result = Action.RunForeach(remapedParams, nextAction);
                                if (result.Type != MessageType.Error)
                                {
                                    result.OutputData["__item__"] = item;
                                }
                            }
                            else // Action
                            {
                                Action action = All[nextAction.ActionId];
                                result = action.run(remapedParams, nextAction);
                            }

                            if (result.Type == MessageType.Error)
                            {
                                foreach (IActionRule_Action reverseActionMap in nextRule.ActionRule_Actions.Where(a => a.Order < nextAction.Order).OrderByDescending(a => a.Order))
                                {
                                    var reverseAction = Action.All[reverseActionMap.ActionId];
                                    reverseAction.ReverseRun(results.ReverseInputData.Last());
                                    results.ReverseInputData.Remove(results.ReverseInputData.Last());
                                }

                                // do not continue
                                results.Join(result);
                                return(results);
                            }

                            nextAction.RemapOutputVariables(result.OutputData);
                            // zpracování výstupů
                            results.Join(result);
                            vars = results.OutputData;
                        }

                        nextRule = Tapestry.GetActionRule(core, nextRule.TargetBlock, results);
                    }
                }
            }
            return(results);
        }
Пример #6
0
        public static ActionResult RunAction(int id, Dictionary <string, object> vars, IActionRule_Action actionRule_action)
        {
            Action action = All[id];

            return(action.run(vars, actionRule_action));
        }
        public static void RemapOutputVariables(this IActionRule_Action actionRule_action, Dictionary <string, object> actionVars)
        {
            KeyValueString mapping = new KeyValueString(actionRule_action.OutputVariablesMapping);

            mapping.ChangeKeysInInput(actionVars);
        }