Base solution for your next web application
Open Closed

Initialize quartz on Server Start (global.asax or something) #3085


User avatar
0
luizluan created

I need to start the quartz when I start the web site, I have two jobs one of them runs once a day and the other one every 6 hours.

The method that calls the Job is in an IDomainService, even if I take it from there I still need to resolve the dependencies.

public class QuartzDomainManager : IQuartzDomainManager
    {
        private readonly IQuartzScheduleJobManager _jobManager;
        private readonly IAbpQuartzConfiguration _quartzConfiguration;

        public QuartzDomainManager(IQuartzScheduleJobManager jobManager, IAbpQuartzConfiguration quartzConfiguration)
        {
            _jobManager = jobManager;
            _quartzConfiguration = quartzConfiguration;
        }
}

3 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    You can start it in PostInitialize method of your module.

  • User Avatar
    0
    luizluan created

    Thanks :D

  • User Avatar
    0
    luizluan created

    Works very well

    public override  async void Initialize()
            {
                IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
    
                AreaRegistration.RegisterAllAreas();
                RouteConfig.RegisterRoutes(RouteTable.Routes);
                BundleConfig.RegisterBundles(BundleTable.Bundles);
                await Configuration.IocManager.Resolve<IQuartzDomainManager>().ScheduleGeneral();
            }