3

使用 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 论坛,但找不到答案。我是否缺少修补程序,我应该联系支持人员,还是有其他方法可以获取交易信息?

4

3 回答 3

3

我不太确定(没有在深夜的这个时候进一步挖掘),但是“信息”属性实际上是一个 XMLElement 而不是文档所说的字符串?当您使用调试器时,您是否可以在此属性上放置一个监视以查看它包含的内容?

于 2012-05-17T03:17:32.213 回答
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); 
于 2012-05-17T06:57:04.073 回答
0

我没有工作环境,所以我只是在研究我可用的任何现有代码。这是事件系统的片段,仅当您具有管理员权限时才会删除队列项目:

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();
    }
}
于 2012-05-17T19:49:12.023 回答