Esempio n. 1
0
        public void ScheduleJob(RiverContext riverContext)
        {
            var jobData = new JobDataMap();
            jobData.Put("riverContext", riverContext);
            IJobDetail job = JobBuilder.Create<RiverJob>()
                .WithIdentity(riverContext.Name) // name "myRiver", group "river"
                .SetJobData(jobData)
                .Build();

            var triggerBuilder = TriggerBuilder.Create()
                .WithIdentity(riverContext.Name)
                .ForJob(riverContext.Name); //, "group1")

            if(!String.IsNullOrWhiteSpace(riverContext.Cron))
                triggerBuilder.WithCronSchedule(riverContext.Cron);
            else
                triggerBuilder.StartNow();

             var trigger = triggerBuilder.Build();

            if (_scheduler.CheckExists(new JobKey(riverContext.Name)))
                _scheduler.DeleteJob(new JobKey(riverContext.Name));

            _scheduler.ScheduleJob(job, trigger);
        }
Esempio n. 2
0
 /*
 // POST api/river
 public void Post([FromBody]string value)
 {
 }
 */
 // PUT api/river/5
 public void Put(string id, RiverContext riverContext)
 {
     WebApiApplication.SchedulerWrapper.ScheduleJob(riverContext);
 }
Esempio n. 3
0
 public River(RiverContext riverContext)
 {
     _riverContext = riverContext;
     _source = Sources.Source.GetSource(riverContext.Source);
     _mouth = new Mouth(riverContext.Destination);
 }