Episerver on before publish event

Vote:
 

Is there a way in episerver that would let me check that when I click publich which properties are changed?

I have been able to hook into the onPublishedEvent like this

[InitializableModule]
    [ModuleDependency(typeof(EPiServer.Web.InitializationModule),
                          typeof(EPiServer.Web.InitializationModule))]
    public class EventsInitialization : IInitializableModule
    {
        public void Initialize(InitializationEngine context)
        {
            var events = context.Locate.ContentEvents();
            events.PublishedContent += EventsPublishedContent;
        }

        public void Preload(string[] parameters)
        {
        }

        public void Uninitialize(InitializationEngine context)
        {
            var events = context.Locate.ContentEvents();
            events.PublishedContent -= EventsPublishedContent;
        }


        public void EventsPublishedContent(object sender, ContentEventArgs eventArgs)
        {
            var pageType = eventArgs.Content as ArticlePage;

            string h = pageType.Heading;

            if (pageType.IsDeleted)
            {
                // if the page is deleted also delete the indexed item
            }
            else
            {
                // if not deleted check if the indexed data is changed or not

               string ds = pageType.DocumentSeries;

               // pageType.ContentLink.CompareTo.
            }


        }

But how do I check if a particular property has changed?

#186091
Dec 12, 2017 11:06
Vote:
 

Hey Chaudhry,

I used the ContentReferenceExtensions to retrieve the previous page then compare:

var previousPage = e.ContentLink.ToReferenceWithoutVersion().GetPageData();

The GetPageData is an extension that wraps the ContentRepository:

            var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
            var data = contentRepository.Get<IContentData>(reference);
            return data as SitePageData;

Hope this helps,

Simon

#186293
Dec 15, 2017 15:19
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.