Ejemplo n.º 1
0
        public JobList ListCurrentlyExecutingJobs()
        {
            JobList jobList = new JobList();

            jobList.Items = new List <Job>();
            IScheduler scheduler = GetScheduler();
            var        jobs      = scheduler.GetCurrentlyExecutingJobs();

            foreach (var j in jobs)
            {
                Job job = new Job
                {
                    JobGroupName = j.JobDetail.Key.Group,
                    JobName      = j.JobDetail.Key.Name
                };
                jobList.Items.Add(job);
            }


            return(jobList);
        }
Ejemplo n.º 2
0
        public JobList ListJobs()
        {
            //http://stackoverflow.com/questions/12489450/get-all-jobs-in-quartz-net-2-0
            JobList jobList = new JobList();

            jobList.Items = new List <Job>();
            IScheduler scheduler = GetScheduler();

            foreach (var getJobGroupName in scheduler.GetJobGroupNames())
            {
                foreach (JobKey jobkey in scheduler.GetJobKeys(GroupMatcher <JobKey> .GroupEquals(getJobGroupName)))
                {
                    var job = new Job
                    {
                        JobGroupName = jobkey.Group,
                        JobName      = jobkey.Name
                    };

                    job.Triggers = new List <Trigger>(); foreach (ITrigger trigger in scheduler.GetTriggersOfJob(jobkey))
                    {
                        job.Triggers.Add(new Trigger
                        {
                            TriggerGroupName    = trigger.Key.Group,
                            TriggerName         = trigger.Key.Name,
                            MayFireAgain        = trigger.GetMayFireAgain(),
                            NextFireTimeUtc     = trigger.GetNextFireTimeUtc(),
                            PreviousFireTimeUtc = trigger.GetPreviousFireTimeUtc(),
                            StartTimeUtc        = trigger.StartTimeUtc,
                            EndTimeUtc          = trigger.EndTimeUtc,
                            UTCNow = DateTime.UtcNow,
                            Status = scheduler.GetTriggerState(trigger.Key).ToString()
                        });
                    }

                    jobList.Items.Add(job);
                }
            }

            return(jobList);
        }