Esempio n. 1
0
        public static void ProcessOutputMapping(IExecutionEnvironment environment, int update, ref bool started, ref int rowIdx, DataRow row, IServiceOutputMapping serviceOutputMapping)
        {
            var rsType   = DataListUtil.GetRecordsetIndexType(serviceOutputMapping.MappedTo);
            var rowIndex = DataListUtil.ExtractIndexRegionFromRecordset(serviceOutputMapping.MappedTo);

            var rs = serviceOutputMapping.RecordSetName;

            if (!string.IsNullOrEmpty(rs) && environment.HasRecordSet(DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.MakeValueIntoHighLevelRecordset(rs, rsType == enRecordsetIndexType.Star))))
            {
                if (started)
                {
                    rowIdx  = environment.GetLength(rs) + 1;
                    started = false;
                }
            }
            else
            {
                try
                {
                    environment.AssignDataShape(serviceOutputMapping.MappedTo);
                }
                catch (Exception e)
                {
                    Dev2Logger.Error(e, GlobalConstants.WarewolfError);
                }
            }

            GetRowIndex(ref started, ref rowIdx, rsType, rowIndex);
            if (!row.Table.Columns.Contains(serviceOutputMapping.MappedFrom))
            {
                return;
            }

            var value = row[serviceOutputMapping.MappedFrom];

            var colDataType = row.Table.Columns[serviceOutputMapping.MappedFrom].DataType;

            if (colDataType.Name == "Byte[]")
            {
                value = Encoding.UTF8.GetString(value as byte[]);
            }

            if (update != 0)
            {
                rowIdx = update;
            }

            var displayExpression = DataListUtil.ReplaceRecordsetBlankWithIndex(DataListUtil.AddBracketsToValueIfNotExist(serviceOutputMapping.MappedTo), rowIdx);

            if (rsType == enRecordsetIndexType.Star)
            {
                displayExpression = DataListUtil.ReplaceStarWithFixedIndex(displayExpression, rowIdx);
            }

            environment.Assign(displayExpression, value.ToString(), update);
        }
Esempio n. 2
0
        static void ProcessOutputMapping(DataTable executeService, IExecutionEnvironment environment, int update, ref bool started, ref int rowIdx, DataRow row, IServiceOutputMapping serviceOutputMapping)
        {
            var rsType   = DataListUtil.GetRecordsetIndexType(serviceOutputMapping.MappedTo);
            var rowIndex = DataListUtil.ExtractIndexRegionFromRecordset(serviceOutputMapping.MappedTo);
            var rs       = serviceOutputMapping.RecordSetName;

            if (!string.IsNullOrEmpty(rs) && environment.HasRecordSet(rs))
            {
                if (started)
                {
                    rowIdx  = environment.GetLength(rs) + 1;
                    started = false;
                }
            }
            else
            {
                try
                {
                    environment.AssignDataShape(serviceOutputMapping.MappedTo);
                }
                catch (Exception e)
                {
                    Dev2Logger.Error(e, GlobalConstants.WarewolfError);
                }
            }
            GetRowIndex(ref started, ref rowIdx, rsType, rowIndex);
            if (!executeService.Columns.Contains(serviceOutputMapping.MappedFrom) && !executeService.Columns.Contains("ReadForXml"))
            {
                return;
            }
            var value = GetColumnValue(executeService, row, serviceOutputMapping);

            if (update != 0)
            {
                rowIdx = update;
            }
            var displayExpression = DataListUtil.ReplaceRecordsetBlankWithIndex(DataListUtil.AddBracketsToValueIfNotExist(serviceOutputMapping.MappedTo), rowIdx);

            if (rsType == enRecordsetIndexType.Star)
            {
                displayExpression = DataListUtil.ReplaceStarWithFixedIndex(displayExpression, rowIdx);
            }
            environment.Assign(displayExpression, value.ToString(), update);
        }
