public void GetInstant_ReturnsCorrectlyInitializedInstant() { var factory = new ScheduleInstantFactory(); var schedule = CrontabSchedule.Parse("* * * * *"); IScheduleInstant instant = null; Assert.DoesNotThrow(() => instant = factory.GetInstant(schedule)); Assert.NotNull(instant); }
private DateTime GetLastInstant(ProcessableCronJob job, IScheduleInstant instant) { DateTime lastInstant; if (job.LastRun != default(DateTime)) { lastInstant = job.LastRun; } else if (job.CreatedAt != default(DateTime)) { lastInstant = job.CreatedAt; } else if (job.Next.HasValue) { lastInstant = job.Next.Value; lastInstant = lastInstant.AddSeconds(-1); } else { lastInstant = instant.NowInstant.AddSeconds(-1); } return(lastInstant); }
private static DateTime GetLastInstant(IReadOnlyDictionary<string, string> recurringJob, IScheduleInstant instant) { DateTime lastInstant; if (recurringJob.ContainsKey("LastExecution")) { lastInstant = JobHelper.DeserializeDateTime(recurringJob["LastExecution"]); } else if (recurringJob.ContainsKey("CreatedAt")) { lastInstant = JobHelper.DeserializeDateTime(recurringJob["CreatedAt"]); } else if (recurringJob.ContainsKey("NextExecution")) { lastInstant = JobHelper.DeserializeDateTime(recurringJob["NextExecution"]); lastInstant = lastInstant.AddSeconds(-1); } else { lastInstant = instant.NowInstant.AddSeconds(-1); } return lastInstant; }
private static DateTime GetLastInstant(IReadOnlyDictionary <string, string> recurringJob, IScheduleInstant instant) { DateTime lastInstant; if (recurringJob.ContainsKey("LastExecution")) { lastInstant = JobHelper.DeserializeDateTime(recurringJob["LastExecution"]); } else if (recurringJob.ContainsKey("CreatedAt")) { lastInstant = JobHelper.DeserializeDateTime(recurringJob["CreatedAt"]); } else if (recurringJob.ContainsKey("NextExecution")) { lastInstant = JobHelper.DeserializeDateTime(recurringJob["NextExecution"]); lastInstant = lastInstant.AddSeconds(-1); } else { lastInstant = instant.NowInstant.AddSeconds(-1); } return(lastInstant); }
private static DateTime GetLastInstant(IReadOnlyDictionary <string, string> recurringJob, IScheduleInstant instant, DateTime?startDateUTC, DateTime?endDateUTC) { DateTime lastInstant; if (recurringJob.ContainsKey("LastExecution")) { lastInstant = DateTime.SpecifyKind(JobHelper.DeserializeDateTime(recurringJob["LastExecution"]), DateTimeKind.Utc); } else if (recurringJob.ContainsKey("CreatedAt")) { lastInstant = DateTime.SpecifyKind(JobHelper.DeserializeDateTime(recurringJob["CreatedAt"]), DateTimeKind.Utc); } else if (recurringJob.ContainsKey("NextExecution")) { lastInstant = DateTime.SpecifyKind(JobHelper.DeserializeDateTime(recurringJob["NextExecution"]), DateTimeKind.Utc); lastInstant = lastInstant.AddSeconds(-1); } else { lastInstant = instant.NowInstant.AddSeconds(-1); } if (startDateUTC.HasValue && lastInstant < startDateUTC.Value) { lastInstant = startDateUTC.Value; } else if (endDateUTC.HasValue && lastInstant > endDateUTC.Value) { lastInstant = endDateUTC.Value; } return(lastInstant); }