/// <summary>
        /// 初始化一个<c>ScheduleCronOptions</c>实例.执行频率为每小时
        /// </summary>
        /// <param name="minute">指定执行的时间:分钟 [0-59]</param>
        public ScheduleCronOptions(int minute)
        {
            this.ValidateOptions(null, null, null, minute);

            Minute = minute;
            this.scheduleCron = ScheduleCron.Hourly;
        }
Exemple #2
0
        /// <summary>
        /// 初始化一个<c>ScheduleCronOptions</c>实例.执行频率为每小时
        /// </summary>
        /// <param name="minute">指定执行的时间:分钟 [0-59]</param>
        public ScheduleCronOptions(int minute)
        {
            this.ValidateOptions(null, null, null, minute);

            Minute            = minute;
            this.scheduleCron = ScheduleCron.Hourly;
        }
        /// <summary>
        /// 初始化一个<c>ScheduleCronOptions</c>实例。执行频率为每天
        /// </summary>
        /// <param name="hour">指定执行的时间:小时 [0-23]</param>
        /// <param name="minute">指定执行的时间:分钟 [0-59]</param>
        public ScheduleCronOptions(int hour, int minute)
        {
            this.ValidateOptions(null, null, hour, minute);

            Minute = minute;
            Hour = hour;
            this.scheduleCron = ScheduleCron.Daily;
        }
Exemple #4
0
        /// <summary>
        /// 初始化一个<c>ScheduleCronOptions</c>实例。执行频率为每天
        /// </summary>
        /// <param name="hour">指定执行的时间:小时 [0-23]</param>
        /// <param name="minute">指定执行的时间:分钟 [0-59]</param>
        public ScheduleCronOptions(int hour, int minute)
        {
            this.ValidateOptions(null, null, hour, minute);

            Minute            = minute;
            Hour              = hour;
            this.scheduleCron = ScheduleCron.Daily;
        }
        /// <summary>
        /// 初始化一个<c>ScheduleCronOptions</c>实例。执行频率为每周
        /// </summary>
        /// <param name="dayOfWeek">指定执行的时间:周几 [0-6]</param>
        /// <param name="hour">指定执行的时间:小时 [0-23]</param>
        /// <param name="minute">指定执行的时间:分钟 [0-59]</param>
        public ScheduleCronOptions(DayOfWeek dayOfWeek, int hour, int minute)
        {
            this.ValidateOptions(null, null, hour, minute);

            Minute = minute;
            Hour = hour;
            Week = (int)dayOfWeek;
            this.scheduleCron = ScheduleCron.Weekly;
        }
Exemple #6
0
        /// <summary>
        /// 初始化一个<c>ScheduleCronOptions</c>实例。执行频率为每周
        /// </summary>
        /// <param name="dayOfWeek">指定执行的时间:周几 [0-6]</param>
        /// <param name="hour">指定执行的时间:小时 [0-23]</param>
        /// <param name="minute">指定执行的时间:分钟 [0-59]</param>
        public ScheduleCronOptions(DayOfWeek dayOfWeek, int hour, int minute)
        {
            this.ValidateOptions(null, null, hour, minute);

            Minute            = minute;
            Hour              = hour;
            Week              = (int)dayOfWeek;
            this.scheduleCron = ScheduleCron.Weekly;
        }
Exemple #7
0
        /// <summary>
        /// 初始化一个<c>ScheduleCronOptions</c>实例。执行频率为每月
        /// </summary>
        /// <param name="day">指定执行的时间:天 [1-31]</param>
        /// <param name="hour">指定执行的时间:小时 [0-23]</param>
        /// <param name="minute">指定执行的时间:分钟 [0-59]</param>
        public ScheduleCronOptions(int day, int hour, int minute)
        {
            this.ValidateOptions(null, day, hour, minute);

            Minute            = minute;
            Hour              = hour;
            Day               = day;
            this.scheduleCron = ScheduleCron.Monthly;
        }
