Example #1
0
 private 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);
                     UpdateForRecordset(dataObject, update, recSets, c);
                     UpdateForScalars(dataObject, update, scalars, c);
                 }
                 else
                 {
                     if (level == 0)
                     {
                         TryConvert(dataObject, c.ChildNodes, inputDefs, update, ++level);
                     }
                 }
             }
         }
     }
     finally
     {
         dataObject.Environment.CommitAssign();
     }
 }
Example #2
0
        private static void PerformRecordsetUpdate(IDSFDataObject dataObject, JToken value, bool isValueRecordset, string input, List <string> recSets, string inputName, List <string> processedRecsets)
        {
            var arrayValue = value as JArray;

            if (!isValueRecordset)
            {
                dataObject.Environment.AddToJsonObjects(DataListUtil.AddBracketsToValueIfNotExist("@" + input + "()"), arrayValue);
            }
            else
            {
                if (arrayValue != null)
                {
                    for (int i = 0; i < arrayValue.Count; i++)
                    {
                        var val    = arrayValue[i];
                        var valObj = val as JObject;
                        if (valObj != null)
                        {
                            var recs = recSets.Where(s => DataListUtil.ExtractRecordsetNameFromValue(s) == inputName);
                            foreach (var rec in recs)
                            {
                                var field     = DataListUtil.ExtractFieldNameOnlyFromValue(rec);
                                var fieldProp = valObj.Properties().FirstOrDefault(property => property.Name == field);
                                if (fieldProp != null)
                                {
                                    dataObject.Environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(rec), fieldProp.Value.ToString(), i + 1);
                                }
                            }
                        }
                    }
                    processedRecsets.Add(inputName);
                }
            }
        }
Example #3
0
 private static void AddRecordsetsOutputs(IEnumerable <IServiceTestOutput> recSets, IExecutionEnvironment environment)
 {
     if (recSets != null)
     {
         var groupedRecsets = recSets.GroupBy(item => DataListUtil.ExtractRecordsetNameFromValue(item.Variable));
         foreach (var groupedRecset in groupedRecsets)
         {
             var dataListItems = groupedRecset.GroupBy(item => DataListUtil.ExtractIndexRegionFromRecordset(item.Variable));
             foreach (var dataListItem in dataListItems)
             {
                 List <IServiceTestOutput> recSetsToAssign = new List <IServiceTestOutput>();
                 var empty = true;
                 foreach (var listItem in dataListItem)
                 {
                     if (!string.IsNullOrEmpty(listItem.Value))
                     {
                         empty = false;
                     }
                     recSetsToAssign.Add(listItem);
                 }
                 if (!empty)
                 {
                     foreach (var serviceTestInput in recSetsToAssign)
                     {
                         environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(serviceTestInput.Variable), serviceTestInput.Value, 0);
                     }
                 }
             }
         }
     }
 }
        private void TryExecuteTool(IDSFDataObject dataObject, int update, ErrorResultTO allErrors)
        {
            var rs = DataListUtil.ExtractRecordsetNameFromValue(RecordsetName);

            if (CountNumber == string.Empty)
            {
                allErrors.AddError(ErrorResource.BlankResultVariable);
            }
            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(new DebugEvalResult(dataObject.Environment.ToStar(RecordsetName), "Recordset", dataObject.Environment, update));
            }
            var rule   = new IsSingleValueRule(() => CountNumber);
            var single = rule.Check();

            if (single != null)
            {
                allErrors.AddError(single.Message);
            }
            else
            {
                if (dataObject.Environment.HasRecordSet(RecordsetName))
                {
                    var count = dataObject.Environment.GetCount(rs);
                    var value = count.ToString();
                    dataObject.Environment.Assign(CountNumber, value, update);
                    AddDebugOutputItem(new DebugEvalResult(CountNumber, "", dataObject.Environment, update));
                }
                else
                {
                    allErrors.AddError(String.Format(ErrorResource.NullRecordSet, RecordsetName));
                }
            }
        }
