Пример #1
0
        public void IsDueInHour_Test(string cron, string moment, bool expected)
        {
            var sut     = new JobRegistration("key1", cron);
            var fromUtc = GetDateTime(moment);

            sut.IsDue(fromUtc.UtcDateTime, TimeSpan.FromHours(1)).ShouldBe(expected);
        }
Пример #2
0
 void ExecuteFromCommand()
 {
     Job = new JobRegistration
     {
         Emploee  = Employee.Model,
         JobStart = DateTime.Now
     };
     TimeSheet = $"{Job.Emploee.FirstName} - {Job.Emploee.LastName} od: {Job.JobStart}";
 }
Пример #3
0
        public JobSchedulerOptions Register(JobRegistration registration, IJob job)
        {
            EnsureArg.IsNotNull(registration, nameof(registration));
            EnsureArg.IsNotNull(job, nameof(job));

            registration.Key ??= HashAlgorithm.ComputeHash(job);
            this.logger.LogInformation($"{{LogKey:l}} registration (key={{JobKey}}, cron={registration.Cron}, isReentrant={registration.IsReentrant}, timeout={registration.Timeout:c}, enabled={registration.Enabled})", LogKeys.JobScheduling, registration.Key);

            var item = this.Registrations.FirstOrDefault(r => r.Key.Key.SafeEquals(registration.Key));

            if (item.Key != null)
            {
                this.Registrations.Remove(item.Key);
            }

            this.Registrations.Add(registration, job);
            return(this);
        }
Пример #4
0
 public void AddJobRegistration(JobRegistration jobRegistration)
 {
     _context.Attach(jobRegistration);
     _context.SaveChanges();
 }