using Sitecore.Publishing;
using Sitecore.Data;
public void Publishing()
{
try
{
string rootItemPath = "/sitecore/Content/foldername/";
Database sourceDb = Sitecore.Configuration.Factory.GetDatabase("master");
Database targeteDb = Sitecore.Configuration.Factory.GetDatabase("web");
var language = Sitecore.Context.Language;
var contentItem = sourceDb.GetItem(rootItemPath);
PublishOptions options = new PublishOptions(sourceDb, targeteDb, PublishMode.Smart, language, DateTime.Now)
{
RootItem = contentItem,
PublishRelatedItems = true,
Deep = true
};
//If publish mode is FULL then CompareRevisions should be false
//options.CompareRevisions = false;
Publisher publisher = new Publisher(options);
bool willBeQueued = publisher.WillBeQueued;
publisher.PublishAsync();
publisher.Publish();
}
catch (Exception ex)
{
throw ex;
}
}
No comments:
Post a Comment