Example #5
0
        public static IList <IDev2Definition> CreateScalarList(IList <IDev2Definition> parsedOutput, bool isOutput)
        {
            IList <IDev2Definition> result = new List <IDev2Definition>();

            foreach (IDev2Definition def in parsedOutput)
            {
                if (isOutput)
                {
                    var rsName = DataListUtil.ExtractRecordsetNameFromValue(def.Value);

                    if (!def.IsRecordSet && string.IsNullOrEmpty(rsName))
                    {
                        result.Add(def);
                    }
                }
                else
                {
                    var rsName = DataListUtil.ExtractRecordsetNameFromValue(def.Name);

                    if (!def.IsRecordSet && string.IsNullOrEmpty(rsName))
                    {
                        result.Add(def);
                    }
                }
            }

            return(result);
        }
        /// <summary>
        /// Converts the a data lang fragment to top level rs notation.
        /// </summary>
        /// <param name="val">The value.</param>
        /// <returns></returns>
        public static string ConvertToTopLevelRSNotation(string val)
        {
            var text = val;

            if (!String.IsNullOrEmpty(text))
            {
                var idxType = DataListUtil.GetRecordsetIndexType(text);

                // extract name if fields where entered
                text = DataListUtil.ExtractRecordsetNameFromValue(text);

                // must be in scalar format, use it and conver to RS notation
                if (string.IsNullOrEmpty(text))
                {
                    text = val;
                }

                // convert to rs notation already ;)
                text = DataListUtil.MakeValueIntoHighLevelRecordset(text);

                // finally add brackets if required ;)
                text = DataListUtil.AddBracketsToValueIfNotExist(text);

                // be nice about it and keep the star if they put it there ;)
                if (idxType == enRecordsetIndexType.Star)
                {
                    text = text.Replace("()", "(*)");
                }

                return(text);
            }

            return(string.Empty);
        }
Example #7
0
        static void ProcessRecordsetInputs(IServiceTestModelTO serviceTestModelTO, IDev2Definition dev2Definition)
        {
            var rec     = DataListUtil.CreateRecordsetDisplayValue(dev2Definition.RecordSetName, dev2Definition.Name, "");
            var indexes = serviceTestModelTO.Inputs.Where(input => DataListUtil.ExtractRecordsetNameFromValue(input.Variable) == dev2Definition.RecordSetName).Select(input => DataListUtil.ExtractIndexRegionFromRecordset(input.Variable)).Distinct(StringComparer.OrdinalIgnoreCase).ToList();

            if (serviceTestModelTO.Inputs.FirstOrDefault(input => DataListUtil.ReplaceRecordsetIndexWithBlank(input.Variable) == rec) == null)
            {
                if (indexes.Count == 0)
                {
                    serviceTestModelTO.Inputs.Add(new ServiceTestInputTO
                    {
                        Variable    = DataListUtil.CreateRecordsetDisplayValue(dev2Definition.RecordSetName, dev2Definition.Name, "1"),
                        Value       = "",
                        EmptyIsNull = false
                    });
                }
                else
                {
                    foreach (var index in indexes)
                    {
                        serviceTestModelTO.Inputs.Add(new ServiceTestInputTO
                        {
                            Variable    = DataListUtil.CreateRecordsetDisplayValue(dev2Definition.RecordSetName, dev2Definition.Name, index),
                            Value       = "",
                            EmptyIsNull = false
                        });
                    }
                }
            }
        }
