public static RepeatedScheduleModel ConvertToRepeatedScheduleModel(RepeatedSchedule repeatedSchedule) { return(new RepeatedScheduleModel { Id = repeatedSchedule.ID, StartDateTime = repeatedSchedule.StartDateTime, Repetition = repeatedSchedule.Repetition, Description = repeatedSchedule.Description, AudioLocation = repeatedSchedule.AudioLocation, PlayerLocation = repeatedSchedule.PlayerLocation }); }
public void UpdateLocalTest() { using (Repository <RepeatedSchedule> repo = new Repository <RepeatedSchedule>()) { var result = repo.Get(3); Assert.IsTrue(result.Status.Success); if (result.Status.Success) { RepeatedSchedule repeatedSchedule = result.Data; repeatedSchedule.Description = "test 3"; var updateResult = repo.Update(repeatedSchedule); Assert.IsTrue(updateResult.Success); } } }
private void RepeatedScheduleElapsed(object sender, ElapsedEventArgs e) { for (int i = 0; i < _repeatedSchedules.Count; i++) { RepeatedSchedule schedule = _repeatedSchedules[i]; TimeSpan now; switch (schedule.Repetition) { case Repetition.Hourly: now = DateTime.Now.TimeOfDay; if ((schedule.StartDateTime.TimeOfDay.Minutes == now.Minutes) && (schedule.StartDateTime.TimeOfDay.Seconds == now.Seconds)) { Task.Run(() => StartSchedule(schedule.AudioLocation, schedule.PlayerLocation)); _eventLog.WriteEntry($"Hourly Repeated Schedule matches!"); } break; case Repetition.Daily: now = DateTime.Now.TimeOfDay; if ((schedule.StartDateTime.TimeOfDay.Hours == now.Hours) && (schedule.StartDateTime.TimeOfDay.Minutes == now.Minutes) && (schedule.StartDateTime.TimeOfDay.Seconds == now.Seconds)) { Task.Run(() => StartSchedule(schedule.AudioLocation, schedule.PlayerLocation)); _eventLog.WriteEntry($"Daily Repeated Schedule matches!"); } break; case Repetition.Monthly: if ((schedule.StartDateTime.Month == DateTime.Now.Month) && (schedule.StartDateTime.Day == DateTime.Now.Day) && (schedule.StartDateTime.TimeOfDay.Hours == DateTime.Now.TimeOfDay.Hours) && (schedule.StartDateTime.TimeOfDay.Minutes == DateTime.Now.TimeOfDay.Minutes) && (schedule.StartDateTime.TimeOfDay.Seconds == DateTime.Now.TimeOfDay.Seconds)) { Task.Run(() => StartSchedule(schedule.AudioLocation, schedule.PlayerLocation)); _eventLog.WriteEntry($"Daily Repeated Schedule matches!"); } break; } } }
public void UpdateAttachTest() { RepeatedSchedule repeatedSchedule = null; using (Repository <RepeatedSchedule> repo = new Repository <RepeatedSchedule>()) { var result = repo.Get(3); Assert.IsTrue(result.Status.Success); if (result.Status.Success) { repeatedSchedule = result.Data; } } Assert.IsNotNull(repeatedSchedule); repeatedSchedule.StartDateTime = DateTime.Now.AddDays(2d); using (Repository <RepeatedSchedule> repo = new Repository <RepeatedSchedule>()) { var result = repo.Update(repeatedSchedule); Assert.IsTrue(result.Success); } }