コード例 #1
0
        public CompileMessageTO ApplyRule(Guid serviceID, StringBuilder beforeAction, StringBuilder afterAction)
        {
            var preDlStr = beforeAction;

            var preDL  = ServiceUtils.ExtractDataList(preDlStr);
            var postDL = ServiceUtils.ExtractDataList(afterAction);


            var outputMappings = DataListUtil.GenerateDefsFromDataList(preDL, enDev2ColumnArgumentDirection.Output);
            var inputMappings  = DataListUtil.GenerateDefsFromDataList(preDL, enDev2ColumnArgumentDirection.Input);

            var outputMappingsPost = DataListUtil.GenerateDefsFromDataList(postDL, enDev2ColumnArgumentDirection.Output);
            var inputMappingsPost  = DataListUtil.GenerateDefsFromDataList(postDL, enDev2ColumnArgumentDirection.Input);

            if (inputMappings.Count != inputMappingsPost.Count || outputMappings.Count != outputMappingsPost.Count)
            {
                var inputDefs  = DataListUtil.GenerateDefsFromDataList(postDL, enDev2ColumnArgumentDirection.Input);
                var outputDefs = DataListUtil.GenerateDefsFromDataList(postDL, enDev2ColumnArgumentDirection.Output);
                var defStr     = "<Args><Input>" + JsonConvert.SerializeObject(inputDefs) + "</Input><Output>" + JsonConvert.SerializeObject(outputDefs) + "</Output></Args>";
                TestCatalog.Instance.UpdateTestsBasedOnIOChange(serviceID, inputDefs, outputDefs);
                return(new CompileMessageTO {
                    MessageID = Guid.NewGuid(), MessageType = CompileMessageType.MappingChange, ServiceID = serviceID, MessagePayload = defStr, ErrorType = ErrorType.Critical
                });
            }
            if (ServiceUtils.MappingNamesChanged(inputMappings, inputMappingsPost) || ServiceUtils.MappingNamesChanged(outputMappings, outputMappingsPost))
            {
                var inputDefs  = DataListUtil.GenerateDefsFromDataList(postDL, enDev2ColumnArgumentDirection.Input);
                var outputDefs = DataListUtil.GenerateDefsFromDataList(postDL, enDev2ColumnArgumentDirection.Output);
                var defStr     = "<Args><Input>" + JsonConvert.SerializeObject(inputDefs) + "</Input><Output>" + JsonConvert.SerializeObject(outputDefs) + "</Output></Args>";
                TestCatalog.Instance.UpdateTestsBasedOnIOChange(serviceID, inputDefs, outputDefs);
                return(new CompileMessageTO {
                    MessageID = Guid.NewGuid(), MessageType = CompileMessageType.MappingChange, ServiceID = serviceID, MessagePayload = defStr, ErrorType = ErrorType.Critical
                });
            }
            TestCatalog.Instance.UpdateTestsBasedOnIOChange(serviceID, null, null);
            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Gets the correct data list.
        /// </summary>
        /// <param name="dataObject">The data object.</param>
        /// <param name="workspaceId">The workspace unique identifier.</param>
        /// <param name="errors">The errors.</param>
        /// <param name="compiler">The compiler.</param>
        /// <returns></returns>
        public Guid CorrectDataList(IDSFDataObject dataObject, Guid workspaceId, out ErrorResultTO errors, IDataListCompiler compiler)
        {
            StringBuilder theShape;
            ErrorResultTO invokeErrors;

            errors = new ErrorResultTO();

            // If no DLID, we need to make it based upon the request ;)
            if (dataObject.DataListID == GlobalConstants.NullDataListID)
            {
                theShape = FindServiceShape(workspaceId, dataObject.ResourceID);
                dataObject.DataListID = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), dataObject.RawPayload, theShape, out invokeErrors);
                errors.MergeErrors(invokeErrors);
                dataObject.RawPayload = new StringBuilder();
            }

            // force all items to exist in the DL ;)
            theShape = FindServiceShape(workspaceId, dataObject.ResourceID);
            var innerDatalistID = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), new StringBuilder(), theShape, out invokeErrors);

            errors.MergeErrors(invokeErrors);

            // Add left to right
            var left = compiler.FetchBinaryDataList(dataObject.DataListID, out invokeErrors);

            errors.MergeErrors(invokeErrors);
            var right = compiler.FetchBinaryDataList(innerDatalistID, out invokeErrors);

            errors.MergeErrors(invokeErrors);

            DataListUtil.MergeDataList(left, right, out invokeErrors);
            errors.MergeErrors(invokeErrors);
            compiler.PushBinaryDataList(left.UID, left, out invokeErrors);
            errors.MergeErrors(invokeErrors);

            return(innerDatalistID);
        }
