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)); }
public Tuple <ActionResult, Block> innerRun(Block block, string buttonId, int modelId, NameValueCollection fc, int deleteId, Dictionary <string, object> blockDependencies = null, Dictionary <string, object> mergeVars = null) { // __CORE__ // __Result[uicName]__ // __ModelId__ // __Model.{TableName}.{columnName} // __TableName__ // init action if (!_results.OutputData.ContainsKey("__CORE__")) { _results.OutputData.Add("__CORE__", _CORE); } if (!string.IsNullOrWhiteSpace(block.ModelName)) { if (!_results.OutputData.ContainsKey("__TableName__")) { _results.OutputData.Add("__TableName__", block.ModelName); } else { _results.OutputData["__TableName__"] = block.ModelName; } } if (modelId >= 0) { if (!_results.OutputData.ContainsKey("__ModelId__")) { _results.OutputData.Add("__ModelId__", modelId); } else { _results.OutputData["__ModelId__"] = modelId; } } if (deleteId >= 0) { if (!_results.OutputData.ContainsKey("__DeleteId__")) { _results.OutputData.Add("__DeleteId__", deleteId); } else { _results.OutputData["__DeleteId__"] = deleteId; } } if (blockDependencies != null) { foreach (KeyValuePair <string, object> dependency in blockDependencies) { _results.OutputData.Add("__Dependency_" + dependency.Key + "__", dependency.Value); } } if (mergeVars != null) { foreach (KeyValuePair <string, object> var in mergeVars) { _results.OutputData[var.Key] = var.Value; } } _results.OutputData.Add("__Button__", buttonId); // get actionRule ActionRule actionRule = null; ActionRule nextRule = GetActionRule(block, _results, buttonId); if (nextRule == null) { if (buttonId == "INIT") { _results.Message.Errors.Clear(); } return(new Tuple <ActionResult, Block>(_results, block)); } // get inputs if (fc != null) { string[] keys = fc.AllKeys; foreach (string key in keys) { _results.OutputData.Add(key, fc[key]); } // map inputs foreach (ResourceMappingPair pair in block.ResourceMappingPairs) { if (pair.relationType == "uiItem__attributeItem") { if (fc.AllKeys.Contains(pair.SourceComponentName)) { _results.OutputData.Add($"__Model.{pair.TargetTableName}.{pair.TargetColumnName}", fc[pair.SourceComponentName]); } for (int panelIndex = 1; fc.AllKeys.Contains($"panelCopy{panelIndex}Marker"); panelIndex++) { if (fc.AllKeys.Contains(pair.SourceComponentName)) { _results.OutputData.Add($"__Model.panelCopy{panelIndex}.{pair.TargetTableName}.{pair.TargetColumnName}", fc[$"panelCopy{panelIndex}_{pair.SourceComponentName}"]); } } } } } List <ActionRule> prevActionRules = new List <ActionRule>(); // run all auto Action while (nextRule != null) { actionRule = nextRule; prevActionRules.Add(nextRule); try { actionRule.Run(_results); } catch (Exception ex) { _results.Message.Errors.Add(ex.Message); OmniusApplicationException.Log(ex, OmniusLogSource.Tapestry, _CORE.Application, _CORE.User); return(new Tuple <ActionResult, Block>(_results, actionRule.TargetBlock)); } if (_results.Type == MessageType.Error) { return(new Tuple <ActionResult, Block>(_results, actionRule.TargetBlock)); //return new Tuple<ActionResult, Block>(_results, Rollback(prevActionRules).SourceBlock); } nextRule = GetActionRule(actionRule.TargetBlock, _results); } Block resultBlock = actionRule.TargetBlock; // if stops on virtual block //if (actionRule.TargetBlock.IsVirtual) //{ // actionRule = Rollback(prevActionRules); // resultBlock = actionRule.SourceBlock; //} // target Block return(new Tuple <ActionResult, Block>(_results, resultBlock)); }