private void OnDeleteRequested(ISensorInfo sensorInfo)
{
if (null == sensorInfo || String.IsNullOrEmpty(sensorInfo.Name) || null == _dbStore) {
MessageBox.Show("Invalid target", "Error");
return;
}
var result = MessageBox.Show(
String.Format("Are you sure you want to delete the sensor named '{0}'?", sensorInfo.Name), "Delete?",
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question
);
if(result != DialogResult.Yes) {
return;
}
result = MessageBox.Show(
String.Format("Are you really sure you want to delete the sensor named '{0}'? All data for this sensor will be removed without possibility of retrieval.", sensorInfo.Name), "DELETE?",
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation
);
if (result != DialogResult.Yes) {
return;
}
try {
if (_dbStore.DeleteSensor(sensorInfo.Name))
Log.InfoFormat("Sensor '{0}' was deleted by the user.", sensorInfo.Name);
else
Log.ErrorFormat("Sensor '{0}' deletion failed and was requested by the user.", sensorInfo.Name);
}
catch(Exception ex) {
Log.Error("Error deleting sensor '" + sensorInfo.Name + "'.", ex);
}
ReloadHistoric();
}