您應該可以查看ResolveInstruction
的ResolvePurpose
,您可以將其作爲自定義解析程序中的一個參數。沿着這些路線的東西:
public void Resolve(IdentifiableObject item, ResolveInstruction instruction, PublishContext context, ISet<ResolvedItem> resolvedItems)
{
if (instruction.Purpose == ResolvePurpose.Publish || instruction.Purpose == ResolvePurpose.RePublish)
{
// We are publishing
}
else if(instruction.Purpose == ResolvePurpose.UnPublish)
{
// We are unpublishing
}
// Don't know if this one exists in 2009, it exists in 2011 SP1
else if(instruction.Purpose == ResolvePurpose.UnknownByClient)
{
// The server is doing something that I don't understand (yet?)
}
}
編輯
我拒絕不能找到一種方法,使這項工作...
事實上,在2009年外表套上你沒有一個Purpose
解決指令。發佈事務中確實有一個Action
,但是這個不直接在解析器中公開。下面是我發現我是如何發佈或取消發佈的 - 如果認爲它過度,你的電話會非常糟糕,但在非生產虛擬機上的性能非常好。
- 找我們解決了
- 當前項目裝入PublishTransaction名單與「正在進行中」
- 的狀態查找該交易爲當前項目
- 確定由動作看
Action
屬性
Filter filter = new Filter();
filter.Conditions["InfoType"] = 2; // Get transactions in Progress
foreach (XmlNode node in item.Session.GetList(typeof(PublishTransaction), filter))
{
if(node.Attributes["ItemID"].Value.Equals(item.Id.ToString()))
{
// we have a winner
string action;
if (node.Attributes["Action"].Value.Equals("0"))
action = "Publish";
if (node.Attributes["Action"].Value.Equals("1"))
action = "Unpublish";
}
}
請想張貼這疑問句的這裏也是:http://tridion.stackexchange.com/grant-beta-access?key=63880f9cbf452c62f726770209533893 – 2013-03-01 12:51:34