Beispiel #1
0
        /// <summary>
        /// Get job details of type <see cref="jobType"/>.
        /// Get all the job details if <see cref="jobType"/> is not specified
        /// </summary>
        /// <param name="jobType"></param>
        /// <returns></returns>
        public IDictionary <IJobDetail, Guid> GetJobDetails(Type jobType = null)
        {
            IDictionary <IJobDetail, Guid> jobDetails = new Dictionary <IJobDetail, Guid>();
            IList <string> jobGroups = _scheduler.GetJobGroupNames();

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

                var jobKeys = _scheduler.GetJobKeys(groupMatcher);
                foreach (var jobKey in jobKeys)
                {
                    var jobId  = _persistanceStore.GetJobId(jobKey);
                    var detail = _scheduler.GetJobDetail(jobKey);

                    if (null == jobType)
                    {
                        jobDetails.Add(detail, jobId);
                    }
                    else
                    {
                        if (jobType == detail.JobType)
                        {
                            jobDetails.Add(detail, jobId);
                        }
                    }
                }
            }

            return(jobDetails);
        }
Beispiel #2
0
        /// <summary>
        /// Get fire instances of currently executing jobs.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <FireInstance> GetExecutingJobs()
        {
            IList <FireInstance> retval = new List <FireInstance>();

            var executingJobs = _scheduler.GetCurrentlyExecutingJobs();

            foreach (var executingJob in executingJobs)
            {
                retval.Add(new FireInstance
                {
                    FireTimeUtc  = executingJob.Trigger.GetPreviousFireTimeUtc(),
                    JobName      = executingJob.JobDetail.Key.Name,
                    JobGroup     = executingJob.JobDetail.Key.Group,
                    TriggerName  = executingJob.Trigger.Key.Name,
                    TriggerGroup = executingJob.Trigger.Key.Group,
                    JobId        = _persistanceStore.GetJobId(executingJob.JobDetail.Key)
                });
            }

            return(retval);
        }