使用Tridion 2009,SP1,因此使用旧的COM + TOM API。我正在尝试获取PublishTransaction的信息,但每次调用PublishTransaction.Information属性时都会收到错误。
这是我的代码:
try
{
var pubTrans = (PublishTransaction)tdse.GetObject("tcm:0-166535-66560",
EnumOpenMode.OpenModeView);
Console.WriteLine("transaction id=" + pubTrans.ID);
Console.WriteLine("transaction itemtype=" + pubTrans.itemType.ToString());
Console.WriteLine("transaction info=" + pubTrans.Information);
}
catch (Exception e)
{
Console.WriteLine(e.Message, e.StackTrace);
}
以上,交易ID和项目类型打印正常。我有其他代码,其中Delete方法工作正常,但任何时候我尝试获取信息,它会爆炸。
这是错误:
<tcm:Error xmlns:tcm="http://www.tridion.com/ContentManager/5.0" ErrorCode="D"
Category="18" Source="Kernel" Severity="1">
<tcm:Line Cause="false" MessageID="16138">
<![CDATA[Unable to get Information of Unknown (tcm:0-166535-66560).]]>
<tcm:Token>RESID_4485</tcm:Token><tcm:Token>Information</tcm:Token>
<tcm:Token>RESID_4663</tcm:Token><tcm:Token>tcm:0-166535-66560</tcm:Token>
</tcm:Line>
<tcm:Line ErrorCode="D" Cause="true"><![CDATA[Type mismatch]]></tcm:Line>
<tcm:Details>
<tcm:CallStack>
<tcm:Location>PublishTransaction.Information</tcm:Location>
<tcm:Location>PublishTransaction.Information</tcm:Location>
</tcm:CallStack>
</tcm:Details>
</tcm:Error>
我搜索过SDL Tridion World论坛,找不到答案。我是否缺少修补程序,是否应该与支持部门联系,或者是否有其他方式来获取交易信息?
答案 0 :(得分:3)
我不太确定(在晚上的这个时候没有进一步挖掘),但是'信息'属性实际上是一个XMLElement而不是文档所说的字符串?当您使用调试器时,您是否可以在此属性上放置监视以查看它包含的内容?
答案 1 :(得分:2)
我以另一种方式尝试了这个以获取PublishTransaction信息。以下是代码: -
PublishTransaction pubTrans = (PublishTransaction)tdse.GetObject(
"tcm:0-4294103-66560",
EnumOpenMode.OpenModeView,
null,
XMLReadFilter.XMLReadNull);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(pubTrans.GetXML(XMLReadFilter.XMLReadAll));
XmlNamespaceManager nameSpace = new XmlNamespaceManager(xmlDoc.NameTable);
nameSpace.AddNamespace("tcm", "http://www.tridion.com/ContentManager/5.0");
nameSpace.AddNamespace("xlink", "http://www.w3.org/1999/xlink");
Console.WriteLine("transaction id=" + pubTrans.ID);
Console.WriteLine("transaction itemtype=" + pubTrans.itemType.ToString());
EnumPublishTransactionState transState = pubTrans.get_State();
if (transState == EnumPublishTransactionState.Failed)
Console.WriteLine("transaction info=" +
xmlDoc.SelectSingleNode("/tcm:PublishTransaction/tcm:Data/tcm:Information",
nameSpace).InnerText);
答案 2 :(得分:0)
我没有工作环境,所以我只是在查看我现有的任何代码。这是来自Event系统的片段,仅当您具有Admin权限时才会删除Queue项目:
public void OnPublicationPublishPost(Publication publication, IXMLDOMDocument2 publishResult)
{
TDSE tdse = Utilities.GetTDSEInstance();
publishResult.setProperty("SelectionNamespaces", "xmlns:tcm=\"http://www.tridion.com/ContentManager/5.0\"");
PublishTransaction publishTransaction = Utilities.GetTridionItem<PublishTransaction>(publishResult.selectSingleNode("/*/*").attributes[2].text, null) as PublishTransaction;
User user = Utilities.GetTridionItem<User>(publishResult.selectSingleNode("/tcm:PublishResponse/tcm:PublisherRequest/tcm:User").attributes[0].text, null) as User;
TDSPrivileges isAdmin = user.privileges;
if (isAdmin != TDSPrivileges.TdsPrivilegeSystemAdministrator)
{
publishTransaction.Delete();
}
}