예제 #1
0
 ObservableCollection <IDev2TOFn> ToObservableCollection()
 {
     if (!string.IsNullOrWhiteSpace(ExpressionText))
     {
         var val       = new StringBuilder(ExpressionText);
         var decisions = DataListUtil.ConvertFromJsonToModel <Dev2DecisionStack>(val);
         if (decisions?.TheStack != null)
         {
             TrueArmText  = decisions.TrueArmText;
             FalseArmText = decisions.FalseArmText;
             DisplayText  = decisions.DisplayText;
             RequireAllDecisionsToBeTrue = decisions.Mode == Dev2DecisionMode.AND;
             return(new ObservableCollection <IDev2TOFn>(decisions.TheStack.Select((a, i) => new DecisionTO(a, i + 1, UpdateDecisionDisplayName, DeleteRow))));
         }
     }
     return(new ObservableCollection <IDev2TOFn> {
         new DecisionTO()
     });
 }
예제 #2
0
        // Travis.Frisinger - 28.01.2013 : Amended for Debug
        public override List <DebugItem> GetDebugOutputs(IExecutionEnvironment dataList, int update)
        {
            if (_debugOutputs != null && _debugOutputs.Count > 0)
            {
                return(_debugOutputs);
            }
            var       result       = new List <DebugItem>();
            string    resultString = _theResult.ToString();
            DebugItem itemToAdd    = new DebugItem();
            var       val          = new StringBuilder(Dev2DecisionStack.ExtractModelFromWorkflowPersistedData(ExpressionText));

            try
            {
                Dev2DecisionStack dds = DataListUtil.ConvertFromJsonToModel <Dev2DecisionStack>(val);

                if (_theResult.ToString() == "True")
                {
                    resultString = dds.TrueArmText;
                }
                else if (_theResult.ToString() == "False")
                {
                    resultString = dds.FalseArmText;
                }

                itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                result.Add(itemToAdd);
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch (Exception)
            // ReSharper restore EmptyGeneralCatchClause
            {
                itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                result.Add(itemToAdd);
            }

            return(result);
        }
예제 #3
0
        // Travis.Frisinger - 28.01.2013 : Amended for Debug
        public override List <DebugItem> GetDebugInputs(IExecutionEnvironment env, int update)
        {
            if (_debugInputs != null && _debugInputs.Count > 0)
            {
                return(_debugInputs);
            }
            List <IDebugItem> result = new List <IDebugItem>();
            var allErrors            = new ErrorResultTO();

            var val = new StringBuilder(Dev2DecisionStack.ExtractModelFromWorkflowPersistedData(ExpressionText));

            try
            {
                Dev2DecisionStack dds = DataListUtil.ConvertFromJsonToModel <Dev2DecisionStack>(val);
                ErrorResultTO     error;
                string            userModel = dds.GenerateUserFriendlyModel(env, dds.Mode, out error);
                allErrors.MergeErrors(error);

                foreach (Dev2Decision dev2Decision in dds.TheStack)
                {
                    AddInputDebugItemResultsAfterEvaluate(result, ref userModel, env, dds.Mode, dev2Decision.Col1, out error);
                    allErrors.MergeErrors(error);
                    AddInputDebugItemResultsAfterEvaluate(result, ref userModel, env, dds.Mode, dev2Decision.Col2, out error);
                    allErrors.MergeErrors(error);
                    AddInputDebugItemResultsAfterEvaluate(result, ref userModel, env, dds.Mode, dev2Decision.Col3, out error);
                    allErrors.MergeErrors(error);
                }

                var itemToAdd = new DebugItem();

                userModel = userModel.Replace("OR", " OR\r\n")
                            .Replace("AND", " AND\r\n")
                            .Replace("\r\n ", "\r\n")
                            .Replace("\r\n\r\n", "\r\n")
                            .Replace("  ", " ");

                AddDebugItem(new DebugItemStaticDataParams(userModel, "Statement"), itemToAdd);
                result.Add(itemToAdd);

                itemToAdd = new DebugItem();
                AddDebugItem(new DebugItemStaticDataParams(dds.Mode == Dev2DecisionMode.AND ? "YES" : "NO", "Require All decisions to be True"), itemToAdd);
                result.Add(itemToAdd);
            }
            catch (JsonSerializationException)
            {
                Dev2Switch ds = new Dev2Switch {
                    SwitchVariable = val.ToString()
                };
                DebugItem itemToAdd = new DebugItem();

                var a           = env.Eval(ds.SwitchVariable, 0);
                var debugResult = new DebugItemWarewolfAtomResult(ExecutionEnvironment.WarewolfEvalResultToString(a), "", ds.SwitchVariable, "", "Switch on", "", "=");
                itemToAdd.AddRange(debugResult.GetDebugItemResult());
                result.Add(itemToAdd);
            }
            catch (Exception e)
            {
                allErrors.AddError(e.Message);
            }
            finally
            {
                if (allErrors.HasErrors())
                {
                    var serviceName = GetType().Name;
                    DisplayAndWriteError(serviceName, allErrors);
                }
            }

            return(result.Select(a => a as DebugItem).ToList());
        }
예제 #4
0
        Dev2DecisionStack EvaluateRegion(string payload, Guid dlId, int update)
        {
            var env = Dev2DataListDecisionHandler._environments[dlId];

            if (payload.StartsWith("{\"TheStack\":[{") || payload.StartsWith("{'TheStack':[{"))
            {
                var dds = DataListUtil.ConvertFromJsonToModel <Dev2DecisionStack>(new StringBuilder(payload));

                if (dds.TheStack != null)
                {
                    var effectedCols = new[] { false, false, false };
                    //Find decisions that mention record sets with starred indexes
                    var invalidDecisions = new List <Dev2Decision>();
                    for (int i = 0; i < dds.TotalDecisions; i++)
                    {
                        var dd = dds.GetModelItem(i);

                        if (dd.Col1 != null && DataListUtil.GetRecordsetIndexType(dd.Col1) == enRecordsetIndexType.Star)
                        {
                            invalidDecisions.Add(dd);
                            effectedCols[0] = true;
                        }
                        else
                        {
                            var warewolfEvalResult = GetWarewolfEvalResult(env, dd.Col1, update);
                            dd.Col1 = ExecutionEnvironment.WarewolfEvalResultToString(warewolfEvalResult);
                        }

                        if (dd.Col2 != null && DataListUtil.GetRecordsetIndexType(dd.Col2) == enRecordsetIndexType.Star)
                        {
                            if (!effectedCols[0])
                            {
                                invalidDecisions.Add(dd);
                            }
                            effectedCols[1] = true;
                        }
                        else
                        {
                            var warewolfEvalResult = GetWarewolfEvalResult(env, dd.Col2, update);
                            dd.Col2 = ExecutionEnvironment.WarewolfEvalResultToString(warewolfEvalResult);
                        }

                        if (dd.Col3 != null && DataListUtil.GetRecordsetIndexType(dd.Col3) == enRecordsetIndexType.Star)
                        {
                            if (!effectedCols[0] && !effectedCols[1])
                            {
                                invalidDecisions.Add(dd);
                            }
                            effectedCols[2] = true;
                        }
                        else
                        {
                            var warewolfEvalResult = GetWarewolfEvalResult(env, dd.Col3, update);
                            dd.Col3 = ExecutionEnvironment.WarewolfEvalResultToString(warewolfEvalResult);
                        }
                    }
                    //Remove those record sets and replace them with a new decision for each resolved value
                    foreach (Dev2Decision decision in invalidDecisions)
                    {
                        dds = ResolveAllRecords(env, dds, decision, effectedCols, out ErrorResultTO errors, update);
                    }
                }

                return(dds);
            }
            return(null);
        }