Example #8
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 #9
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();
     }
 }
 public DebugEvalResult(string inputVariable, string label, IExecutionEnvironment environment, bool isDataMerge = false)
 {
     _inputVariable = inputVariable.Trim();
     _label         = label;
     try
     {
         if (ExecutionEnvironment.IsRecordsetIdentifier(_inputVariable) && DataListUtil.IsEvaluated(_inputVariable))
         {
             if (DataListUtil.GetRecordsetIndexType(_inputVariable) == enRecordsetIndexType.Blank)
             {
                 var length = environment.GetLength(DataListUtil.ExtractRecordsetNameFromValue(_inputVariable));
                 _inputVariable = DataListUtil.ReplaceRecordsetBlankWithIndex(_inputVariable, length);
             }
         }
         if (isDataMerge)
         {
             var evalForDataMerge = environment.EvalForDataMerge(_inputVariable);
             var innerIterator    = new WarewolfListIterator();
             var innerListOfIters = new List <WarewolfIterator>();
             foreach (var listOfIterator in evalForDataMerge)
             {
                 var inIterator = new WarewolfIterator(listOfIterator);
                 innerIterator.AddVariableToIterateOn(inIterator);
                 innerListOfIters.Add(inIterator);
             }
             var atomList = new List <DataASTMutable.WarewolfAtom>();
             while (innerIterator.HasMoreData())
             {
                 var stringToUse = "";
                 // ReSharper disable once LoopCanBeConvertedToQuery
                 foreach (var warewolfIterator in innerListOfIters)
                 {
                     stringToUse += warewolfIterator.GetNextValue();
                 }
                 atomList.Add(DataASTMutable.WarewolfAtom.NewDataString(stringToUse));
             }
             var finalString = string.Join("", atomList);
             _evalResult = WarewolfDataEvaluationCommon.WarewolfEvalResult.NewWarewolfAtomListresult(new WarewolfAtomList <DataASTMutable.WarewolfAtom>(DataASTMutable.WarewolfAtom.Nothing, atomList));
             if (DataListUtil.IsFullyEvaluated(finalString))
             {
                 _inputVariable = finalString;
                 _evalResult    = environment.Eval(finalString);
             }
         }
         else
         {
             var evalToExpression = environment.EvalToExpression(_inputVariable);
             if (DataListUtil.IsEvaluated(evalToExpression))
             {
                 _inputVariable = evalToExpression;
             }
             _evalResult = environment.Eval(_inputVariable);
         }
     }
     catch (Exception e)
     {
         Dev2Logger.Log.Error(e.Message, e);
         _evalResult = WarewolfDataEvaluationCommon.WarewolfEvalResult.NewWarewolfAtomResult(DataASTMutable.WarewolfAtom.Nothing);
     }
 }
Example #11
0
        public DebugEvalResult(string inputVariable, string label, IExecutionEnvironment environment, int update, bool isDataMerge, bool isCalculate, bool mockSelected)
        {
            _inputVariable = inputVariable?.Trim();
            LabelText      = label;
            _isCalculate   = isCalculate;
            MockSelected   = mockSelected;
            try
            {
                if (ExecutionEnvironment.IsRecordsetIdentifier(_inputVariable) && DataListUtil.IsEvaluated(_inputVariable) && DataListUtil.GetRecordsetIndexType(_inputVariable) == enRecordsetIndexType.Blank)
                {
                    var length = environment.GetLength(DataListUtil.ExtractRecordsetNameFromValue(_inputVariable));
                    _inputVariable = DataListUtil.ReplaceRecordsetBlankWithIndex(_inputVariable, length);
                }

                if (isDataMerge)
                {
                    DataMergeItem(environment, update);
                }
                else
                {
                    RegularItem(environment, update, isCalculate);
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Error(e.Message, e, GlobalConstants.WarewolfError);
                _evalResult = CommonFunctions.WarewolfEvalResult.NewWarewolfAtomResult(DataStorage.WarewolfAtom.Nothing);
            }
        }
        private void TryExecuteTool(IDSFDataObject dataObject, int update, ErrorResultTO allErrors)
        {
            var rs = DataListUtil.ExtractRecordsetNameFromValue(RecordsetName);
            if (RecordsLength == string.Empty)
            {
                allErrors.AddError(ErrorResource.BlankResultVariable);
            }
            if (dataObject.IsDebugMode())
            {
                var warewolfEvalResult = dataObject.Environment.Eval(RecordsetName.Replace("()", "(*)"), update);
                if (warewolfEvalResult.IsWarewolfRecordSetResult && warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfRecordSetResult recsetResult)
                {
                    AddDebugInputItem(new DebugItemWarewolfRecordset(recsetResult.Item, RecordsetName, "Recordset", "="));
                }

                //Because the environment eval above where you can only send through a recordset name and not list this code wont be reached.
                //No Coverage added.
                if (warewolfEvalResult.IsWarewolfAtomListresult && warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult atomListResult)
                {
                    AddDebugInputItem(new DebugEvalResult(RecordsetName, "Recordset", dataObject.Environment, update));
                }

            }
            var rule = new IsSingleValueRule(() => RecordsLength);
            var single = rule.Check();
            if (single != null)
            {
                allErrors.AddError(single.Message);
            }
            else
            {

                if (dataObject.Environment.HasRecordSet(RecordsetName))
                {
                    var count = dataObject.Environment.GetLength(rs);
                    var value = count.ToString();
                    dataObject.Environment.Assign(RecordsLength, value, update);
                    if (dataObject.Environment.Errors != null && !dataObject.Environment.Errors.Any())
                    {
                        AddDebugOutputItem(new DebugItemWarewolfAtomResult(value, RecordsLength, ""));
                    }

                }
                else
                {
                    if (TreatNullAsZero)
                    {
                        dataObject.Environment.Assign(RecordsLength, 0.ToString(), update);
                        AddDebugOutputItem(new DebugItemWarewolfAtomResult(0.ToString(), RecordsLength, ""));
                    }
                    else
                    {
                        allErrors.AddError(string.Format(ErrorResource.NullRecordSet, RecordsetName));
                    }

                }

            }
        }
        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);
        }
 private AssignValue AddDebugOutputItem(IDSFDataObject dataObject, int update, int innerCount, AssignValue assignValue)
 {
     if (DataListUtil.IsValueRecordset(assignValue.Name) && DataListUtil.GetRecordsetIndexType(assignValue.Name) == enRecordsetIndexType.Blank)
     {
         var length = dataObject.Environment.GetObjectLength(DataListUtil.ExtractRecordsetNameFromValue(assignValue.Name));
         assignValue = new AssignValue(DataListUtil.ReplaceObjectBlankWithIndex(assignValue.Name, length), assignValue.Value);
     }
     AddSingleDebugOutputItem(dataObject.Environment, innerCount, assignValue, update);
     return(assignValue);
 }
