//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) { errors = new ErrorResultTO(); ForEachType = forEachType; IDev2IteratorCollection colItr = Dev2ValueObjectFactory.CreateIteratorCollection(); IIndexIterator localIndexIterator; IndexList indexList; switch(forEachType) { case enForEachType.InRecordset: var records = compiler.EvalRecordSetIndexes(recordsetName); if (!compiler.HasRecordSet(recordsetName) ) { errors.AddError("When selecting a recordset only valid recordsets can be used"); break; } var isEmpty =! records.Any(); if(isEmpty) { localIndexIterator = new IndexListIndexIterator(records); } else { 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 = Warewolf.Storage.ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(@from)); 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= Warewolf.Storage.ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(@to)); int intTo; if (!int.TryParse(evalledTo, out intTo) || intTo < 1) { errors.AddError("To range must be a whole number from 1 onwards."); break; } 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 = Warewolf.Storage.ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(csvNumbers)); 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 = Warewolf.Storage.ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(numberOfExecutes)); 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; } }