コード例 #1
0
        /// <summary>
        /// Deletes the indexed documents by calendar.
        /// </summary>
        /// <param name="calendarId">The calendar identifier.</param>
        public void DeleteIndexedDocumentsByCalendarId(int calendarId)
        {
            // Ensure provided calendar is indexable
            var calendar = EventCalendarCache.Get(calendarId);

            if (calendar == null || !calendar.IsIndexEnabled)
            {
                return;
            }

            // Get event items for this calendar that are ONLY on this calendar.
            // We don't want to delete items that are also on another calendar.
            var eventItems = new EventItemService(new RockContext())
                             .GetActiveItemsByCalendarId(calendarId)
                             .Where(i => i.EventCalendarItems.Count() == 1)
                             .Select(a => a.Id).ToList();

            int eventItemEntityTypeId = EntityTypeCache.GetId <Rock.Model.EventItem>().Value;

            foreach (var eventItemId in eventItems)
            {
                var deleteEntityTypeIndexMsg = new DeleteEntityTypeIndex.Message
                {
                    EntityTypeId = eventItemEntityTypeId,
                    EntityId     = eventItemId
                };

                deleteEntityTypeIndexMsg.Send();
            }
        }
コード例 #2
0
        /// <summary>
        /// Bulks the index documents by calendar.
        /// </summary>
        /// <param name="calendarId">The calendar identifier.</param>
        public void BulkIndexDocumentsByCalendar(int calendarId)
        {
            // Ensure provided calendar is indexable
            var calendar = EventCalendarCache.Get(calendarId);

            if (calendar == null || !calendar.IsIndexEnabled)
            {
                return;
            }

            var eventItems = new EventItemService(new RockContext())
                             .GetActiveItemsByCalendarId(calendarId)
                             .Select(a => a.Id).ToList();

            int eventItemEntityTypeId = EntityTypeCache.GetId <Rock.Model.EventItem>().Value;

            foreach (var eventItemId in eventItems)
            {
                var deleteEntityTypeIndexMsg = new DeleteEntityTypeIndex.Message
                {
                    EntityTypeId = eventItemEntityTypeId,
                    EntityId     = eventItemId
                };

                deleteEntityTypeIndexMsg.Send();
            }
        }
コード例 #3
0
        /// <summary>
        /// Queues ContentChannelItems of this ContentChannel to have their indexes deleted
        /// </summary>
        /// <param name="contentChannelId">The content channel identifier.</param>
        public void DeleteIndexedDocumentsByContentChannel(int contentChannelId)
        {
            var contentChannelItemIds = new ContentChannelItemService(new RockContext()).Queryable()
                                        .Where(i => i.ContentChannelId == contentChannelId).Select(a => a.Id).ToList();

            int contentChannelItemEntityTypeId = EntityTypeCache.GetId <Rock.Model.ContentChannelItem>().Value;

            foreach (var contentChannelItemId in contentChannelItemIds)
            {
                var deleteEntityTypeIndexMsg = new DeleteEntityTypeIndex.Message
                {
                    EntityTypeId = contentChannelItemEntityTypeId,
                    EntityId     = contentChannelItemId
                };

                deleteEntityTypeIndexMsg.Send();
            }
        }
コード例 #4
0
        /// <summary>
        /// Queues groups of this type to have their indexes deleted
        /// </summary>
        /// <param name="groupTypeId">The group type identifier.</param>
        public void DeleteIndexedDocumentsByGroupType(int groupTypeId)
        {
            var groupIds = new GroupService(new RockContext()).Queryable()
                           .Where(i => i.GroupTypeId == groupTypeId)
                           .Select(a => a.Id).ToList();

            int groupEntityTypeId = EntityTypeCache.GetId <Rock.Model.Group>().Value;

            foreach (var groupId in groupIds)
            {
                var deleteEntityTypeIndexMsg = new DeleteEntityTypeIndex.Message
                {
                    EntityTypeId = groupEntityTypeId,
                    EntityId     = groupId
                };

                deleteEntityTypeIndexMsg.Send();
            }
        }