示例#1
0
        public async Task ExecuteJob(string name, CancellationToken cancellationToken = default)
        {
            var internalDetail = internalDetails
                                 .FirstOrDefault(dt => dt.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));

            if (internalDetail == null)
            {
                throw new ArgumentException($"Unknown job name: {name}");
            }

            var jobDetail = await quartzScheduler.GetJobDetail(internalDetail.JobKey);

            var jobData = new JobDataMap();

            if (jobDetail.JobDataMap != null)
            {
                jobData = (JobDataMap)jobDetail.JobDataMap.Clone();
            }

            await quartzScheduler.TriggerJob(
                new JobKey(jobDetail.Key.Name, jobDetail.Key.Group),
                jobData,
                cancellationToken);
        }