Example #15
0
 static void AddRecordsetsOutputs(IEnumerable <IServiceTestOutput> recSets, IExecutionEnvironment environment)
 {
     if (recSets != null)
     {
         var groupedRecsets = recSets.GroupBy(item => DataListUtil.ExtractRecordsetNameFromValue(item.Variable));
         foreach (var groupedRecset in groupedRecsets)
         {
             AddEntireRecsetGroup(environment, groupedRecset);
         }
     }
 }
Example #16
0
 static void AddRecordsetsInputs(IEnumerable <IServiceTestInput> recSets, IExecutionEnvironment environment)
 {
     if (recSets != null)
     {
         var groupedRecsets = recSets.GroupBy(item => DataListUtil.ExtractRecordsetNameFromValue(item.Variable));
         foreach (var groupedRecset in groupedRecsets)
         {
             var dataListItems = groupedRecset.GroupBy(item => DataListUtil.ExtractIndexRegionFromRecordset(item.Variable));
             foreach (var dataListItem in dataListItems)
             {
                 AddRecordsetInput(environment, dataListItem);
             }
         }
     }
 }
Example #17
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 #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
        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 #20
0
 static void UpdateEnvironmentFromJObject(IDSFDataObject dataObject, List <string> recSets, string inputName, int i, JToken val)
 {
     if (val is JObject valObj)
     {
         var recs = recSets.Where(s => DataListUtil.ExtractRecordsetNameFromValue(s) == inputName);
         foreach (var rec in recs)
         {
             var field     = DataListUtil.ExtractFieldNameOnlyFromValue(rec);
             var fieldProp = valObj.Properties().FirstOrDefault(property => property.Name == field);
             if (fieldProp != null)
             {
                 dataObject.Environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(rec), fieldProp.Value.ToString(), i + 1);
             }
         }
     }
 }
