Esempio n. 1
0
        static void EvalAssignComplexObjects(IExecutionEnvironment innerEnvironment, IExecutionEnvironment environment, IDev2Definition dev2Definition)
        {
            var warewolfEvalResult = innerEnvironment.EvalJContainer(DataListUtil.AddBracketsToValueIfNotExist(dev2Definition.Name));

            if (warewolfEvalResult != null)
            {
                environment.AddToJsonObjects(DataListUtil.AddBracketsToValueIfNotExist(dev2Definition.Value), warewolfEvalResult);
            }
        }
        protected void BuildShapeAndTestData()
        {
            var shape = new XElement("root");
            var data  = new XElement("root");

            // ReSharper disable NotAccessedVariable
            int     row = 0;
            dynamic variableList;

            ScenarioContext.Current.TryGetValue("variableList", out variableList);

            if (variableList != null)
            {
                try
                {
                    foreach (dynamic variable in variableList)
                    {
                        if (!string.IsNullOrEmpty(variable.Item1) && !string.IsNullOrEmpty(variable.Item2))
                        {
                            DataObject.Environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(variable.Item1), variable.Item2 == "blank"?"":variable.Item2);
                        }
                        //Build(variable, shape, data, row);
                        row++;
                    }
                }
                // ReSharper disable EmptyGeneralCatchClause
                catch
                // ReSharper restore EmptyGeneralCatchClause
                {
                }
            }

            List <Tuple <string, string> > emptyRecordset;
            bool isAdded = ScenarioContext.Current.TryGetValue("rs", out emptyRecordset);

            if (isAdded)
            {
                foreach (Tuple <string, string> emptyRecord in emptyRecordset)
                {
                    DataObject.Environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(emptyRecord.Item1), emptyRecord.Item2);
                    //var recSetElement = shape
                    //                  .Descendants(emptyRecord.Item1)
                    //                  .FirstOrDefault();
                    //if (recSetElement == null)
                    //{
                    //    shape.Add(new XElement(emptyRecord.Item1, new XElement(emptyRecord.Item2)));
                    //}
                    //else
                    //{
                    //    recSetElement.Add(new XElement(emptyRecord.Item2));
                    //}
                }
            }

            CurrentDl = shape.ToString();
            TestData  = data.ToString();
        }
