From c09f2e5aed6f2c82016952a0b165f50345653b6e Mon Sep 17 00:00:00 2001 From: James Schafer Date: Sun, 11 Jun 2017 20:10:13 -0400 Subject: [PATCH] Fixed issue where an email failure resulted in no emails being sent. It will now retry next run. --- Melody49Notifier/Melody49Notifier.cs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Melody49Notifier/Melody49Notifier.cs b/Melody49Notifier/Melody49Notifier.cs index 99f9f8d..c7d1f0e 100644 --- a/Melody49Notifier/Melody49Notifier.cs +++ b/Melody49Notifier/Melody49Notifier.cs @@ -15,22 +15,25 @@ public static void Run([TimerTrigger("0 0 8-18 * * FRI")]TimerInfo myTimer, Trac { log.Info($"C# Timer trigger function started at: {DateTime.Now}."); - if (TheaterScheduleHasUpdated(log, out TheaterSchedule currentTheaterSchedule)) + ICurrentTheaterScheduleDataFileManager currentTheaterScheduleDataFileManager = new CurrentTheaterScheduleDataFileManager(log); + + if (TheaterScheduleHasUpdated(log, currentTheaterScheduleDataFileManager, out TheaterSchedule currentTheaterSchedule)) { - log.Info($"Theater Schedule has updated. Sending Notifications."); + log.Info($"The Theater Schedule has updated. Sending Notifications."); SendNotification(log, currentTheaterSchedule); + + currentTheaterScheduleDataFileManager.UpdateCurrentTheaterSchedule(currentTheaterSchedule); } else { - log.Info($"Theater Schedule has not updated."); + log.Info($"The Theater Schedule has not updated."); } log.Info($"C# Timer trigger function completed at: {DateTime.Now}."); } - private static bool TheaterScheduleHasUpdated(TraceWriter log, out TheaterSchedule currentTheaterSchedule) - { - ICurrentTheaterScheduleDataFileManager currentTheaterScheduleDataFileManager = new CurrentTheaterScheduleDataFileManager(log); + private static bool TheaterScheduleHasUpdated(TraceWriter log, ICurrentTheaterScheduleDataFileManager currentTheaterScheduleDataFileManager, out TheaterSchedule currentTheaterSchedule) + { ICurrentTheaterScheduleWebRequestManager currentTheaterScheduleWebRequestManager = new CurrentTheaterScheduleWebRequestManager(log, new TheaterScheduleHTMLParser(log)); ITheaterScheduleComparer theaterScheduleComparer = new TheaterScheduleComparer(log); @@ -39,14 +42,7 @@ private static bool TheaterScheduleHasUpdated(TraceWriter log, out TheaterSchedu currentTheaterSchedule = currentTheaterScheduleFromWebSite; - if (!theaterScheduleComparer.AreEqual(currentTheaterScheduleFromFile, currentTheaterScheduleFromWebSite)) - { - currentTheaterScheduleDataFileManager.UpdateCurrentTheaterSchedule(currentTheaterScheduleFromWebSite); - - return true; - } - - return false; + return !theaterScheduleComparer.AreEqual(currentTheaterScheduleFromFile, currentTheaterScheduleFromWebSite); } private static void SendNotification(TraceWriter log, TheaterSchedule currentTheaterSchedule)