コード例 #3
0
ファイル: CommonSteps.cs プロジェクト: tuga1975/Warewolf
        void AddSingleDebugResult(string rowValue, DebugItemResult debugItemResult)
        {
            var variableValuePair = rowValue.Split(new[] { " =" }, StringSplitOptions.None);

            debugItemResult.Variable = variableValuePair[0];
            debugItemResult.Value    = variableValuePair[1];
            debugItemResult.Type     = DebugItemResultType.Variable;
            var variable = debugItemResult.Variable;

            if (DataListUtil.IsValueRecordset(variable))
            {
                var indexRegionFromRecordset = DataListUtil.ExtractIndexRegionFromRecordset(variable);
                if (!string.IsNullOrEmpty(indexRegionFromRecordset))
                {
                    int.TryParse(indexRegionFromRecordset, out int indexForRecset);

                    if (!_scenarioContext.TryGetValue("variableList", out List <Tuple <string, string> > variableList))
                    {
                        return;
                    }

                    var indexType = enRecordsetIndexType.Star;
                    if (variableList.Find(tuple => tuple.Item1 == variable) != null)
                    {
                        indexType = enRecordsetIndexType.Numeric;
                    }

                    if (indexForRecset > 0 && indexType != enRecordsetIndexType.Numeric)
                    {
                        var indexOfOpenningBracket = variable.IndexOf("(", StringComparison.Ordinal) + 1;
                        debugItemResult.GroupIndex = indexForRecset;
                        var groupName = variable.Substring(0, indexOfOpenningBracket) + "*" + variable.Substring(indexOfOpenningBracket + indexRegionFromRecordset.Length);
                        debugItemResult.GroupName = variableList.Find(tuple => tuple.Item1 == groupName) != null ? groupName : groupName.Replace("*", "");
                    }
                }
            }
        }
コード例 #4
0
        public override IActionableErrorInfo Check()
        {
            var  value   = GetValue();
            bool isValid = true;

            string calculationExpression;

            if (DataListUtil.IsCalcEvaluation(value, out calculationExpression))
            {
                IntellisenseProviderContext context = new IntellisenseProviderContext
                {
                    CaretPosition     = value.Length,
                    InputText         = value,
                    IsInCalculateMode = true,
                    DesiredResultSet  = IntellisenseDesiredResultSet.ClosestMatch
                };

                var results = _intellisenseProvider.GetIntellisenseResults(context);

                if (results.Any(e => e.IsError))
                {
                    isValid   = false;
                    ErrorText = results.First(e => e.IsError).Description;
                }
            }

            if (!isValid)
            {
                return(new ActionableErrorInfo(DoError)
                {
                    Message = string.Format("{0} {1}", LabelText, ErrorText)
                });
            }

            return(null);
        }
コード例 #5
0
ファイル: CalculateSteps.cs プロジェクト: won21kr/Warewolf
        public void ThenTheCalculateResultShouldBe(string expectedResult)
        {
            string error;
            string actualValue;

            expectedResult = expectedResult.Replace('"', ' ').Trim();
            var result = ScenarioContext.Current.Get <IDSFDataObject>("result");

            GetScalarValueFromEnvironment(result.Environment, DataListUtil.RemoveLanguageBrackets(ResultVariable),
                                          out actualValue, out error);

            if (expectedResult == "[Now]")
            {
                DateTime.Parse(actualValue).Subtract(DateTime.Now).TotalMilliseconds.Should().BeLessThan(1000, "we expect DateTime.Now but give a 1 second grace period for the formula to complete");
                return;
            }
            if (expectedResult == "[Today]")
            {
                DateTime.Parse(actualValue).Day.Should().Be(DateTime.Now.Day, "we expect today's date");
                return;
            }
            if (expectedResult == "[Int]")
            {
                int outval;
                Assert.IsTrue(int.TryParse(actualValue, out outval));
                return;
            }
            if (string.IsNullOrEmpty(expectedResult))
            {
                actualValue.Should().BeNullOrEmpty("the expected value is null or empty");
            }
            else
            {
                actualValue.Should().Be(expectedResult);
            }
        }
