示例#1
0
        public ContentIndexResult ReindexSiteForRecovery(IContent siteRoot)
        {
            SlimContentReader slimContentReader = new SlimContentReader(this._contentRepository, siteRoot.ContentLink, (c =>
            {
                return(true);
            }));
            var listDocument = new List <SearchDocument>();

            while (slimContentReader.Next())
            {
                if (!slimContentReader.Current.ContentLink.CompareToIgnoreWorkID(ContentReference.RootPage))
                {
                    IVersionable current = slimContentReader.Current as IVersionable;
                    if (current == null || current.Status == VersionStatus.Published)
                    {
                        if (LuceneConfiguration.CanIndexContent(slimContentReader.Current))
                        {
                            var document = GetDocFromContent(slimContentReader.Current);
                            if (document != null)
                            {
                                listDocument.Add(document);
                            }
                        }
                    }
                }
            }
            _documentRepository.ReindexSiteForRecovery(listDocument, siteRoot.ContentGuid);
            return(new ContentIndexResult());
        }
示例#2
0
        public virtual ContentIndexResult IndexContent(IContent content, bool includeChild = false)
        {
            SlimContentReader slimContentReader = new SlimContentReader(this._contentRepository, content.ContentLink, (c =>
            {
                return(includeChild);
            }));
            var listDocument = new List <SearchDocument>();

            while (slimContentReader.Next())
            {
                if (!slimContentReader.Current.ContentLink.CompareToIgnoreWorkID(ContentReference.RootPage))
                {
                    IVersionable current = slimContentReader.Current as IVersionable;
                    if (current == null || current.Status == VersionStatus.Published)
                    {
                        if (LuceneConfiguration.CanIndexContent(slimContentReader.Current))
                        {
                            var document = GetDocFromContent(slimContentReader.Current);
                            if (document != null)
                            {
                                listDocument.Add(document);
                            }
                        }
                    }
                }
            }
            _documentRepository.UpdateBatchIndex(listDocument);
            return(new ContentIndexResult());
        }
示例#3
0
 private void DeleteContentLanguage(object sender, ContentEventArgs e)
 {
     Task.Run(() =>
     {
         if (SiteCreationServiceBase.IsSettingUpSite())
         {
             return;
         }
         if (LuceneConfiguration.CanIndexContent(e.Content))
         {
             _indexingHandler.Value.ProcessRequest(new IndexRequestItem(e.Content, IndexRequestItem.REMOVE_LANGUAGE));
         }
     });
 }
        public string IndexSite(List <int> siteStartPageIds)
        {
            var progress = new StringBuilder();

            progress.AppendLine("Start Indexing </br>");
            if (!LuceneConfiguration.Active)
            {
                progress.AppendLine("Lucene not activated </br>");
                return(progress.ToString());
            }
            foreach (var siteId in siteStartPageIds)
            {
                PageData siteRoot;
                if (_contentRepository.TryGet <PageData>(new ContentReference(siteId), out siteRoot))
                {
                    if (siteRoot == null)
                    {
                        continue;
                    }
                    try
                    {
                        SlimContentReader slimContentReader = new SlimContentReader(this._contentRepository, siteRoot.ContentLink, (c =>
                        {
                            return(true);
                        }));
                        while (slimContentReader.Next())
                        {
                            var currentContent = slimContentReader.Current;
                            if (currentContent != null && !currentContent.ContentLink.CompareToIgnoreWorkID(ContentReference.RootPage))
                            {
                                if (LuceneConfiguration.CanIndexContent(currentContent))
                                {
                                    _indexingHandler.ProcessRequest(new IndexRequestItem(currentContent));
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        _logger.Error($"Lucene Index Site Error: {siteRoot.ContentLink.ID} - {siteRoot.Name}", e);
                        progress.AppendLine($"{siteRoot.ContentLink.ID} - {siteRoot.Name} index failed </br>");
                        continue;
                    }
                    progress.AppendLine($"Site: {siteRoot.ContentLink.ID} - {siteRoot.Name} indexed; </br>");
                }
            }
            progress.AppendLine("Indexing completed</br>");
            return(progress.ToString());
        }
示例#5
0
 private void UpdateSecurity(object sender, ContentSecurityEventArg e)
 {
     Task.Run(() =>
     {
         if (SiteCreationServiceBase.IsSettingUpSite())
         {
             return;
         }
         var content = _contentRepository.Value.Get <IContent>(e.ContentLink);
         if (LuceneConfiguration.CanIndexContent(content))
         {
             _indexingHandler.Value.ProcessRequest(new IndexRequestItem(content));
         }
     });
 }