Example #1
0
 static void TryConvert(IDSFDataObject dataObject, XmlNodeList children, List <string> inputDefs, int update, int level = 0)
 {
     try
     {
         // spin through each element in the XML
         foreach (XmlNode c in children)
         {
             if (c.Name != GlobalConstants.NaughtyTextNode)
             {
                 if (level > 0)
                 {
                     var c1         = c;
                     var scalars    = inputDefs.Where(definition => definition == c1.Name);
                     var recSets    = inputDefs.Where(definition => DataListUtil.ExtractRecordsetNameFromValue(definition) == c1.Name);
                     var scalarDefs = scalars as string[] ?? scalars.ToArray();
                     var recSetDefs = recSets as string[] ?? recSets.ToArray();
                     if (recSetDefs.Length != 0)
                     {
                         var nl = c.ChildNodes;
                         foreach (XmlNode subc in nl)
                         {
                             foreach (var definition in recSetDefs)
                             {
                                 if (DataListUtil.IsValueRecordset(definition))
                                 {
                                     if (DataListUtil.ExtractFieldNameFromValue(definition) == subc.Name)
                                     {
                                         var recSetAppend = DataListUtil.ReplaceRecordsetIndexWithBlank(definition);
                                         var a            = subc.InnerXml;
                                         a = RemoveXMLPrefix(a);
                                         dataObject.Environment.AssignWithFrame(new AssignValue(recSetAppend, a), update);
                                     }
                                 }
                             }
                         }
                     }
                     if (scalarDefs.Length != 0)
                     {
                         // fetch recordset index
                         // process recordset
                         var a = c.InnerXml;
                         a = RemoveXMLPrefix(a);
                         dataObject.Environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(c.Name), a, update);
                     }
                 }
                 else
                 {
                     if (level == 0)
                     {
                         TryConvert(dataObject, c.ChildNodes, inputDefs, update, ++level);
                     }
                 }
             }
         }
     }
     finally
     {
         dataObject.Environment.CommitAssign();
     }
 }
Example #2
0
        public override string ValidateName(string name)
        {
            var parser = new Dev2DataLanguageParser();

            if (!string.IsNullOrEmpty(name))
            {
                var fieldName = DataListUtil.ExtractFieldNameFromValue(name);
                var recName   = DataListUtil.ExtractRecordsetNameFromValue(name);
                if (!string.IsNullOrEmpty(recName))
                {
                    ValidateName(parser, recName);
                }
                if (!string.IsNullOrEmpty(fieldName))
                {
                    name = ValidateName(name, parser, fieldName);
                }
                else
                {
                    var intellisenseResult = parser.ValidateName(name, "Recordset field");
                    if (intellisenseResult != null)
                    {
                        SetError(intellisenseResult.Message);
                    }
                }
            }
            return(name);
        }
