Exemple #1
0
        protected List <string> RetrieveAllRecordSetFieldValues(IExecutionEnvironment environment, string recordSetName, string fieldToRetrieve, out string error)
        {
            var retVals = environment.EvalAsListOfStrings("[[" + recordSetName + "(*)." + fieldToRetrieve + "]]", 0);

            error = "";
            var retrieveAllRecordSetFieldValues = (List <string>)retVals;

            return(retrieveAllRecordSetFieldValues);
        }
Exemple #2
0
        protected List <string> RetrieveAllRecordSetFieldValuesSkipEmpty(IExecutionEnvironment environment, string recordSetName, string fieldToRetrieve, out string error)
        {
            var retVals = environment.EvalAsListOfStrings("[[" + recordSetName + "(*)." + fieldToRetrieve + "]]", 0);

            error = "";
            var retrieveAllRecordSetFieldValues = (List <string>)retVals;

            return(retrieveAllRecordSetFieldValues.Where(s => !string.IsNullOrEmpty(s)).ToList());
        }
Exemple #3
0
        public static IList <string> GetAllPossibleExpressionsForFunctionOperations(string expression, IExecutionEnvironment env, out ErrorResultTO errors, int update)
        {
            IList <string> result = new List <string>();

            errors = new ErrorResultTO();
            try
            {
                result = env.EvalAsListOfStrings(expression, update);
            }
            catch (Exception err)
            {
                errors.AddError(err.Message);
            }

            return(result);
        }
Exemple #4
0
        private IDev2Tokenizer CreateSplitPattern(ref string stringToSplit, IEnumerable <DataSplitDTO> args, IExecutionEnvironment compiler, out ErrorResultTO errors, int update)
        {
            Dev2TokenizerBuilder dtb = new Dev2TokenizerBuilder {
                ToTokenize = stringToSplit, ReverseOrder = ReverseOrder
            };

            errors = new ErrorResultTO();

            foreach (DataSplitDTO t in args)
            {
                t.At = t.At ?? "";
                string entry;

                switch (t.SplitType)
                {
                case "Index":
                    try
                    {
                        entry = compiler.EvalAsListOfStrings(t.At, update).FirstOrDefault();
                        if (entry == null)
                        {
                            throw new Exception("null iterator expression");
                        }
                        string index    = entry;
                        int    indexNum = Convert.ToInt32(index);
                        if (indexNum > 0)
                        {
                            dtb.AddIndexOp(indexNum);
                        }
                    }
                    catch (Exception ex)
                    {
                        errors.AddError(ex.Message);
                    }
                    break;

                case "End":
                    dtb.AddEoFOp();
                    break;

                case "Space":
                    dtb.AddTokenOp(" ", t.Include);
                    break;

                case "Tab":
                    dtb.AddTokenOp("\t", t.Include);
                    break;

                case "New Line":
                    if (stringToSplit.Contains("\r\n"))
                    {
                        dtb.AddTokenOp("\r\n", t.Include);
                    }
                    else if (stringToSplit.Contains("\n"))
                    {
                        dtb.AddTokenOp("\n", t.Include);
                    }
                    else if (stringToSplit.Contains("\r"))
                    {
                        dtb.AddTokenOp("\r", t.Include);
                    }
                    break;

                case "Chars":
                    if (!string.IsNullOrEmpty(t.At))
                    {
                        entry = compiler.EvalAsListOfStrings(t.At, update).FirstOrDefault();
                        if (entry != null && (entry.Contains(@"\r\n") || entry.Contains(@"\n")))
                        {
                            var match = Regex.Match(stringToSplit, @"[\r\n]+");
                            if (match.Success && !SkipBlankRows)
                            {
                                stringToSplit  = Regex.Escape(stringToSplit);
                                dtb.ToTokenize = stringToSplit;
                            }
                        }
                        string escape = t.EscapeChar;
                        if (!String.IsNullOrEmpty(escape))
                        {
                            escape = compiler.EvalAsListOfStrings(t.EscapeChar, update).FirstOrDefault();
                        }
                        dtb.AddTokenOp(entry, t.Include, escape);
                    }
                    break;
                }
                _indexCounter++;
            }
            return(string.IsNullOrEmpty(dtb.ToTokenize) || errors.HasErrors() ? null : dtb.Generate());
        }
