Not sure that you are able to catch events, as job that is responsible for scheduled publishing is not publishing a page through data factory, but instead - modifies StartPublish property date directly and then - saves the content.
IContent content2 = content1; IVersionable versionable1 = content2 as IVersionable; if (versionable1 != null) { IVersionable versionable2 = contentRepository.Get<IContent>(...) as IVersionable; if (versionable2 != null && versionable2.Status == VersionStatus.Published) versionable1.StartPublish = versionable2.StartPublish; } contentRepository.Save(content2, (SaveAction) 259, AccessLevel.NoAccess);
You could intercept saving event, check for IVersionable interface and check it's status:
IVersionable versionable2 = contentRepository.Get<IContent>(...) as IVersionable; if(versionable2 != null && versionable2.Status == VersionStatus.DelayedPublish) { // black magic here }
Hi,
Did you manage to catch saving event when triggered from the scheduled job?
My breakpoint doesn't get hit, but something is fishy with this project's delayed publishing scheduled job, since I always get 0 pages were published and they are in fact published.
Thx,
Marija
No I couldn't get it working. I think at the time I realised I would have to have my own delayed publishing job to get it working. The problem for me was that I have a cache layer above Episerver data cache and the cache would not get invalidated if the page/block was scheduled to be published. It's no a major issue for us at the moment as our editors don't use scheduled publishing often.
Please let me know if you find a solution or a fix from Episerver is released.
What version are you using?
I have EPiServer.CMS.Core 7.19.2 and the PublishedEvent is actually fired for delayed publishing (when the EpiServer job "Publish Delayed Content Versions" is executed)
I start to listen for the event in SiteInit.cs:
context.Locate.ContentEvents().PublishedContent += NotifyCacheManager;
EPiServer 6 R2 for me.
I ended up sending emails in my own scheduled job instead. So, I send an email and set a flag on the page that the email has been sent (so that I send it only once). (And I do this after a specific datetime, so that I don't end up sending emails for all the pages ever published :D)
BR,
Marija
We are using 7.13 . I have a code below:
DataFactory.Instance.PublishedContent += Instance_PublishedContent;
It has either been fixed in the newer versions or I should use contex.Locate.ContentEvents() like you have.
Thanks for sharing Sven.
Hi,
I have some code in the solution that is executed when a page is published. Like below :
However, when a page or block is scheduled to be published in the future, this event is not raised and the code will not run as a result.
Is there anyway I can catch delayed publish event in my code?