Esempio n. 1
0
 public JsonResult GetDetailJobDataMap(JobDetailInput input)
 {
     if (!input.JobGroup.IsNullOrEmpty() && !input.JobName.IsNullOrEmpty())
     {
         var detail = StdSchedulerManager.GetJobDetail(new JobKey(input.JobName, input.JobGroup));
         var maps   = detail.JobDataMap;
         return(Json(maps.Select(map => new Parameters {
             Key = map.Key, Value = map.Value
         }).ToList()));
     }
     return(null);
 }
Esempio n. 2
0
        public async Task <JsonResult> GetAllJobs()
        {
            IList <QuartzOutput> models = new List <QuartzOutput>();
            var jobGroups = await StdSchedulerManager.GetJobGroupNames();

            foreach (string group in jobGroups)
            {
                var groupMatcher = GroupMatcher <JobKey> .GroupContains(group);

                var jobKeys = await StdSchedulerManager.GetJobKeys(groupMatcher);

                foreach (var jobKey in jobKeys)
                {
                    var detail = await StdSchedulerManager.GetJobDetail(jobKey);

                    var triggers = await StdSchedulerManager.GetTriggersOfJob(jobKey);

                    foreach (ITrigger trigger in triggers)
                    {
                        var model = new QuartzOutput
                        {
                            JobGroup       = group,
                            JobName        = jobKey.Name,
                            JobDescription = detail.Description,
                            TriggerState   = "Complete",
                            NamespaceName  = detail.JobType.Namespace,
                            ClassName      = detail.JobType.FullName
                        };
                        model.TriggerName  = trigger.Key.Name;
                        model.TriggerGroup = trigger.Key.Group;
                        model.TriggerType  = trigger.GetType().Name;
                        model.TriggerState = (await StdSchedulerManager.GetTriggerState(trigger.Key)).ToString();
                        var nextFireTime = trigger.GetNextFireTimeUtc();
                        if (nextFireTime.HasValue)
                        {
                            model.NextFireTime = TimeZone.CurrentTimeZone.ToLocalTime(nextFireTime.Value.DateTime);
                        }

                        var previousFireTime = trigger.GetPreviousFireTimeUtc();
                        if (previousFireTime.HasValue)
                        {
                            model.PreviousFireTime =
                                TimeZone.CurrentTimeZone.ToLocalTime(previousFireTime.Value.DateTime);
                        }
                        models.Add(model);
                    }
                }
            }
            return(JsonForGridLoadOnce(models.OrderBy(o => o.NextFireTime)));
        }
Esempio n. 3
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));
        }