Пример #1
0
 /// <summary>
 /// Loads all root descendents by default
 /// </summary>
 /// <param name="contentIndexer"></param>
 /// <returns></returns>
 public virtual IEnumerable <ContentReference> GetSearchContentReferences(IVulcanContentIndexer contentIndexer)
 {
     return(_ContentLoader.GetDescendents(contentIndexer.GetRoot().Key));
 }
Пример #2
0
        private bool IndexContent(ContentReference contentReference, int contentRecord, IVulcanContentIndexer cmsIndexer, IVulcanFeatureCacheScope isCacheScopeFeature, int totalCount)
        {
            if
            (
                isCacheScopeFeature?.Enabled != true &&
                cmsIndexer is IVulcanContentIndexerWithCacheClearing cacheClearingIndexer &&
                cacheClearingIndexer.ClearCacheItemInterval >= 0
            )
            {
                if (contentRecord % cacheClearingIndexer.ClearCacheItemInterval == 0)
                {
                    cacheClearingIndexer.ClearCache();
                }
            }

            // only update this every 100 records (reduce load on db)
            if (contentRecord % 100 == 0)
            {
                OnStatusChanged($"{cmsIndexer.IndexerName} indexing item {contentRecord + 1} of {totalCount} items of {cmsIndexer.GetRoot().Value} content");
            }

            IContent content;

            try
            {
                content = LoadWithCacheScope(contentReference, isCacheScopeFeature);
            }
            catch (OutOfMemoryException)
            {
                Logger.Warning($"Vulcan encountered an OutOfMemory exception, attempting again to index content item {contentReference}...");

                // try once more
                try
                {
                    // ReSharper disable once RedundantAssignment
                    content = LoadWithCacheScope(contentReference, isCacheScopeFeature);
                }
                catch (Exception eNested)
                {
                    Logger.Error($"Vulcan could not recover from an out of memory exception when it tried again to index content item  {contentReference} : {eNested}");
                }

                return(false);
            }
            catch (Exception eOther)
            {
                Logger.Error($"Vulcan could not index content item {contentReference} : {eOther}");

                return(false);
            }

            if (content == null)
            {
                Logger.Error($"Vulcan could not index content item {contentReference}: content was null");

                return(false);
            }

            Logger.Information($"Vulcan indexed content with reference: {contentReference} and name: {content.Name}");

            _vulcanHandler.IndexContentEveryLanguage(content, _vulcanIndexContentJobSettings.EnableAlwaysUp ? VulcanHelper.TempAlias : null);

            return(true);
        }