Esempio n. 3
0
        void MapScalarValue(IList <IDev2Definition> outputDefs, int update, IDSFDataObject dataObj, XmlNode c1)
        {
            var scalarName = outputDefs.FirstOrDefault(definition => definition.Name == c1.Name);

            if (scalarName != null)
            {
                dataObj.Environment.AssignWithFrame(new AssignValue(DataListUtil.AddBracketsToValueIfNotExist(scalarName.RawValue), UnescapeRawXml(c1.InnerXml)), update);
            }
        }
        private static string Eval(DsfDataObject dataObject, string messageVariable)
        {
            var warewolfEvalResult = dataObject.Environment.Eval(DataListUtil.AddBracketsToValueIfNotExist(messageVariable), 0, true);

            var atomResult = (warewolfEvalResult as CommonFunctions.WarewolfEvalResult.WarewolfAtomResult).Item;
            var actual     = (atomResult as DataStorage.WarewolfAtom.DataString).Item;

            return(actual);
        }
        /// <summary>
        ///     A new version of GetValue since Evaluate will now handle complex expressions it is now possible to create gnarly looking debug items
        ///     This method handles these ;)
        /// </summary>
        /// <param name="dlEntry">The dl entry.</param>
        /// <param name="indexType">Type of the index.</param>
        /// <param name="results">The results.</param>
        /// <param name="initExpression">The init expression.</param>
        /// <param name="recordField">The record field.</param>
        /// <param name="index">The index.</param>
        /// <param name="labelText"></param>
        void NewGetValue(IBinaryDataListEntry dlEntry, enRecordsetIndexType indexType, IList <IDebugItemResult> results, string initExpression, IBinaryDataListItem recordField, int index, string labelText)
        {
            string injectVal = string.Empty;
            ComplexExpressionAuditor auditorObj = dlEntry.ComplexExpressionAuditor;

            if (indexType == enRecordsetIndexType.Star && auditorObj != null)
            {
                string instanceData;
                IList <ComplexExpressionAuditItem> auditData = auditorObj.FetchAuditItems();
                if (index <= auditData.Count && index > 0)
                {
                    ComplexExpressionAuditItem useData = auditData[index - 1];
                    instanceData = useData.TokenBinding;
                    injectVal    = useData.BoundValue;
                }
                else
                {
                    string recsetName = DataListUtil.CreateRecordsetDisplayValue(dlEntry.Namespace,
                                                                                 recordField.FieldName,
                                                                                 index.ToString(CultureInfo.InvariantCulture));
                    instanceData = DataListUtil.AddBracketsToValueIfNotExist(recsetName);
                }

                results.Add(new DebugItemResult
                {
                    Label      = labelText,
                    Type       = DebugItemResultType.Variable,
                    Value      = injectVal,
                    Operator   = string.IsNullOrEmpty(instanceData) ? "" : "=",
                    Variable   = instanceData,
                    GroupName  = initExpression,
                    GroupIndex = index
                });
            }
            else
            {
                injectVal = recordField.TheValue;

                string displayValue = recordField.DisplayValue;

                if (displayValue.IndexOf(GlobalConstants.NullEntryNamespace, StringComparison.Ordinal) >= 0)
                {
                    displayValue = DataListUtil.CreateRecordsetDisplayValue("Evaluated", GlobalConstants.EvaluationRsField, index.ToString(CultureInfo.InvariantCulture));
                }

                results.Add(new DebugItemResult
                {
                    Type       = DebugItemResultType.Variable,
                    Variable   = DataListUtil.AddBracketsToValueIfNotExist(displayValue),
                    Operator   = string.IsNullOrEmpty(displayValue) ? "" : "=",
                    GroupName  = initExpression,
                    Value      = injectVal,
                    GroupIndex = index
                });
            }
        }
Esempio n. 6
0
        public static void ProcessOutputMapping(IExecutionEnvironment environment, int update, ref bool started, ref int rowIdx, DataRow row, IServiceOutputMapping serviceOutputMapping)
        {
            var rsType   = DataListUtil.GetRecordsetIndexType(serviceOutputMapping.MappedTo);
            var rowIndex = DataListUtil.ExtractIndexRegionFromRecordset(serviceOutputMapping.MappedTo);

            var rs = serviceOutputMapping.RecordSetName;

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

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

            var value = row[serviceOutputMapping.MappedFrom];

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

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

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

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

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

            environment.Assign(displayExpression, value.ToString(), update);
        }
Esempio n. 7
0
 public ServiceOutputMapping(string mappedFrom, string mapping, string recordsetName)
 {
     MappedFrom    = mappedFrom;
     MappedTo      = mapping;
     RecordSetName = recordsetName;
     if (string.IsNullOrEmpty(_recordSetName) && !string.IsNullOrEmpty(mapping))
     {
         MappedTo = DataListUtil.AddBracketsToValueIfNotExist(mapping);
     }
 }
 void TryConvert(XmlNodeList children, IList <IDev2Definition> outputDefs, IDictionary <string, int> indexCache, int level = 0)
 {
     // spin through each element in the XML
     foreach (XmlNode c in children)
     {
         if (c.Name != GlobalConstants.NaughtyTextNode)
         {
             // scalars and recordset fetch
             if (level > 0)
             {
                 var c1              = c;
                 var recSetName      = outputDefs.Where(definition => definition.RecordSetName == c1.Name);
                 var dev2Definitions = recSetName as IDev2Definition[] ?? recSetName.ToArray();
                 if (dev2Definitions.Count() != 0)
                 {
                     // fetch recordset index
                     int fetchIdx;
                     var idx = indexCache.TryGetValue(c.Name, out fetchIdx) ? fetchIdx : 1;
                     // process recordset
                     var nl = c.ChildNodes;
                     foreach (XmlNode subc in nl)
                     {
                         // Extract column being mapped to ;)
                         foreach (var definition in dev2Definitions)
                         {
                             if (definition.MapsTo == subc.Name)
                             {
                                 DataObj.Environment.AssignWithFrame(new AssignValue(definition.RawValue, subc.InnerXml));
                             }
                         }
                     }
                     // update this recordset index
                     DataObj.Environment.CommitAssign();
                     indexCache[c.Name] = ++idx;
                 }
                 else
                 {
                     var scalarName = outputDefs.FirstOrDefault(definition => definition.Name == c1.Name);
                     if (scalarName != null)
                     {
                         DataObj.Environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(scalarName.RawValue), c1.InnerXml);
                     }
                 }
             }
             else
             {
                 if (level == 0)
                 {
                     // Only recurse if we're at the first level!!
                     TryConvert(c.ChildNodes, outputDefs, indexCache, ++level);
                 }
             }
         }
     }
 }