Example #21
0
        public static IBinaryDataListEntry EvaluateBinaryDataListEntry(string expression, Guid executionID)
        {
            ErrorResultTO     errors;
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            var dataList = compiler.FetchBinaryDataList(executionID, out errors);

            if (DataListUtil.IsValueRecordset(expression))
            {
                IBinaryDataListEntry expressionsEntry;
                string error;
                dataList.TryGetEntry(DataListUtil.ExtractRecordsetNameFromValue(expression), out expressionsEntry, out error);
                return(compiler.Evaluate(executionID, enActionType.User, expression, false, out errors));
            }

            return(compiler.Evaluate(executionID, enActionType.User, expression, false, out errors));
        }
        void ExecuteField(IDSFDataObject dataObject, int update, int innerCount, ActivityDTO t, ErrorResultTO allErrors)
        {
            var assignValue      = new AssignValue(t.FieldName, t.FieldValue);
            var isCalcEvaluation = DataListUtil.IsCalcEvaluation(t.FieldValue, out string cleanExpression);

            if (isCalcEvaluation)
            {
                assignValue = new AssignValue(t.FieldName, cleanExpression);
            }
            DebugItem debugItem = null;

            if (dataObject.IsDebugMode())
            {
                debugItem = TryCreateDebugInput(dataObject.Environment, innerCount, assignValue, update);
            }

            try
            {
                if (isCalcEvaluation)
                {
                    DoCalculation(dataObject.Environment, t.FieldName, t.FieldValue, update);
                }
                else
                {
                    dataObject.Environment.AssignWithFrame(assignValue, update);
                }
            } catch (Exception e)
            {
                Dev2Logger.Error(nameof(DsfMultiAssignActivity), e, GlobalConstants.WarewolfError);
                allErrors.AddError(e.Message);
            }

            if (debugItem != null)
            {
                _debugInputs.Add(debugItem);
            }
            if (dataObject.IsDebugMode())
            {
                if (DataListUtil.IsValueRecordset(assignValue.Name) && DataListUtil.GetRecordsetIndexType(assignValue.Name) == enRecordsetIndexType.Blank)
                {
                    var length = dataObject.Environment.GetLength(DataListUtil.ExtractRecordsetNameFromValue(assignValue.Name));
                    assignValue = new AssignValue(DataListUtil.ReplaceRecordsetBlankWithIndex(assignValue.Name, length), assignValue.Value);
                }
                AddSingleDebugOutputItem(dataObject.Environment, innerCount, assignValue, update);
            }
        }
        ErrorResultTO TryExecute(IDSFDataObject dataObject, int update, ErrorResultTO allErrors)
        {
            var rs = DataListUtil.ExtractRecordsetNameFromValue(RecordsetName);

            if (RecordsLength == string.Empty)
            {
                allErrors.AddError(ErrorResource.BlankResultVariable);
            }
            if (dataObject.IsDebugMode())
            {
                var warewolfEvalResult = dataObject.Environment.Eval(RecordsetName.Replace("()", "(*)"), update);
                if (warewolfEvalResult.IsWarewolfRecordSetResult && warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfRecordSetResult recsetResult)
                {
                    AddDebugInputItem(new DebugItemWarewolfRecordset(recsetResult.Item, RecordsetName, "Recordset", "="));
                }

                if (warewolfEvalResult.IsWarewolfAtomListresult && warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult atomListResult)
                {
                    AddDebugInputItem(new DebugEvalResult(RecordsetName, "Recordset", dataObject.Environment, update));
                }
            }
            var rule   = new IsSingleValueRule(() => RecordsLength);
            var single = rule.Check();

            if (single != null)
            {
                allErrors.AddError(single.Message);
            }
            else
            {
                var count = 0;
                if (dataObject.Environment.HasRecordSet(RecordsetName))
                {
                    count = dataObject.Environment.GetLength(rs);
                }
                else
                {
                    allErrors.AddError("Recordset: " + RecordsetName + " does not exist.");
                }
                var value = count.ToString();
                dataObject.Environment.Assign(RecordsLength, value, update);
                AddDebugOutputItem(new DebugItemWarewolfAtomResult(value, RecordsLength, ""));
            }
            return(allErrors);
        }
