问题:如果发布项目到TargetDatabase失败,则无法捕获。
在sitecore UI中,当我将一个项目从master数据库发布到Web数据库(目标数据库)时,我想在UI中显示之前检查发布是否成功。
查看John West关于管道订单的以下帖子: http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2011/08/intercept-item-publishing-with-the-sitecore-aspnet-cms.aspx
我添加了以下发布项处理器:
<processor patch:after="*[@type='Sitecore.Publishing.Pipelines.PublishItem.PerformAction, Sitecore.Kernel']" type="BOTWLibrary.Pipelines.EvaluateResult, BOTWLibrary"/>
在EvaluateResult.cs
中public class EvaluateResult : PublishItemProcessor
{
public override void Process(PublishItemContext context)
{
// check if publish was successful.
}
}
提前致谢。
答案 0 :(得分:0)
如果发布失败,则会将结果操作设置为none,并为未知发布操作提供原因。这不是发布失败的保证,但我认为它是您最接近的。
public class EvaluateResult : PublishItemProcessor
{
public override void Process(PublishItemContext context)
{
// check if publish was successful.
if(context.Result.Operation == PublishOperation.None)
{
throw new Exception(context.Result.Explanation);
}
}
}