Esempio n. 9
0
        private void DebugOutput(IDSFDataObject dataObject, int update, ErrorResultTO allErrors, string parentServiceName, string serviceName, Guid oldResourceId)
        {
            if (!dataObject.WorkflowResumeable || !dataObject.IsDataListScoped)
            {
                // Handle Errors
                if (allErrors.HasErrors())
                {
                    var env = dataObject.Environment;
                    foreach (var allError in allErrors.FetchErrors())
                    {
                        env.AddError(allError);
                    }

                    // add to datalist in variable specified
                    if (!String.IsNullOrEmpty(OnErrorVariable))
                    {
                        var errorString    = env.FetchErrors();
                        var errors         = ErrorResultTO.MakeErrorResultFromDataListString(errorString, true);
                        var upsertVariable = DataListUtil.AddBracketsToValueIfNotExist(OnErrorVariable);
                        if (errors.HasErrors())
                        {
                            foreach (var error in errors.FetchErrors())
                            {
                                //TODO: duplicate check on the Recordset might hide the real issue,
                                //of multiple execution calls passing here which seems not to be the same on F7
                                env.Assign(upsertVariable, error, update);
                            }
                        }
                        else
                        {
                            env.Assign(upsertVariable, errorString, update);
                        }
                    }
                    DisplayAndWriteError(dataObject, serviceName, allErrors);
                }
            }

            if (dataObject.IsDebugMode() || dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer)
            {
                var dt = DateTime.Now;
                DispatchDebugState(dataObject, StateType.After, update, dt);
                ChildDebugStateDispatch(dataObject);
                _debugOutputs = new List <DebugItem>();
                DispatchDebugState(dataObject, StateType.Duration, update, dt);
            }

            dataObject.ParentInstanceID        = _previousInstanceId;
            dataObject.ParentServiceName       = parentServiceName;
            dataObject.ServiceName             = serviceName;
            dataObject.RemoteInvokeResultShape = new StringBuilder(); // reset targnet shape ;)
            dataObject.RunWorkflowAsync        = false;
            dataObject.RemoteInvokerID         = Guid.Empty.ToString();
            dataObject.EnvironmentID           = Guid.Empty;
            dataObject.ResourceID = oldResourceId;
        }
