Beispiel #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)}");
                }
            }
        }
Beispiel #2
0
        public SharepointListDeleteDesignerViewModel(ModelItem modelItem)
            : base(modelItem, new AsyncWorker(), EnvironmentRepository.Instance.ActiveEnvironment, EventPublishers.Aggregator, false)
        {
            WhereOptions = new ObservableCollection <string>(SharepointSearchOptions.SearchOptions());
            dynamic mi = ModelItem;

            InitializeItems(mi.FilterCriteria);
        }
        public SharepointListDeleteDesignerViewModel(ModelItem modelItem)
            : base(modelItem, new AsyncWorker(), ServerRepository.Instance.ActiveServer, EventPublishers.Aggregator, false)
        {
            WhereOptions = new ObservableCollection <string>(SharepointSearchOptions.SearchOptions());
            dynamic mi = ModelItem;

            InitializeItems(mi.FilterCriteria);
            HelpText = Warewolf.Studio.Resources.Languages.HelpText.Tool_SharePoint_Delete_List_Item;
        }
Beispiel #4
0
        public SharepointListReadDesignerViewModel(ModelItem modelItem, IAsyncWorker asyncWorker, IServer envModel)
            : base(modelItem, asyncWorker, envModel, EventPublishers.Aggregator, false)
        {
            WhereOptions = new ObservableCollection <string>(SharepointSearchOptions.SearchOptions());
            dynamic mi = ModelItem;

            InitializeItems(mi.FilterCriteria);
            HelpText = Warewolf.Studio.Resources.Languages.HelpText.Tool_SharePoint_Read_List_Item;
        }
        public void SharepointListReadDesignerViewModel_WhereOptions_Constructor_ShouldBePopulatedWithCorrectOptions()
        {
            //------------Setup for test--------------------------


            //------------Execute Test---------------------------
            var sharepointListReadDesignerViewModel = new SharepointListReadDesignerViewModel(CreateModelItem(), new SynchronousAsyncWorker(), new Mock <IServer>().Object);

            //------------Assert Results-------------------------
            Assert.IsNotNull(sharepointListReadDesignerViewModel);
            Assert.IsNotNull(sharepointListReadDesignerViewModel.WhereOptions);
            Assert.AreEqual(9, sharepointListReadDesignerViewModel.WhereOptions.Count);
            CollectionAssert.AreEqual(SharepointSearchOptions.SearchOptions(), sharepointListReadDesignerViewModel.WhereOptions);
        }
        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)));
            }
        }