November Happy Hour will be moved to Thursday December 5th.

Send Information Message back to user during PublishedContent event

Ayo
Ayo
Vote:
 

When a user publishes a given Page Type, I am performing some business logic (creating a PDF file) How do I send an Information message back to the UI notifying the user that the PDF was genrated successfully.

So...

private void EventsPublishedContent(object sender, ContentEventArgs e)
{

if (e.Content is MyPageType)

//Business Logic Here...

InformationMessage here <>< how do I send a message..

}



#190655
Apr 13, 2018 17:06
Vote:
 

Using the IValidate interface you can code stuff and show as information to the user which might be a good option if the PDF creation is fast and stable:
http://jondjones.com/learn-episerver-cms/episerver-developers-guide/common-web-page-component-tutorials/how-to-return-different-validation-warnings-to-content-editors-when-publishing-content-in-episerver

To avoid users having to wait a lot when publishing if the PDF generation is slow it's probably better to run a job and alert the user by notification instead.

#190669
Apr 14, 2018 14:28
Ayo
Vote:
 

Update: By adding this to my project

public IEnumerable<ValidationError> Validate(MyTypeinstance)
{
return new[]
{
new ValidationError()
{
ErrorMessage = "A PDF for this page has been generated.",
PropertyName = "test",
Severity = ValidationErrorSeverity.Info,
ValidationType = ValidationErrorType.AttributeMatched
},
};
}

In the back office as soon as I change something I can see the notification message in the back office, but this is before the publish button is clicked. 

Is this the best you can do, in episerver?

#190739
Edited, Apr 16, 2018 16:41
Vote:
 

You could consider hooking into the notifications framework. This would mean the message would appear as a new notification in the bell at the top right in the UI. The nice thing about this approach is that the PDF generation could happen async and the notification would appear as/when the PDF is ready.

More information here: https://world.episerver.com/documentation/developer-guides/CMS/using-notifications/

#190777
Apr 16, 2018 18:20
* 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.