Пример #1
0
        public TaskScheduleModel(QuartzTriggers item)
        {
            string expression = string.Empty;

            if (item.QuartzCronTriggers != null)
            {
                expression = item.QuartzCronTriggers.CronExpression;
            }

            if (item.QuartzSimpleTriggers != null)
            {
                expression = (item.QuartzSimpleTriggers.RepeatInterval / 1000) + "秒";
            }

            var jobDetail = SchedulerCenter.Instance.Scheduler.GetJobDetail(new JobKey(item.JobName, item.JobGroup)).Result;

            this.Url            = jobDetail.JobDataMap.GetString(Constant.RequestUrl);
            this.Name           = item.TriggerName;
            this.Group          = item.JobGroup;
            this.TriggerState   = item.TriggerState;
            this.NextFireTime   = item.NextFireTime?.AddHours(8);
            this.PrevFireTime   = item.PrevFireTime?.AddHours(8);
            this.StartTime      = item.StartTime.AddHours(8);
            this.EndTime        = item.EndTime?.AddHours(8);
            this.CronExpression = expression;

            bool isNotPaused = item.TriggerState.ToUpperInvariant() != "PAUSED";

            this.IsPaused  = !isNotPaused;
            this.IconClass = !isNotPaused ? "pause" : "play_circle_filled";
        }
Пример #2
0
        public EdieTaskScheduleModel(QuartzTriggers item)
        {
            if (item.QuartzCronTriggers != null)
            {
                this.CronExpression = item.QuartzCronTriggers.CronExpression;
                this.TriggerType    = TriggerTypeEnum.Cron;
            }

            if (item.QuartzSimpleTriggers != null)
            {
                if (item.QuartzSimpleTriggers.RepeatInterval % 1000000 != 0)
                {
                    this.IntervalTime = (int)item.QuartzSimpleTriggers.RepeatInterval;
                    this.IntervalType = TimeSpanParseRule.Milliseconds;
                }
                else
                {
                    this.IntervalTime = (int)(item.QuartzSimpleTriggers.RepeatInterval / 1000000);
                    this.IntervalType = TimeSpanParseRule.Seconds;
                    if (this.IntervalTime % 60 == 0)
                    {
                        this.IntervalType  = TimeSpanParseRule.Minutes;
                        this.IntervalTime /= 60;
                        if (this.IntervalTime % 60 == 0)
                        {
                            this.IntervalType  = TimeSpanParseRule.Hours;
                            this.IntervalTime /= 60;
                        }
                    }
                }

                this.TriggerType = TriggerTypeEnum.Simple;
            }

            var jobDetail = SchedulerCenter.Instance.Scheduler.GetJobDetail(new JobKey(item.TriggerName, item.JobGroup)).Result;

            this.Url = jobDetail.JobDataMap.GetString(Constant.RequestUrl);
            bool isNotPaused = item.TriggerState.ToLower() != "paused";

            this.Name         = item.TriggerName;
            this.Group        = item.JobGroup;
            this.TriggerState = item.TriggerState;
            this.NextFireTime = item.NextFireTime;
            this.PrevFireTime = item.PrevFireTime;
            this.StartTime    = item.StartTime;
            this.EndTime      = item.EndTime;
            this.IsPaused     = !isNotPaused;
        }