看一看从米哈伊Cadariu这两个博客文章:
有了这两个,你应该能够找到你需要的东西。
你在TBB所需要的基本功能是这样的:
public PublishTransaction GetPublishTransaction(Engine engine)
{
String binaryPath = engine.PublishingContext.PublishInstruction.
RenderInstruction.BinaryStoragePath;
Regex tcmRegex = new Regex(@"tcm_\d+-\d+-66560");
Match match = tcmRegex.Match(binaryPath);
if (match.Success)
{
String transactionId = match.Value.Replace('_', ':');
TcmUri transactionUri = new TcmUri(transactionId);
return new PublishTransaction(transactionUri, engine.GetSession());
}
return null;
}
它也可能是值得指出的是,呈现在PreviewMode或从模板生成器编码器时相比,当地产engine.PublishingContext.PublishInstruction.RenderInstruction.BinaryStoragePath
将返回不同的东西该代码正在发布服务器中运行。要查看BinaryStoragePath中的PublishTransaction URI,必须将Visual Studio TBB Debug项目附加到TcmPublisher.exe
进程中,以便实际上存在PublishTransaction对象,否则BinaryStoragePath将只包含像../preview这样的通用路径。
很好,我添加了Mihai和Chris的代码,现在我有了PublishTransaction - 非常感谢 – GourmetCMS 2012-07-27 02:02:42