Esempio n. 10
0
        //protected override void BuildDataList()
        //{
        //    List<Tuple<string, string>> variableList;
        //    ScenarioContext.Current.TryGetValue("variableList", out variableList);

        //    if(variableList == null)
        //    {
        //        variableList = new List<Tuple<string, string>>();
        //        ScenarioContext.Current.Add("variableList", variableList);
        //    }

        //    variableList.Add(new Tuple<string, string>(ResultVariable, ""));
        //    BuildShapeAndTestData();


        //}

        protected override void BuildDataList()
        {
            var shape = new XElement("root");
            var data  = new XElement("root");

            // ReSharper disable NotAccessedVariable
            int     row = 0;
            dynamic variableList;

            ScenarioContext.Current.TryGetValue("variableList", out variableList);

            if (variableList != null)
            {
                foreach (dynamic variable in variableList)
                {
                    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.AssignWithFrame(new AssignValue(DataListUtil.AddBracketsToValueIfNotExist(variable.Item1), value), 0);
                        }
                    }
                    //Build(variable, shape, data, row);
                    row++;
                }
                DataObject.Environment.CommitAssign();
            }

            string recordSetName;

            ScenarioContext.Current.TryGetValue("recordset", out recordSetName);

            var recordset = ScenarioContext.Current.Get <string>("recordset");

            var length = new DsfRecordsetLengthActivity
            {
                RecordsetName = recordset,
                RecordsLength = ResultVariable
            };

            TestStartNode = new FlowStep
            {
                Action = length
            };
            ScenarioContext.Current.Add("activity", length);
            CurrentDl = shape.ToString();
            TestData  = data.ToString();
        }
        void LoadListFields(bool isFromListChange = false, System.Action continueWith = null)
        {
            if (!IsListSelected)
            {
                if (continueWith != null)
                {
                    continueWith();
                }
                return;
            }

            var selectedSharepointServer = SelectedSharepointServer;
            var selectedList             = SelectedList;

            // ReSharper disable ImplicitlyCapturedClosure
            _asyncWorker.Start(() => GetListFields(selectedSharepointServer, selectedList), columnList =>
                               // ReSharper restore ImplicitlyCapturedClosure
            {
                if (columnList != null)
                {
                    var fieldMappings = columnList.Select(mapping =>
                    {
                        var recordsetDisplayValue = DataListUtil.CreateRecordsetDisplayValue(selectedList.FullName.Replace(" ", "").Replace(".", ""), GetValidVariableName(mapping), "*");
                        var sharepointReadListTo  = new SharepointReadListTo(DataListUtil.AddBracketsToValueIfNotExist(recordsetDisplayValue), mapping.Name, mapping.InternalName, mapping.Type.ToString())
                        {
                            IsRequired = mapping.IsRequired
                        };
                        return(sharepointReadListTo);
                    }).ToList();
                    if (ReadListItems == null || ReadListItems.Count == 0 || isFromListChange)
                    {
                        ReadListItems = fieldMappings;
                    }
                    else
                    {
                        foreach (var sharepointReadListTo in fieldMappings)
                        {
                            var listTo     = sharepointReadListTo;
                            var readListTo = ReadListItems.FirstOrDefault(to => to.FieldName == listTo.FieldName);
                            if (readListTo == null)
                            {
                                ReadListItems.Add(sharepointReadListTo);
                            }
                        }
                    }
                    ListItems = ReadListItems;
                }
                if (continueWith != null)
                {
                    continueWith();
                }
            });
        }
Esempio n. 12
0
 private void MapToScalar(IServiceInput serviceInput)
 {
     if (_activeDataList.ActiveDataList.ScalarCollection != null)
     {
         var value = serviceInput.Name;
         if (value != null)
         {
             var variable = DataListUtil.AddBracketsToValueIfNotExist(value.Split('(').First().TrimEnd(' '));
             serviceInput.Value = variable;
         }
     }
 }
Esempio n. 13
0
 private static void PerformRecordsetUpdate(IDSFDataObject dataObject, JToken value, List <string> processedRecsets, string input, List <string> recSets, string inputName, bool isValueRecordset)
 {
     if (isValueRecordset)
     {
         var arr = new JArray(value);
         PerformRecordsetUpdate(dataObject, arr, true, input, recSets, inputName, processedRecsets);
     }
     else
     {
         var jContainer = value as JContainer;
         dataObject.Environment.AddToJsonObjects(DataListUtil.AddBracketsToValueIfNotExist("@" + input), jContainer);
     }
 }
