public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { StringBuilder result = new StringBuilder(""); int cnt = 0; errors = new ErrorResultTO(); // build the output for decisions foreach(Dev2Decision dd in TheStack) { result.Append(dd.GenerateUserFriendlyModel(env, Mode, out errors)); // append mode if not at end if((cnt + 1) < TheStack.Count) { result.Append(Mode); } result.AppendLine(); cnt++; } // append the arms result.Append("THEN " + TrueArmText); result.AppendLine(); result.Append("ELSE " + FalseArmText); return result.ToString(); }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { StringBuilder result = new StringBuilder(""); int cnt = 0; errors = new ErrorResultTO(); // build the output for decisions foreach (Dev2Decision dd in TheStack) { result.Append(dd.GenerateUserFriendlyModel(env, Mode, out errors)); // append mode if not at end if ((cnt + 1) < TheStack.Count) { result.Append(Mode); } result.AppendLine(); cnt++; } // append the arms result.Append("THEN " + TrueArmText); result.AppendLine(); result.Append("ELSE " + FalseArmText); return(result.ToString()); }
private static void AddAllColumns(Dev2DecisionMode mode, ErrorResultTO errors, ErrorResultTO allErrors, string fn, StringBuilder expandStarredIndices, IList <string> allCol1Values, IList <string> allCol2Values) { for (var i = 0; i < Math.Max(allCol1Values.Count, allCol2Values.Count); i++) { if (i > allCol1Values.Count) { allCol1Values.Add(null); } if (i > allCol2Values.Count) { allCol2Values.Add(null); } try { expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + allCol2Values[i]); } catch (IndexOutOfRangeException) { errors.AddError(ErrorResource.RecordsetsHaveDifferntSizes); allErrors.MergeErrors(errors); } } }
public ToolLabelGenerator(enDecisionType evaluationFn, int populatedColumnCount, string col1, string col2, string col3, IExecutionEnvironment env, Dev2DecisionMode mode) { this._evaluationFn = evaluationFn; this._populatedColumnCount = populatedColumnCount; this._col1 = col1; this._col2 = col2; this._col3 = col3; this._env = env; this._mode = mode; }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); return "For " + CaseValue; }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); ErrorResultTO allErrors = new ErrorResultTO(); string fn = DecisionDisplayHelper.GetDisplayValue(EvaluationFn); if (PopulatedColumnCount == 0) { return("If " + fn + " "); } if (PopulatedColumnCount == 1) { if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star) { var allValues = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); allErrors.MergeErrors(errors); StringBuilder expandStarredIndex = new StringBuilder(); expandStarredIndex.Append(allValues[0] + " " + fn); allValues.RemoveAt(0); foreach (var value in allValues) { expandStarredIndex.Append(" " + mode + " " + value + " " + fn); } errors = allErrors; return("If " + expandStarredIndex); } errors = allErrors; return("If " + Col1 + " " + fn + " "); } if (PopulatedColumnCount == 2) { StringBuilder expandStarredIndices = new StringBuilder(); if (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star) { var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0); allErrors.MergeErrors(errors); expandStarredIndices.Append(Col1 + " " + fn + " " + allCol2Values[0]); allCol2Values.RemoveAt(0); foreach (var value in allCol2Values) { expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + value); } errors = allErrors; return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + Col2); allCol1Values.RemoveAt(0); foreach (var value in allCol1Values) { expandStarredIndices.Append(" " + mode + " " + value + " " + fn + " " + Col2); } errors = allErrors; return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star || DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); allErrors.MergeErrors(errors); var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0); allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0]); allCol1Values.RemoveAt(0); allCol2Values.RemoveAt(0); for (var i = 0; i < Math.Max(allCol1Values.Count, allCol2Values.Count); i++) { if (i > allCol1Values.Count) { allCol1Values.Add(null); } if (i > allCol2Values.Count) { allCol2Values.Add(null); } try { expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + allCol2Values[i]); } catch (IndexOutOfRangeException) { errors.AddError("You appear to have recordsets of differnt sizes"); allErrors.MergeErrors(errors); } } errors = allErrors; return("If " + expandStarredIndices); } errors = allErrors; return("If " + Col1 + " " + fn + " " + Col2 + " "); } if (PopulatedColumnCount == 3) { var expandStarredIndices = ResolveStarredIndices(env, mode.ToString(), out errors); allErrors.MergeErrors(errors); if (!string.IsNullOrEmpty(expandStarredIndices)) { errors = allErrors; return(expandStarredIndices); } errors = allErrors; return("If " + Col1 + " " + fn + " " + Col2 + " and " + Col3); } errors = allErrors; return("<< Internal Error Generating Decision Model: Populated Column Count Cannot Exeed 3 >>"); }
public string GenerateToolLabel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { return(new ToolLabelGenerator(EvaluationFn, PopulatedColumnCount, Col1, Col2, Col3, env, mode).Generate(out errors)); }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); var allErrors = new ErrorResultTO(); var fn = DecisionDisplayHelper.GetDisplayValue(EvaluationFn); if (PopulatedColumnCount == 0) { return("If " + fn + " "); } if (PopulatedColumnCount == 1) { if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star) { var allValues = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); allErrors.MergeErrors(errors); var expandStarredIndex = new StringBuilder(); expandStarredIndex.Append(allValues[0] + " " + fn); allValues.RemoveAt(0); foreach (var value in allValues) { expandStarredIndex.Append(" " + mode + " " + value + " " + fn); } errors = allErrors; return("If " + expandStarredIndex); } errors = allErrors; return("If " + Col1 + " " + fn + " "); } if (PopulatedColumnCount == 2) { var expandStarredIndices = new StringBuilder(); if (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star) { var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0); allErrors.MergeErrors(errors); expandStarredIndices.Append(Col1 + " " + fn + " " + allCol2Values[0]); allCol2Values.RemoveAt(0); foreach (var value in allCol2Values) { expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + value); } errors = allErrors; return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + Col2); allCol1Values.RemoveAt(0); foreach (var value in allCol1Values) { expandStarredIndices.Append(" " + mode + " " + value + " " + fn + " " + Col2); } errors = allErrors; return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star || DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); allErrors.MergeErrors(errors); var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0); allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0]); allCol1Values.RemoveAt(0); if (allCol2Values.Count > 0) { allCol2Values.RemoveAt(0); } AddAllColumns(mode, errors, allErrors, fn, expandStarredIndices, allCol1Values, allCol2Values); errors = allErrors; return("If " + expandStarredIndices); } errors = allErrors; return("If " + Col1 + " " + fn + " " + Col2 + " "); } if (PopulatedColumnCount == 3) { var expandStarredIndices = ResolveStarredIndices(env, mode.ToString(), out errors); allErrors.MergeErrors(errors); if (!string.IsNullOrEmpty(expandStarredIndices)) { errors = allErrors; return(expandStarredIndices); } errors = allErrors; return("If " + Col1 + " " + fn + " " + Col2 + " and " + Col3); } errors = allErrors; return("<< Internal Error Generating Decision Model: Populated Column Count Cannot Exceed 3 >>"); }
public string GenerateUserFriendlyModel(Guid dlid, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); return("on " + SwitchVariable); }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); ErrorResultTO allErrors = new ErrorResultTO(); string fn = DecisionDisplayHelper.GetDisplayValue(EvaluationFn); if(PopulatedColumnCount == 0) { return "If " + fn + " "; } if(PopulatedColumnCount == 1) { if(DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star) { var allValues = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors); allErrors.MergeErrors(errors); StringBuilder expandStarredIndex = new StringBuilder(); expandStarredIndex.Append(allValues[0] + " " + fn); allValues.RemoveAt(0); foreach(var value in allValues) { expandStarredIndex.Append(" " + mode + " " + value + " " + fn); } errors = allErrors; return "If " + expandStarredIndex; } errors = allErrors; return "If " + Col1 + " " + fn + " "; } if(PopulatedColumnCount == 2) { StringBuilder expandStarredIndices = new StringBuilder(); if(DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star) { var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors); allErrors.MergeErrors(errors); expandStarredIndices.Append(Col1 + " " + fn + " " + allCol2Values[0]); allCol2Values.RemoveAt(0); foreach(var value in allCol2Values) { expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + value); } errors = allErrors; return "If " + expandStarredIndices; } if(DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors); allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + Col2); allCol1Values.RemoveAt(0); foreach(var value in allCol1Values) { expandStarredIndices.Append(" " + mode + " " + value + " " + fn + " " + Col2); } errors = allErrors; return "If " + expandStarredIndices; } if((DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star) || (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star)) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors); allErrors.MergeErrors(errors); var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors); allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0]); allCol1Values.RemoveAt(0); allCol2Values.RemoveAt(0); for(var i = 0; i < Math.Max(allCol1Values.Count, allCol2Values.Count); i++) { if(i > allCol1Values.Count) { allCol1Values.Add(null); } if(i > allCol2Values.Count) { allCol2Values.Add(null); } try { expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + allCol2Values[i]); } catch(IndexOutOfRangeException) { errors.AddError("You appear to have recordsets of differnt sizes"); allErrors.MergeErrors(errors); } } errors = allErrors; return "If " + expandStarredIndices; } errors = allErrors; return "If " + Col1 + " " + fn + " " + Col2 + " "; } if(PopulatedColumnCount == 3) { var expandStarredIndices = ResolveStarredIndices(env, mode.ToString(), out errors); allErrors.MergeErrors(errors); if(!string.IsNullOrEmpty(expandStarredIndices)) { errors = allErrors; return expandStarredIndices; } errors = allErrors; return "If " + Col1 + " " + fn + " " + Col2 + " and " + Col3; } errors = allErrors; return "<< Internal Error Generating Decision Model: Populated Column Count Cannot Exeed 3 >>"; }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); return("For " + CaseValue); }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); return("on " + SwitchVariable); }
private string EvaluateExpressiomToStringValue(string expression, Dev2DecisionMode mode, IBinaryDataList dataList) { string result = string.Empty; IDataListCompiler c = DataListFactory.CreateDataListCompiler(); ErrorResultTO errors; var dlEntry = c.Evaluate(dataList.UID, enActionType.User, expression, false, out errors); if (dlEntry != null && dlEntry.IsRecordset) { if (DataListUtil.GetRecordsetIndexType(expression) == enRecordsetIndexType.Numeric) { int index; if (int.TryParse(DataListUtil.ExtractIndexRegionFromRecordset(expression), out index)) { string error; IList <IBinaryDataListItem> listOfCols = dlEntry.FetchRecordAt(index, out error); if (listOfCols != null) { foreach (IBinaryDataListItem binaryDataListItem in listOfCols) { result = binaryDataListItem.TheValue; } } } } else { if (DataListUtil.GetRecordsetIndexType(expression) == enRecordsetIndexType.Star) { IDev2IteratorCollection colItr = Dev2ValueObjectFactory.CreateIteratorCollection(); IBinaryDataListEntry entry = c.Evaluate(dataList.UID, enActionType.User, expression, false, out errors); IDev2DataListEvaluateIterator col1Iterator = Dev2ValueObjectFactory.CreateEvaluateIterator(entry); colItr.AddIterator(col1Iterator); bool firstTime = true; while (colItr.HasMoreData()) { if (firstTime) { result = colItr.FetchNextRow(col1Iterator).TheValue; firstTime = false; } else { result += " " + mode + " " + colItr.FetchNextRow(col1Iterator).TheValue; } } } else { result = string.Empty; } } } else { if (dlEntry != null) { var scalarItem = dlEntry.FetchScalar(); result = scalarItem.TheValue; } } return(result); }
void AddInputDebugItemResultsAfterEvaluate(List <IDebugItem> result, ref string userModel, IBinaryDataList dataList, Dev2DecisionMode decisionMode, string expression, out ErrorResultTO error, DebugItem parent = null) { error = new ErrorResultTO(); if (expression != null && DataListUtil.IsEvaluated(expression)) { DebugOutputBase debugResult; if (error.HasErrors()) { debugResult = new DebugItemStaticDataParams("", expression, ""); } else { var expressiomToStringValue = EvaluateExpressiomToStringValue(expression, decisionMode, dataList); userModel = userModel.Replace(expression, expressiomToStringValue); ErrorResultTO errors; IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); IBinaryDataListEntry expressionsEntry = compiler.Evaluate(dataList.UID, enActionType.User, expression, false, out errors); debugResult = new DebugItemVariableParams(expression, "", expressionsEntry, dataList.UID); } var itemResults = debugResult.GetDebugItemResult(); var allReadyAdded = new List <IDebugItemResult>(); itemResults.ForEach(a => { var found = result.SelectMany(r => r.FetchResultsList()) .SingleOrDefault(r => r.Variable.Equals(a.Variable)); if (found != null) { allReadyAdded.Add(a); } }); allReadyAdded.ForEach(i => itemResults.Remove(i)); if (parent == null) { result.Add(new DebugItem(itemResults)); } else { parent.AddRange(itemResults); } } }
void AddInputDebugItemResultsAfterEvaluate(List <IDebugItem> result, ref string userModel, IExecutionEnvironment env, Dev2DecisionMode decisionMode, string expression, out ErrorResultTO error, DebugItem parent = null) { error = new ErrorResultTO(); if (expression != null && DataListUtil.IsEvaluated(expression)) { DebugOutputBase debugResult; if (error.HasErrors()) { debugResult = new DebugItemStaticDataParams("", expression, ""); } else { var expressiomToStringValue = ExecutionEnvironment.WarewolfEvalResultToString(env.Eval(expression, 0));// EvaluateExpressiomToStringValue(expression, decisionMode, dataList); userModel = userModel.Replace(expression, expressiomToStringValue); debugResult = new DebugItemWarewolfAtomResult(expressiomToStringValue, expression, ""); } var itemResults = debugResult.GetDebugItemResult(); var allReadyAdded = new List <IDebugItemResult>(); itemResults.ForEach(a => { var found = result.SelectMany(r => r.FetchResultsList()) .SingleOrDefault(r => r.Variable.Equals(a.Variable)); if (found != null) { allReadyAdded.Add(a); } }); allReadyAdded.ForEach(i => itemResults.Remove(i)); if (parent == null) { result.Add(new DebugItem(itemResults)); } else { parent.AddRange(itemResults); } } }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); return "on " + SwitchVariable; }
public string GenerateUserFriendlyModel(Guid dlid, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); return("For " + CaseValue); }