-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from MTUHIDE/1.1
1.1
- Loading branch information
Showing
21 changed files
with
559 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package controllers.ApplicationComponents; | ||
|
||
import com.google.inject.Singleton; | ||
import controllers.Databases.AppointmentsDB; | ||
import models.AppointmentsModel; | ||
import play.Logger; | ||
|
||
import java.util.*; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
@Singleton | ||
public class EmailScheduler { | ||
public EmailScheduler(){ | ||
Calendar today = Calendar.getInstance(); | ||
today.set(Calendar.HOUR_OF_DAY, 8); | ||
today.set(Calendar.MINUTE, 0); | ||
today.set(Calendar.SECOND, 0); | ||
Timer timer = new Timer(); | ||
Logger.info("Email Reminder Service Started for - " + today.getTime().toString()); | ||
timer.schedule(new AppointmentEmailTask(), today.getTime(), TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS)); | ||
} | ||
|
||
private class AppointmentEmailTask extends TimerTask { | ||
|
||
@Override | ||
public void run() { | ||
Calendar startDay = Calendar.getInstance(); | ||
startDay.set(Calendar.HOUR_OF_DAY, 0); | ||
Calendar endDay = Calendar.getInstance(); | ||
endDay.set(Calendar.HOUR_OF_DAY, 24); | ||
Logger.info("Checking for daily appointments."); | ||
List<AppointmentsModel> appointments = AppointmentsDB.getAppointmentsByDate(startDay.getTime(), endDay.getTime()); | ||
for(AppointmentsModel a : appointments) { | ||
MailerService.sendAppointmentReminder(a); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.