In my application i associate jobs to each user:
IJobDetail job = JobBuilder.Create<SampleJob>()
.UsingJobData("userId", 10)
.WithIdentity("job1", "group1")
.Build();
then i would like to get all jobs scheduled in quartz.net associated to some user of my application.
Would it be possible, or someone can suggest a solution for this? Thanks
Assuming you want to do it after scheduling, we can populate a
List<JobDetail>
but I couldn't find a better way than iterating through the keys. I had to do something similar but later changed the dependency to the JobKey instead as Rabban asks.
var groupMatcher = GroupMatcher<JobKey>.GroupContains("group1");
var keys = await scheduler.GetJobKeys(groupMatcher); // Get all JobKeys
// Get all JobDetails
var jobDetails = new List<IJobDetail>();
foreach(var key in keys)
{
jobDetails.Add(await scheduler.GetJobDetail(key));
}
var userTensJobs = jobDetails.Where(j => j.JobDataMap.WrappedMap.Any(x =>
x.Key.Equals("userId") && x.Value.Equals(10)));
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.