I am using Publishing Service and tried to implement the Publish Manager API to retrieve Publish Status, but once the publishing is completed (successfully or unsuccessfully) the PublishManager.GetStatus(handle) returns null.
So, I am not able to actually get the exact status of publishing once its completed.
Below is the code that I tried to implement:
var handle = PublishManager.PublishItem(item, new[] { _webDb }, _webDb.Languages, true, false);
if (handle != null)
{
var publishStatus = PublishManager.GetStatus(handle);
if (publishStatus != null)
{
while (!publishStatus.IsDone)
{
Thread.Sleep(30000);
publishStatus = PublishManager.GetStatus(handle);
}
// Log the publishing status once its finished
Logger.Info("Publish Status: " + publishStatus.State);
Logger.Info("Publish Status : IsDone: " + publishStatus.IsDone);
Logger.Info("Publish Status : IsExpired: " + publishStatus.Expired);
Logger.Info("Publish Status : IsFailed: " + publishStatus.Failed);
}
}
Also I tried to implement below, but this also returns Publish Status as null
var handle = PublishManager.PublishItem(sitemapRoot, new[] { _webDb }, _webDb.Languages, true, false);
PublishManager.WaitFor(handle);
var publishStatus = PublishManager.GetStatus(handle);
Could there be any other way by which we can get the Publishing Status to know whether it was a success or failure?