November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Even saving blocks i get that weird unable to cast errors... what is happening...
anyone had this before:
Do you have any listeners for events like contentsave of contentpublish?
The error points to some code you have that trying to do stuff when users are publishing or saving your content
Yes i have one...
[InitializableModule] [ModuleDependency(typeof(InitializableModule))] public class PublishEventInitialization : IInitializableModule { public void Initialize(InitializationEngine context) { //Debugger.Break(); context.InitComplete += Context_InitComplete; } private void Context_InitComplete(object sender, EventArgs e) { var events = ServiceLocator.Current.GetInstance<IContentEvents>(); events.PublishedContent += Events_PublishedContent; } private void Events_PublishedContent(object sender, ContentEventArgs e) { /// Push notification if it's a new Coupe being published if (((PageData)e.Content).PageTypeName == "CoupePage") { PageData page = (PageData)e.Content; //first check if the pageId exists in the custom table, if not then sent notifications to the hub if(!NotificationHubHelper.Exists(page.ContentLink.ID)) { AzureNotificationsHubClient client = new AzureNotificationsHubClient(); bool androidSent = client.SendNewArticleAndroidNotificationsAsync(page.Name, page.ContentLink.ID); bool iOSSent = client.SendNewArticleiOSNotificationsAsync(page.Name, page.ContentLink.ID); //after add the current pageId to the custom table NotificationHubHelper.UpdateOrAdd(page.ContentLink.ID); } } } public void Preload(string[] parameters) { } public void Uninitialize(InitializationEngine context) { var events = ServiceLocator.Current.GetInstance<IContentEvents>(); context.InitComplete -= Context_InitComplete; events.PublishedContent -= Events_PublishedContent; } }
How can we improve this? The publish event should only fire if the page is of type "CoupePage"
Yes, there are the error.
To improve and make it work you need to wrap it with a test if it is the correct contentType
You can do it in many ways, but this is one:
private void Events_PublishedContent(object sender, ContentEventArgs e) { var coupePage = e.Content as CoupePage; if coupePage == null) { return; } PageData page = (PageData)e.Content; //first check if the pageId exists in the custom table, if not then sent notifications to the hub if(!NotificationHubHelper.Exists(page.ContentLink.ID)) { AzureNotificationsHubClient client = new AzureNotificationsHubClient(); bool androidSent = client.SendNewArticleAndroidNotificationsAsync(page.Name, page.ContentLink.ID); bool iOSSent = client.SendNewArticleiOSNotificationsAsync(page.Name, page.ContentLink.ID); //after add the current pageId to the custom table NotificationHubHelper.UpdateOrAdd(page.ContentLink.ID); } }
[Pasting files is not allowed]
Hey Guys,
i have a problem. I could upload images just fine in media...
But recently i get the error when trying to upload an image.. It says Failed. When i'm hovering it says: "Unable to cast object of type 'Castle.Proxies.ImageFileProxy' to type 'EPiServer.Core.PageData'" What the hell??!? Where did that come from?
i have a class like so:
This was working fine. We didnt update anything.. what am i missing ?