Exemplo n.º 1
0
        private void DocumentOnAfterPublish(Document sender, PublishEventArgs publishEventArgs)
        {
            IndexingRepository indexingRepository = new IndexingRepository((ICmsIndexer) new UmbracoIndexer(), (ILogFacade) new LogFacade(typeof(IndexingRepository)));

            indexingRepository.IndexNode(((CMSNode)sender).Id, true);
            indexingRepository.BuildSpellcheckDictionary();
        }
Exemplo n.º 2
0
        private void PublishingStrategyOnUnPublished(IPublishingStrategy sender, PublishEventArgs <IContent> publishEventArgs)
        {
            if (!publishEventArgs.PublishedEntities.Any <IContent>())
            {
                return;
            }
            IndexingRepository indexingRepository = new IndexingRepository((ICmsIndexer) new UmbracoIndexer(), (ILogFacade) new LogFacade(typeof(IndexingRepository)));

            using (IEnumerator <IContent> enumerator1 = publishEventArgs.PublishedEntities.GetEnumerator())
            {
                while (((IEnumerator)enumerator1).MoveNext())
                {
                    IContent current1 = enumerator1.Current;
                    try
                    {
                        using (IEnumerator <PropertyType> enumerator2 = ((IContentBase)current1).PropertyTypes.GetEnumerator())
                        {
                            while (((IEnumerator)enumerator2).MoveNext())
                            {
                                PropertyType current2 = enumerator2.Current;
                                try
                                {
                                    if (current2.DataTypeDefinitionId == -90)
                                    {
                                        this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, string.Format("{0} was detected as upload property, will remove file from index", (object)current2.Alias), (Exception)null);
                                        Property property = ((KeyedCollection <string, Property>)((IContentBase)current1).Properties)[current2.Alias];
                                        if (property.Value != null && property.Value.ToString() != string.Empty)
                                        {
                                            string standaloneMediaId = MediaResolver.GetStandaloneMediaId(property.Value.ToString());
                                            if (!string.IsNullOrWhiteSpace(standaloneMediaId))
                                            {
                                                indexingRepository.DeleteMediaFromIndex("media" + standaloneMediaId);
                                                MediaResolver.RemoveStandAloneMedia(standaloneMediaId);
                                            }
                                        }
                                        else
                                        {
                                            this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, "Property value is empty, nothing to remove", (Exception)null);
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Error, "Error removing upload property media item from index.", ex);
                                }
                            }
                        }
                        this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, "Unpublishing document \"" + ((IUmbracoEntity)current1).Name + "\", removing from Solr index.", (Exception)null);
                        indexingRepository.DeleteFromPublishedIndex((object)((IEntity)current1).Id);
                    }
                    catch (Exception ex)
                    {
                        this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Error, "Error removing node " + (object)((IEntity)current1).Id + " from index, are you sure Solr is running?", ex);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void ContentServiceOnDeleted(IContentService sender, DeleteEventArgs <IContent> SaveEventArgs)
        {
            IndexingRepository indexingRepository = new IndexingRepository((ICmsIndexer) new UmbracoIndexer(), (ILogFacade) new LogFacade(typeof(IndexingRepository)));

            foreach (var n in SaveEventArgs.DeletedEntities)
            {
                indexingRepository.DeleteFromIndex(n.Id);
            }
        }
Exemplo n.º 4
0
        private void ContentServiceOnSaved(IContentService sender, SaveEventArgs <IContent> SaveEventArgs)
        {
            IndexingRepository indexingRepository = new IndexingRepository((ICmsIndexer) new UmbracoIndexer(), (ILogFacade) new LogFacade(typeof(IndexingRepository)));

            foreach (var n in SaveEventArgs.SavedEntities)
            {
                indexingRepository.IndexNode(n.Id, false);
                indexingRepository.BuildSpellcheckDictionary();
            }
        }
Exemplo n.º 5
0
        protected void btnClearIndex_Click(object sender, EventArgs e)
        {
            IndexingRepository indexingRepository = new IndexingRepository((ICmsIndexer) new UmbracoIndexer(), (ILogFacade) new LogFacade(typeof(IndexingRepository)));

            try
            {
                DateTime now1 = DateTime.Now;
                indexingRepository.ClearIndex();
                DateTime now2 = DateTime.Now;
                this.LoadStatistics();
                this.lblStatus.Text = string.Format("Done, index cleared in {0} seconds.", (object)(now2 - now1).TotalSeconds.ToString("N2"));
            }
            catch (Exception ex)
            {
                this.lblStatus.Text = "An error occured, index not cleared. Errormessage: " + ex.Message;
                this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Error, "Error rebuilding index", ex);
            }
        }
Exemplo n.º 6
0
        private void ContentServiceOnPublished(IPublishingStrategy sender, PublishEventArgs <IContent> publishEventArgs)
        {
            if (!publishEventArgs.PublishedEntities.Any <IContent>())
            {
                return;
            }
            IndexingRepository indexingRepository = new IndexingRepository((ICmsIndexer) new UmbracoIndexer(), (ILogFacade) new LogFacade(typeof(IndexingRepository)));
            List <int>         intList            = new List <int>();

            using (IEnumerator <IContent> enumerator = publishEventArgs.PublishedEntities.GetEnumerator())
            {
                while (((IEnumerator)enumerator).MoveNext())
                {
                    IContent current = enumerator.Current;
                    indexingRepository.IndexNode(((IEntity)current).Id, true);
                }
            }
            indexingRepository.BuildSpellcheckDictionary();
        }
Exemplo n.º 7
0
        private void MediaServiceDeleted(IMediaService sender, DeleteEventArgs <IMedia> e)
        {
            IndexingRepository indexingRepository = new IndexingRepository((ICmsIndexer) new UmbracoIndexer(), (ILogFacade) new LogFacade(typeof(IndexingRepository)));

            using (IEnumerator <IMedia> enumerator = e.DeletedEntities.GetEnumerator())
            {
                while (((IEnumerator)enumerator).MoveNext())
                {
                    IMedia current = enumerator.Current;
                    try
                    {
                        this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, "Deleted media item \"" + ((IUmbracoEntity)current).Name + "\", removing from Solr index.", (Exception)null);
                        indexingRepository.DeleteMediaFromIndex(((IEntity)current).Id.ToString((IFormatProvider)CultureInfo.InvariantCulture));
                    }
                    catch (Exception ex)
                    {
                        this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Error, "Error removing media item " + (object)((IEntity)current).Id + " from index, are you sure Solr is running?", ex);
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void ContentServiceOnTrashed(IContentService sender, MoveEventArgs <IContent> MoveEventArgs)
        {
            IndexingRepository indexingRepository = new IndexingRepository((ICmsIndexer) new UmbracoIndexer(), (ILogFacade) new LogFacade(typeof(IndexingRepository)));

            indexingRepository.DeleteFromIndex(MoveEventArgs.Entity.Id);
        }