コード例 #6
0
        protected void GetRecordSetFieldValueFromDataList(IExecutionEnvironment environment, string recordSet, string fieldNameToRetrieve, out IList <string> result, out string error)
        {
            var variableName = recordSet;

            result = new List <string>();
            error  = "";
            try
            {
                if (!string.IsNullOrEmpty(fieldNameToRetrieve))
                {
                    variableName = DataListUtil.CreateRecordsetDisplayValue(recordSet, fieldNameToRetrieve, "*");
                }
                var warewolfEvalResult = environment.Eval(DataListUtil.AddBracketsToValueIfNotExist(variableName), 0);

                if (warewolfEvalResult == null)
                {
                    return;
                }
                var listResult = warewolfEvalResult as WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomListresult;
                if (listResult != null)
                {
                    foreach (var res in listResult.Item)
                    {
                        result.Add(ExecutionEnvironment.WarewolfAtomToString(res));
                    }
                }
            }
            catch (Exception e)
            {
                error = e.Message;
            }

            if (!string.IsNullOrEmpty(error))
            {
            }
        }
コード例 #7
0
        public void WhenISelectTheFollowingOption(string option)
        {
            var    context = ScenarioContext.Current.Get <IntellisenseProviderContext>("context");
            string result;
            bool   isFileProvider;

            if (ScenarioContext.Current.TryGetValue("isFileProvider", out isFileProvider))
            {
                if (DataListUtil.IsEvaluated(option) || string.IsNullOrEmpty(option))
                {
                    result = new DefaultIntellisenseProvider().PerformResultInsertion(option, context);
                }
                else
                {
                    result = new FileSystemIntellisenseProvider().PerformResultInsertion(option, context);
                }
            }
            else
            {
                result = new DefaultIntellisenseProvider().PerformResultInsertion(option, context);
            }

            ScenarioContext.Current.Add("result", result);
        }
コード例 #8
0
        void AddBlankIndexDebugOutputs(IList <OutputTO> outputs, SharepointSource sharepointSource, string path)
        {
            if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Blank)
            {
                if (IsFoldersSelected)
                {
                    var folders = GetSharePointFolders(sharepointSource, path);

                    foreach (var folder in folders)
                    {
                        outputs.Add(DataListFactory.CreateOutputTO(Result, folder));
                    }
                }
                if (IsFilesSelected)
                {
                    var files = GetSharePointFiles(sharepointSource, path);

                    foreach (var file in files)
                    {
                        outputs.Add(DataListFactory.CreateOutputTO(Result, file));
                    }
                }

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

                    foreach (var fileAndfolder in folderAndPathList)
                    {
                        outputs.Add(DataListFactory.CreateOutputTO(Result, fileAndfolder));
                    }
                }
            }
        }
コード例 #9
0
        public void DataListUtil_ShapeDefinitionsToDataList_WhenOutputContainsDifferentRecordset_ExpectTwoRecordsets()
        {
            //------------Setup for test--------------------------
            const string defs = @"<Outputs><Output Name=""MapLocationID"" MapsTo=""[[MapLocationID]]"" Value=""[[dbo_proc_GetAllMapLocations(*).MapLocationID]]"" Recordset=""dbo_proc_GetAllMapLocations"" /><Output Name=""StreetAddress"" MapsTo=""[[StreetAddress]]"" Value=""[[dbo_proc_GetAllMapLocations2(*).StreetAddress]]"" Recordset=""dbo_proc_GetAllMapLocations"" /><Output Name=""Latitude"" MapsTo=""[[Latitude]]"" Value=""[[dbo_proc_GetAllMapLocations(*).Latitude]]"" Recordset=""dbo_proc_GetAllMapLocations"" /><Output Name=""Longitude"" MapsTo=""[[Longitude]]"" Value=""[[dbo_proc_GetAllMapLocations(*).Longitude]]"" Recordset=""dbo_proc_GetAllMapLocations"" /></Outputs>";

            //------------Execute Test---------------------------
            ErrorResultTO invokeErrors;
            var           result = DataListUtil.ShapeDefinitionsToDataList(defs, enDev2ArgumentType.Output, out invokeErrors, isDbService: true);

            //------------Assert Results-------------------------
            const string expected = @"<ADL>
<dbo_proc_GetAllMapLocations>
	<MapLocationID></MapLocationID>
	<Latitude></Latitude>
	<Longitude></Longitude>
</dbo_proc_GetAllMapLocations>
<dbo_proc_GetAllMapLocations2>
	<StreetAddress></StreetAddress>
</dbo_proc_GetAllMapLocations2>

</ADL>";

            Assert.AreEqual(expected, result.ToString());
        }
