This article describes how to control what job types appear in the Job Class dropdown when you use Schedule Job Dialog:
If you use Schedule Job functionality of CrystalQuartzPanel to add new jobs, you might notice that it is not possible for a user to enter any job class, you should select it from a dropdown instead:
It is so for security reasons to avoid possible runs of harmful jobs.
But you may run into a situation where the Job Class dropdown does not contain the job you want to schedule. This situation is fairly common, because by default the dropdown contains only the job classes that are already scheduled, so if you want to schedule something new, it is definitely not in the list. And if your scheduler is empty yet, you will see the error.
Can not schedule a job as no allowed job types provided. Please make sure you configured allowed job types
In any of these cases you need to provide CrystalQuartzPanel with the list of Allowed Job Types
by setting AllowedJobTypes
property of CrystalQuartzOptions
object.
For example, here is how we can enable standard Quartz 2 mail sending job:
app.UseCrystalQuartz( |
Now the SendMailJob
can be selected in the dropdown:
If particular job types are not known, it is possible to do an “assembly scan”. Just to demonstrate this technique we can enable all Quartz 2 standard jobs:
app.UseCrystalQuartz( |
Now we can select standard Quartz 2 jobs:
Please note that the list includes Quartz.Job.NativeJob
that can run any command
on the application machine and is really dangerous in production, so please consider
the risks when you use this technique to expose job types.