コード例 #1
0
ファイル: ContentChannelItem.cs プロジェクト: ewin66/rockrms
        /// <summary>
        /// Bulks the index documents.
        /// </summary>
        public void BulkIndexDocuments()
        {
            List <ContentChannelItemIndex> indexableChannelItems = new List <ContentChannelItemIndex>();

            // return all approved content channel items that are in content channels that should be indexed
            RockContext rockContext         = new RockContext();
            var         contentChannelItems = new ContentChannelItemService(rockContext).Queryable()
                                              .Where(i =>
                                                     i.ContentChannel.IsIndexEnabled &&
                                                     (i.ContentChannel.RequiresApproval == false || i.ContentChannel.ContentChannelType.DisableStatus || i.Status == ContentChannelItemStatus.Approved));

            int recordCounter = 0;

            foreach (var item in contentChannelItems)
            {
                var indexableChannelItem = ContentChannelItemIndex.LoadByModel(item);
                indexableChannelItems.Add(indexableChannelItem);

                recordCounter++;

                if (recordCounter > 100)
                {
                    IndexContainer.IndexDocuments(indexableChannelItems);
                    indexableChannelItems = new List <ContentChannelItemIndex>();
                    recordCounter         = 0;
                }
            }

            IndexContainer.IndexDocuments(indexableChannelItems);
        }
コード例 #2
0
        /// <summary>
        /// Deletes the indexed documents by content channel.
        /// </summary>
        /// <param name="contentChannelId">The content channel identifier.</param>
        public void DeleteIndexedDocumentsByContentChannel(int contentChannelId)
        {
            var contentItems = new ContentChannelItemService(new RockContext()).Queryable()
                               .Where(i => i.ContentChannelId == contentChannelId);

            foreach (var item in contentItems)
            {
                var indexableChannelItem = ContentChannelItemIndex.LoadByModel(item);
                IndexContainer.DeleteDocument <ContentChannelItemIndex>(indexableChannelItem);
            }
        }
コード例 #3
0
ファイル: ContentChannelItem.cs プロジェクト: ewin66/rockrms
        /// <summary>
        /// Indexes the document.
        /// </summary>
        /// <param name="id"></param>
        public void IndexDocument(int id)
        {
            var itemEntity = new ContentChannelItemService(new RockContext()).Get(id);

            // only index if the content channel is set to be indexed
            if (itemEntity.ContentChannel != null && itemEntity.ContentChannel.IsIndexEnabled)
            {
                // ensure it's meant to be indexed
                if (itemEntity.ContentChannel.IsIndexEnabled && (itemEntity.ContentChannel.RequiresApproval == false || itemEntity.ContentChannel.ContentChannelType.DisableStatus || itemEntity.Status == ContentChannelItemStatus.Approved))
                {
                    var indexItem = ContentChannelItemIndex.LoadByModel(itemEntity);
                    IndexContainer.IndexDocument(indexItem);
                }
            }
        }