Esempio n. 14
0
        static void UpdateForScalars(IDSFDataObject dataObject, int update, IEnumerable <string> scalars, XmlNode c)
        {
            var scalarDefs = scalars as string[] ?? scalars.ToArray();

            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);
            }
        }
        private void AddAllFolders(IList <OutputTO> outputs, SharepointSource sharepointSource, string path, string recsetName, string fieldName)
        {
            var folders         = GetSharePointFolders(sharepointSource, path);
            var indexToUpsertTo = 1;

            foreach (var folder in folders)
            {
                var fullRecsetName = DataListUtil.CreateRecordsetDisplayValue(recsetName, fieldName,
                                                                              indexToUpsertTo.ToString(CultureInfo.InvariantCulture));
                outputs.Add(DataListFactory.CreateOutputTO(DataListUtil.AddBracketsToValueIfNotExist(fullRecsetName), folder));
                indexToUpsertTo++;
            }
        }
 void OldGetValue(IBinaryDataListEntry dlEntry, string value, int iterCnt, string fieldName, enRecordsetIndexType indexType, IList <IDebugItemResult> results, string initExpression, IBinaryDataListItem recordField, int index, string labelText)
 {
     if ((string.IsNullOrEmpty(fieldName) || recordField.FieldName.Equals(fieldName, StringComparison.InvariantCultureIgnoreCase)))
     {
         string injectVal;
         try
         {
             injectVal = recordField.TheValue;
         }
         catch (Exception)
         {
             injectVal = "";
         }
         if (!string.IsNullOrEmpty(value) && recordField.ItemCollectionIndex == (iterCnt + 1))
         {
             injectVal = value;
             _rsCachedValues[recordField.DisplayValue] = injectVal;
         }
         else if (string.IsNullOrEmpty(injectVal) && recordField.ItemCollectionIndex != (iterCnt + 1))
         {
             // is it in the cache? ;)
             _rsCachedValues.TryGetValue(recordField.DisplayValue, out injectVal);
             if (injectVal == null)
             {
                 injectVal = string.Empty;
             }
         }
         string recsetName;
         if (indexType == enRecordsetIndexType.Star)
         {
             recsetName = DataListUtil.CreateRecordsetDisplayValue(dlEntry.Namespace,
                                                                   recordField.FieldName,
                                                                   index.ToString(CultureInfo.InvariantCulture));
             recsetName = DataListUtil.AddBracketsToValueIfNotExist(recsetName);
         }
         else
         {
             recsetName = DataListUtil.AddBracketsToValueIfNotExist(recordField.DisplayValue);
         }
         results.Add(new DebugItemResult
         {
             Label      = labelText,
             Type       = DebugItemResultType.Variable,
             Variable   = recsetName,
             Operator   = string.IsNullOrEmpty(recsetName) ? "" : "=",
             Value      = injectVal,
             GroupName  = initExpression,
             GroupIndex = index
         });
     }
 }
Esempio n. 17
0
 private void MapToObject(IServiceInput serviceInput)
 {
     if (_activeDataList.ActiveDataList.ComplexObjectCollection != null)
     {
         var value = serviceInput.Name;
         if (value != null)
         {
             value = value.Split('(').First().TrimEnd(' ');
             var objectName = "@" + value;
             var variable   = DataListUtil.AddBracketsToValueIfNotExist(objectName);
             serviceInput.Value = variable;
         }
     }
 }
 private static void EvalAssignComplexObjects(IExecutionEnvironment innerEnvironment, IExecutionEnvironment environment, IEnumerable <IDev2Definition> outputComplexObjectList)
 {
     foreach (var dev2Definition in outputComplexObjectList)
     {
         if (dev2Definition.IsObject)
         {
             var warewolfEvalResult = innerEnvironment.EvalJContainer(DataListUtil.AddBracketsToValueIfNotExist(dev2Definition.Name));
             if (warewolfEvalResult != null)
             {
                 environment.AddToJsonObjects(DataListUtil.AddBracketsToValueIfNotExist(dev2Definition.Value), warewolfEvalResult);
             }
         }
     }
 }
