Tridion 2009 - Using Interops - is it possible to add multiple setConditions for the same name

Stuck with a little problem.

I want to add several setConditions for the same Name as for PublicationTarget . This uses interops dll.

ListRowFilter rowFilter = mTDSE.CreateListRowFilter(); rowFilter.SetCondition("StartDate", sDate); rowFilter.SetCondition("EndDate", eDate); rowFilter.SetCondition("PublicationTarget", pubStgTarget); 

For this PublicationTarget , I want to filter with an intermediate and lively purpose, and I tried all the ways, but didn't use it.

 rowFilter.SetCondition("PublicationTarget", pubStgTarget); 

Please suggest
1. Passing xis perhaps what is best to achieve?

I tried these methods, but no luck;

 rowFilter.SetCondition("PublicationTarget", "tcm:0-1-65537"); // Gives only staging rowFilter.SetCondition("PublicationTarget", "tcm:0-2-65537"); // Gives only Live rowFilter.SetCondition("PublicationTarget", "tcm:0-1-65537|tcm:0-1-65537"); // No result rowFilter.SetCondition("PublicationTarget", oPubList); // No result - `oPubList` is a 

List<string>

+6
source share
2 answers

No, unfortunately, this is not possible. If you want to put a condition on a PublicationTarget , it must be only one PublicationTarget .

However, there are 2 workarounds:

  • Create two RowFilters and set a different PublicationTarget condition in each of them. Then you send a request twice (once for each filter). This means you need to process 2 XML result nodes.

  • Do not use the PublicationTarget clause when executing GetListPublishTransactions() . You will then get an XML element containing entries for all PublicationTargets . In your code, you will filter only those that interest you (for example, Staging or Live).

I would probably use # 2 (if I don't know that the publishing queue could potentially return a very large number of entries, in this case I would use # 1).

Sample code for # 2:

 tdse = new TDS.TDSEClass(); tdse.Impersonate(user.Title); tdse.Initialize(); mgtInfo = tdse.GetManagementInfo(); filter = tdse.CreateListRowFilter(); filter.SetCondition("InfoType", 2); // InProgress filter.SetCondition("Publication", "tcm:0-23-1"); XmlDocument dom = new XmlDocument(); dom.LoadXml(mgtInfo.GetListPublishTransactions(filter)); XmlNamespaceManager namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("tcm", "http://www.tridion.com/ContentManager/5.0"); String xPath = String.Format( "tcm:ListPublishTransactions/tcm:Item[@PublicationTarget='{0}'] | " + "tcm:ListPublishTransactions/tcm:Item[@PublicationTarget='{1}']", stagingTcmUri, liveTcmUri); XmlNodeList nodeList = dom.SelectNodes(xPath, namespaceManager); foreach (XmlNode node in dom.DocumentElement.ChildNodes) { //do your thing } 

Note: double check XPath expression, I have not actually tested this bit.

+6
source
 Public Function GetListPublishTransactions( Optional ByVal rowFilter As TDS.ListRowFilter ) As String 

The GetListPublishTransactions method accepts the following conditions as part of a filter:

  • InfoType (string) (ScheduledForPublish 0, WaitingForPublish 1, InProgress 2, ScheduledForDeployment 3, WaitingForDeployment 4, Failed 5, Success 6) (Omit for all)
  • StartDate (dateTime) Return only items after this date
  • EndDate (dateTime) Returns only items up to this date.
  • User (string) Returns only items for the user
  • Publication (row) Only return items for this publication
  • PublicationTarget (string) Only return element for this publication purpose

It is impossible to have conditions that are used more than once.

You may need to make several TOM API calls to achieve the desired results?

+2
source

Source: https://habr.com/ru/post/913227/


All Articles