简体   繁体   中英

Quartz.net schedule job from asp.net, execute in a windows service app

I'm new to .NET and using the Quartz.net scheduler for the first time. I want to schedule jobs from ASP.NET but execute them in a .NET based windows service (or console) application. I can see that this is possible in: Use one windows service to execute jobs and two web applications to schedule jobs

In most of the examples that I read, the Job Class the available in the context which is scheduling the job. For eg: Executing Quartz.NET jobs from a Windows Service

However in my case, I don't see how this is possible because the Job Class will not be available in ASP.NET.

EDIT: Based on an event (user triggered) in the ASP application, I want to schedule a one time job with some data parameters (job details). This is the part that I'm confused about, is this possible using only Quartz or do I have to write some sort of communication mechanism to the windows service to schedule the job.

On the other hand, I will also have some jobs running on a fixed schedule, where it's clear that the code will only be a part of the windows service.

Quartz scheduler is used for executing jobs repeatedly based on a pre-defined schedule. In your case both the scheduling information and the job execution needs to be handled by the windows service.

The asp.net application is to be used to gather the schedule information from the users, the information thus gathered needs to be fed to the scheduler running inside the windows service.

Hope this helps.

Code to create a trigger that runs a job just once.

TriggerBuilder.Create()
                .WithIdentity(batch.BatchId.ToString())
                .StartNow()
                .WithSimpleSchedule(x => x.WithRepeatCount(0)).Build();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM