SaveAndPublishWithStatus set to false but still raised Publishing event
Hi All,
I'm running Umbraco V7.3.1 and I'm detecting the ContentService.Published event on Content Node.
All I need is to detect the publishing event on specific DocTypes. Make some properties changes and then save and publish it. But It ended up in a loop of event publishing detection even when i have my .SaveAndPublishWithStatus raiseEvent set to false. Any idea anyone?
Thanks
public class RegisterEvents : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase httpApplicationBase, ApplicationContext applicationContext)
{
ContentService.Published += Proj_ContentServicePublished;
}
private static void Proj_ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> args)
{
var contentService = ApplicationContext.Current.Services.ContentService;
foreach (var projNode in args.PublishedEntities.Where(node => node.ContentType.Alias == "something"))
{
// Update some properties
projNode.SetValue("booleanValue", true);
// Then save and publish
contentService.SaveAndPublishWithStatus(projNode, 0, false);
}
}
}
Having a quick look at the source for the content service, I think setting RaiseEvents to false only prevents the raising of Saving events, so it seems the publish events still fire... (so do you check to see if the property is set before setting it again as a work around ?)
or what you are trying to achieve, would it work if you moved the code to the Saving event ?
SaveAndPublishWithStatus set to false but still raised Publishing event
Hi All,
I'm running Umbraco V7.3.1 and I'm detecting the ContentService.Published event on Content Node.
All I need is to detect the publishing event on specific DocTypes. Make some properties changes and then save and publish it. But It ended up in a loop of event publishing detection even when i have my .SaveAndPublishWithStatus raiseEvent set to false. Any idea anyone?
Thanks
Hi Jlon
Having a quick look at the source for the content service, I think setting RaiseEvents to false only prevents the raising of Saving events, so it seems the publish events still fire... (so do you check to see if the property is set before setting it again as a work around ?)
or what you are trying to achieve, would it work if you moved the code to the Saving event ?
Because then you wouldn't need to call SaveAndPublishWithStatus from within the Published event.
is working on a reply...