コード例 #1
0
ファイル: BuiltIn.cs プロジェクト: vjswaroop/PnP-Tools
        public string ContentByQueryToHighlightedContentProperties(string webUrl, string listGuid, string listName, string serverTemplate, string contentTypeBeginsWithId,
                                                                   string filterField1, string filter1ChainingOperator, string filterField1Value, string filterOperator1,
                                                                   string filterField2, string filter2ChainingOperator, string filterField2Value, string filterOperator2,
                                                                   string filterField3, string filterField3Value, string filterOperator3,
                                                                   string sortBy, string sortByDirection, string groupBy, string groupByDirection, string itemLimit, int displayColumns,
                                                                   string dataMappings)
        {
            ContentByQuery cbq = new ContentByQuery()
            {
                WebUrl                  = webUrl,
                ListGuid                = listGuid,
                ListName                = listName,
                ServerTemplate          = serverTemplate,
                ContentTypeBeginsWithId = contentTypeBeginsWithId,

                FilterField1            = filterField1,
                Filter1ChainingOperator = (FilterChainingOperator)Enum.Parse(typeof(FilterChainingOperator), filter1ChainingOperator, true),
                FilterField1Value       = filterField1Value,
                FilterOperator1         = (FilterFieldQueryOperator)Enum.Parse(typeof(FilterFieldQueryOperator), filterOperator1, true),
                FilterField2            = filterField2,
                Filter2ChainingOperator = (FilterChainingOperator)Enum.Parse(typeof(FilterChainingOperator), filter2ChainingOperator, true),
                FilterField2Value       = filterField2Value,
                FilterOperator2         = (FilterFieldQueryOperator)Enum.Parse(typeof(FilterFieldQueryOperator), filterOperator2, true),
                FilterField3            = filterField3,
                FilterField3Value       = filterField3Value,
                FilterOperator3         = (FilterFieldQueryOperator)Enum.Parse(typeof(FilterFieldQueryOperator), filterOperator3, true),

                SortBy           = sortBy,
                SortByDirection  = (SortDirection)Enum.Parse(typeof(SortDirection), sortByDirection, true),
                GroupBy          = groupBy,
                GroupByDirection = (SortDirection)Enum.Parse(typeof(SortDirection), groupByDirection, true),

                ItemLimit      = Convert.ToInt32(itemLimit),
                DisplayColumns = displayColumns,

                DataMappings = dataMappings
            };

            ContentByQuerySearchTransformator cqs = new ContentByQuerySearchTransformator(this.clientContext);
            var res = cqs.TransformContentByQueryWebPartToHighlightedContent(cbq);

            return(res);
        }
コード例 #2
0
        public void TestMethod3()
        {
            using (var cc = TestCommon.CreateClientContext())
            {
                // sample config from web part filtering data from document library
                ContentByQuery cbq = new ContentByQuery()
                {
                    WebUrl                  = "~sitecollection",
                    ListGuid                = "c3f3860d-53c9-4118-b985-8701af1505b0", // done
                    ListName                = "Documents",                            // done
                    ServerTemplate          = "101",
                    ContentTypeBeginsWithId = "0x0101",


                    // Done for Title
                    FilterField1            = "Title",
                    FilterField1Value       = "value1",
                    FilterOperator1         = FilterFieldQueryOperator.BeginsWith,
                    Filter1ChainingOperator = FilterChainingOperator.And,
                    FilterField2            = "FileLeafRef",
                    FilterField2Value       = "value2",
                    FilterOperator2         = FilterFieldQueryOperator.Eq,
                    Filter2ChainingOperator = FilterChainingOperator.And,
                    FilterField3            = "Title",
                    FilterField3Value       = "value3",
                    FilterOperator3         = FilterFieldQueryOperator.Contains,

                    SortBy           = "FileLeafRef",      // Done, not usable unless managed property
                    SortByDirection  = SortDirection.Asc,  // Done, not usable unless managed property
                    GroupBy          = "",                 // Done, not usable today
                    GroupByDirection = SortDirection.Desc, // Done, not usable today

                    ItemLimit      = 15,                   // done
                    DisplayColumns = 1,                    // done

                    DataMappings = "Description:|ImageUrl:|Title:{fa564e0f-0c70-4ab9-b863-0177e6ddd247},Title,Text;|LinkUrl:{94f89715-e097-4e8b-ba79-ea02aa8b7adb},FileRef,Lookup;|"
                };

                ContentByQuerySearchTransformator cqs = new ContentByQuerySearchTransformator(cc);
                var res = cqs.TransformContentByQueryWebPartToHighlightedContent(cbq);
            }
        }