Example #3
0
        private static void UpdateForRecordset(IDSFDataObject dataObject, int update, IEnumerable <string> recSets, XmlNode c)
        {
            var recSetDefs = recSets as string[] ?? recSets.ToArray();

            if (recSetDefs.Length != 0)
            {
                var nl = c.ChildNodes;
                foreach (XmlNode subc in nl)
                {
                    foreach (var definition in recSetDefs)
                    {
                        if (DataListUtil.IsValueRecordset(definition))
                        {
                            if (DataListUtil.ExtractFieldNameFromValue(definition) == subc.Name)
                            {
                                var recSetAppend = DataListUtil.ReplaceRecordsetIndexWithBlank(definition);
                                var a            = subc.InnerXml;
                                a = RemoveXMLPrefix(a);
                                dataObject.Environment.AssignWithFrame(new AssignValue(recSetAppend, a), update);
                            }
                        }
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// Builds the column name to index map.
        /// </summary>
        /// <param name="dtCols">The dt cols.</param>
        /// <param name="defs">Defs to use</param>
        /// <returns></returns>
        // ReSharper disable ParameterTypeCanBeEnumerable.Local
        private IDictionary <int, string> BuildColumnNameToIndexMap(DataColumnCollection dtCols, IList <IDev2Definition> defs)
        // ReSharper restore ParameterTypeCanBeEnumerable.Local
        {
            Dictionary <int, string> result = new Dictionary <int, string>();

            if (result.Count == 0 && defs != null)
            {
                // use positional adjustment
                foreach (var def in defs)
                {
                    var idx = dtCols.IndexOf(def.Name);
                    if (idx != -1)
                    {
                        if (def.IsRecordSet && DataListUtil.IsValueRecordsetWithFields(def.RawValue))
                        {
                            result.Add(idx, DataListUtil.ExtractFieldNameFromValue(def.RawValue));
                        }
                        else
                        {
                            result.Add(idx, def.Value);
                        }
                    }
                }
            }

            return(result);
        }
        public override string ValidateName(string name)
        {
            Dev2DataLanguageParser parser = new Dev2DataLanguageParser();

            if (!string.IsNullOrEmpty(name))
            {
                var fieldName = DataListUtil.ExtractFieldNameFromValue(name);
                var recName   = DataListUtil.ExtractRecordsetNameFromValue(name);
                if (!string.IsNullOrEmpty(recName))
                {
                    var intellisenseResult = parser.ValidateName(recName, "Recordset");
                    if (intellisenseResult != null)
                    {
                        SetError(intellisenseResult.Message);
                    }
                    else
                    {
                        if (!string.Equals(ErrorMessage, StringResources.ErrorMessageDuplicateValue, StringComparison.InvariantCulture) &&
                            !string.Equals(ErrorMessage, StringResources.ErrorMessageDuplicateVariable, StringComparison.InvariantCulture) &&
                            !string.Equals(ErrorMessage, StringResources.ErrorMessageDuplicateRecordset, StringComparison.InvariantCulture) &&
                            !string.Equals(ErrorMessage, StringResources.ErrorMessageEmptyRecordSet, StringComparison.InvariantCulture))
                        {
                            RemoveError();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(fieldName))
                {
                    var intellisenseResult = parser.ValidateName(fieldName, "Recordset field");
                    if (intellisenseResult != null)
                    {
                        SetError(intellisenseResult.Message);
                    }
                    else
                    {
                        if (!string.Equals(ErrorMessage, StringResources.ErrorMessageDuplicateValue, StringComparison.InvariantCulture) &&
                            !string.Equals(ErrorMessage, StringResources.ErrorMessageDuplicateVariable, StringComparison.InvariantCulture) &&
                            !string.Equals(ErrorMessage, StringResources.ErrorMessageDuplicateRecordset, StringComparison.InvariantCulture) &&
                            !string.Equals(ErrorMessage, StringResources.ErrorMessageEmptyRecordSet, StringComparison.InvariantCulture))
                        {
                            RemoveError();
                            name = fieldName;
                        }
                    }
                }
                else
                {
                    var intellisenseResult = parser.ValidateName(name, "Recordset field");
                    if (intellisenseResult != null)
                    {
                        SetError(intellisenseResult.Message);
                    }
                }
            }
            return(name);
        }
Example #6
0
 private static void UpdateForChildNodes(IDSFDataObject dataObject, int update, XmlNode subc, string definition)
 {
     if (DataListUtil.IsValueRecordset(definition) && DataListUtil.ExtractFieldNameFromValue(definition) == subc.Name)
     {
         var recSetAppend = DataListUtil.ReplaceRecordsetIndexWithBlank(definition);
         var a            = subc.InnerXml;
         a = RemoveXMLPrefix(a);
         dataObject.Environment.AssignWithFrame(new AssignValue(recSetAppend, a), update);
     }
 }
Example #7
0
        public string RetrieveItemForEvaluation(enIntellisensePartType partType, string value)
        {
            var rawRef = DataListUtil.StripBracketsFromValue(value);
            var objRef = string.Empty;

            if (partType == enIntellisensePartType.RecordsetsOnly)
            {
                objRef = DataListUtil.ExtractRecordsetNameFromValue(rawRef);
            }
            else if (partType == enIntellisensePartType.RecordsetFields)
            {
                objRef = DataListUtil.ExtractFieldNameFromValue(rawRef);
            }

            return(objRef);
        }
Example #8
0
        void ExecuteForListOfDir(IList <IActivityIOPath> listOfDir, IList <OutputTO> outputs)
        {
            var recsetName = DataListUtil.ExtractRecordsetNameFromValue(Result);
            var fieldName  = DataListUtil.ExtractFieldNameFromValue(Result);

            var indexToUpsertTo = 1;

            if (listOfDir != null)
            {
                foreach (IActivityIOPath pa in listOfDir)
                {
                    var fullRecsetName = DataListUtil.CreateRecordsetDisplayValue(recsetName, fieldName,
                                                                                  indexToUpsertTo.ToString(CultureInfo.InvariantCulture));
                    outputs.Add(DataListFactory.CreateOutputTO(DataListUtil.AddBracketsToValueIfNotExist(fullRecsetName), pa.Path));
                    indexToUpsertTo++;
                }
            }
        }
Example #9
0
        /// <summary>
        /// Determines whether [is recorset without field] [the specified field].
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="recSet">The rec set.</param>
        /// <returns>
        ///   <c>true</c> if [is recorset without field] [the specified field]; otherwise, <c>false</c>.
        /// </returns>
        private bool IsRecorsetWithoutField(string field, string recSet)
        {
            bool result = false;

            if (string.IsNullOrWhiteSpace(DataListUtil.ExtractFieldNameFromValue(field)))
            {
                if (string.IsNullOrWhiteSpace(DataListUtil.ExtractIndexRegionFromRecordset(field)))
                {
                    string recsetName = DataListUtil.ExtractRecordsetNameFromValue(field);
                    if (recsetName == recSet)
                    {
                        result = true;
                    }
                }
            }

            return(result);
        }
        static string GetValueForDecisionVariable(Guid dlId, string decisionColumn)
        {
            if (!String.IsNullOrEmpty(decisionColumn))
            {
                IBinaryDataListItem  binaryDataListItem = null;
                ErrorResultTO        errors;
                IBinaryDataListEntry entry = Compiler.Evaluate(dlId, enActionType.User, decisionColumn, false, out errors);
                if (entry != null && entry.IsRecordset)
                {
                    string error;
                    var    indexType = DataListUtil.GetRecordsetIndexType(decisionColumn);
                    if (indexType == enRecordsetIndexType.Numeric)
                    {
                        var index      = int.Parse(DataListUtil.ExtractIndexRegionFromRecordset(decisionColumn));
                        var columnName = DataListUtil.ExtractFieldNameFromValue(decisionColumn);

                        binaryDataListItem = entry.TryFetchRecordsetColumnAtIndex(columnName, index, out error);
                    }
                    else
                    {
                        binaryDataListItem = entry.TryFetchLastIndexedRecordsetUpsertPayload(out error);
                    }
                }
                else
                {
                    if (entry != null)
                    {
                        binaryDataListItem = entry.FetchScalar();
                    }
                }
                if (binaryDataListItem != null)
                {
                    var value = binaryDataListItem.TheValue;
                    // handle \n coming from value ;)
                    value = value.Replace("\r\n", "__R__N__");
                    value = value.Replace("\n", "\r\n");
                    value = value.Replace("__R__N__", "\r\n");
                    return(value);
                }
            }
            return(null);
        }
        private void ExecuteConcreteAction(IList <OutputTO> outputs, WarewolfListIterator colItr, SharepointSource sharepointSource, WarewolfIterator serverInputFromItr, WarewolfIterator serverInputFromTo)
        {
            var serverPath = colItr.FetchNextValue(serverInputFromItr);
            var localPath  = colItr.FetchNextValue(serverInputFromTo);

            if (DataListUtil.IsValueRecordset(Result) && DataListUtil.GetRecordsetIndexType(Result) != enRecordsetIndexType.Numeric)
            {
                if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Star)
                {
                    var recsetName = DataListUtil.ExtractRecordsetNameFromValue(Result);
                    var fieldName  = DataListUtil.ExtractFieldNameFromValue(Result);

                    var newPath = CopyFile(sharepointSource, serverPath, localPath);

                    var indexToUpsertTo = 1;

                    foreach (var file in newPath)
                    {
                        var fullRecsetName = DataListUtil.CreateRecordsetDisplayValue(recsetName, fieldName,
                                                                                      indexToUpsertTo.ToString(CultureInfo.InvariantCulture));
                        outputs.Add(DataListFactory.CreateOutputTO(DataListUtil.AddBracketsToValueIfNotExist(fullRecsetName), file));
                        indexToUpsertTo++;
                    }
                }
                else
                {
                    if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Blank)
                    {
                        AddOutputsForBlankIndex(outputs, sharepointSource, serverPath, localPath);
                    }
                }
            }
            else
            {
                var newPath = CopyFile(sharepointSource, serverPath, localPath);

                var xmlList = string.Join(",", newPath.Select(c => c));
                outputs.Add(DataListFactory.CreateOutputTO(Result));
                outputs.Last().OutputStrings.Add(xmlList);
            }
        }
Example #12
0
        /// <summary>
        /// Determines whether [name is valid].
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>
        ///   <c>true</c> if [name is valid]; otherwise, <c>false</c>.
        /// </returns>
        public override string ValidateName(string name)
        {
            Dev2DataLanguageParser parser = new Dev2DataLanguageParser();

            if (!string.IsNullOrEmpty(name))
            {
                if (IsRecordset)
                {
                    name = DataListUtil.RemoveRecordsetBracketsFromValue(name);
                }
                else if (IsField)
                {
                    name = DataListUtil.ExtractFieldNameFromValue(name);
                }

                if (!string.IsNullOrEmpty(name))
                {
                    var intellisenseResult = parser.ValidateName(name, IsRecordset ? "Recordset" : "Variable");
                    if (intellisenseResult != null)
                    {
                        SetError(intellisenseResult.Message);
                    }
                    else
                    {
                        if (!string.Equals(ErrorMessage, StringResources.ErrorMessageDuplicateValue, StringComparison.InvariantCulture) &&
                            !string.Equals(ErrorMessage, StringResources.ErrorMessageDuplicateVariable, StringComparison.InvariantCulture) &&
                            !string.Equals(ErrorMessage, StringResources.ErrorMessageDuplicateRecordset, StringComparison.InvariantCulture) &&
                            !string.Equals(ErrorMessage, StringResources.ErrorMessageEmptyRecordSet, StringComparison.InvariantCulture))
                        {
                            RemoveError();
                        }
                    }
                }
            }
            return(name);
        }
Example #13
0
        protected override void ExecuteTool(IDSFDataObject dataObject, int update)
        {
            IDev2IndexFinder indexFinder = new Dev2IndexFinder();
            ErrorResultTO    allErrors   = new ErrorResultTO();
            ErrorResultTO    errors      = new ErrorResultTO();

            InitializeDebug(dataObject);

            try
            {
                var outerIteratorCollection = new WarewolfListIterator();
                var innerIteratorCollection = new WarewolfListIterator();

                allErrors.MergeErrors(errors);

                #region Iterate and Find Index

                if (dataObject.IsDebugMode())
                {
                    AddDebugInputItem(new DebugEvalResult(InField, "In Field", dataObject.Environment, update));
                    AddDebugInputItem(new DebugItemStaticDataParams(Index, "Index"));
                    AddDebugInputItem(new DebugEvalResult(Characters, "Characters", dataObject.Environment, update));
                    AddDebugInputItem(new DebugItemStaticDataParams(Direction, "Direction"));
                }

                var itrChar = new WarewolfIterator(dataObject.Environment.Eval(Characters, update));
                outerIteratorCollection.AddVariableToIterateOn(itrChar);

                var completeResultList = new List <string>();
                if (String.IsNullOrEmpty(InField))
                {
                    allErrors.AddError("'In Field' is blank");
                }
                else if (String.IsNullOrEmpty(Characters))
                {
                    allErrors.AddError("'Characters' is blank");
                }
                else
                {
                    while (outerIteratorCollection.HasMoreData())
                    {
                        allErrors.MergeErrors(errors);
                        errors.ClearErrors();
                        var itrInField = new WarewolfIterator(dataObject.Environment.Eval(InField, update));
                        innerIteratorCollection.AddVariableToIterateOn(itrInField);

                        string chars = outerIteratorCollection.FetchNextValue(itrChar);
                        while (innerIteratorCollection.HasMoreData())
                        {
                            if (!string.IsNullOrEmpty(InField) && !string.IsNullOrEmpty(Characters))
                            {
                                var val = innerIteratorCollection.FetchNextValue(itrInField);
                                if (val != null)
                                {
                                    IEnumerable <int> returedData = indexFinder.FindIndex(val, Index, chars, Direction, MatchCase, StartIndex);
                                    completeResultList.AddRange(returedData.Select(value => value.ToString(CultureInfo.InvariantCulture)).ToList());
                                    //2013.06.03: Ashley Lewis for bug 9498 - handle multiple regions in result
                                }
                            }
                        }
                    }
                    var rule   = new IsSingleValueRule(() => Result);
                    var single = rule.Check();
                    if (single != null)
                    {
                        allErrors.AddError(single.Message);
                    }
                    else
                    {
                        if (DataListUtil.IsValueRecordset(Result))
                        {
                            var rsType = DataListUtil.GetRecordsetIndexType(Result);
                            if (rsType == enRecordsetIndexType.Numeric)
                            {
                                dataObject.Environment.Assign(Result, string.Join(",", completeResultList), update);
                                allErrors.MergeErrors(errors);
                            }
                            else
                            {
                                var idx = 1;
                                foreach (var res in completeResultList)
                                {
                                    if (rsType == enRecordsetIndexType.Blank)
                                    {
                                        dataObject.Environment.Assign(Result, res, update);
                                    }
                                    if (rsType == enRecordsetIndexType.Star)
                                    {
                                        var expression = DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(Result), DataListUtil.ExtractFieldNameFromValue(Result), idx.ToString());
                                        dataObject.Environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(expression), res, update);
                                        idx++;
                                    }
                                }
                            }
                        }
                        else
                        {
                            dataObject.Environment.Assign(Result, string.Join(",", completeResultList), update);
                        }
                        allErrors.MergeErrors(errors);
                        if (!allErrors.HasErrors() && dataObject.IsDebugMode())
                        {
                            AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update));
                        }
                    }
                }

                #endregion
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error("DSFFindActivity", e);
                allErrors.AddError(e.Message);
            }
            finally
            {
                #region Handle Errors

                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfIndexActivity", allErrors);
                    var errorString = allErrors.MakeDisplayReady();
                    dataObject.Environment.AddError(errorString);
                }

                #endregion

                if (dataObject.IsDebugMode())
                {
                    if (hasErrors)
                    {
                        AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update));
                    }
                    DispatchDebugState(dataObject, StateType.Before, update);
                    DispatchDebugState(dataObject, StateType.After, update);
                }
            }
        }
