Esempio n. 1
0
        IEnumerable <string> BuildQueryFromTo(SharepointSearchTo sharepointSearchTo, IExecutionEnvironment env, ISharepointFieldTo sharepointFieldTo, int update)
        {
            var warewolfEvalResult = env.Eval(sharepointSearchTo.ValueToMatch, update);
            var fieldType          = sharepointFieldTo.GetFieldType();

            if (sharepointSearchTo.SearchType == "In")
            {
                var startSearchTerm = $"{SharepointSearchOptions.GetStartTagForSearchOption(sharepointSearchTo.SearchType)}<FieldRef Name=\"{sharepointSearchTo.InternalName}\"></FieldRef>";

                startSearchTerm += "<Values>";
                if (warewolfEvalResult.IsWarewolfAtomListresult)
                {
                    startSearchTerm = AddAtomListResult(sharepointFieldTo, warewolfEvalResult, fieldType, startSearchTerm);
                }
                else
                {
                    startSearchTerm = AddAtomResult(sharepointFieldTo, warewolfEvalResult, fieldType, startSearchTerm);
                }
                startSearchTerm += "</Values>";
                startSearchTerm += SharepointSearchOptions.GetEndTagForSearchOption(sharepointSearchTo.SearchType);
                yield return(startSearchTerm);
            }
            else
            {
                var iterator = new WarewolfIterator(warewolfEvalResult);
                while (iterator.HasMoreData())
                {
                    yield return($"{SharepointSearchOptions.GetStartTagForSearchOption(sharepointSearchTo.SearchType)}<FieldRef Name=\"{sharepointSearchTo.InternalName}\"></FieldRef><Value Type=\"{fieldType}\">{CastWarewolfValueToCorrectType(iterator.GetNextValue(), sharepointFieldTo.Type)}</Value>{SharepointSearchOptions.GetEndTagForSearchOption(sharepointSearchTo.SearchType)}");
                }
            }
        }
        IEnumerable <string> BuildQueryFromTo(SharepointSearchTo sharepointSearchTo, IExecutionEnvironment env, ISharepointFieldTo sharepointFieldTo, int update)
        {
            var warewolfEvalResult = env.Eval(sharepointSearchTo.ValueToMatch, update);
            var fieldType          = sharepointFieldTo.GetFieldType();

            if (sharepointSearchTo.SearchType == "In")
            {
                var startSearchTerm = string.Format("{0}<FieldRef Name=\"{1}\"></FieldRef>", SharepointSearchOptions.GetStartTagForSearchOption(sharepointSearchTo.SearchType), sharepointSearchTo.InternalName);

                startSearchTerm += "<Values>";
                if (warewolfEvalResult.IsWarewolfAtomListresult)
                {
                    var listResult = warewolfEvalResult as CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult;
                    if (listResult != null)
                    {
                        foreach (var warewolfAtom in listResult.Item)
                        {
                            var valueString = warewolfAtom.ToString();
                            if (valueString.Contains(","))
                            {
                                var listOfValues = valueString.Split(',');
                                startSearchTerm = listOfValues.Select(listOfValue => CastWarewolfValueToCorrectType(listOfValue, sharepointFieldTo.Type)).Aggregate(startSearchTerm, (current, value) => current + string.Format("<Value Type=\"{0}\">{1}</Value>", fieldType, value));
                            }
                            else
                            {
                                var value = CastWarewolfValueToCorrectType(valueString, sharepointFieldTo.Type);
                                startSearchTerm += string.Format("<Value Type=\"{0}\">{1}</Value>", fieldType, value);
                            }
                        }
                    }
                }
                else
                {
                    var scalarResult = warewolfEvalResult as CommonFunctions.WarewolfEvalResult.WarewolfAtomResult;
                    if (scalarResult != null)
                    {
                        var valueString = scalarResult.Item.ToString();
                        if (valueString.Contains(","))
                        {
                            var listOfValues = valueString.Split(',');
                            startSearchTerm = listOfValues.Select(listOfValue => CastWarewolfValueToCorrectType(listOfValue, sharepointFieldTo.Type)).Aggregate(startSearchTerm, (current, value) => current + string.Format("<Value Type=\"{0}\">{1}</Value>", fieldType, value));
                        }
                        else
                        {
                            var value = CastWarewolfValueToCorrectType(valueString, sharepointFieldTo.Type);
                            startSearchTerm += string.Format("<Value Type=\"{0}\">{1}</Value>", fieldType, value);
                        }
                    }
                }
                startSearchTerm += "</Values>";
                startSearchTerm += SharepointSearchOptions.GetEndTagForSearchOption(sharepointSearchTo.SearchType);
                yield return(startSearchTerm);
            }
            else
            {
                WarewolfIterator iterator = new WarewolfIterator(warewolfEvalResult);
                while (iterator.HasMoreData())
                {
                    yield return(string.Format("{0}<FieldRef Name=\"{1}\"></FieldRef><Value Type=\"{2}\">{3}</Value>{4}", SharepointSearchOptions.GetStartTagForSearchOption(sharepointSearchTo.SearchType), sharepointSearchTo.InternalName, fieldType, CastWarewolfValueToCorrectType(iterator.GetNextValue(), sharepointFieldTo.Type), SharepointSearchOptions.GetEndTagForSearchOption(sharepointSearchTo.SearchType)));
                }
            }
        }
        IEnumerable <string> BuildQueryFromTo(SharepointSearchTo sharepointSearchTo, IExecutionEnvironment env, ISharepointFieldTo sharepointFieldTo, int update)
        {
            WarewolfIterator iterator = new WarewolfIterator(env.Eval(sharepointSearchTo.ValueToMatch, update));

            while (iterator.HasMoreData())
            {
                var fieldType = sharepointFieldTo.GetFieldType();
                yield return(string.Format("{0}<FieldRef Name=\"{1}\"></FieldRef><Value Type=\"{2}\">{3}</Value>{4}", SharepointSearchOptions.GetStartTagForSearchOption(sharepointSearchTo.SearchType), sharepointSearchTo.InternalName, fieldType, CastWarewolfValueToCorrectType(iterator.GetNextValue(), sharepointFieldTo.Type), SharepointSearchOptions.GetEndTagForSearchOption(sharepointSearchTo.SearchType)));
            }
        }