Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Aug 15, 2022 @ 15:50
    Alex Skrypnyk
    0

    Running a bunch of SaveAndPublish each hour

    Hello,

    What is the way to create a job that will be running each hour that contains many SaveAndPublish node creations?

    Are async Tasks okay? Or maybe it's better to build a separate Windows service to avoid performance implications on the website?

    Thanks, Alex

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 15, 2022 @ 19:05
    Huw Reddick
    1

    I use hangfire jobs for this kind of thing

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Aug 16, 2022 @ 12:20
    Alex Skrypnyk
    0

    do you use a package?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 16, 2022 @ 15:04
    Huw Reddick
    0

    No, I added hangfire manually to Umbraco using hangfires nuget package, then a little bit of config in umbraco startup to sort out the dashboard. I create jobs based on settings in a custom table, one of the jobs involves adding/updating product nodes to a shop.

    Hangfire was pretty easy to add to 9/10 (a lot easier than 8) and works great for running jobs in the background. I can dig out some sample code if you are interested

  • Connie Willis 1 post 72 karma points
    Aug 16, 2022 @ 08:41
    Connie Willis
    1

    I found out that if I do this then it works.

    var umbf = Umbraco.Web.Composing.Current.Factory.GetInstance<IUmbracoContextFactory>();
    using (var contextf = umbf.EnsureUmbracoContext())
    {
        var umbcontext = contextf.UmbracoContext;
        IContentService cs = Umbraco.Core.Composing.Current.Services.ContentService;
        cs.SaveAndPublish(child);
    
    }
    
  • James Shelley 9 posts 103 karma points
    Aug 20, 2022 @ 13:08
    James Shelley
    2

    A RecurringHostedService (v9) or BackgroundTaskRunner (v8) should do the job - https://our.umbraco.com/documentation/Reference/Scheduling/.

Please Sign in or register to post replies

Write your reply to:

Draft