Exemple #5
0
        Dev2DecisionStack ResolveAllRecords(IExecutionEnvironment env, Dev2DecisionStack stack, Dev2Decision decision, bool[] effectedCols, out ErrorResultTO errors, int update)
        {
            if (effectedCols == null)
            {
                throw new ArgumentNullException("effectedCols");
            }
            var stackIndex = stack.TheStack.IndexOf(decision);

            stack.TheStack.Remove(decision);
            errors = new ErrorResultTO();
            if (effectedCols[0])
            {
                var data = env.EvalAsListOfStrings(decision.Col1, update);

                var reStackIndex = stackIndex;

                foreach (var item in data)
                {
                    var newDecision = new Dev2Decision {
                        Col1 = item, Col2 = decision.Col2, Col3 = decision.Col3, EvaluationFn = decision.EvaluationFn
                    };
                    stack.TheStack.Insert(reStackIndex++, newDecision);
                }
            }
            if (effectedCols[1])
            {
                var data         = env.EvalAsListOfStrings(decision.Col2, update);
                var reStackIndex = stackIndex;

                foreach (var item in data)
                {
                    var newDecision = new Dev2Decision {
                        Col1 = FetchStackValue(stack, reStackIndex, 1), Col2 = item, Col3 = decision.Col3, EvaluationFn = decision.EvaluationFn
                    };
                    if (effectedCols[0])
                    {
                        // ensure we have the correct indexing ;)
                        if (reStackIndex < stack.TheStack.Count)
                        {
                            stack.TheStack[reStackIndex++] = newDecision;
                        }
                        else
                        {
                            stack.TheStack.Insert(reStackIndex++, newDecision);
                        }
                    }
                    else
                    {
                        stack.TheStack.Insert(reStackIndex++, newDecision);
                    }
                }
            }
            if (effectedCols[2])
            {
                var data         = env.EvalAsListOfStrings(decision.Col3, update);
                var reStackIndex = stackIndex;

                foreach (var item in data)
                {
                    var newDecision = new Dev2Decision {
                        Col1 = FetchStackValue(stack, reStackIndex, 1), Col2 = FetchStackValue(stack, reStackIndex, 2), Col3 = item, EvaluationFn = decision.EvaluationFn
                    };
                    if (effectedCols[0] || effectedCols[1])
                    {
                        // ensure we have the correct indexing ;)
                        if (reStackIndex < stack.TheStack.Count)
                        {
                            stack.TheStack[reStackIndex++] = newDecision;
                        }
                        else
                        {
                            stack.TheStack.Insert(reStackIndex++, newDecision);
                        }
                    }
                    else
                    {
                        stack.TheStack.Insert(reStackIndex++, newDecision);
                    }
                }
            }
            return(stack);
        }
 public IList <string> EvalAsListOfStrings(string expression, int update) => _inner.EvalAsListOfStrings(UpdateDataSourceWithIterativeValue(_datasource, update, expression), 0);
        Dev2DecisionStack ResolveAllRecords(IExecutionEnvironment env, Dev2DecisionStack stack, Dev2Decision decision, bool[] effectedCols, out ErrorResultTO errors)
        {
            if(effectedCols == null)
            {
                throw new ArgumentNullException("effectedCols");
            }
            int stackIndex = stack.TheStack.IndexOf(decision);
            stack.TheStack.Remove(decision);
            errors = new ErrorResultTO();
            if(effectedCols[0])
            {
                var data = env.EvalAsListOfStrings(decision.Col1);
               
                int reStackIndex = stackIndex;

                foreach(var item in data)
                {


                    var newDecision = new Dev2Decision { Col1 = item, Col2 = decision.Col2, Col3 = decision.Col3, EvaluationFn = decision.EvaluationFn };
                    stack.TheStack.Insert(reStackIndex++, newDecision);
                }
            }
            if(effectedCols[1])
            {
                var data = env.EvalAsListOfStrings(decision.Col2);
                int reStackIndex = stackIndex;

                 foreach(var item in data)
                {
                    var newDecision = new Dev2Decision { Col1 = FetchStackValue(stack, reStackIndex, 1), Col2 = item, Col3 = decision.Col3, EvaluationFn = decision.EvaluationFn };
                    if(effectedCols[0])
                    {
                        // ensure we have the correct indexing ;)
                        if(reStackIndex < stack.TheStack.Count)
                        {
                            stack.TheStack[reStackIndex++] = newDecision;
                        }
                        else
                        {
                            stack.TheStack.Insert(reStackIndex++, newDecision);
                        }
                    }
                    else
                    {
                        stack.TheStack.Insert(reStackIndex++, newDecision);
                    }
                }
            }
            if(effectedCols[2])
            {
                var data = env.EvalAsListOfStrings(decision.Col3);
                int reStackIndex = stackIndex;

                foreach (var item in data)
                {
                    var newDecision = new Dev2Decision { Col1 = FetchStackValue(stack, reStackIndex, 1), Col2 = FetchStackValue(stack, reStackIndex, 2), Col3 = item, EvaluationFn = decision.EvaluationFn };
                    if(effectedCols[0] || effectedCols[1])
                    {
                        // ensure we have the correct indexing ;)
                        if(reStackIndex < stack.TheStack.Count)
                        {
                            stack.TheStack[reStackIndex++] = newDecision;
                        }
                        else
                        {
                            stack.TheStack.Insert(reStackIndex++, newDecision);
                        }
                    }
                    else
                    {
                        stack.TheStack.Insert(reStackIndex++, newDecision);
                    }
                }
            }
            return stack;
        }