How to get publishing status of any Component using Core Service? I want to fetch those TCM Ids which have been published successfully, un-published successfully and failed for a specific Publication Target.
-
1There is an already question and answer for this, tridion.stackexchange.com/questions/7473/…– Velmurugan ♦Commented Nov 23, 2018 at 14:58
-
Hi Velmurugan , the code provided on the above link does not work for me.– User 45Commented Nov 27, 2018 at 13:51
-
what you have tried so far and any errors please edit your question and share the error/logs details?– Velmurugan ♦Commented Nov 27, 2018 at 14:15
-
The requirement is like - 10 components sent to publishing queue and 5 components successfully published, 3 components successfully unpublished and 2 components failed. I want those component TCM Ids through core service code.– User 45Commented Nov 29, 2018 at 8:46
Add a comment
|
1 Answer
You can use To filter capabilities of the Publishing queue, take a look at the PublishTransactionsFilterData and its properties. Use the filter paired with GetSystemWideList or GetSystemWideListXml and you can obtain an array of PublishTransactionData or their Ids.
Example coreservice code:
using System;
using System.ServiceModel;
using System.Xml.Linq;
using Tridion.ContentManager.CoreService.Client;
namespace PublishingQueue
{
static class Program
{
static void Main()
{
var client = GetClient("localhost:7086", @"username", "password");
var filter = new PublishTransactionsFilterData()
{
StartDate = System.DateTime.Now.AddMonths(-2),
EndDate = System.DateTime.Now,
PublishTransactionState = PublishTransactionState.Success
};
XElement publishTransactions = client.GetSystemWideListXml(filter);
foreach (XElement queueItem in publishTransactions.Descendants())
{
Console.WriteLine("ID = " + queueItem.Attribute("ID").Value);
Console.WriteLine("Title = " + queueItem.Attribute("Title").Value);
Console.WriteLine("ItemUri = " + queueItem.Attribute("ItemID").Value);
Console.WriteLine("User = " + queueItem.Attribute("User").Value);
Console.WriteLine("Publication = " + queueItem.Attribute("Publication").Value);
Console.WriteLine("PublicationTarget = "+ queueItem.Attribute("PublicationTarget").Value);
Console.WriteLine("ItemPath = " + queueItem.Attribute("ItemPath").Value);
}
Console.Read();
}
static ICoreService GetClient(string hostname, string username, string password)
{
var binding = new BasicHttpsBinding()
{
MaxBufferSize = 4194304, // 4MB
MaxBufferPoolSize = 4194304,
MaxReceivedMessageSize = 4194304,
ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
{
MaxStringContentLength = 4194304, // 4MB
MaxArrayLength = 4194304,
},
Security = new BasicHttpsSecurity()
{
Mode = BasicHttpsSecurityMode.Transport,
Transport = new HttpTransportSecurity()
{
ClientCredentialType = HttpClientCredentialType.Basic
}
}
};
hostname = string.Format("{0}{1}{2}", hostname.StartsWith("https") ? "" : "https://", hostname, hostname.EndsWith("/") ? "" : "/");
var endpoint = new EndpointAddress(hostname + "/webservices/CoreService201603.svc/basicHttp");
var factory = new ChannelFactory<ICoreService>(binding, endpoint);
var credentialBehaviour = factory.Endpoint.Behaviors.Find<System.ServiceModel.Description.ClientCredentials>();
credentialBehaviour.UserName.UserName = username;
credentialBehaviour.UserName.Password = password;
return factory.CreateChannel();
}
}
}
I hope it helps
-
Hi Velmurugan, Thanks for your help. With the reference above code the my implementation works. Thanks for your assistance. I have added just extra two filter to get the results for specific publication and publication targets -
ForRepository = new LinkToRepositoryData { IdRef = "tcm:0-32-1" }, PublicationTarget = new LinkToPublicationTargetData { IdRef = "tcm:0-12-65537" }
– User 45Commented Nov 29, 2018 at 11:32 -
Good to now it helps to resolved your issue, please upvote– Velmurugan ♦Commented Nov 29, 2018 at 12:12
-
Hi Velmurugan, one more input is required. How to get those components from publishing queue which has been unpublished successfully?– User 45Commented Nov 29, 2018 at 18:53
-
1
-
I have raised a new question for the query. Thanks @AtilaSos. Here is the question reference - tridion.stackexchange.com/questions/19546/…– User 45Commented Nov 30, 2018 at 7:43