/// <summary> /// Purge Alerts from the database /// </summary> /// <param name="dtBefore"></param> /// <returns></returns> public int AlertPurge(DateTime aDtBeforeDate) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "DELETE FROM ALERTS " + "WHERE (datediff(day, _ALERTDATE, @dtPurgeDate) > 0)"; SqlCeParameter[] spParams = new SqlCeParameter[1]; spParams[0] = new SqlCeParameter("@dtPurgeDate", aDtBeforeDate); using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddRange(spParams); command.ExecuteNonQuery(); } } } 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(); lAuditWizardDataAccess.AlertPurge(aDtBeforeDate); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(0); }