MihaiCadariuからの次の2つのブログ投稿をご覧ください。
これらの2つを使用すると、必要なものを見つけることができるはずです。
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;
}
engine.PublishingContext.PublishInstruction.RenderInstruction.BinaryStoragePath
また、PreviewModeで、またはTemplate Builderからコーダーをレンダリングする場合、コードがPublisherで実行されている場合と比較して、プロパティが異なるものを返すことにも注意してください。BinaryStoragePathでPublishTransactionURIを表示するには、Visual Studio TBBデバッグプロジェクトをTcmPublisher.exe
プロセスにアタッチして、実際にPublishTransactionオブジェクトが存在するようにする必要があります。そうしないと、BinaryStoragePathに../previewなどの汎用パスが含まれるだけです。