Example #14
0
        /// <summary>
        /// Checks the validity of the input argument and returns the fields in a list of strings
        /// </summary>
        /// <param name="to">To.</param>
        /// <param name="bdl">The BDL.</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        public Func <IList <RecordSetSearchPayload> > GenerateInputRange(IRecsetSearch to, IBinaryDataList bdl, out ErrorResultTO errors)
        {
            errors = new ErrorResultTO();
            ErrorResultTO allErrors = new ErrorResultTO();

            Func <IList <RecordSetSearchPayload> > result = () =>
            {
                IList <RecordSetSearchPayload> fieldList = new List <RecordSetSearchPayload>();
                string InputField = to.FieldsToSearch;
                string recSet     = DataListUtil.ExtractRecordsetNameFromValue(DataListUtil.StripLeadingAndTrailingBracketsFromValue(InputField));
                IBinaryDataListEntry bdle;
                string error;

                bdl.TryGetEntry(recSet, out bdle, out error);
                allErrors.AddError(error);

                if (bdle == null)
                {
                    throw new RecordsetNotFoundException("Could not find Recordset [ " + recSet + " ]");
                }

                IList <Dev2Column> realCols = bdle.Columns;
                string[]           tmpCols  = InputField.Replace(" ", "").Split(',');

                // Travis.Frisinger : 09.25.2012
                // we need to adjust the tmpCols to avoid * causing crap with the match

                int loc = 0;

                foreach (string tc in tmpCols)
                {
                    string recset      = DataListUtil.ExtractRecordsetNameFromValue(tc);
                    string field       = DataListUtil.ExtractFieldNameFromValue(tc);
                    string myNewSearch = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.MakeValueIntoHighLevelRecordset(recset));

                    if (field != string.Empty)
                    {
                        myNewSearch = DataListUtil.MakeValueIntoHighLevelRecordset(recset) + "." + field;
                    }

                    tmpCols[loc] = DataListUtil.AddBracketsToValueIfNotExist(myNewSearch);
                    loc++;
                }

                int  pos   = 0;
                bool found = true;
                int  start;
                Int32.TryParse(to.StartIndex, out start);

                if (start == 0)
                {
                    start = 1;
                }

                while (pos < tmpCols.Length && found)
                {
                    int innerPos;
                    if (IsMatch(tmpCols[pos], recSet, realCols, out innerPos))
                    {
                        for (int i = start; i <= bdle.FetchLastRecordsetIndex(); i++)
                        {
                            IBinaryDataListItem tmp = bdle.TryFetchRecordsetColumnAtIndex(realCols[innerPos].ColumnName, i, out error);
                            if (error != string.Empty)
                            {
                                allErrors.AddError(error);
                            }
                            RecordSetSearchPayload p = new RecordSetSearchPayload {
                                Index = i, Payload = tmp.TheValue
                            };
                            fieldList.Add(p);
                        }
                    }
                    else
                    {
                        if (IsRecorsetWithoutField(tmpCols[pos], recSet))
                        {
                            IIndexIterator ixItr = bdle.FetchRecordsetIndexes();
                            while (ixItr.HasMore())
                            {
                                int next = ixItr.FetchNextIndex();
                                foreach (Dev2Column col in realCols)
                                {
                                    IBinaryDataListItem    tmp = bdle.TryFetchRecordsetColumnAtIndex(col.ColumnName, next, out error);
                                    RecordSetSearchPayload p   = new RecordSetSearchPayload {
                                        Index = next, Payload = tmp.TheValue
                                    };
                                    fieldList.Add(p);
                                }
                            }
                        }
                        else
                        {
                            found = false;
                        }
                    }
                    pos++;
                }

                if (!found)
                {
                    fieldList.Clear();
                }

                return(fieldList);
            };


            return(result);
        }
Example #15
0
        protected override IList <OutputTO> ExecuteConcreteAction(NativeActivityContext context, out ErrorResultTO allErrors)
        {
            IsNotCertVerifiable = true;

            allErrors = new ErrorResultTO();
            IList <OutputTO> outputs    = new List <OutputTO>();
            IDSFDataObject   dataObject = context.GetExtension <IDSFDataObject>();

            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();

            ErrorResultTO           errors;
            Guid                    executionId = dataObject.DataListID;
            IDev2IteratorCollection colItr      = Dev2ValueObjectFactory.CreateIteratorCollection();

            //get all the possible paths for all the string variables
            IBinaryDataListEntry inputPathEntry = compiler.Evaluate(executionId, enActionType.User, InputPath, false, out errors);

            allErrors.MergeErrors(errors);
            IDev2DataListEvaluateIterator inputItr = Dev2ValueObjectFactory.CreateEvaluateIterator(inputPathEntry);

            colItr.AddIterator(inputItr);

            IBinaryDataListEntry usernameEntry = compiler.Evaluate(executionId, enActionType.User, Username, false, out errors);

            allErrors.MergeErrors(errors);
            IDev2DataListEvaluateIterator unameItr = Dev2ValueObjectFactory.CreateEvaluateIterator(usernameEntry);

            colItr.AddIterator(unameItr);

            IBinaryDataListEntry passwordEntry = compiler.Evaluate(executionId, enActionType.User, Password, false, out errors);

            allErrors.MergeErrors(errors);
            IDev2DataListEvaluateIterator passItr = Dev2ValueObjectFactory.CreateEvaluateIterator(passwordEntry);

            colItr.AddIterator(passItr);

            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(InputPath, "Input Path", inputPathEntry, executionId);
                AddDebugInputItem(new DebugItemStaticDataParams(GetReadType().GetDescription(), "Read"));
                AddDebugInputItemUserNamePassword(executionId, usernameEntry);
            }

            while (colItr.HasMoreData())
            {
                IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker();
                IActivityIOPath           ioPath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextRow(inputItr).TheValue,
                                                                                          colItr.FetchNextRow(unameItr).TheValue,
                                                                                          colItr.FetchNextRow(passItr).TheValue,
                                                                                          true);
                IActivityIOOperationsEndPoint endPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ioPath);

                try
                {
                    IList <IActivityIOPath> listOfDir = broker.ListDirectory(endPoint, GetReadType());
                    if (DataListUtil.IsValueRecordset(Result) && DataListUtil.GetRecordsetIndexType(Result) != enRecordsetIndexType.Numeric)
                    {
                        if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Star)
                        {
                            string recsetName = DataListUtil.ExtractRecordsetNameFromValue(Result);
                            string fieldName  = DataListUtil.ExtractFieldNameFromValue(Result);

                            int indexToUpsertTo = 1;
                            if (listOfDir != null)
                            {
                                foreach (IActivityIOPath pa in listOfDir)
                                {
                                    string fullRecsetName = DataListUtil.CreateRecordsetDisplayValue(recsetName, fieldName,
                                                                                                     indexToUpsertTo.ToString(CultureInfo.InvariantCulture));
                                    outputs.Add(DataListFactory.CreateOutputTO(DataListUtil.AddBracketsToValueIfNotExist(fullRecsetName), pa.Path));
                                    indexToUpsertTo++;
                                }
                            }
                        }
                        else if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Blank)
                        {
                            if (listOfDir != null)
                            {
                                foreach (IActivityIOPath pa in listOfDir)
                                {
                                    outputs.Add(DataListFactory.CreateOutputTO(Result, pa.Path));
                                }
                            }
                        }
                    }
                    else
                    {
                        if (listOfDir != null)
                        {
                            string xmlList = string.Join(",", listOfDir.Select(c => c.Path));
                            outputs.Add(DataListFactory.CreateOutputTO(Result));
                            outputs.Last().OutputStrings.Add(xmlList);
                        }
                    }
                }
                catch (Exception e)
                {
                    outputs.Add(DataListFactory.CreateOutputTO(null));
                    allErrors.AddError(e.Message);
                    break;
                }
            }

            return(outputs);
        }