Esempio n. 19
0
        private static IEnumerable <string> AddChildrenPartForFindMissing(ParseTO child)
        {
            List <string> results = new List <string>();

            if (child != null)
            {
                results.Add(DataListUtil.AddBracketsToValueIfNotExist(child.Payload));
                if (child.Child != null)
                {
                    results.AddRange(AddChildrenPart(child.Child).Select(DataListUtil.AddBracketsToValueIfNotExist));
                }
            }
            return(results);
        }
        string CreateInjectValue(bool isOutputMapping, FuzzyMatchVo fuzzyMatch, IDev2Definition def)
        {
            string injectValue;
            // When output mapping we need to replace the recordset name if present with MasterRecordset
            //
            string masterRecordsetName;

            if (isOutputMapping && def.IsRecordSet && fuzzyMatch != null)
            {
                var field = def.Name;

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

                injectValue = FormatString(masterRecordsetName, field);
            }
            else
            {
                if (def.IsRecordSet)
                {
                    if (fuzzyMatch != null)
                    {
                        var 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(def.Name);
                }
            }

            return(injectValue);
        }
        IList <IInputOutputViewModel> CreateMappingList(string mappingDefinitions, IDev2LanguageParser parser, bool autoAddBrackets, bool isOutputMapping, FuzzyMatchVo fuzzyMatch = null)
        {
            IList <IInputOutputViewModel> result = new List <IInputOutputViewModel>();
            var concreteDefinitions = parser.ParseAndAllowBlanks(mappingDefinitions);

            foreach (var def in concreteDefinitions)
            {
                var injectValue = def.RawValue;
                if (autoAddBrackets)
                {
                    injectValue = CreateInjectValue(isOutputMapping, fuzzyMatch, def);
                }
                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);
                viewModel.IsObject = def.IsObject;
                if (def.IsObject)
                {
                    var complexObjectItemModel = _complexObjects.FirstOrDefault(model => model.Name == def.Name);
                    if (complexObjectItemModel != null)
                    {
                        viewModel.JsonString = complexObjectItemModel.GetJson();
                    }
                }
                result.Add(viewModel);
            }

            return(result);
        }
Esempio n. 22
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);
             }
         }
     }
 }
        List <IDebugItemResult> BuildDebugItemFromAtomList()
        {
            var results = new List <IDebugItemResult>();


            foreach (var item in _warewolfRecordset.Data)
            {
                if (item.Key == "WarewolfPositionColumn")
                {
                    continue;
                }

                var grpIdx = 0;
                foreach (var warewolfAtom in item.Value)
                {
                    var index    = _warewolfRecordset.Data["WarewolfPositionColumn"][grpIdx];
                    var position = ExecutionEnvironment.WarewolfAtomToString(index);
                    grpIdx++;
                    var displayExpression = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(_variable), item.Key, position));
                    var debugType         = DebugItemResultType.Value;
                    if (DataListUtil.IsEvaluated(displayExpression))
                    {
                        _operand  = "=";
                        debugType = DebugItemResultType.Variable;
                    }
                    else
                    {
                        displayExpression = null;
                    }
                    if (!warewolfAtom.IsNothing)
                    {
                        results.Add(new DebugItemResult
                        {
                            Type         = debugType,
                            Label        = _labelText,
                            Variable     = displayExpression,
                            Operator     = _operand,
                            GroupName    = _variable,
                            Value        = ExecutionEnvironment.WarewolfAtomToString(warewolfAtom),
                            GroupIndex   = grpIdx,
                            MockSelected = _mockSelected
                        });
                    }
                }
            }
            return(results);
        }
 private void AddTableToDataList(Table table)
 {
     // build up DataTable
     foreach (TableRow row in table.Rows)
     {
         var i = 0;
         foreach (string columnName in table.Header)
         {
             var recordsetDisplayValue = DataListUtil.CreateRecordsetDisplayValue("rs", columnName, "");
             var assignValue           = new AssignValue(DataListUtil.AddBracketsToValueIfNotExist(recordsetDisplayValue), row[i]);
             DataObject.Environment.AssignWithFrame(assignValue, 0);
             i++;
         }
         DataObject.Environment.CommitAssign();
     }
     // Execute Translator
 }
Esempio n. 25
0
        /// <summary>
        /// Gets a value from data list for a expression.
        /// </summary>
        /// <param name="expression">The expression to find the value for.</param>
        /// <param name="datalistID">The datalist unique identifier.</param>
        /// <param name="compiler">The compiler.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception"></exception>
        private static string GetValueFromDataList(string expression, Guid datalistID, IDataListCompiler compiler)
        {
            expression = DataListUtil.AddBracketsToValueIfNotExist(expression);
            ErrorResultTO errors;

            IBinaryDataListEntry returnedEntry = compiler.Evaluate(datalistID, enActionType.User, expression, false, out errors);

            if (returnedEntry == null)
            {
                throw new Exception(errors.MakeUserReady());
            }

            IBinaryDataListItem item = returnedEntry.FetchScalar();
            string result            = item.TheValue;

            return(result);
        }
