Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I run a BackgroundWorker Thread after the Startup-Event, that checks for Nodes with an expired Date.
var contentService = ApplicationContext.Current.Services.ContentService; foreach (IContent node in contentService.GetContentOfContentType(SerienTerminType.Id)) { if (node.Status == ContentStatus.Published) { //DO THE MAGIC DateTime nt = Convert.ToDateTime(node.GetValue("naechsterTermin")); if((DateTime.Now.Date - nt).TotalDays > 0) { try { contentService.SaveAndPublishWithStatus(node,0, true); } catch(Exception ex) { // Error happens } } }
The SaveAndPublish function throws an error, that the httpContext is null. In Version 7.3.x it worked. What has changed and how can I fix it?
Hello,
If you want to work without httpContext try the Umbraco console application example: https://github.com/sitereactor/umbraco-console-example
Jeroen
Cool hint! Thnx a lot.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Access Contentservice from BackgroundWorker Class
Hi,
I run a BackgroundWorker Thread after the Startup-Event, that checks for Nodes with an expired Date.
The SaveAndPublish function throws an error, that the httpContext is null. In Version 7.3.x it worked. What has changed and how can I fix it?
Hello,
If you want to work without httpContext try the Umbraco console application example: https://github.com/sitereactor/umbraco-console-example
Jeroen
Cool hint! Thnx a lot.
is working on a reply...