Example #24
0
        private void AssignField(IDSFDataObject dataObject, int update, int innerCount, ActivityDTO t, ErrorResultTO allErrors)
        {
            var assignValue      = new AssignValue(t.FieldName, t.FieldValue);
            var isCalcEvaluation = DataListUtil.IsCalcEvaluation(t.FieldValue, out string cleanExpression);

            if (isCalcEvaluation)
            {
                assignValue = new AssignValue(t.FieldName, cleanExpression);
            }
            DebugItem debugItem = null;

            if (dataObject.IsDebugMode())
            {
                debugItem = AddSingleInputDebugItem(dataObject.Environment, innerCount, assignValue, update);
            }

            try
            {
                if (isCalcEvaluation)
                {
                    DoCalculation(dataObject.Environment, t.FieldName, t.FieldValue, update);
                }
                else
                {
                    dataObject.Environment.AssignWithFrame(assignValue, update);
                }
            } catch (Exception e)
            {
                allErrors.AddError(e.Message);
            }

            if (debugItem != null)
            {
                _debugInputs.Add(debugItem);
            }
            if (dataObject.IsDebugMode())
            {
                if (DataListUtil.IsValueRecordset(assignValue.Name) && DataListUtil.GetRecordsetIndexType(assignValue.Name) == enRecordsetIndexType.Blank && !assignValue.Name.Contains(DataListUtil.ObjectStartMarker))
                {
                    var length = dataObject.Environment.GetLength(DataListUtil.ExtractRecordsetNameFromValue(assignValue.Name));
                    assignValue = new AssignValue(DataListUtil.ReplaceRecordsetBlankWithIndex(assignValue.Name, length), assignValue.Value);
                }
                AddSingleDebugOutputItem(dataObject.Environment, innerCount, assignValue, update);
            }
        }
Example #25
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 #26
0
 void UpdateMappingRecordSetValue(string newMappedTo)
 {
     if (!string.IsNullOrEmpty(newMappedTo))
     {
         if (!DataListUtil.IsValueRecordset(newMappedTo) && !string.IsNullOrEmpty(RecordSetName))
         {
             _recordSetName = string.Empty;
         }
         else
         {
             if (DataListUtil.IsValueRecordset(newMappedTo) && string.IsNullOrEmpty(RecordSetName))
             {
                 _recordSetName = DataListUtil.ExtractRecordsetNameFromValue(newMappedTo);
             }
         }
         OnPropertyChanged("RecordSetName");
     }
 }
Example #27
0
        // ReSharper disable MemberCanBePrivate.Global
        public string GetDestinationWithName(string sourceName)
        // ReSharper restore MemberCanBePrivate.Global
        {
            string destName = null;

            if (DataListUtil.IsFullyEvaluated(sourceName))
            {
                if (DataListUtil.IsValueRecordset(sourceName) || DataListUtil.IsValueRecordsetWithFields(sourceName))
                {
                    destName = DataListUtil.ExtractRecordsetNameFromValue(sourceName);
                }
                else
                {
                    destName = DataListUtil.StripBracketsFromValue(sourceName);
                }
            }
            return(destName);
        }
Example #28
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);
        }
Example #29
0
        void AddBlankRowToRecordset(IServiceTestOutput dlItem, IList <IScalar> columns, int indexToInsertAt, int indexNum, IDataListModel dataList)
        {
            IList <IScalar> recsetCols = columns.Distinct(Scalar.Comparer).ToList();
            string          colName    = null;

            foreach (var col in recsetCols.Distinct(new ScalarNameComparer()))
            {
                if (string.IsNullOrEmpty(colName) || !colName.Equals(col.Name))
                {
                    var recSetName        = DataListUtil.ExtractRecordsetNameFromValue(dlItem.Variable);
                    var varName           = string.Concat(recSetName, @"(", indexNum, @").", col.Name);
                    var serviceTestOutput = new ServiceTestOutput(varName, string.Empty, string.Empty, string.Empty);
                    serviceTestOutput.AddNewAction = () => AddRow(serviceTestOutput, dataList);
                    Outputs.Insert(indexToInsertAt + 1, serviceTestOutput);
                    indexToInsertAt++;
                }
                colName = col.Name;
            }
        }
        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);
            }
        }