Tags

,

My Friend Aditya Patil is a good programmer from India. He develops for Windows Phone 8 and Windows 8. Recently he was asking about setting Reminders perodically to remind patients about their Food timings. I have roughly done this with simple for loops. This throws exception but it works

The below is the code

DateTime reminderStartTime = new DateTime();
DateTime reminderEndTime = new DateTime();

for (int y = 2014; y < 2016; y++)
{
for (int m = 2; m < 13; m++)
{
for (int d = 11; d < 28; d++)
{
foreach (int hour in new int[] { 19, 20 })
{
for (int min = 16; min < 22; min += 2)
{
reminderStartTime = new DateTime(y, m, d, hour, min, 0);
reminderEndTime = new DateTime(y, m, d, hour, min+3, 0);

String name = System.Guid.NewGuid().ToString();
Reminder reminder = new Reminder(name);
reminder.Title = "Test";
reminder.Content = name;
reminder.BeginTime = reminderStartTime;
ScheduledActionService.Add(reminder);
}
}
}
}
}

Advertisements