Exemplo n.º 1
0
        /// <summary>
        /// Return a table of any suppoprt contracts for which alerts should be generated
        /// </summary>
        /// <param name="applicationID"></param>
        /// <returns></returns>
        public DataTable EnumerateSupportContractAlerts()
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in");
            }

            DataTable alertsTable = new DataTable(TableNames.SUPPORT_STATISTICS);

            if (compactDatabaseType)
            {
                try
                {
                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        string commandText =
                            "SELECT LICENSES._SUPPORT_EXPIRES, LICENSES._SUPPORT_ALERTDAYS, LICENSES._SUPPORT_ALERTBYEMAIL, LICENSES._SUPPORT_ALERTRECIPIENTS " +
                            ",APPLICATIONS._NAME " +
                            "FROM LICENSES " +
                            "LEFT JOIN APPLICATIONS ON (LICENSES._APPLICATIONID = APPLICATIONS._APPLICATIONID) " +
                            "WHERE _SUPPORTED = 1 " +
                            "AND _SUPPORT_ALERTDAYS <> -1 " +
                            "AND ((_SUPPORT_EXPIRES - _SUPPORT_ALERTDAYS) <= GETDATE())";

                        using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                        {
                            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.EnumerateSupportContractAlerts();
            }

            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out");
            }
            return(alertsTable);
        }