コード例 #10
0
        public override IRuleSet GetRuleSet(string propertyName, string datalist)
        {
            var ruleSet = new RuleSet();

            if (IsEmpty())
            {
                return(ruleSet);
            }

            switch (propertyName)
            {
            case "OutputVariable":
                var outputExprRule = new IsValidExpressionRule(() => OutputVariable, datalist, "1");
                ruleSet.Add(outputExprRule);
                ruleSet.Add(new IsValidExpressionRule(() => outputExprRule.ExpressionValue, datalist));

                if (!string.IsNullOrEmpty(XPath))
                {
                    ruleSet.Add(new IsStringEmptyRule(() => OutputVariable));
                }
                break;

            case "XPath":
                if (!string.IsNullOrEmpty(OutputVariable))
                {
                    ruleSet.Add(new IsStringEmptyRule(() => XPath));

                    if (!string.IsNullOrEmpty(XPath) && !DataListUtil.IsEvaluated(XPath))
                    {
                        ruleSet.Add(new IsValidXpathRule(() => XPath));
                    }
                }
                break;
            }
            return(ruleSet);
        }
コード例 #11
0
        private void ExecuteConcreteAction(IList <OutputTO> outputs, WarewolfListIterator colItr, SharepointSource sharepointSource, WarewolfIterator serverInputItr, WarewolfIterator localInputItr)
        {
            var serverPath = colItr.FetchNextValue(serverInputItr);
            var localPath  = colItr.FetchNextValue(localInputItr);

            if (DataListUtil.IsValueRecordset(Result) && DataListUtil.GetRecordsetIndexType(Result) != enRecordsetIndexType.Numeric)
            {
                if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Star)
                {
                    var recsetName      = DataListUtil.ExtractRecordsetNameFromValue(Result);
                    var fieldName       = DataListUtil.ExtractFieldNameFromValue(Result);
                    var newPath         = DownLoadFile(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
                {
                    AddBlankIndexDebugOutputs(outputs, sharepointSource, serverPath, localPath);
                }
            }
            else
            {
                var newPath = DownLoadFile(sharepointSource, serverPath, localPath);

                var xmlList = string.Join(",", newPath.Select(c => c));
                outputs.Add(DataListFactory.CreateOutputTO(Result));
                outputs.Last().OutputStrings.Add(xmlList);
            }
        }
コード例 #12
0
        IList <IDataListItem> ConvertToIDataListItem(IRecordSet recordSet, enDev2ColumnArgumentDirection directionToGet)
        {
            IList <IDataListItem> result = new List <IDataListItem>();
            var dataListEntry            = recordSet;

            foreach (var column in dataListEntry.Columns)
            {
                var fields = column.Value.Where(c => c.IODirection == enDev2ColumnArgumentDirection.Both || c.IODirection == directionToGet).ToList();
                foreach (var col in fields)
                {
                    IDataListItem singleRes = new DataListItem();
                    singleRes.CanHaveMutipleRows = true;
                    singleRes.Recordset          = recordSet.Name;
                    singleRes.Field        = col.Name;
                    singleRes.Index        = column.Key.ToString();
                    singleRes.Value        = col.Value.UnescapeString();
                    singleRes.DisplayValue = DataListUtil.CreateRecordsetDisplayValue(recordSet.Name, col.Name, column.Key.ToString());
                    singleRes.Description  = col.Description;
                    result.Add(singleRes);
                }
            }

            return(result);
        }
コード例 #13
0
        public void ThenTheValueOfIsNull(string variable)
        {
            var result = scenarioContext.Get <IDSFDataObject>("result");

            try
            {
                if (DataListUtil.IsValueRecordset(variable))
                {
                    result.Environment.EvalAsListOfStrings(variable, 0);
                }
                else
                {
                    string actualValue;
                    string error;
                    GetScalarValueFromEnvironment(result.Environment, variable,
                                                  out actualValue, out error);
                }
                Assert.Fail("Should have thrown NullReferenceException");
            }
            catch (NullReferenceException)
            {
                Assert.IsTrue(true, "Exception thrown");
            }
        }
コード例 #14
0
        /// <summary>
        /// Determines whether [name is valid].
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>
        ///   <c>true</c> if [name is valid]; otherwise, <c>false</c>.
        /// </returns>
        public override string ValidateName(string name)
        {
            Dev2DataLanguageParser parser = new Dev2DataLanguageParser();

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

                if (!string.IsNullOrEmpty(name))
                {
                    var intellisenseResult = parser.ValidateName(name, IsRecordset ? "Recordset" : "Variable");
                    if (intellisenseResult != null)
                    {
                        SetError(intellisenseResult.Message);
                    }
                    else
                    {
                        if (!string.Equals(ErrorMessage, StringResources.ErrorMessageDuplicateValue, StringComparison.InvariantCulture) &&
                            !string.Equals(ErrorMessage, StringResources.ErrorMessageDuplicateVariable, StringComparison.InvariantCulture) &&
                            !string.Equals(ErrorMessage, StringResources.ErrorMessageDuplicateRecordset, StringComparison.InvariantCulture) &&
                            !string.Equals(ErrorMessage, StringResources.ErrorMessageEmptyRecordSet, StringComparison.InvariantCulture))
                        {
                            RemoveError();
                        }
                    }
                }
            }
            return(name);
        }
