예제 #1
0
        /// <summary>
        ///   Gets the name of the job.
        /// </summary>
        /// <param name="job">The job.</param>
        /// <returns>
        ///   The name of the job.
        /// </returns>
        /// <exception cref="System.ArgumentNullException"><paramref name="job"/> is <see langword="null"/>.</exception>
        public string GetJobName([NotNull] ScheduledJob job)
        {
            if (job == null)
            {
                throw new ArgumentNullException(nameof(job));
            }

            return(Resources.JobScheduler_Start_Job_Prefix.FormatWith(job.GetType().Name));
        }
예제 #2
0
        /// <summary>
        ///     Creates the trigger.
        /// </summary>
        /// <param name="job">The job.</param>
        /// <param name="jobIndex">Index of the job.</param>
        /// <returns>
        ///     The trigger.
        /// </returns>
        /// <exception cref="System.ArgumentNullException"><paramref name="job"/> is <see langword="null"/>.</exception>
        public ITrigger CreateTrigger(
            [NotNull] ScheduledJob job,
            int jobIndex)
        {
            if (job == null)
            {
                throw new ArgumentNullException(nameof(job));
            }

            var jobType = job.GetType();

            var trigger = TriggerBuilder
                          .Create()
                          .WithIdentity("Trigger." + jobType.Name)
                          .StartAt(SystemTime.UtcNow().AddSeconds(DefaultJobsInterval * jobIndex))
                          .WithSimpleSchedule(x => x.WithInterval(job.Interval).RepeatForever())
                          .Build();

            return(trigger);
        }