Пример #1
0
        public async Task <JsonResult> JobEdit(JobDetailInput input)
        {
            var output = new QuartzOutput();

            if (!input.JobName.IsNullOrEmpty() && !input.JobGroup.IsNullOrEmpty())
            {
                var key = new JobKey(input.JobName, input.JobGroup);
                //作业详情
                var detal = await StdSchedulerManager.GetJobDetail(key);

                output.NamespaceName = detal.JobType.Namespace;
                output.ClassName     = detal.JobType.Name;
                //触发器
                var triggerKey = new TriggerKey(input.TriggerName, input.TriggerGroup);
                var trigger    = await StdSchedulerManager.GetTrigger(triggerKey);

                output.JobType        = detal.JobType.FullName;
                output.JobGroup       = detal.Key.Group;
                output.JobName        = detal.Key.Name;
                output.JobDescription = detal.Description;

                output.TriggerType        = trigger.GetType().Name;
                output.TriggerName        = trigger.Key.Name;
                output.TriggerGroup       = trigger.Key.Group;
                output.TriggerDescription = trigger.Description;

                //获取trigger类型
                switch (trigger.GetType().Name)
                {
                case "SimpleTriggerImpl":
                    var simpleTriggerImpl = (SimpleTriggerImpl)trigger;
                    output.Interval = simpleTriggerImpl.RepeatInterval;
                    break;

                case "CronTriggerImpl":
                    //获取表达式
                    var cronTriggerImpl = (CronTriggerImpl)trigger;
                    output.Expression = cronTriggerImpl.CronExpressionString;
                    break;
                }
                output.ReplaceExists = true;
            }
            return(Json(output));
        }