Esempio n. 3
0
        void TranslateDataTableToEnvironment(DataTable executeService, IExecutionEnvironment environment)
        {
            if (executeService != null && InstanceOutputDefintions != null)
            {
                var defs = DataListFactory.CreateOutputParser().Parse(InstanceOutputDefintions);
                HashSet <string>          processedRecNames = new HashSet <string>();
                IDictionary <int, string> colMapping        = BuildColumnNameToIndexMap(executeService.Columns, defs);
                foreach (var def in defs)
                {
                    var expression = def.Value;
                    var rs         = def.RawValue;
                    var rsName     = DataListUtil.ExtractRecordsetNameFromValue(expression);
                    var rsType     = DataListUtil.GetRecordsetIndexType(expression);
                    var rowIndex   = DataListUtil.ExtractIndexRegionFromRecordset(expression);
                    var rsNameUse  = def.RecordSetName;
                    environment.AssignDataShape(def.RawValue);

                    if (DataListUtil.IsValueRecordset(rs))
                    {
                        if (string.IsNullOrEmpty(rsName))
                        {
                            rsName = rsNameUse;
                        }
                        if (string.IsNullOrEmpty(rsName))
                        {
                            rsName = def.Name;
                        }

                        if (processedRecNames.Contains(rsName))
                        {
                            continue;
                        }

                        processedRecNames.Add(rsName);


                        // now convert to binary datalist ;)
                        int rowIdx = 1;

                        if (environment.HasRecordSet(rs))
                        {
                            rowIdx = environment.GetLength(rs);
                        }

                        if (rsType == enRecordsetIndexType.Star)
                        {
                            rowIdx = 1;
                        }
                        if (rsType == enRecordsetIndexType.Numeric)
                        {
                            rowIdx = int.Parse(rowIndex);
                        }

                        if (executeService.Rows != null)
                        {
                            foreach (DataRow row in executeService.Rows)
                            {
                                // build up the row
                                int idx = 0;

                                foreach (var item in row.ItemArray)
                                {
                                    string colName;

                                    if (colMapping.TryGetValue(idx, out colName))
                                    {
                                        var displayExpression = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(def.Value), colName, rowIdx.ToString()));
                                        environment.Assign(displayExpression, item.ToString(), 0);
                                    }

                                    idx++;
                                }

                                rowIdx++;
                            }
                        }
                    }
                    else
                    {
                        // handle a scalar coming out ;)
                        if (executeService.Rows != null && executeService.Rows.Count == 1)
                        {
                            var row = executeService.Rows[0].ItemArray;
                            // Look up the correct index from the columns ;)

                            int pos  = 0;
                            var cols = executeService.Columns;
                            int idx  = -1;

                            while (pos < cols.Count && idx == -1)
                            {
                                if (colMapping[pos] == expression)
                                {
                                    idx = pos;
                                }
                                pos++;
                            }
                            environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(expression), row[idx].ToString(), 0);
                        }
                    }
                }
            }
        }
        //MO - Changed : new ctor that accepts the new arguments
        public ForEachBootstrapTO(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, IExecutionEnvironment compiler, out ErrorResultTO errors, int update)
        {
            errors = new ErrorResultTO();
            ForEachType = forEachType;
            IIndexIterator localIndexIterator;

            switch(forEachType)
            {
                case enForEachType.InRecordset:
                    
                    var records = compiler.EvalRecordSetIndexes(recordsetName, update);
                    if (!compiler.HasRecordSet(recordsetName) )
                    {
                        errors.AddError("When selecting a recordset only valid recordsets can be used");
                        break;
                    }

                        localIndexIterator = new IndexListIndexIterator(records);

                    
                    IndexIterator = localIndexIterator;
                    break;

                case enForEachType.InRange:
                    if(string.IsNullOrWhiteSpace(@from))
                    {
                        errors.AddError("The from field can not be left empty.");
                        break;
                    }

                    if(string.IsNullOrWhiteSpace(to))
                    {
                        errors.AddError("The to field can not be left empty.");
                        break;
                    }

                    if(@from.Contains("(*)"))
                    {
                        errors.AddError("The Star notation is not accepted in the From field.");
                        break;
                    }

                    

                    var evalledFrom = ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(@from, update));
                    int intFrom;
                    if (!int.TryParse(evalledFrom, out intFrom) || intFrom < 1)
                    {
                        errors.AddError("From range must be a whole number from 1 onwards.");
                        break;
                    }

                    if(to.Contains("(*)"))
                    {
                        errors.AddError("The Star notation is not accepted in the To field.");
                        break;
                    }

                    var evalledTo= ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(@to, update));
               
                    int intTo;
                    if (!int.TryParse(evalledTo, out intTo) || intTo < 1)
                    {
                        errors.AddError("To range must be a whole number from 1 onwards.");
                        break;
                    }
                    IndexList indexList;
                    if(intFrom > intTo)
                    {
                        indexList = new IndexList(new HashSet<int>(), 0) { MinValue = intFrom, MaxValue = intTo };
                        ReverseIndexIterator revIdxItr = new ReverseIndexIterator(new HashSet<int>(), 0) { IndexList = indexList };
                        IndexIterator = revIdxItr;
                    }
                    else
                    {
                        indexList = new IndexList(new HashSet<int>(), 0) { MinValue = intFrom, MaxValue = intTo };
                        localIndexIterator = new IndexIterator(new HashSet<int>(), 0) { IndexList = indexList };
                        IndexIterator = localIndexIterator;
                    }

                    break;
                case enForEachType.InCSV:
                    var csvIndexedsItr = ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(csvNumbers, update));

                    ErrorResultTO allErrors;
                    List<int> listOfIndexes = SplitOutCsvIndexes(csvIndexedsItr, out allErrors);
                    if(allErrors.HasErrors())
                    {
                        errors.MergeErrors(allErrors);
                        break;
                    }
                    ListIndexIterator listLocalIndexIterator = new ListIndexIterator(listOfIndexes);
                    ListOfIndex listOfIndex = new ListOfIndex(listOfIndexes);
                    listLocalIndexIterator.IndexList = listOfIndex;
                    IndexIterator = listLocalIndexIterator;
                    break;
                default:

                    if(numberOfExecutes != null && numberOfExecutes.Contains("(*)"))
                    {
                        errors.AddError("The Star notation is not accepted in the Numbers field.");
                        break;
                    }

                    int intExNum;
                    var numOfExItr = ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(numberOfExecutes, update));

                    if (!int.TryParse(numOfExItr, out intExNum))
                    {
                        errors.AddError("Number of executes must be a whole number from 1 onwards.");
                    }
                    IndexIterator = new IndexIterator(new HashSet<int>(), intExNum);
                    break;
            }

        }