コード例 #15
0
        static void AddRecordsetInput(IExecutionEnvironment environment, IGrouping <string, IServiceTestInput> dataListItem)
        {
            var recSetsToAssign = new List <IServiceTestInput>();
            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)
                {
                    if (!serviceTestInput.EmptyIsNull || !string.IsNullOrEmpty(serviceTestInput.Value))
                    {
                        environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(serviceTestInput.Variable), serviceTestInput.Value, 0);
                    }
                }
            }
        }
コード例 #16
0
ファイル: DataListTO.cs プロジェクト: Warewolf-ESB/Warewolf
        static void LoadInputsFromAllElements(List <string> inputs, XElement rootEl)
        {
            if (rootEl is null)
            {
                return;
            }

            var inputsWithNoElements = rootEl.Elements()
                                       .Where(element => !element.HasElements)
                                       .Select(element => element.Name.ToString());

            inputs.AddRange(inputsWithNoElements);

            var elementsWithElements = rootEl.Elements().Where(el => el.HasElements);

            inputs.AddRange(elementsWithElements.Elements().Select(element =>
            {
                if (element.Parent != null)
                {
                    return(DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(element.Parent.Name.ToString(), element.Name.ToString(), "*")));
                }
                return("");
            }));
        }
コード例 #17
0
        public void ThenTheValueOfTheVariableIsAValid(string variable, string type)
        {
            string error;
            var    result = scenarioContext.Get <IDSFDataObject>("result");

            if (DataListUtil.IsValueRecordset(variable))
            {
                var recordset       = RetrieveItemForEvaluation(enIntellisensePartType.RecordsetsOnly, variable);
                var column          = RetrieveItemForEvaluation(enIntellisensePartType.RecordsetFields, variable);
                var recordSetValues = RetrieveAllRecordSetFieldValues(result.Environment, recordset, column,
                                                                      out error);
                recordSetValues = recordSetValues.Where(i => !string.IsNullOrEmpty(i)).ToList();
                foreach (string recordSetValue in recordSetValues)
                {
                    Verify(type, recordSetValue, error);
                }
            }
            else
            {
                GetScalarValueFromEnvironment(result.Environment, DataListUtil.RemoveLanguageBrackets(variable),
                                              out string actualValue, out error);
                Verify(type, actualValue, error);
            }
        }
コード例 #18
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, ""));
         }
     }
 }