Example #16
0
        protected override IList <OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject, out ErrorResultTO allErrors, int update)
        {
            _debugInputs = new List <DebugItem>();
            allErrors    = new ErrorResultTO();
            IList <OutputTO> outputs = new List <OutputTO>();
            var colItr = new WarewolfListIterator();

            var sharepointSource = ResourceCatalog.GetResource <SharepointSource>(dataObject.WorkspaceID, SharepointServerResourceId);

            if (sharepointSource == null)
            {
                sharepointSource           = SharepointSource;
                SharepointServerResourceId = sharepointSource.ResourceID;
            }

            ValidateRequest();

            var serverInputItr = new WarewolfIterator(dataObject.Environment.Eval(ServerInputPath, update));

            colItr.AddVariableToIterateOn(serverInputItr);

            var localInputItr = new WarewolfIterator(dataObject.Environment.Eval(LocalInputPath, update));

            colItr.AddVariableToIterateOn(localInputItr);

            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(ServerInputPath, "ServerInput Path", dataObject.Environment, update);
                AddDebugInputItem(LocalInputPath, "LocalInput Path", dataObject.Environment, update);
            }

            while (colItr.HasMoreData())
            {
                try
                {
                    var serverPath = colItr.FetchNextValue(serverInputItr);
                    var localPath  = colItr.FetchNextValue(localInputItr);

                    if (DataListUtil.IsValueRecordset(Result) && DataListUtil.GetRecordsetIndexType(Result) != enRecordsetIndexType.Numeric)
                    {
                        if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Star)
                        {
                            string recsetName = DataListUtil.ExtractRecordsetNameFromValue(Result);
                            string fieldName  = DataListUtil.ExtractFieldNameFromValue(Result);

                            var newPath = DownLoadFile(sharepointSource, serverPath, localPath);

                            int indexToUpsertTo = 1;

                            foreach (var file in newPath)
                            {
                                string fullRecsetName = DataListUtil.CreateRecordsetDisplayValue(recsetName, fieldName,
                                                                                                 indexToUpsertTo.ToString(CultureInfo.InvariantCulture));
                                outputs.Add(DataListFactory.CreateOutputTO(DataListUtil.AddBracketsToValueIfNotExist(fullRecsetName), file));
                                indexToUpsertTo++;
                            }
                        }
                        else if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Blank)
                        {
                            var newPath = DownLoadFile(sharepointSource, serverPath, localPath);

                            foreach (var folder in newPath)
                            {
                                outputs.Add(DataListFactory.CreateOutputTO(Result, folder));
                            }
                        }
                    }
                    else
                    {
                        var newPath = DownLoadFile(sharepointSource, serverPath, localPath);

                        string xmlList = string.Join(",", newPath.Select(c => c));
                        outputs.Add(DataListFactory.CreateOutputTO(Result));
                        outputs.Last().OutputStrings.Add(xmlList);
                    }
                }
                catch (Exception e)
                {
                    outputs.Add(DataListFactory.CreateOutputTO(null));
                    allErrors.AddError(e.Message);
                    break;
                }
            }

            return(outputs);
        }
Example #17
0
        static void UpdateStarNotationColumns(DebugItem itemToAdd)
        {
            var groups = itemToAdd.ResultsList.Where(a => DataListUtil.IsValueRecordset(a.Variable) && String.IsNullOrEmpty(a.GroupName)).GroupBy(a => DataListUtil.ExtractRecordsetNameFromValue(a.Variable) + DataListUtil.ExtractFieldNameFromValue(a.Variable));

            var maxId = itemToAdd.ResultsList.Count > 0 ? itemToAdd.ResultsList.Max(a => a.GroupIndex) : 0;

            foreach (var g in groups)
            {
                foreach (var res in g)
                {
                    maxId++;
                    res.GroupIndex = maxId;
                    res.GroupName  = "[[" + DataListUtil.ExtractRecordsetNameFromValue(res.Variable) + "()." + DataListUtil.ExtractFieldNameFromValue(res.Variable) + "]]";
                }
            }
        }
Example #18
0
        private void RecordsetGroupName(ref int grpIdx, ref string displayExpression, string rawExpression, ref string groupName)
        {
            grpIdx++;
            groupName = rawExpression;
            var dataLanguageParser = new Dev2DataLanguageParser();
            var vals = dataLanguageParser.ParseForActivityDataItems(_assignedToVariableName);

            if (vals != null)
            {
                foreach (var val in vals)
                {
                    var repVal = DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(val), DataListUtil.ExtractFieldNameFromValue(val), grpIdx.ToString());
                    displayExpression = _assignedToVariableName.Replace(val, repVal);
                }
            }
        }
Example #19
0
        string GetGroupName(string displayExpression, string rawExpression, ref int grpIdx, ref string item, ref string groupName)
        {
            var expr = displayExpression;

            if (displayExpression.Contains("().") || displayExpression.Contains("(*)."))
            {
                grpIdx++;
                var index = grpIdx.ToString(CultureInfo.InvariantCulture);
                if (rawExpression.Contains(".WarewolfPositionColumn"))
                {
                    index = item;
                    item  = "";
                }
                groupName = rawExpression.Replace(".WarewolfPositionColumn", "");
                expr      = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(_variable), DataListUtil.ExtractFieldNameFromValue(_variable), index)).Replace(".WarewolfPositionColumn", "");
            }
            else
            {
                var indexRegionFromRecordset = DataListUtil.ExtractIndexRegionFromRecordset(expr);
                int.TryParse(indexRegionFromRecordset, out int indexForRecset);

                if (indexForRecset > 0)
                {
                    var indexOfOpenningBracket = expr.IndexOf("(", StringComparison.Ordinal) + 1;
                    var group = expr.Substring(0, indexOfOpenningBracket) + "*" + expr.Substring(indexOfOpenningBracket + indexRegionFromRecordset.Length);
                    grpIdx++;
                    groupName = @group;
                }
            }
            return(expr);
        }
        public static string GetJsonOutputFromEnvironment(IDSFDataObject dataObject, Guid workspaceGuid, string dataList)
        {
            var           environment    = dataObject.Environment;
            var           dataListTO     = new DataListTO(dataList);
            StringBuilder result         = new StringBuilder("{");
            var           keyCnt         = 0;
            var           scalarOutputs  = dataListTO.Outputs.Where(s => !DataListUtil.IsValueRecordset(s));
            var           recSetOutputs  = dataListTO.Outputs.Where(DataListUtil.IsValueRecordset);
            var           groupedRecSets = recSetOutputs.GroupBy(DataListUtil.ExtractRecordsetNameFromValue);
            var           recSets        = groupedRecSets as IGrouping <string, string>[] ?? groupedRecSets.ToArray();

            foreach (var groupedRecSet in recSets)
            {
                var i = 0;
                var warewolfListIterators = new WarewolfListIterator();
                Dictionary <string, IWarewolfIterator> iterators = new Dictionary <string, IWarewolfIterator>();
                foreach (var name in groupedRecSet)
                {
                    var warewolfIterator = new WarewolfIterator(environment.Eval(name));
                    iterators.Add(DataListUtil.ExtractFieldNameFromValue(name), warewolfIterator);
                    warewolfListIterators.AddVariableToIterateOn(warewolfIterator);
                }
                result.Append("\"");
                result.Append(groupedRecSet.Key);
                result.Append("\" : [");


                while (warewolfListIterators.HasMoreData())
                {
                    int colIdx = 0;
                    result.Append("{");
                    foreach (var namedIterator in iterators)
                    {
                        var value = warewolfListIterators.FetchNextValue(namedIterator.Value);
                        result.Append("\"");
                        result.Append(namedIterator.Key);
                        result.Append("\":\"");
                        result.Append(value);
                        result.Append("\"");

                        colIdx++;
                        if (colIdx < iterators.Count)
                        {
                            result.Append(",");
                        }
                    }
                    if (warewolfListIterators.HasMoreData())
                    {
                        result.Append("}");
                        result.Append(",");
                    }
                }
                result.Append("}");
                result.Append("]");
                i++;
                if (i < recSets.Count())
                {
                    result.Append(",");
                }
            }

            var scalars = scalarOutputs as string[] ?? scalarOutputs.ToArray();

            foreach (var output in scalars)
            {
                var evalResult = environment.Eval(DataListUtil.AddBracketsToValueIfNotExist(output));
                if (evalResult.IsWarewolfAtomResult)
                {
                    var scalarResult = evalResult as WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomResult;
                    if (scalarResult != null && !scalarResult.Item.IsNothing)
                    {
                        result.Append("\"");
                        result.Append(output);
                        result.Append("\":\"");
                        result.Append(scalarResult.Item);
                        result.Append("\"");
                    }
                }
                keyCnt++;
                if (keyCnt < scalars.Count())
                {
                    result.Append(",");
                }
            }
            var jsonOutputFromEnvironment = result.ToString();

            jsonOutputFromEnvironment += "}";
            return(jsonOutputFromEnvironment);
        }
