Ejemplo n.º 1
0
        public void AddAndStart(ScheduledTask task)
        {
            _scheduler.StartIfNeeded();

            var job = task.GetJob();

            if (_scheduler.CheckExists(job.Key))
            {
                _scheduler.DeleteJob(job.Key);
            }

            var trigger = task.GetTrigger();
            _scheduler.ScheduleJob(job, trigger);

            _logger.Info("Job scheduled job name: {0} ,the job will fire at {1}", job.Key, trigger.GetNextFireTimeUtc());

            if (job.JobDataMap.ContainsKey("data"))
                _logger.Info("Job {0} has data: {1}", job.Key, job.JobDataMap["data"]);
        }