0

我们有一个带有 1 个 CMS 和 3 个从服务器的分阶段环境

我想在从服务器上创建一个页面,该页面将在成功发布时由登台模块调用,它将重建所有索引和链接数据库。

我知道我可以使用:

Globals.LinkDatabase.Rebuild(Factory.GetDatabase("web"));

重建链接数据库。

如何在可以访问 sitecore 上下文的单独进程中获取上述代码,以及如何重建 Web 数据库的所有索引 - 再次在单独的后台线程中。

谢谢

4

1 回答 1

2

我之前在使用 Sitecore 时遇到过这个问题,并采取了稍微不同的方法。我没有使用暂存模块调用的页面,而是使用了 publish:end 事件并添加了一个自定义处理程序来重建链接数据库。

<event name="publish:end">
    <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
        <sites hint="list">
            <site>website</site>
        </sites>
    </handler>
    <handler type="Sitecore.EventHandlers.CredentialCacheClearer, Sitecore.EventHandlers" method="ClearCache">
        <sites hint="list">
            <site>website</site>
        </sites>
    </handler>

    // Custom Publish Action Below
    <handler type="Customized.Publish.LinkDatabase, Customized" method="Process"/>
</event>
namespace Customized.Publish
{
    public class LinkDatabase
    {
        /// <summary>
        /// Rebuild the web link database.
        /// </summary>

        public void Process()
        {
            // Web db
            Sitecore.Globals.LinkDatabase.Rebuild(Sitecore.Configuration.Factory.GetDatabase("web"));
        }

        /// <summary>
        /// For invoking as an event, typically publish:end.
        /// </summary>
        public void Process(object sender, EventArgs args)
        {
            this.Process();
        }
    }
}
于 2009-07-09T21:19:48.610 回答