Esempio n. 5
0
 public bool HasRecordSet(string recordsetName) => _inner.HasRecordSet(recordsetName);
        //MO - Changed : new ctor that accepts the new arguments
        public ForEachBootstrapTO(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, IExecutionEnvironment compiler, out ErrorResultTO errors, int update)
        {
            errors      = new ErrorResultTO();
            ForEachType = forEachType;
            IIndexIterator localIndexIterator;

            switch (forEachType)
            {
            case enForEachType.InRecordset:

                if (string.IsNullOrEmpty(recordsetName))
                {
                    errors.AddError(string.Format(ErrorResource.IsRequired, "The Recordset Field"));
                    break;
                }
                var records = compiler.EvalRecordSetIndexes(recordsetName, update);
                if (!compiler.HasRecordSet(recordsetName))
                {
                    errors.AddError("When selecting a recordset only valid recordsets can be used");
                    break;
                }

                localIndexIterator = new IndexListIndexIterator(records);


                IndexIterator = localIndexIterator;
                break;

            case enForEachType.InRange:
                if (string.IsNullOrWhiteSpace(@from))
                {
                    errors.AddError(string.Format(ErrorResource.IsRequired, "The FROM field"));
                    break;
                }

                if (string.IsNullOrWhiteSpace(to))
                {
                    errors.AddError(string.Format(ErrorResource.IsRequired, "The TO field"));
                    break;
                }

                if (@from.Contains("(*)"))
                {
                    errors.AddError(string.Format(ErrorResource.StarNotationNotAllowed, "From field"));
                    break;
                }



                var evalledFrom = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@from, update));
                int intFrom;
                if (!int.TryParse(evalledFrom, out intFrom) || intFrom < 1)
                {
                    errors.AddError(string.Format(ErrorResource.RangeFromOne, "FROM range"));
                    break;
                }

                if (to.Contains("(*)"))
                {
                    errors.AddError(string.Format(ErrorResource.StarNotationNotAllowed, "TO field."));
                    break;
                }

                var evalledTo = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@to, update));

                int intTo;
                if (!int.TryParse(evalledTo, out intTo) || intTo < 1)
                {
                    errors.AddError(string.Format(ErrorResource.RangeFromOne, "TO range"));
                    break;
                }
                IndexList indexList;
                if (intFrom > intTo)
                {
                    indexList = new IndexList(new HashSet <int>(), 0)
                    {
                        MinValue = intFrom, MaxValue = intTo
                    };
                    var revIdxItr = new ReverseIndexIterator(new HashSet <int>(), 0)
                    {
                        IndexList = indexList
                    };
                    IndexIterator = revIdxItr;
                }
                else
                {
                    indexList = new IndexList(new HashSet <int>(), 0)
                    {
                        MinValue = intFrom, MaxValue = intTo
                    };
                    localIndexIterator = new IndexIterator(new HashSet <int>(), 0)
                    {
                        IndexList = indexList
                    };
                    IndexIterator = localIndexIterator;
                }

                break;

            case enForEachType.InCSV:
                if (string.IsNullOrEmpty(csvNumbers))
                {
                    errors.AddError(string.Format(ErrorResource.IsRequired, "The CSV Field"));
                    break;
                }
                var csvIndexedsItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(csvNumbers, update));

                ErrorResultTO allErrors;
                var           listOfIndexes = SplitOutCsvIndexes(csvIndexedsItr, out allErrors);
                if (allErrors.HasErrors())
                {
                    errors.MergeErrors(allErrors);
                    break;
                }
                var listLocalIndexIterator = new ListIndexIterator(listOfIndexes);
                var listOfIndex            = new ListOfIndex(listOfIndexes);
                listLocalIndexIterator.IndexList = listOfIndex;
                IndexIterator = listLocalIndexIterator;
                break;

            default:

                if (numberOfExecutes != null && numberOfExecutes.Contains("(*)"))
                {
                    errors.AddError(string.Format(ErrorResource.StarNotationNotAllowed, "Numbers field."));
                    break;
                }

                int intExNum;
                var numOfExItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(numberOfExecutes, update));

                if (!int.TryParse(numOfExItr, out intExNum) || intExNum < 1)
                {
                    errors.AddError(string.Format(ErrorResource.RangeFromOne, "Number of executes"));
                }
                IndexIterator = new IndexIterator(new HashSet <int>(), intExNum);
                break;
            }
        }
        //MO - Changed : new ctor that accepts the new arguments
        public ForEachBootstrapTO(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, IExecutionEnvironment compiler, out ErrorResultTO errors, int update)
        {
            errors      = new ErrorResultTO();
            ForEachType = forEachType;
            IIndexIterator localIndexIterator;

            switch (forEachType)
            {
            case enForEachType.InRecordset:

                var records = compiler.EvalRecordSetIndexes(recordsetName, update);
                if (!compiler.HasRecordSet(recordsetName))
                {
                    errors.AddError("When selecting a recordset only valid recordsets can be used");
                    break;
                }

                localIndexIterator = new IndexListIndexIterator(records);


                IndexIterator = localIndexIterator;
                break;

            case enForEachType.InRange:
                if (string.IsNullOrWhiteSpace(@from))
                {
                    errors.AddError("The from field can not be left empty.");
                    break;
                }

                if (string.IsNullOrWhiteSpace(to))
                {
                    errors.AddError("The to field can not be left empty.");
                    break;
                }

                if (@from.Contains("(*)"))
                {
                    errors.AddError("The Star notation is not accepted in the From field.");
                    break;
                }



                var evalledFrom = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@from, update));
                int intFrom;
                if (!int.TryParse(evalledFrom, out intFrom) || intFrom < 1)
                {
                    errors.AddError("From range must be a whole number from 1 onwards.");
                    break;
                }

                if (to.Contains("(*)"))
                {
                    errors.AddError("The Star notation is not accepted in the To field.");
                    break;
                }

                var evalledTo = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@to, update));

                int intTo;
                if (!int.TryParse(evalledTo, out intTo) || intTo < 1)
                {
                    errors.AddError("To range must be a whole number from 1 onwards.");
                    break;
                }
                IndexList indexList;
                if (intFrom > intTo)
                {
                    indexList = new IndexList(new HashSet <int>(), 0)
                    {
                        MinValue = intFrom, MaxValue = intTo
                    };
                    ReverseIndexIterator revIdxItr = new ReverseIndexIterator(new HashSet <int>(), 0)
                    {
                        IndexList = indexList
                    };
                    IndexIterator = revIdxItr;
                }
                else
                {
                    indexList = new IndexList(new HashSet <int>(), 0)
                    {
                        MinValue = intFrom, MaxValue = intTo
                    };
                    localIndexIterator = new IndexIterator(new HashSet <int>(), 0)
                    {
                        IndexList = indexList
                    };
                    IndexIterator = localIndexIterator;
                }

                break;

            case enForEachType.InCSV:
                var csvIndexedsItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(csvNumbers, update));

                ErrorResultTO allErrors;
                List <int>    listOfIndexes = SplitOutCsvIndexes(csvIndexedsItr, out allErrors);
                if (allErrors.HasErrors())
                {
                    errors.MergeErrors(allErrors);
                    break;
                }
                ListIndexIterator listLocalIndexIterator = new ListIndexIterator(listOfIndexes);
                ListOfIndex       listOfIndex            = new ListOfIndex(listOfIndexes);
                listLocalIndexIterator.IndexList = listOfIndex;
                IndexIterator = listLocalIndexIterator;
                break;

            default:

                if (numberOfExecutes != null && numberOfExecutes.Contains("(*)"))
                {
                    errors.AddError("The Star notation is not accepted in the Numbers field.");
                    break;
                }

                int intExNum;
                var numOfExItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(numberOfExecutes, update));

                if (!int.TryParse(numOfExItr, out intExNum))
                {
                    errors.AddError("Number of executes must be a whole number from 1 onwards.");
                }
                IndexIterator = new IndexIterator(new HashSet <int>(), intExNum);
                break;
            }
        }