Example #21
0
        // ReSharper restore RedundantOverridenMember

        /// <summary>
        /// Breaks the InFields and validates they belong to the same recordset ;)
        /// </summary>
        /// <param name="dlId">The dl ID.</param>
        /// <param name="compiler">The compiler.</param>
        /// <param name="token">The token.</param>
        /// <param name="dataObject">The data object.</param>
        /// <param name="evaluateForDebug">if set to <c>true</c> [evaluate for debug].</param>
        /// <param name="errors">The errors.</param>
        /// <param name="rsEntry">The rs entry.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception">Mismatched Recordsets. Encountered {  + rs +  } , but already processed {  + masterRs +  }
        /// or
        /// Invalid field {  + col +  } for recordset {  + masterRs +  }</exception>
        private List <string> BreakAndValidate(Guid dlId, IDataListCompiler compiler, string token, IDSFDataObject dataObject, bool evaluateForDebug, out ErrorResultTO errors, out IBinaryDataListEntry rsEntry)
        {
            var searchFields = DataListCleaningUtils.SplitIntoRegions(token);

            errors  = new ErrorResultTO();
            rsEntry = null;
            var masterRs = string.Empty;

            List <string> toProcessColumns = new List <string>();

            // fish out each column name and validate that all belong to same recordset ;)
            foreach (var entry in searchFields)
            {
                // now validate as a RS in the list and extract the field ;)
                var rs    = DataListUtil.ExtractRecordsetNameFromValue(entry);
                var field = DataListUtil.ExtractFieldNameFromValue(entry);

                if (masterRs != rs && !string.IsNullOrEmpty(masterRs))
                {
                    // an issue has been detected ;(
                    throw new Exception("Mismatched Recordsets. Encountered { " + rs + " } , but already processed { " + masterRs + " }");
                }

                // set the first pass ;)
                if (string.IsNullOrEmpty(masterRs) && !string.IsNullOrEmpty(rs))
                {
                    // set it ;)
                    masterRs = rs;
                }

                // add to column collection ;)
                toProcessColumns.Add(field);
            }

            ErrorResultTO invokeErrors;

            // Now validate each column ;)
            masterRs = DataListUtil.MakeValueIntoHighLevelRecordset(masterRs, true);
            var myRs = DataListUtil.AddBracketsToValueIfNotExist(masterRs);

            rsEntry = compiler.Evaluate(dlId, enActionType.User, myRs, false, out invokeErrors);
            errors.MergeErrors(invokeErrors);

            if (rsEntry != null)
            {
                var cols = rsEntry.Columns;
                foreach (var col in toProcessColumns)
                {
                    if (cols.All(c => c.ColumnName != col))
                    {
                        throw new Exception("Invalid field { " + col + " } for recordset { " + masterRs + " }");
                    }
                }
            }

            if (dataObject.IsDebugMode())
            {
                if (evaluateForDebug)
                {
                    AddDebugInputItem(new DebugItemStaticDataParams("", "In Field(s)"));
                    foreach (var field in searchFields)
                    {
                        // TODO : if EvaluateforDebug
                        if (!string.IsNullOrEmpty(field))
                        {
                            var debugEval = compiler.Evaluate(dlId, enActionType.User, field, false, out invokeErrors);
                            errors.MergeErrors(invokeErrors);
                            if (errors.HasErrors())
                            {
                                AddDebugInputItem(new DebugItemStaticDataParams("", field, ""));
                            }
                            else
                            {
                                AddDebugInputItem(new DebugItemVariableParams(field, "", debugEval, dlId));
                            }
                        }
                    }
                }
                else
                {
                    AddDebugInputItem(DataListUtil.IsEvaluated(token) ? new DebugItemStaticDataParams("", token, "Return Fields") : new DebugItemStaticDataParams(token, "Return Fields"));
                }
            }

            return(toProcessColumns);
        }
        protected override IList <OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject, out ErrorResultTO allErrors, int update)
        {
            IsNotCertVerifiable = true;

            allErrors = new ErrorResultTO();
            IList <OutputTO> outputs = new List <OutputTO>();

            var colItr = new WarewolfListIterator();

            //get all the possible paths for all the string variables
            var inputItr = new WarewolfIterator(dataObject.Environment.Eval(InputPath, update));

            colItr.AddVariableToIterateOn(inputItr);

            var unameItr = new WarewolfIterator(dataObject.Environment.Eval(Username, update));

            colItr.AddVariableToIterateOn(unameItr);

            var passItr = new WarewolfIterator(dataObject.Environment.Eval(DecryptedPassword, update));

            colItr.AddVariableToIterateOn(passItr);

            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(InputPath, "Input Path", dataObject.Environment, update);
                AddDebugInputItem(new DebugItemStaticDataParams(GetReadType().GetDescription(), "Read"));
                AddDebugInputItemUserNamePassword(dataObject.Environment, update);
            }

            while (colItr.HasMoreData())
            {
                IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker();
                IActivityIOPath           ioPath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(inputItr),
                                                                                          colItr.FetchNextValue(unameItr),
                                                                                          colItr.FetchNextValue(passItr),
                                                                                          true);
                IActivityIOOperationsEndPoint endPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ioPath);

                try
                {
                    IList <IActivityIOPath> listOfDir = broker.ListDirectory(endPoint, GetReadType());
                    if (DataListUtil.IsValueRecordset(Result) && DataListUtil.GetRecordsetIndexType(Result) != enRecordsetIndexType.Numeric)
                    {
                        if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Star)
                        {
                            string recsetName = DataListUtil.ExtractRecordsetNameFromValue(Result);
                            string fieldName  = DataListUtil.ExtractFieldNameFromValue(Result);

                            int indexToUpsertTo = 1;
                            if (listOfDir != null)
                            {
                                foreach (IActivityIOPath pa in listOfDir)
                                {
                                    string fullRecsetName = DataListUtil.CreateRecordsetDisplayValue(recsetName, fieldName,
                                                                                                     indexToUpsertTo.ToString(CultureInfo.InvariantCulture));
                                    outputs.Add(DataListFactory.CreateOutputTO(DataListUtil.AddBracketsToValueIfNotExist(fullRecsetName), pa.Path));
                                    indexToUpsertTo++;
                                }
                            }
                        }
                        else if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Blank)
                        {
                            if (listOfDir != null)
                            {
                                foreach (IActivityIOPath pa in listOfDir)
                                {
                                    outputs.Add(DataListFactory.CreateOutputTO(Result, pa.Path));
                                }
                            }
                        }
                    }
                    else
                    {
                        if (listOfDir != null)
                        {
                            string xmlList = string.Join(",", listOfDir.Select(c => c.Path));
                            outputs.Add(DataListFactory.CreateOutputTO(Result));
                            outputs.Last().OutputStrings.Add(xmlList);
                        }
                    }
                }
                catch (Exception e)
                {
                    outputs.Add(DataListFactory.CreateOutputTO(null));
                    allErrors.AddError(e.Message);
                    break;
                }
            }

            return(outputs);
        }
        private void OldValueAtomListResult(List <IDebugItemResult> results)
        {
            var    recSetResult = _oldValue as CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult;
            string groupName    = null;
            int    grpIdx       = 0;

            if (recSetResult != null)
            {
                foreach (var item in recSetResult.Item)
                {
                    string displayExpression = _assignedToVariableName;
                    string rawExpression     = _assignedToVariableName;
                    if (displayExpression.Contains("().") || displayExpression.Contains("(*)."))
                    {
                        grpIdx++;
                        groupName = rawExpression;
                        Dev2DataLanguageParser dataLanguageParser = new Dev2DataLanguageParser();
                        var vals = dataLanguageParser.ParseForActivityDataItems(_assignedToVariableName);
                        if (vals != null)
                        {
                            foreach (var val in vals)
                            {
                                var repVal = DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(val), DataListUtil.ExtractFieldNameFromValue(val), grpIdx.ToString());
                                displayExpression = _assignedToVariableName.Replace(val, repVal);
                            }
                        }
                    }
                    else
                    {
                        string indexRegionFromRecordset = DataListUtil.ExtractIndexRegionFromRecordset(displayExpression);
                        int    indexForRecset;
                        int.TryParse(indexRegionFromRecordset, out indexForRecset);

                        if (indexForRecset > 0)
                        {
                            int    indexOfOpenningBracket = displayExpression.IndexOf("(", StringComparison.Ordinal) + 1;
                            string group = displayExpression.Substring(0, indexOfOpenningBracket) + "*" + displayExpression.Substring(indexOfOpenningBracket + indexRegionFromRecordset.Length);
                            grpIdx++;
                            groupName = @group;
                        }
                    }

                    var debugOperator = "";
                    var debugType     = DebugItemResultType.Value;
                    if (DataListUtil.IsEvaluated(displayExpression))
                    {
                        debugOperator = "=";
                        debugType     = DebugItemResultType.Variable;
                        if (_isCalculate)
                        {
                            displayExpression = groupName ?? displayExpression;
                        }
                    }
                    else
                    {
                        displayExpression = null;
                    }
                    var debugItemResult = new DebugItemResult
                    {
                        Type         = debugType,
                        Label        = _rightLabel,
                        Variable     = DataListUtil.IsEvaluated(displayExpression) ? displayExpression : null,
                        Operator     = debugOperator,
                        GroupName    = groupName,
                        Value        = ExecutionEnvironment.WarewolfAtomToString(item),
                        GroupIndex   = grpIdx,
                        MockSelected = _mockSelected
                    };
                    results.Add(debugItemResult);
                }
            }
        }
        List <IDebugItemResult> BuildDebugItemFromAtomList()
        {
            var results = new List <IDebugItemResult>();

            if (!string.IsNullOrEmpty(_leftLabel))
            {
                string groupName = null;
                int    grpIdx    = 0;
                if (_warewolfAtomListresult != null)
                {
                    foreach (var atomItem in _warewolfAtomListresult.Item)
                    {
                        string displayExpression = _variable;
                        string rawExpression     = _variable;
                        var    item = atomItem.ToString();
                        if (displayExpression.Contains("().") || displayExpression.Contains("(*)."))
                        {
                            grpIdx++;
                            string index = grpIdx.ToString(CultureInfo.InvariantCulture);
                            if (rawExpression.Contains(".WarewolfPositionColumn"))
                            {
                                index = item;
                                item  = "";
                            }
                            groupName = rawExpression.Replace(".WarewolfPositionColumn", "");
                            // ReSharper disable EmptyStatement
                            displayExpression = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(_variable), DataListUtil.ExtractFieldNameFromValue(_variable), index)).Replace(".WarewolfPositionColumn", "");;
                            // ReSharper restore EmptyStatement
                        }
                        else
                        {
                            string indexRegionFromRecordset = DataListUtil.ExtractIndexRegionFromRecordset(displayExpression);
                            int    indexForRecset;
                            int.TryParse(indexRegionFromRecordset, out indexForRecset);

                            if (indexForRecset > 0)
                            {
                                int    indexOfOpenningBracket = displayExpression.IndexOf("(", StringComparison.Ordinal) + 1;
                                string group = displayExpression.Substring(0, indexOfOpenningBracket) + "*" + displayExpression.Substring(indexOfOpenningBracket + indexRegionFromRecordset.Length);
                                grpIdx++;
                                groupName = @group;
                            }
                        }

                        var debugOperator = "";
                        var debugType     = DebugItemResultType.Value;
                        if (DataListUtil.IsEvaluated(displayExpression))
                        {
                            debugOperator = String.IsNullOrEmpty(item)?"": "=";
                            debugType     = DebugItemResultType.Variable;
                        }
                        else
                        {
                            displayExpression = null;
                        }
                        results.Add(new DebugItemResult
                        {
                            Type       = debugType,
                            Label      = _leftLabel,
                            Variable   = DataListUtil.IsEvaluated(displayExpression) ? displayExpression : null,
                            Operator   = debugOperator,
                            GroupName  = groupName,
                            Value      = item,
                            GroupIndex = grpIdx
                        });
                    }
                }
                else
                {
                    results.Add(new DebugItemResult
                    {
                        Type       = DebugItemResultType.Variable,
                        Label      = _leftLabel,
                        Variable   = DataListUtil.IsEvaluated(Variable) ? Variable : null,
                        Operator   = _operand,
                        GroupName  = null,
                        Value      = "",
                        GroupIndex = grpIdx
                    });
                }
            }

            if (!string.IsNullOrEmpty(_rightLabel))
            {
                if (_oldValue != null)
                {
                    if (_oldValue.IsWarewolfAtomResult)
                    {
                        var scalarResult = _oldValue as WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomResult;
                        if (scalarResult != null)
                        {
                            results.Add(new DebugItemResult
                            {
                                Type       = DebugItemResultType.Variable,
                                Label      = _rightLabel,
                                Variable   = DataListUtil.IsEvaluated(_assignedToVariableName) ? _assignedToVariableName : null,
                                Operator   = string.IsNullOrEmpty(_operand) ? "" : "=",
                                GroupName  = null,
                                Value      = ExecutionEnvironment.WarewolfAtomToString(scalarResult.Item),
                                GroupIndex = 0
                            });
                        }
                    }
                    else if (_oldValue.IsWarewolfAtomListresult)
                    {
                        var    recSetResult = _oldValue as WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomListresult;
                        string groupName    = null;
                        int    grpIdx       = 0;
                        if (recSetResult != null)
                        {
                            foreach (var item in recSetResult.Item)
                            {
                                string displayExpression = _assignedToVariableName;
                                string rawExpression     = _assignedToVariableName;
                                if (displayExpression.Contains("().") || displayExpression.Contains("(*)."))
                                {
                                    grpIdx++;
                                    groupName         = rawExpression;
                                    displayExpression = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(_assignedToVariableName), DataListUtil.ExtractFieldNameFromValue(_assignedToVariableName), grpIdx.ToString()));
                                }
                                else
                                {
                                    string indexRegionFromRecordset = DataListUtil.ExtractIndexRegionFromRecordset(displayExpression);
                                    int    indexForRecset;
                                    int.TryParse(indexRegionFromRecordset, out indexForRecset);

                                    if (indexForRecset > 0)
                                    {
                                        int    indexOfOpenningBracket = displayExpression.IndexOf("(", StringComparison.Ordinal) + 1;
                                        string group = displayExpression.Substring(0, indexOfOpenningBracket) + "*" + displayExpression.Substring(indexOfOpenningBracket + indexRegionFromRecordset.Length);
                                        grpIdx++;
                                        groupName = @group;
                                    }
                                }

                                var debugOperator = "";
                                var debugType     = DebugItemResultType.Value;
                                if (DataListUtil.IsEvaluated(displayExpression))
                                {
                                    debugOperator = "=";
                                    debugType     = DebugItemResultType.Variable;
                                }
                                else
                                {
                                    displayExpression = null;
                                }
                                var debugItemResult = new DebugItemResult
                                {
                                    Type       = debugType,
                                    Label      = _rightLabel,
                                    Variable   = DataListUtil.IsEvaluated(displayExpression) ? displayExpression : null,
                                    Operator   = debugOperator,
                                    GroupName  = groupName,
                                    Value      = ExecutionEnvironment.WarewolfAtomToString(item),
                                    GroupIndex = grpIdx
                                };
                                results.Add(debugItemResult);
                            }
                        }
                    }
                }
                if (_oldValue == null)
                {
                    var debugItemResult = new DebugItemResult
                    {
                        Type       = DebugItemResultType.Variable,
                        Label      = _rightLabel,
                        Variable   = null,
                        Operator   = "=",
                        GroupName  = null,
                        Value      = _newValue,
                        GroupIndex = 0
                    };
                    results.Add(debugItemResult);
                }
            }

            if (string.IsNullOrEmpty(_rightLabel) && string.IsNullOrEmpty(_leftLabel))
            {
                string groupName = null;
                int    grpIdx    = 0;
                if (_warewolfAtomListresult != null)
                {
                    foreach (var item in _warewolfAtomListresult.Item)
                    {
                        string displayExpression = _variable;
                        string rawExpression     = _variable;
                        if (displayExpression.Contains("().") || displayExpression.Contains("(*)."))
                        {
                            grpIdx++;
                            groupName         = rawExpression;
                            displayExpression = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(_variable), DataListUtil.ExtractFieldNameOnlyFromValue(DataListUtil.AddBracketsToValueIfNotExist(_variable)), grpIdx.ToString()));

                            if (DataListUtil.GetRecordsetIndexType(_variable) == enRecordsetIndexType.Star)
                            {
                                displayExpression += _variable.Replace(DataListUtil.ReplaceRecordsetIndexWithStar(displayExpression), "");
                            }
                            else if (DataListUtil.GetRecordsetIndexType(_variable) == enRecordsetIndexType.Blank)
                            {
                                displayExpression += _variable.Replace(DataListUtil.ReplaceRecordsetIndexWithBlank(displayExpression), "");
                            }
                        }
                        else
                        {
                            string indexRegionFromRecordset = DataListUtil.ExtractIndexRegionFromRecordset(displayExpression);
                            int    indexForRecset;
                            int.TryParse(indexRegionFromRecordset, out indexForRecset);

                            if (indexForRecset > 0)
                            {
                                int    indexOfOpenningBracket = displayExpression.IndexOf("(", StringComparison.Ordinal) + 1;
                                string group = displayExpression.Substring(0, indexOfOpenningBracket) + "*" + displayExpression.Substring(indexOfOpenningBracket + indexRegionFromRecordset.Length);
                                grpIdx++;
                                groupName = @group;
                            }
                        }

                        var debugOperator = "";
                        var debugType     = DebugItemResultType.Value;
                        if (DataListUtil.IsEvaluated(displayExpression))
                        {
                            debugOperator = "=";
                            debugType     = DebugItemResultType.Variable;
                        }
                        else
                        {
                            displayExpression = null;
                        }
                        results.Add(new DebugItemResult
                        {
                            Type       = debugType,
                            Variable   = DataListUtil.IsEvaluated(displayExpression) ? displayExpression : null,
                            Operator   = debugOperator,
                            GroupName  = groupName,
                            Value      = ExecutionEnvironment.WarewolfAtomToString(item),
                            GroupIndex = grpIdx
                        });
                    }
                }
                else
                {
                    results.Add(new DebugItemResult
                    {
                        Type       = DebugItemResultType.Variable,
                        Variable   = DataListUtil.IsEvaluated(Variable) ? Variable : null,
                        Operator   = _operand,
                        GroupName  = null,
                        Value      = "",
                        GroupIndex = grpIdx
                    });
                }
            }
            return(results);
        }
        IList <IDebugItemResult> CreateRecordsetDebugItems(string expression, IBinaryDataListEntry dlEntry, string value, int iterCnt, string labelText)
        {
            var results = new List <IDebugItemResult>();

            if (dlEntry.ComplexExpressionAuditor == null)
            {
                string initExpression = expression;

                string fieldName = DataListUtil.ExtractFieldNameFromValue(expression);
                enRecordsetIndexType indexType = DataListUtil.GetRecordsetIndexType(expression);
                if (indexType == enRecordsetIndexType.Blank && string.IsNullOrEmpty(fieldName))
                {
                    indexType = enRecordsetIndexType.Star;
                }
                if (indexType == enRecordsetIndexType.Star || indexType == enRecordsetIndexType.Numeric)
                {
                    IIndexIterator idxItr = dlEntry.FetchRecordsetIndexes();
                    while (idxItr.HasMore())
                    {
                        GetValues(dlEntry, value, iterCnt, idxItr, indexType, results, initExpression, labelText, fieldName);
                    }
                }
            }
            else
            {
                // Complex expressions are handled differently ;)
                ComplexExpressionAuditor auditor   = dlEntry.ComplexExpressionAuditor;
                enRecordsetIndexType     indexType = DataListUtil.GetRecordsetIndexType(expression);

                foreach (ComplexExpressionAuditItem item in auditor.FetchAuditItems())
                {
                    int grpIdx = -1;

                    try
                    {
                        grpIdx = Int32.Parse(DataListUtil.ExtractIndexRegionFromRecordset(item.TokenBinding));
                    }
                    // ReSharper disable EmptyGeneralCatchClause
                    catch (Exception)
                    // ReSharper restore EmptyGeneralCatchClause
                    {
                        // Best effort ;)
                    }

                    if (indexType == enRecordsetIndexType.Star)
                    {
                        string displayExpression = item.Expression.Replace(item.Token, item.RawExpression);
                        results.Add(new DebugItemResult {
                            Type = DebugItemResultType.Variable, Value = displayExpression, GroupName = displayExpression, GroupIndex = grpIdx
                        });
                        results.Add(new DebugItemResult {
                            Type = DebugItemResultType.Label, Value = GlobalConstants.EqualsExpression, GroupName = displayExpression, GroupIndex = grpIdx
                        });
                        results.Add(new DebugItemResult {
                            Type = DebugItemResultType.Value, Value = item.BoundValue, GroupName = displayExpression, GroupIndex = grpIdx
                        });
                    }
                }
            }

            return(results);
        }
        public List <IDebugItemResult> CreateDebugItemsFromEntry(string expression, IBinaryDataListEntry dlEntry, Guid dlId, enDev2ArgumentType argumentType, string labelText, int indexToUse = -1)
        {
            var results = new List <IDebugItemResult>();
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            IBinaryDataList   dataList = compiler.FetchBinaryDataList(dlId, out ErrorsTo);

            if (
                !(expression.Contains(GlobalConstants.CalculateTextConvertPrefix) &&
                  expression.Contains(GlobalConstants.CalculateTextConvertSuffix)))
            {
                if (!expression.ContainsSafe("[["))
                {
                    results.Add(new DebugItemResult
                    {
                        Label = labelText,
                        Type  = DebugItemResultType.Value,
                        Value = expression
                    });
                    return(results);
                }
            }
            else
            {
                expression =
                    expression.Replace(GlobalConstants.CalculateTextConvertPrefix, string.Empty)
                    .Replace(GlobalConstants.CalculateTextConvertSuffix, string.Empty);
            }

            if (dlEntry != null && dlEntry.ComplexExpressionAuditor == null)
            {
                int groupIndex = 0;
                enRecordsetIndexType rsType = DataListUtil.GetRecordsetIndexType(expression);

                if (dlEntry.IsRecordset &&
                    (DataListUtil.IsValueRecordset(expression) &&
                     (rsType == enRecordsetIndexType.Star ||
                      (rsType == enRecordsetIndexType.Numeric &&
                       DataListUtil.ExtractFieldNameFromValue(expression) == string.Empty) ||
                      (rsType == enRecordsetIndexType.Blank &&
                       DataListUtil.ExtractFieldNameFromValue(expression) == string.Empty))))
                {
                    // Added IsEmpty check for Bug 9263 ;)
                    if (!dlEntry.IsEmpty())
                    {
                        IList <IDebugItemResult> collection = CreateRecordsetDebugItems(expression, dlEntry, string.Empty,
                                                                                        -1, labelText);
                        if (collection.Count < 2 && collection.Count > 0)
                        {
                            collection[0].GroupName = "";
                        }
                        results.AddRange(collection);
                    }
                    else
                    {
                        results.Add(new DebugItemResult
                        {
                            Type     = DebugItemResultType.Variable,
                            Label    = labelText,
                            Variable = expression,
                            Operator = string.IsNullOrEmpty(expression) ? "" : "=",
                            Value    = "",
                        });
                    }
                }
                else
                {
                    if (DataListUtil.IsValueRecordset(expression) &&
                        (DataListUtil.GetRecordsetIndexType(expression) == enRecordsetIndexType.Blank))
                    {
                        if (indexToUse == -1)
                        {
                            IBinaryDataListEntry tmpEntry;
                            string error;
                            dataList.TryGetEntry(DataListUtil.ExtractRecordsetNameFromValue(expression),
                                                 out tmpEntry, out error);
                            if (tmpEntry != null)
                            {
                                int index = tmpEntry.FetchAppendRecordsetIndex() - 1;
                                if (index > 0)
                                {
                                    groupIndex = index;
                                    expression = expression.Replace("().", string.Concat("(", index, ")."));
                                }
                            }
                        }
                        else
                        {
                            expression = expression.Replace("().", string.Concat("(", indexToUse, ")."));
                        }
                    }

                    if (dlEntry.IsRecordset)
                    {
                        var strIndx = DataListUtil.ExtractIndexRegionFromRecordset(expression);
                        int indx;
                        if (int.TryParse(strIndx, out indx))
                        {
                            if (indx > 0)
                            {
                                IBinaryDataListItem item = dlEntry.FetchScalar();
                                try
                                {
                                    CreateScalarDebugItems(expression, item.TheValue, labelText, results, "", groupIndex);
                                }
                                catch (NullValueInVariableException)
                                {
                                    CreateScalarDebugItems(expression, "", labelText, results, "", groupIndex);
                                }
                            }
                            else
                            {
                                CreateScalarDebugItems(expression, "", labelText, results, "", groupIndex);
                            }
                        }
                        else
                        {
                            IBinaryDataListItem itemx = dlEntry.FetchScalar();

                            if (!string.IsNullOrEmpty(strIndx))
                            {
                                IBinaryDataListEntry indexBinaryEntry;
                                IBinaryDataListItem  indexItem = null;
                                string error;
                                if (DataListUtil.IsValueRecordset(strIndx))
                                {
                                    dataList.TryGetEntry(DataListUtil.ExtractRecordsetNameFromValue(strIndx),
                                                         out indexBinaryEntry, out error);
                                    var fieldName = DataListUtil.ExtractFieldNameFromValue(strIndx);
                                    int index;
                                    if (int.TryParse(DataListUtil.ExtractIndexRegionFromRecordset(strIndx), out index))
                                    {
                                        indexItem = indexBinaryEntry.TryFetchRecordsetColumnAtIndex(fieldName, index, out error);
                                    }
                                }
                                else
                                {
                                    dataList.TryGetEntry(strIndx, out indexBinaryEntry, out error);
                                    indexItem = indexBinaryEntry.FetchScalar();
                                }
                                if (indexItem != null)
                                {
                                    expression = expression.Replace(string.Format("({0})", strIndx), string.Format("({0})", indexItem.TheValue));
                                }
                            }

                            try
                            {
                                CreateScalarDebugItems(expression, itemx.TheValue, labelText, results, "", groupIndex);
                            }
// ReSharper disable EmptyGeneralCatchClause
                            catch (Exception)
// ReSharper restore EmptyGeneralCatchClause
                            {
                            }
                        }
                    }
                    else
                    {
                        IBinaryDataListItem item = dlEntry.FetchScalar();
                        try
                        {
                            CreateScalarDebugItems(expression, item.TheValue, labelText, results, "", groupIndex);
                        }
                        catch (Exception)
                        {
                            CreateScalarDebugItems(expression, null, labelText, results, "", groupIndex);
                        }
                    }
                }
            }
            else
            {
                // Complex expressions are handled differently ;)
                if (dlEntry != null)
                {
                    ComplexExpressionAuditor auditor = dlEntry.ComplexExpressionAuditor;

                    int idx = 1;

                    foreach (ComplexExpressionAuditItem item in auditor.FetchAuditItems())
                    {
                        int    grpIdx            = idx;
                        string groupName         = item.RawExpression;
                        string displayExpression = item.RawExpression;
                        if (displayExpression.Contains("()."))
                        {
                            displayExpression = displayExpression.Replace("().",
                                                                          string.Concat("(", auditor.GetMaxIndex(), ")."));
                        }
                        if (displayExpression.Contains("(*)."))
                        {
                            displayExpression = displayExpression.Replace("(*).", string.Concat("(", idx, ")."));
                        }

                        results.Add(new DebugItemResult
                        {
                            Type       = DebugItemResultType.Variable,
                            Label      = labelText,
                            Variable   = displayExpression,
                            Operator   = string.IsNullOrEmpty(displayExpression) ? "" : "=",
                            GroupName  = groupName,
                            Value      = item.BoundValue,
                            GroupIndex = grpIdx
                        });

                        idx++;
                    }
                }
            }

            return(results);
        }
