示例#1
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);
                }
            }
        }
示例#2
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);
             }
         }
     }
 }
示例#3
0
 void UpdateMappedToValue(string newRecordsetName)
 {
     if (!string.IsNullOrEmpty(_recordSetName) && !string.IsNullOrEmpty(_mappedTo) && DataListUtil.IsValueRecordsetWithFields(_mappedTo))
     {
         var recSetName = DataListUtil.ExtractRecordsetNameFromValue(_mappedTo);
         var fieldName  = DataListUtil.ExtractFieldNameOnlyFromValue(_mappedTo);
         if (string.Equals(recSetName, _recordSetName, StringComparison.OrdinalIgnoreCase) && !string.Equals(recSetName, newRecordsetName, StringComparison.OrdinalIgnoreCase))
         {
             MappedTo = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(newRecordsetName, fieldName, ""));
         }
         if (string.IsNullOrEmpty(newRecordsetName) && string.IsNullOrEmpty(DataListUtil.ExtractRecordsetNameFromValue(_mappedTo)))
         {
             MappedTo = DataListUtil.AddBracketsToValueIfNotExist(fieldName);
         }
     }
     else
     {
         if (string.IsNullOrEmpty(_recordSetName) && !string.IsNullOrEmpty(newRecordsetName) && !string.IsNullOrEmpty(_mappedTo) && !DataListUtil.IsValueRecordsetWithFields(_mappedTo))
         {
             var varName = DataListUtil.RemoveLanguageBrackets(_mappedTo);
             MappedTo = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(newRecordsetName, varName, ""));
         }
     }
 }
示例#4
0
        protected void BuildShapeAndTestData()
        {
            var shape = new XElement("root");
            var data  = new XElement("root");

            var row = 0;

            _scenarioContext.TryGetValue("variableList", out dynamic variableList);
            if (variableList != null)
            {
                try
                {
                    foreach (dynamic variable in variableList)
                    {
                        var variableName = DataListUtil.AddBracketsToValueIfNotExist(variable.Item1);
                        if (!string.IsNullOrEmpty(variable.Item1) && !string.IsNullOrEmpty(variable.Item2))
                        {
                            string value = variable.Item2 == "blank" ? "" : variable.Item2;
                            if (value.ToUpper() == "NULL")
                            {
                                DataObject.Environment.AssignDataShape(variable.Item1);
                            }
                            else
                            {
                                DataObject.Environment.Assign(variableName, value, 0);
                            }
                        }
                        if (DataListUtil.IsValueScalar(variableName))
                        {
                            var scalarName      = DataListUtil.RemoveLanguageBrackets(variableName);
                            var scalarItemModel = new ScalarItemModel(scalarName);
                            if (!scalarItemModel.HasError)
                            {
                                DataListSingleton.ActiveDataList.Add(scalarItemModel);
                            }
                        }
                        if (DataListUtil.IsValueRecordsetWithFields(variableName))
                        {
                            var rsName    = DataListUtil.ExtractRecordsetNameFromValue(variableName);
                            var fieldName = DataListUtil.ExtractFieldNameOnlyFromValue(variableName);
                            var rs        = DataListSingleton.ActiveDataList.RecsetCollection.FirstOrDefault(model => model.Name == rsName);
                            if (rs == null)
                            {
                                var recordSetItemModel = new RecordSetItemModel(rsName);
                                DataListSingleton.ActiveDataList.Add(recordSetItemModel);
                                recordSetItemModel.Children.Add(new RecordSetFieldItemModel(fieldName,
                                                                                            recordSetItemModel));
                            }
                            else
                            {
                                var recordSetFieldItemModel = rs.Children.FirstOrDefault(model => model.Name == fieldName);
                                if (recordSetFieldItemModel == null)
                                {
                                    rs.Children.Add(new RecordSetFieldItemModel(fieldName, rs));
                                }
                            }
                        }
                        //Build(variable, shape, data, row)
                        row++;
                    }
                    DataListSingleton.ActiveDataList.WriteToResourceModel();
                }
                catch
                {
                    //Exception
                }
            }

            var isAdded = _scenarioContext.TryGetValue("rs", out List <Tuple <string, string> > emptyRecordset);

            if (isAdded)
            {
                foreach (Tuple <string, string> emptyRecord in emptyRecordset)
                {
                    DataObject.Environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(emptyRecord.Item1), emptyRecord.Item2, 0);
                }
            }

            _scenarioContext.TryGetValue("objList", out dynamic objList);
            if (objList != null)
            {
                try
                {
                    foreach (dynamic variable in objList)
                    {
                        if (!string.IsNullOrEmpty(variable.Item1) && !string.IsNullOrEmpty(variable.Item2))
                        {
                            string value = variable.Item2 == "blank" ? "" : variable.Item2;
                            if (value.ToUpper() == "NULL")
                            {
                                DataObject.Environment.AssignDataShape(variable.Item1);
                            }
                            else
                            {
                                DataObject.Environment.AssignJson(new AssignValue(DataListUtil.AddBracketsToValueIfNotExist(variable.Item1), value), 0);
                            }
                        }
                    }
                }
                catch
                {
                    //Exception
                }
            }

            CurrentDl = shape.ToString();
            TestData  = data.ToString();
        }