Esempio n. 8
0
 public bool HasRecordSet(string recordsetName)
 {
     return(_inner.HasRecordSet(recordsetName));
 }
Esempio n. 9
0
        private void TranslateDataTableToEnvironment(DataTable executeService, IExecutionEnvironment environment, int update)
        {
            var started = true;

            if (executeService != null && Outputs != null && Outputs.Count != 0)
            {
                if (executeService.Rows != null)
                {
                    var rowIdx = 1;
                    foreach (DataRow row in executeService.Rows)
                    {
                        foreach (var serviceOutputMapping in Outputs)
                        {
                            if (!string.IsNullOrEmpty(serviceOutputMapping.MappedTo))
                            {
                                var rsType   = DataListUtil.GetRecordsetIndexType(serviceOutputMapping.MappedTo);
                                var rowIndex = DataListUtil.ExtractIndexRegionFromRecordset(serviceOutputMapping.MappedTo);
                                var rs       = serviceOutputMapping.RecordSetName;

                                if (environment.HasRecordSet(rs))
                                {
                                    if (started)
                                    {
                                        rowIdx  = environment.GetLength(rs) + 1;
                                        started = false;
                                    }
                                }
                                else
                                {
                                    environment.AssignDataShape(serviceOutputMapping.MappedTo);
                                }
                                if (rsType == enRecordsetIndexType.Star && started)
                                {
                                    rowIdx  = 1;
                                    started = false;
                                }
                                if (rsType == enRecordsetIndexType.Numeric)
                                {
                                    rowIdx = int.Parse(rowIndex);
                                }
                                if (!executeService.Columns.Contains(serviceOutputMapping.MappedFrom))
                                {
                                    continue;
                                }
                                var value = row[serviceOutputMapping.MappedFrom];
                                if (update != 0)
                                {
                                    rowIdx = update;
                                }
                                var displayExpression = DataListUtil.ReplaceRecordsetBlankWithIndex(DataListUtil.AddBracketsToValueIfNotExist(serviceOutputMapping.MappedTo), rowIdx);
                                if (rsType == enRecordsetIndexType.Star)
                                {
                                    displayExpression = DataListUtil.ReplaceStarWithFixedIndex(displayExpression, rowIdx);
                                }
                                environment.Assign(displayExpression, value.ToString(), update);
                            }
                        }
                        rowIdx++;
                    }
                }
            }
        }