After blogging about my beautiful script on purging old Publish Transaction from the Publishing Queue, it turned out the PurgeQueue.exe tool provided by SDL with SDLTridion 2011 simply did not work.
More exactly, I was attempting to delete Publish Transactions with any status (Success or Failed) from the Publishing Queue, that had a date earlier than one year ago today. PurgeQueue.exe runs and displays a message that the Publishing Queue has been purged. In fact the Publish Transactions were not deleted and still appeared in the Publishing Queue.
So it was time to write my own custom PurgeTool, using the Core Service .NET API. The requirement stays the same -- delete Publish Transactions that are at least a year old.
I started with the programmatic instantiation of the the Core Service client, as described in my earlier post Core Service Client Sample Code. Once I had a SessionAwareCoreServiceClient client object the rest of the code is trivial:
More exactly, I was attempting to delete Publish Transactions with any status (Success or Failed) from the Publishing Queue, that had a date earlier than one year ago today. PurgeQueue.exe runs and displays a message that the Publishing Queue has been purged. In fact the Publish Transactions were not deleted and still appeared in the Publishing Queue.
So it was time to write my own custom PurgeTool, using the Core Service .NET API. The requirement stays the same -- delete Publish Transactions that are at least a year old.
I started with the programmatic instantiation of the the Core Service client, as described in my earlier post Core Service Client Sample Code. Once I had a SessionAwareCoreServiceClient client object the rest of the code is trivial:
PublishTransactionsFilterData filter = new
PublishTransactionsFilterData()
{
EndDate = DateTime.Now.AddYears(-1)
};
XElement element = client.GetSystemWideListXml(filter);
foreach (XElement child in element.Descendants())
{
string id =
child.Attribute(XName.Get("ID")).Value;
client.Delete(id);
}
Comments