Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Commit

Permalink
Fixed issue where an email failure resulted in no emails being sent. …
Browse files Browse the repository at this point in the history
…It will now retry next run.
  • Loading branch information
bofirial committed Jun 12, 2017
1 parent d811775 commit c09f2e5
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions Melody49Notifier/Melody49Notifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)
Expand Down

0 comments on commit c09f2e5

Please sign in to comment.