Esempio n. 1
0
        public EmailJobDetails Get([FromBody] string jobName, [FromBody] string jobGroup = null)
        {
            Logger.InfoFormat("Entered EmailsController.Get(). jobName = {0}, jobName = {1}", jobName, jobGroup);

            IEnumerable <ITrigger> quartzTriggers = _schedulerCore.GetTriggersOfJob(jobName, jobGroup);

            IList <TriggerDetails> triggerDetails = new List <TriggerDetails>();

            foreach (ITrigger quartzTrigger in quartzTriggers)
            {
                var triggerType = string.Empty;
                if (quartzTrigger is ICronTrigger)
                {
                    triggerType = "Cron";
                }
                if (quartzTrigger is ISimpleTrigger)
                {
                    triggerType = "Simple";
                }
                var nextFireTimeUtc     = quartzTrigger.GetNextFireTimeUtc();
                var previousFireTimeUtc = quartzTrigger.GetPreviousFireTimeUtc();
                triggerDetails.Add(new TriggerDetails
                {
                    Name         = quartzTrigger.Key.Name,
                    Group        = quartzTrigger.Key.Group,
                    JobName      = quartzTrigger.JobKey.Name,
                    JobGroup     = quartzTrigger.JobKey.Group,
                    Description  = quartzTrigger.Description,
                    StartTimeUtc = quartzTrigger.StartTimeUtc.UtcDateTime,
                    EndTimeUtc   =
                        (quartzTrigger.EndTimeUtc.HasValue) ? quartzTrigger.EndTimeUtc.Value.UtcDateTime : (DateTime?)null,
                    NextFireTimeUtc     = (nextFireTimeUtc.HasValue) ? nextFireTimeUtc.Value.UtcDateTime : (DateTime?)null,
                    PreviousFireTimeUtc =
                        (previousFireTimeUtc.HasValue) ? previousFireTimeUtc.Value.UtcDateTime : (DateTime?)null,
                    FinalFireTimeUtc =
                        (quartzTrigger.FinalFireTimeUtc.HasValue)
                            ? quartzTrigger.FinalFireTimeUtc.Value.UtcDateTime
                            : (DateTime?)null,
                    Type = triggerType
                });
            }

            var retval = new EmailJobDetails
            {
                Name           = jobName,
                TriggerDetails = new List <TriggerDetails>()
            };

            retval.TriggerDetails = triggerDetails;

            return(retval);
        }
Esempio n. 2
0
        public EmailJobDetails Get([FromBody]string jobName, [FromBody]string jobGroup = null)
        {
            Logger.InfoFormat("Entered EmailsController.Get(). jobName = {0}, jobName = {1}", jobName, jobGroup);

            IEnumerable<ITrigger> quartzTriggers = _schedulerCore.GetTriggersOfJob(jobName, jobGroup);

            IList<TriggerDetails> triggerDetails = new List<TriggerDetails>();

            foreach (ITrigger quartzTrigger in quartzTriggers)
            {
                var triggerType = string.Empty;
                if (quartzTrigger is ICronTrigger)
                {
                    triggerType = "Cron";
                }
                if (quartzTrigger is ISimpleTrigger)
                {
                    triggerType = "Simple";
                }
                var nextFireTimeUtc = quartzTrigger.GetNextFireTimeUtc();
                var previousFireTimeUtc = quartzTrigger.GetPreviousFireTimeUtc();
                triggerDetails.Add(new TriggerDetails
                {
                    Name = quartzTrigger.Key.Name,
                    Group = quartzTrigger.Key.Group,
                    JobName = quartzTrigger.JobKey.Name,
                    JobGroup = quartzTrigger.JobKey.Group,
                    Description = quartzTrigger.Description,
                    StartTimeUtc = quartzTrigger.StartTimeUtc.UtcDateTime,
                    EndTimeUtc =
                        (quartzTrigger.EndTimeUtc.HasValue) ? quartzTrigger.EndTimeUtc.Value.UtcDateTime : (DateTime?)null,
                    NextFireTimeUtc = (nextFireTimeUtc.HasValue) ? nextFireTimeUtc.Value.UtcDateTime : (DateTime?)null,
                    PreviousFireTimeUtc =
                        (previousFireTimeUtc.HasValue) ? previousFireTimeUtc.Value.UtcDateTime : (DateTime?)null,
                    FinalFireTimeUtc =
                        (quartzTrigger.FinalFireTimeUtc.HasValue)
                            ? quartzTrigger.FinalFireTimeUtc.Value.UtcDateTime
                            : (DateTime?)null,
                    Type = triggerType
                });
            }

            var retval = new EmailJobDetails
            {
                Name = jobName,
                TriggerDetails = new List<TriggerDetails>()
            };

            retval.TriggerDetails = triggerDetails;

            return retval;
        }