Better error handling/messages

This commit is contained in:
Stefan Persson 2010-10-29 13:21:18 +00:00
parent a049d60090
commit e0330e6bb7

View file

@ -22,8 +22,6 @@ namespace DeviceSchedulerAgent
try try
{ {
//Makesure that we have all data loaded. //Makesure that we have all data loaded.
DataStorage data = LoadData(); DataStorage data = LoadData();
@ -44,16 +42,23 @@ namespace DeviceSchedulerAgent
{ {
Device item = handler.Find(action.DeviceID); Device item = handler.Find(action.DeviceID);
if (action.TurnOn) if (item != null)
handler.TurnOnWithDelay(item); {
else if (action.TurnOn)
handler.TurnOffWithDelay(item); handler.TurnOnWithDelay(item);
else
handler.TurnOffWithDelay(item);
}
else
{
MessageBox.Show("Device could not be found. Please make sure that TelldusService is running and no device scheduled for turn on/off has been removed.", "Telldus scheduler");
}
} }
} }
else else
{ {
MessageBox.Show("Programmet kunde inte hitta något jobb."); MessageBox.Show("No scheduled jobs could be found.", "Telldus scheduler");
} }
} }
catch (Exception ex) catch (Exception ex)