コード例 #19
0
        void TranslateDataTableToEnvironment(DataTable executeService, IExecutionEnvironment environment)
        {
            if (executeService != null && InstanceOutputDefintions != null)
            {
                var defs = DataListFactory.CreateOutputParser().Parse(InstanceOutputDefintions);
                HashSet <string>          processedRecNames = new HashSet <string>();
                IDictionary <int, string> colMapping        = BuildColumnNameToIndexMap(executeService.Columns, defs);
                foreach (var def in defs)
                {
                    var expression = def.Value;
                    var rs         = def.RawValue;
                    var rsName     = DataListUtil.ExtractRecordsetNameFromValue(expression);
                    var rsType     = DataListUtil.GetRecordsetIndexType(expression);
                    var rowIndex   = DataListUtil.ExtractIndexRegionFromRecordset(expression);
                    var rsNameUse  = def.RecordSetName;
                    environment.AssignDataShape(def.RawValue);

                    if (DataListUtil.IsValueRecordset(rs))
                    {
                        if (string.IsNullOrEmpty(rsName))
                        {
                            rsName = rsNameUse;
                        }
                        if (string.IsNullOrEmpty(rsName))
                        {
                            rsName = def.Name;
                        }

                        if (processedRecNames.Contains(rsName))
                        {
                            continue;
                        }

                        processedRecNames.Add(rsName);


                        // now convert to binary datalist ;)
                        int rowIdx = 1;

                        if (environment.HasRecordSet(rs))
                        {
                            rowIdx = environment.GetLength(rs);
                        }

                        if (rsType == enRecordsetIndexType.Star)
                        {
                            rowIdx = 1;
                        }
                        if (rsType == enRecordsetIndexType.Numeric)
                        {
                            rowIdx = int.Parse(rowIndex);
                        }

                        if (executeService.Rows != null)
                        {
                            foreach (DataRow row in executeService.Rows)
                            {
                                // build up the row
                                int idx = 0;

                                foreach (var item in row.ItemArray)
                                {
                                    string colName;

                                    if (colMapping.TryGetValue(idx, out colName))
                                    {
                                        var displayExpression = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(def.Value), colName, rowIdx.ToString()));
                                        environment.Assign(displayExpression, item.ToString(), 0);
                                    }

                                    idx++;
                                }

                                rowIdx++;
                            }
                        }
                    }
                    else
                    {
                        // handle a scalar coming out ;)
                        if (executeService.Rows != null && executeService.Rows.Count == 1)
                        {
                            var row = executeService.Rows[0].ItemArray;
                            // Look up the correct index from the columns ;)

                            int pos  = 0;
                            var cols = executeService.Columns;
                            int idx  = -1;

                            while (pos < cols.Count && idx == -1)
                            {
                                if (colMapping[pos] == expression)
                                {
                                    idx = pos;
                                }
                                pos++;
                            }
                            environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(expression), row[idx].ToString(), 0);
                        }
                    }
                }
            }
        }
コード例 #20
0
        protected override IList <OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject, out ErrorResultTO allErrors, int update)
        {
            IsNotCertVerifiable = true;

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

            var colItr = new WarewolfListIterator();

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

            colItr.AddVariableToIterateOn(inputItr);

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

            colItr.AddVariableToIterateOn(unameItr);

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

            colItr.AddVariableToIterateOn(passItr);

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

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

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

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

            return(outputs);
        }
コード例 #21
0
        public IRecordSetCollection Generate()
        {
            IDictionary <string, IList <IDev2Definition> > tmpCollections = new Dictionary <string, IList <IDev2Definition> >();
            IList <string> tmpNames = new List <string>();

            foreach (IDev2Definition tmp in ParsedOutput)
            {
                var rsName     = DataListUtil.ExtractRecordsetNameFromValue(tmp.Value);
                var scanRsName = tmp.RecordSetName;

                if (IsOutput)
                {
                    if (IsDbService)
                    {
                        if (!string.IsNullOrEmpty(rsName))
                        {
                            scanRsName = rsName;
                        }
                    }
                }
                else
                {
                    scanRsName = DataListUtil.ExtractRecordsetNameFromValue(tmp.Value);
                }

                if (tmp.IsRecordSet)
                {
                    // is already present in the record set?
                    if (tmpCollections.ContainsKey(scanRsName))
                    {
                        tmpCollections[scanRsName].Add(tmp);
                    }
                    else
                    { // first time adding for this record set
                        IList <IDev2Definition> newList = new List <IDev2Definition>();
                        newList.Add(tmp);
                        tmpCollections.Add(scanRsName, newList);
                        tmpNames.Add(scanRsName);
                    }
                }
                // Handle scalars that are really recordsets ;)
                else if (!string.IsNullOrEmpty(scanRsName))
                {
                    // is already present in the record set?
                    if (tmpCollections.ContainsKey(scanRsName))
                    {
                        tmpCollections[scanRsName].Add(tmp); // ???
                    }
                    else
                    { // first time adding for this record set
                        IList <IDev2Definition> newList = new List <IDev2Definition>();
                        newList.Add(tmp);
                        tmpCollections.Add(scanRsName, newList);
                        tmpNames.Add(scanRsName);
                    }
                }
            }
            IList <IRecordSetDefinition> tmpDefs = new List <IRecordSetDefinition>();

            // ReSharper disable LoopCanBeConvertedToQuery
            foreach (string setName in tmpNames)
            {
                // ReSharper restore LoopCanBeConvertedToQuery
                IList <IDev2Definition> tmpOutput = tmpCollections[setName];
                tmpDefs.Add(new RecordSetDefinition(setName, tmpOutput));
            }

            IRecordSetCollection result = new RecordSetCollection(tmpDefs, tmpNames);

            return(result);
        }