示例#5
0
        private string GetObjectDisplayExpression(int grpIdx)
        {
            string 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), "");
                }
            }

            return(displayExpression);
        }
        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);
        }
        public void GivenIHaveVariablesAs(Table table)
        {
            var variableListViewModel = Utils.GetViewModel <DataListViewModel>();
            var rows = table.Rows;

            foreach (var tableRow in rows)
            {
                var variableName      = tableRow["Variable"];
                var isUsedStringValue = tableRow["IsUsed"];
                var isInput           = !string.IsNullOrEmpty(tableRow["Input"]) && tableRow["Input"].Equals("YES", StringComparison.OrdinalIgnoreCase);
                var isOutput          = !string.IsNullOrEmpty(tableRow["Output"]) && tableRow["Output"].Equals("YES", StringComparison.OrdinalIgnoreCase);
                var ioDirection       = enDev2ColumnArgumentDirection.None;
                if (isInput && isOutput)
                {
                    ioDirection = enDev2ColumnArgumentDirection.Both;
                }
                else if (isInput)
                {
                    ioDirection = enDev2ColumnArgumentDirection.Input;
                }
                else if (isOutput)
                {
                    ioDirection = enDev2ColumnArgumentDirection.Output;
                }
                var isUsed = isUsedStringValue != null && (!string.IsNullOrEmpty(isUsedStringValue) || isUsedStringValue.Equals("YES", StringComparison.OrdinalIgnoreCase));
                if (DataListUtil.IsValueRecordset(variableName))
                {
                    var recSetName = DataListUtil.ExtractRecordsetNameFromValue(variableName);
                    var columnName = DataListUtil.ExtractFieldNameOnlyFromValue(variableName);

                    var existingRecordSet = variableListViewModel.RecsetCollection.FirstOrDefault(model => model.DisplayName.Equals(recSetName, StringComparison.OrdinalIgnoreCase));
                    if (existingRecordSet == null)
                    {
                        existingRecordSet = DataListItemModelFactory.CreateRecordSetItemModel(recSetName);
                        if (existingRecordSet != null)
                        {
                            existingRecordSet.DisplayName = recSetName;
                            variableListViewModel.RecsetCollection.Add(existingRecordSet);
                        }
                    }
                    if (!string.IsNullOrEmpty(columnName))
                    {
                        var item = DataListItemModelFactory.CreateRecordSetFieldItemModel(columnName, "", existingRecordSet);
                        if (item != null)
                        {
                            item.DisplayName       = variableName;
                            item.IsUsed            = isUsed;
                            item.ColumnIODirection = ioDirection;
                            existingRecordSet?.Children.Add(item);
                        }
                    }
                }
                else
                {
                    var displayName = DataListUtil.RemoveLanguageBrackets(variableName);
                    var item        = DataListItemModelFactory.CreateScalarItemModel(displayName);
                    if (item != null)
                    {
                        item.DisplayName       = variableName;
                        item.IsUsed            = isUsed;
                        item.ColumnIODirection = ioDirection;
                        variableListViewModel.ScalarCollection.Add(item);
                    }
                }
            }
        }
        private void AtomListResultNoLabel(List <IDebugItemResult> results)
        {
            string groupName = null;
            int    grpIdx    = 0;

            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;
                    if (_isCalculate)
                    {
                        displayExpression = groupName ?? displayExpression;
                    }
                }
                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,
                    MockSelected = _mockSelected
                });
            }
        }