/// <summary> /// Return a table containing all of the Alerts have been triggered since the specified date /// </summary> /// <returns></returns> public DataTable EnumerateAlerts(DateTime aSinceDate) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } DataTable alertsTable = new DataTable(TableNames.ALERTS); if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "SELECT ALERTS.* " + "FROM ALERTS " + "WHERE _ALERTDATE >= @dtSinceDate " + "ORDER BY _ALERTID"; using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddWithValue("@dtSinceDate", aSinceDate); new SqlCeDataAdapter(command).Fill(alertsTable); } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); alertsTable = lAuditWizardDataAccess.EnumerateAlerts(aSinceDate); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(alertsTable); }
public int Populate(DateTime dtSince) { // Ensure that the list is empty initially this.Clear(); AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); DataTable table = lwDataAccess.EnumerateAlerts(dtSince); // Iterate through the returned rows in the table and create AssetType objects for each foreach (DataRow row in table.Rows) { AddAlert(row); } return(this.Count); }