Esempio n. 26
0
        protected void BuildShapeAndTestData()
        {
            var shape = new XElement("root");
            var data  = new XElement("root");

            // ReSharper disable NotAccessedVariable
            int     row = 0;
            dynamic variableList;

            scenarioContext.TryGetValue("variableList", out variableList);

            if (variableList != null)
            {
                foreach (dynamic variable in variableList)
                {
                    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(DataListUtil.AddBracketsToValueIfNotExist(variable.Item1), value, 0);
                        }
                    }
                    row++;
                }
            }

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

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

            CurrentDl = shape.ToString();
            TestData  = data.ToString();
        }
Esempio n. 27
0
        private LanguageAST.JsonIdentifierExpression AddJsonVariables(LanguageAST.JsonIdentifierExpression currentVar, string parentName)
        {
            if (currentVar != null)
            {
                var namedExpression = currentVar as LanguageAST.JsonIdentifierExpression.NameExpression;
                if (namedExpression != null)
                {
                    var name       = namedExpression.Item.Name;
                    var objectName = parentName == null ? name : parentName + "." + name;
                    if (!objectName.Contains("@"))
                    {
                        objectName = "@" + objectName;
                    }
                    PatriciaTrieJsonObjects.Add(DataListUtil.AddBracketsToValueIfNotExist(objectName), DataListUtil.AddBracketsToValueIfNotExist(objectName));
                    return(null);
                }

                var indexNestedExpression = currentVar as LanguageAST.JsonIdentifierExpression.IndexNestedNameExpression;
                if (indexNestedExpression != null)
                {
                    var name       = Equals(indexNestedExpression.Item.Index, LanguageAST.Index.Star) ? indexNestedExpression.Item.ObjectName + "(*)" : indexNestedExpression.Item.ObjectName + "()";
                    var objectName = parentName == null ? name : parentName + "." + name;
                    if (!objectName.Contains("@"))
                    {
                        objectName = "@" + objectName;
                    }
                    PatriciaTrieJsonObjects.Add(DataListUtil.AddBracketsToValueIfNotExist(objectName), DataListUtil.AddBracketsToValueIfNotExist(objectName));
                    return(AddJsonVariables(indexNestedExpression.Item.Next, objectName));
                }

                var nestedNameExpression = currentVar as LanguageAST.JsonIdentifierExpression.NestedNameExpression;
                if (nestedNameExpression != null)
                {
                    var objectName = parentName == null ? nestedNameExpression.Item.ObjectName : parentName + "." + nestedNameExpression.Item.ObjectName;
                    if (!objectName.Contains("@"))
                    {
                        objectName = "@" + objectName;
                    }
                    PatriciaTrieJsonObjects.Add(DataListUtil.AddBracketsToValueIfNotExist(objectName), DataListUtil.AddBracketsToValueIfNotExist(objectName));
                    var next = nestedNameExpression.Item.Next;
                    return(AddJsonVariables(next, objectName));
                }
            }
            return(null);
        }
Esempio n. 28
0
 void Map(XElement rootEl)
 {
     if (rootEl == null)
     {
         return;
     }
     Inputs.AddRange(rootEl.Elements().Where(element => !element.HasElements).Select(element => element.Name.ToString()));
     var xElements = rootEl.Elements().Where(el => el.HasElements);
     var enumerable = xElements as IList<XElement> ?? xElements.ToList();
     Inputs.AddRange(enumerable.Elements().Select(element =>
     {
         if (element.Parent != null)
         {
             return DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(element.Parent.Name.ToString(), element.Name.ToString(), "*"));
         }
         return "";
     }));
 }
 protected void GetScalarValueFromEnvironment(IExecutionEnvironment env, string fieldToRetrieve, out string result, out string error)
 {
     error  = "";
     result = null;
     if (fieldToRetrieve == GlobalConstants.ErrorPayload)
     {
         result = env.FetchErrors();
         return;
     }
     try
     {
         result = ExecutionEnvironment.WarewolfEvalResultToString(env.Eval(DataListUtil.AddBracketsToValueIfNotExist(fieldToRetrieve), 0));
     }
     catch (Exception err)
     {
         error = err.Message;
     }
 }
Esempio n. 30
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);
        }