Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tridion 2009 - Using Interops - Is there a possibility to add multiple setConditions for the same Name

Am stuck with small problem.

I want to add multiple setConditions for the same Name that is for PublicationTarget. This is using 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 staging & live target and I tried all the ways but no use.

rowFilter.SetCondition("PublicationTarget", pubStgTarget);

Please suggest,
1. Passing xis possible, what is the best way to achieve?

I tried this ways 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>

like image 795
Siva Charan Avatar asked Apr 15 '12 05:04

Siva Charan


2 Answers

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

However there are 2 workarounds:

  1. Create two RowFilters and set a different PublicationTarget condition in each of them. Then you would issue the query twice (once for each filter). This means you would need to process 2 XML result nodes.

  2. Don't use a PublicationTarget condition when performing the GetListPublishTransactions(). You will then get back an XML element that contains records for all PublicationTargets. In your code, you will filter only those that are of interest to you (e.g. Staging or Live).

I would probably use #2 (unless I know the Publish Queue could potentially return a very large number of records, in which 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 the XPath expression, I haven't actually tested that bit.

like image 194
Mihai Cădariu Avatar answered Oct 10 '22 08:10

Mihai Cădariu


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

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

  • InfoType (string) (ScheduledForPublish 0, WaitingForPublish 1, InProgress 2, ScheduledForDeployment 3, WaitingForDeployment 4, Failed 5, Success 6) (Omit for all)
  • StartDate (dateTime) Only return items after this date
  • EndDate (dateTime) Only return items before this date
  • User (string) Only return items of for user
  • Publication (string) Only return items for this publication
  • PublicationTarget (string) Only return item for this publication target

It's not possible to have conditions that are used more than once.

You might have to make more than one call to the TOM API to achieve the results you require?

like image 22
Dave Houlker Avatar answered Oct 10 '22 06:10

Dave Houlker