コード例 #1
0
        private static void UpdateOrAddJob(ScheduleJobInfo job)
        {
            if (CheckExists(job.JobId))
            {
                DeleteJob(job.JobId);
            }

            if (job.JobState == JobState.Normal)
            {
                var jobDetail = JobBuilder.Create <HttpJob>()
                                .WithIdentity(job.JobId)
                                .Build();

                ITrigger trigger = TriggerBuilder.Create()
                                   .WithIdentity(job.JobId)
                                   .WithCronSchedule(job.Cron)
                                   .Build();

                ScheduleJob(jobDetail, trigger);
            }
        }
コード例 #2
0
        public ScheduleJobInfo UpdateJob(ScheduleJobInfo dto)
        {
            var model = dto;

            using (var trans = SqlMapper.BeginTransaction())
            {
                try
                {
                    trans.Entity <Models.ScheduleJobInfo>().Set(x => new { x.JobState }, false).Update(model);
                    ScheduleManager.UpdateJob(model);
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw ex;
                }
            }

            return(GetJob(model.JobId));
        }
コード例 #3
0
        public ScheduleJobInfo AddJob(ScheduleJobInfo dto)
        {
            var model = dto;

            model.JobId = Guid.NewGuid().ToString("N").ToLower();

            using (var trans = SqlMapper.BeginTransaction())
            {
                try
                {
                    trans.Entity <Models.ScheduleJobInfo>().Insert(model);
                    ScheduleManager.AddJob(model);
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw ex;
                }
            }

            return(GetJob(model.JobId));
        }
コード例 #4
0
 public ScheduleJobInfo UpdateJob(ScheduleJobInfo dto)
 {
     return(_scheduleService.UpdateJob(dto));
 }
コード例 #5
0
 public ScheduleJobInfo AddJob(ScheduleJobInfo dto)
 {
     return(_scheduleService.AddJob(dto));
 }
コード例 #6
0
 public static void UpdateJob(ScheduleJobInfo job)
 {
     UpdateOrAddJob(job);
 }