Exemple #8
0
        /// <summary>
        /// 初始化一个<c>ScheduleCronOptions</c>实例。执行频率为每年
        /// </summary>
        /// <param name="month">指定执行的时间:月 [1-12]</param>
        /// <param name="day">指定执行的时间:天 [1-31]</param>
        /// <param name="hour">指定执行的时间:小时 [0-23]</param>
        /// <param name="minute">指定执行的时间:分钟 [0-59]</param>
        public ScheduleCronOptions(int month, int day, int hour, int minute)
        {
            this.ValidateOptions(month, day, hour, minute);

            Minute            = minute;
            Hour              = hour;
            Day               = day;
            Month             = month;
            this.scheduleCron = ScheduleCron.Yearly;
        }
        public void SchedulingJob_ForEveryCronTrigger_DispatchesJobMessage()
        {
            var probe          = CreateTestProbe("job-probe");
            var scheduler      = (TestScheduler)Sys.Scheduler;
            var cronExpression = "* */12 * * *";
            var jobId          = TestJobId.New;
            var greeting       = $"hi here here is a random guid {Guid.NewGuid()}";
            var job            = new TestJob(greeting);
            var when           = DateTime.UtcNow.AddMonths(1);
            var twelveHours    = TimeSpan.FromHours(12);
            Expression <Func <TestJobScheduler> > testJobSchedulerExpression = () => new TestJobScheduler();
            Expression <Func <TestJobRunner> >    testJobRunnerExpression    = () => new TestJobRunner(probe);

            var testJobManager = Sys.ActorOf(
                Props.Create(() =>
                             new JobManager <TestJobScheduler, TestJobRunner, TestJob, TestJobId>(
                                 testJobSchedulerExpression,
                                 testJobRunnerExpression))
                .WithDispatcher(CallingThreadDispatcher.Id));

            var schedule = new ScheduleCron <TestJob, TestJobId>(jobId, job, cronExpression, when)
                           .WithAck(TestJobAck.Instance)
                           .WithNack(TestJobNack.Instance);

            testJobManager.Tell(schedule, probe);
            probe.ExpectMsg <TestJobAck>();
            scheduler.AdvanceTo(when);



            probe.ExpectMsg <TestJobDone>(x =>
            {
                x.At.Should().BeCloseTo(when);
                return(x.Greeting == greeting);
            });
            scheduler.Advance(twelveHours);
            probe.ExpectMsg <TestJobDone>(x =>
            {
                x.At.Should().BeCloseTo(when.Add(twelveHours));
                return(x.Greeting == greeting);
            });
            scheduler.Advance(twelveHours);
            probe.ExpectMsg <TestJobDone>(x =>
            {
                x.At.Should().BeCloseTo(when.Add(twelveHours * 2));

                return(x.Greeting == greeting);
            });
        }
        /// <summary>
        /// 初始化一个<c>ScheduleCronOptions</c>实例。执行频率为每月
        /// </summary>
        /// <param name="day">指定执行的时间:天 [1-31]</param>
        /// <param name="hour">指定执行的时间:小时 [0-23]</param>
        /// <param name="minute">指定执行的时间:分钟 [0-59]</param>
        public ScheduleCronOptions(int day, int hour, int minute)
        {
            this.ValidateOptions(null, day, hour, minute);

            Minute = minute;
            Hour = hour;
            Day = day;
            this.scheduleCron = ScheduleCron.Monthly;
        }
 /// <summary>
 /// 初始化一个<c>ScheduleCronOptions</c>实例.执行频率为每分钟.
 /// 注:按每分钟执行时,执行的秒并不一定是 00 时间点
 /// </summary>
 public ScheduleCronOptions()
 {
     this.scheduleCron = ScheduleCron.Minutely;
 }
        /// <summary>
        /// 初始化一个<c>ScheduleCronOptions</c>实例。执行频率为每年
        /// </summary>
        /// <param name="month">指定执行的时间:月 [1-12]</param>
        /// <param name="day">指定执行的时间:天 [1-31]</param>
        /// <param name="hour">指定执行的时间:小时 [0-23]</param>
        /// <param name="minute">指定执行的时间:分钟 [0-59]</param>
        public ScheduleCronOptions(int month, int day, int hour, int minute)
        {
            this.ValidateOptions(month, day, hour, minute);

            Minute = minute;
            Hour = hour;
            Day = day;
            Month = month;
            this.scheduleCron = ScheduleCron.Yearly;
        }
Exemple #13
0
 /// <summary>
 /// 初始化一个<c>ScheduleCronOptions</c>实例.执行频率为每分钟.
 /// 注:按每分钟执行时,执行的秒并不一定是 00 时间点
 /// </summary>
 public ScheduleCronOptions()
 {
     this.scheduleCron = ScheduleCron.Minutely;
 }
Exemple #14
0
 public ScheduleAttribute(ScheduleCron cron)
 {
     Cron = cron;
 }