Example #27
0
        /// <summary>
        /// Creates the mapping list.
        /// </summary>
        /// <param name="mappingDefinitions">The mapping definitions.</param>
        /// <param name="parser">The parser.</param>
        /// <param name="autoAddBrackets">if set to <c>true</c> [automatic add brackets].</param>
        /// <param name="isOutputMapping">if set to <c>true</c> [is output mapping].</param>
        /// <param name="fuzzyMatch">The fuzzy match.</param>
        /// <returns></returns>
        private IList <IInputOutputViewModel> CreateMappingList(string mappingDefinitions, IDev2LanguageParser parser, bool autoAddBrackets, bool isOutputMapping, FuzzyMatchVo fuzzyMatch = null)
        {
            IList <IInputOutputViewModel> result = new List <IInputOutputViewModel>();
            IList <IDev2Definition>       concreteDefinitions = parser.ParseAndAllowBlanks(mappingDefinitions);


            var masterRecordsetName = string.Empty;

            foreach (var def in concreteDefinitions)
            {
                var injectValue = def.RawValue;

                if (!string.IsNullOrEmpty(injectValue) || IsWorkflow)
                {
                    if (autoAddBrackets)
                    {
                        // When output mapping we need to replace the recordset name if present with MasterRecordset
                        //
                        if (isOutputMapping && def.IsRecordSet && fuzzyMatch != null)
                        {
                            var field = DataListUtil.ExtractFieldNameFromValue(injectValue);

                            if (IsWorkflow)
                            {
                                field = def.Name;
                            }

                            string recordsetName = fuzzyMatch.FetchMatch(def.Name, def.RecordSetName);
                            if (!string.IsNullOrEmpty(recordsetName))
                            {
                                masterRecordsetName = recordsetName;
                            }
                            else
                            {
                                // we have no match, use the current mapping value ;)
                                masterRecordsetName = !IsWorkflow?DataListUtil.ExtractRecordsetNameFromValue(injectValue) : def.RecordSetName;
                            }


                            injectValue = FormatString(masterRecordsetName, field);
                        }
                        else
                        {
                            if (def.IsRecordSet)
                            {
                                if (fuzzyMatch != null)
                                {
                                    string recordsetName = fuzzyMatch.FetchMatch(def.Name, def.RecordSetName);
                                    masterRecordsetName = !String.IsNullOrEmpty(recordsetName) ? recordsetName : def.RecordSetName;
                                }
                                else
                                {
                                    masterRecordsetName = def.RecordSetName;
                                }

                                injectValue = FormatString(masterRecordsetName, def.Name);
                            }
                            else
                            {
                                injectValue = DataListUtil.AddBracketsToValueIfNotExist(!IsWorkflow ? injectValue : def.Name);
                            }
                        }
                    }
                }
                else
                {
                    if (!def.IsRecordSet)
                    {
                        if (!String.IsNullOrEmpty(def.RawValue) && String.IsNullOrEmpty(SavedInputMapping))
                        {
                            injectValue = DataListUtil.AddBracketsToValueIfNotExist(def.Name);
                        }
                    }
                    else
                    {
                        if (!isOutputMapping)
                        {
                            var field = def.Name;

                            if (fuzzyMatch != null && def.IsRecordSet)
                            {
                                if (string.IsNullOrEmpty(masterRecordsetName))
                                {
                                    string recordsetName = fuzzyMatch.FetchMatch(def.Name, def.RecordSetName);
                                    masterRecordsetName = !string.IsNullOrEmpty(recordsetName) ? recordsetName : def.RecordSetName;
                                }

                                injectValue = DataListUtil.ComposeIntoUserVisibleRecordset(masterRecordsetName,
                                                                                           string.Empty, field);
                                injectValue = DataListUtil.AddBracketsToValueIfNotExist(injectValue);
                            }
                            else
                            {
                                if (!String.IsNullOrEmpty(def.RawValue) && String.IsNullOrEmpty(SavedInputMapping))
                                {
                                    injectValue = FormatString(def.RecordSetName, def.Name);
                                }
                            }
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(def.RawValue) && String.IsNullOrEmpty(SavedOutputMapping))
                            {
                                injectValue = FormatString(def.RecordSetName, def.Name);
                            }
                        }
                    }
                }

                var injectMapsTo = def.MapsTo;

                // no saved mappings add brackets ;)
                if (!string.IsNullOrEmpty(injectMapsTo) && string.IsNullOrEmpty(SavedInputMapping))
                {
                    injectMapsTo = DataListUtil.AddBracketsToValueIfNotExist(injectMapsTo);
                }
                else
                {
                    if (def.IsRecordSet)
                    {
                        var tmp = injectValue.Replace("()", "(*)");
                        injectMapsTo = tmp; // tag it as the same ;)
                    }
                    else
                    {
                        injectMapsTo = injectValue; // tag it as the same ;)
                    }
                }

                // def.RecordSetName -> recordsetName
                var viewModel = new InputOutputViewModel(def.Name, injectValue, injectMapsTo, def.DefaultValue, def.IsRequired, def.RecordSetName, def.EmptyToNull);

                result.Add(viewModel);
            }

            return(result);
        }
 static string GetFieldName(DataColumnMapping dc)
 {
     return(string.IsNullOrEmpty(dc.InputColumn) ? string.Empty : DataListUtil.ExtractFieldNameFromValue(dc.InputColumn));
 }
        private void ExecuteConcreteAction(IList <OutputTO> outputs, WarewolfListIterator colItr, SharepointSource sharepointSource, WarewolfIterator inputItr)
        {
            var path = colItr.FetchNextValue(inputItr);

            if (DataListUtil.IsValueRecordset(Result) && DataListUtil.GetRecordsetIndexType(Result) != enRecordsetIndexType.Numeric)
            {
                if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Star)
                {
                    var recsetName = DataListUtil.ExtractRecordsetNameFromValue(Result);
                    var fieldName  = DataListUtil.ExtractFieldNameFromValue(Result);

                    if (IsFoldersSelected)
                    {
                        AddAllFolders(outputs, sharepointSource, path, recsetName, fieldName);
                    }
                    if (IsFilesSelected)
                    {
                        AddAllFiles(outputs, sharepointSource, path, recsetName, fieldName);
                    }

                    if (IsFilesAndFoldersSelected)
                    {
                        AddAllFilesAndFolders(outputs, sharepointSource, path, recsetName, fieldName);
                    }
                }
                else
                {
                    AddBlankIndexDebugOutputs(outputs, sharepointSource, path);
                }
            }
            else
            {
                if (IsFoldersSelected)
                {
                    var folders = GetSharePointFolders(sharepointSource, path);

                    var xmlList = string.Join(",", folders.Select(c => c));
                    outputs.Add(DataListFactory.CreateOutputTO(Result));
                    outputs.Last().OutputStrings.Add(xmlList);
                }
                if (IsFilesSelected)
                {
                    var files = GetSharePointFiles(sharepointSource, path);

                    var xmlList = string.Join(",", files.Select(c => c));
                    outputs.Add(DataListFactory.CreateOutputTO(Result));
                    outputs.Last().OutputStrings.Add(xmlList);
                }

                if (IsFilesAndFoldersSelected)
                {
                    var folderAndPathList = new List <string>();
                    folderAndPathList.AddRange(GetSharePointFiles(sharepointSource, path));
                    folderAndPathList.AddRange(GetSharePointFolders(sharepointSource, path));

                    var xmlList = string.Join(",", folderAndPathList.Select(c => c));
                    outputs.Add(DataListFactory.CreateOutputTO(Result));
                    outputs.Last().OutputStrings.Add(xmlList);
                }
            }
        }
        public static string GetXmlInputFromEnvironment(IDSFDataObject dataObject, Guid workspaceGuid, string dataList)
        {
            var           environment    = dataObject.Environment;
            var           dataListTO     = new DataListTO(dataList);
            StringBuilder result         = new StringBuilder("<" + "DataList" + ">");
            var           scalarOutputs  = dataListTO.Inputs.Where(s => !DataListUtil.IsValueRecordset(s));
            var           recSetOutputs  = dataListTO.Inputs.Where(DataListUtil.IsValueRecordset);
            var           groupedRecSets = recSetOutputs.GroupBy(DataListUtil.ExtractRecordsetNameFromValue);

            foreach (var groupedRecSet in groupedRecSets)
            {
                var i = 1;
                var warewolfListIterators = new WarewolfListIterator();
                Dictionary <string, IWarewolfIterator> iterators = new Dictionary <string, IWarewolfIterator>();
                foreach (var name in groupedRecSet)
                {
                    var warewolfIterator = new WarewolfIterator(environment.Eval(name));
                    iterators.Add(DataListUtil.ExtractFieldNameFromValue(name), warewolfIterator);
                    warewolfListIterators.AddVariableToIterateOn(warewolfIterator);
                }
                while (warewolfListIterators.HasMoreData())
                {
                    result.Append("<");
                    result.Append(groupedRecSet.Key);
                    result.Append(string.Format(" Index=\"{0}\">", i));
                    foreach (var namedIterator in iterators)
                    {
                        var value = warewolfListIterators.FetchNextValue(namedIterator.Value);
                        result.Append("<");
                        result.Append(namedIterator.Key);
                        result.Append(">");
                        result.Append(value);
                        result.Append("</");
                        result.Append(namedIterator.Key);
                        result.Append(">");
                    }
                    result.Append("</");
                    result.Append(groupedRecSet.Key);
                    result.Append(">");
                    i++;
                }
            }


            foreach (var output in scalarOutputs)
            {
                var evalResult = environment.Eval(DataListUtil.AddBracketsToValueIfNotExist(output));
                if (evalResult.IsWarewolfAtomResult)
                {
                    var scalarResult = evalResult as WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomResult;
                    if (scalarResult != null && !scalarResult.Item.IsNothing)
                    {
                        result.Append("<");
                        result.Append(output);
                        result.Append(">");
                        result.Append(scalarResult.Item);
                        result.Append("</");
                        result.Append(output);
                        result.Append(">");
                    }
                }
            }

            result.Append("</" + "DataList" + ">");


            return(result.ToString());
        }