예제 #1
0
        public virtual void Reindex(int itemID, bool affectsChildren)
        {
            var itemX = persister.Get(itemID);

            if (itemX == null)
            {
                return;
            }

            string title    = itemX.Title;
            var    document = indexer.CreateDocument(itemX);

            Execute(new Work
            {
                Name   = "Reindex #" + itemID + " (affectsChildren = " + affectsChildren + ")",
                Action = () =>
                {
                    // update the index
                    currentWork = "Indexing " + title + " #" + itemID;
                    indexer.Update(document);

                    if (affectsChildren)
                    {
                        var reindexIds = persister.Repository
                                         .Select(Parameter.Equal("Parent.ID", itemID), "ID")
                                         .Select(d => d["ID"]).Cast <int>().ToList();

                        foreach (var childId in reindexIds)
                        {
                            Reindex(childId, affectsChildren);
                        }
                    }
                }
            });
        }
예제 #2
0
        public virtual void Reindex(int itemID, bool affectsChildren)
        {
            var itemX = persister.Get(itemID);

            if (itemX == null)
            {
                return;
            }

            string            title    = itemX.Title;
            string            itemType = itemX.GetType().Name;
            IndexableDocument document = null;

            if (indexer.IsIndexable(itemX))
            {
                document = indexer.CreateDocument(itemX);
            }

            Execute(new Work
            {
                Name   = "Reindex #" + itemID + "[" + itemType + "]" + "(affectsChildren = " + affectsChildren + ")",
                Action = () =>
                {
                    // update the index
                    if (document != null)
                    {
                        currentWork = "Indexing: [" + itemType + "] " + " #" + itemID + " " + title;
                        indexer.Update(document);
                    }
                    else
                    {
                        currentWork = "Skipping: [" + itemType + "] " + " #" + itemID + " " + title;
                    }

                    if (affectsChildren)
                    {
                        var reindexIds = persister.Repository
                                         .Select(Parameter.Equal("Parent.ID", itemID), "ID")
                                         .Select(d => d["ID"]).Cast <int>().ToList();

                        foreach (var childId in reindexIds)
                        {
                            Reindex(childId, affectsChildren);
                        }
                    }
                }
            });
        }