コード例 #22
0
        /// <summary>
        /// Formats the string.
        /// </summary>
        /// <param name="recset">The recset.</param>
        /// <param name="field">The field.</param>
        /// <returns></returns>
        private string FormatString(string recset, string field)
        {
            var tmp = DataListUtil.ComposeIntoUserVisibleRecordset(recset, string.Empty, field);

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


            var masterRecordsetName = string.Empty;

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

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

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

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


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

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

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

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

                var injectMapsTo = def.MapsTo;

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

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

                result.Add(viewModel);
            }

            return(result);
        }
コード例 #24
0
 private bool ArePureScalarTargets(IEnumerable <DataSplitDTO> args)
 {
     return(args.All(arg => !DataListUtil.IsValueRecordset(arg.OutputVariable)));
 }
コード例 #25
0
ファイル: JsonMappingTo.cs プロジェクト: tuga1975/Warewolf
        public string GetDestinationWithName(string sourceName)

        {
            string destName = null;

            if (DataListUtil.IsFullyEvaluated(sourceName))
            {
                destName = DataListUtil.IsValueRecordset(sourceName) || DataListUtil.IsValueRecordsetWithFields(sourceName) ? DataListUtil.ExtractRecordsetNameFromValue(sourceName) : DataListUtil.StripBracketsFromValue(sourceName);
            }
            return(destName);
        }
コード例 #26
0
 /// <summary>
 /// Create a DL shape as per IO mapping
 /// </summary>
 /// <param name="arguments">The arguments.</param>
 /// <param name="typeOf">The type of.</param>
 /// <param name="errors">The errors.</param>
 /// <param name="flipGeneration">if set to <c>true</c> [flip generation].</param>
 /// <returns></returns>
 private StringBuilder ShapeDefinitionsToDataList(string arguments, enDev2ArgumentType typeOf, out ErrorResultTO errors, bool flipGeneration = false)
 {
     return(DataListUtil.ShapeDefinitionsToDataList(arguments, typeOf, out errors, flipGeneration));
 }
コード例 #27
0
 /// <summary>
 /// Generate DL shape from IO defs
 /// </summary>
 /// <param name="defs">The defs.</param>
 /// <param name="withData">if set to <c>true</c> [with data].</param>
 /// <returns></returns>
 private StringBuilder GenerateDataListFromDefs(IList <IDev2Definition> defs, bool withData = false)
 {
     return(DataListUtil.GenerateDataListFromDefs(defs, withData));
 }
コード例 #28
0
ファイル: RecordsetHandler.cs プロジェクト: kapiya/Warewolf
 static string BuildErrorMessage(IDataListItemModel model) => DataListUtil.AddBracketsToValueIfNotExist(model.DisplayName) + " : " + model.ErrorMessage;
コード例 #29
0
        protected static string GetPostData(ICommunicationContext ctx)
        {
            var baseStr = HttpUtility.UrlDecode(ctx.Request.Uri.ToString());

            baseStr = HttpUtility.UrlDecode(CleanupXml(baseStr));
            if (baseStr != null)
            {
                var startIdx = baseStr.IndexOf("?", StringComparison.Ordinal);
                if (startIdx > 0)
                {
                    var payload = baseStr.Substring((startIdx + 1));
                    if (payload.IsXml() || payload.IsJSON())
                    {
                        return(payload);
                    }
                }
            }

            if (ctx.Request.Method == "GET")
            {
                var pairs = ctx.Request.QueryString;
                return(ExtractKeyValuePairs(pairs, ctx.Request.BoundVariables));
            }

            if (ctx.Request.Method == "POST")
            {
                using (var reader = new StreamReader(ctx.Request.InputStream, ctx.Request.ContentEncoding))
                {
                    try
                    {
                        string data = reader.ReadToEnd();
                        if (DataListUtil.IsXml(data) || DataListUtil.IsJson(data))
                        {
                            return(data);
                        }



                        NameValueCollection pairs = new NameValueCollection(5);
                        var keyValuePairs         = data.Split(new[] { "&" }, StringSplitOptions.RemoveEmptyEntries).ToList();
                        foreach (var keyValuePair in keyValuePairs)
                        {
                            var keyValue = keyValuePair.Split(new[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                            if (keyValue.Length > 1)
                            {
                                pairs.Add(keyValue[0], keyValue[1]);
                            }
                            else if (keyValue.Length == 1)
                            {
                                if (keyValue[0].IsXml() || keyValue[0].IsJSON())
                                {
                                    pairs.Add(keyValue[0], keyValue[0]);
                                }
                            }
                        }

                        if (pairs.Count == 0)
                        {
                            pairs = ctx.Request.QueryString;
                        }

                        return(ExtractKeyValuePairs(pairs, ctx.Request.BoundVariables));
                    }
                    catch (Exception ex)
                    {
                        Dev2Logger.Log.Error("AbstractWebRequestHandler", ex);
                    }
                }
            }

            return(string.Empty);
        }
コード例 #30
0
        // Travis.Frisinger - 28.01.2013 : Amended for Debug
        public override List <DebugItem> GetDebugInputs(IExecutionEnvironment env, int update)
        {
            if (_debugInputs != null && _debugInputs.Count > 0)
            {
                return(_debugInputs);
            }
            List <IDebugItem> result = new List <IDebugItem>();
            var allErrors            = new ErrorResultTO();

            var val = new StringBuilder(Dev2DecisionStack.ExtractModelFromWorkflowPersistedData(ExpressionText));

            try
            {
                Dev2DecisionStack dds = DataListUtil.ConvertFromJsonToModel <Dev2DecisionStack>(val);
                ErrorResultTO     error;
                string            userModel = dds.GenerateUserFriendlyModel(env, dds.Mode, out error);
                allErrors.MergeErrors(error);

                foreach (Dev2Decision dev2Decision in dds.TheStack)
                {
                    AddInputDebugItemResultsAfterEvaluate(result, ref userModel, env, dds.Mode, dev2Decision.Col1, out error);
                    allErrors.MergeErrors(error);
                    AddInputDebugItemResultsAfterEvaluate(result, ref userModel, env, dds.Mode, dev2Decision.Col2, out error);
                    allErrors.MergeErrors(error);
                    AddInputDebugItemResultsAfterEvaluate(result, ref userModel, env, dds.Mode, dev2Decision.Col3, out error);
                    allErrors.MergeErrors(error);
                }

                var itemToAdd = new DebugItem();

                userModel = userModel.Replace("OR", " OR\r\n")
                            .Replace("AND", " AND\r\n")
                            .Replace("\r\n ", "\r\n")
                            .Replace("\r\n\r\n", "\r\n")
                            .Replace("  ", " ");

                AddDebugItem(new DebugItemStaticDataParams(userModel, "Statement"), itemToAdd);
                result.Add(itemToAdd);

                itemToAdd = new DebugItem();
                AddDebugItem(new DebugItemStaticDataParams(dds.Mode == Dev2DecisionMode.AND ? "YES" : "NO", "Require All decisions to be True"), itemToAdd);
                result.Add(itemToAdd);
            }
            catch (JsonSerializationException)
            {
                Dev2Switch ds = new Dev2Switch {
                    SwitchVariable = val.ToString()
                };
                DebugItem itemToAdd = new DebugItem();

                var a           = env.Eval(ds.SwitchVariable, 0);
                var debugResult = new DebugItemWarewolfAtomResult(ExecutionEnvironment.WarewolfEvalResultToString(a), "", ds.SwitchVariable, "", "Switch on", "", "=");
                itemToAdd.AddRange(debugResult.GetDebugItemResult());
                result.Add(itemToAdd);
            }
            catch (Exception e)
            {
                allErrors.AddError(e.Message);
            }
            finally
            {
                if (allErrors.HasErrors())
                {
                    var serviceName = GetType().Name;
                    DisplayAndWriteError(serviceName, allErrors);
                }
            }

            return(result.Select(a => a as DebugItem).ToList());
        }