Beispiel #1
0
        private OracleConnection GetDatabaseConnection()
        {
            OracleConnection connection = null;

            try
            {
                connection = new OracleConnection(connectionString);
            }
            catch (Exception ex)
            {
                LoggingUtility.WriteLog(ELogLevel.ERROR, "Error in GetDatabaseConnection() " + ex.Message.ToString());
            }
            return(connection);
        }
Beispiel #2
0
        public void ProcessEmailNotificationsWithAttachments(bool IsConnectionSuccess)
        {
            LoggingUtility.WriteLog(ELogLevel.INFO, "Processing attachment emails started");
            Email     email;
            DataTable emailNotificationsData = dbContext.GetEmailNotificationsWithAttachment();

            if (emailNotificationsData != null && emailNotificationsData.Rows.Count > 0)
            {
                foreach (DataRow notification in emailNotificationsData.Rows)
                {
                    int notificationId = 0;
                    try
                    {
                        notificationId = Convert.ToInt32(notification["NOTIFICATIONID"]);
                        email          = new Email();
                        email.To       = Convert.ToString(notification["MailTo"]);
                        if (!string.IsNullOrEmpty(Convert.ToString(notification["EmailTEMPLATEID"])) && !string.IsNullOrEmpty(Convert.ToString(notification["EVENTDATE"])))
                        {
                            email.Bcc = Program.appConfig[Constants.ACCEASecretariat].ToString();
                        }
                        email.Subject        = Convert.ToString(notification["MailSubject"]);
                        email.Body           = Convert.ToString(notification["MailBody"]);
                        email.AttachmentName = Convert.ToString(notification["COMMFILENAME"]);
                        email.AttachmentData = (byte[])(notification["Communicationfile"]);
                        bool result = sendMail.TriggerEmail(email);
                        dbContext.UpdateMailAttemptsAndStatus(notificationId, result, Convert.ToInt32(Program.appConfig[Constants.MaxRetryAttempts]));
                    }
                    catch (Exception ex)
                    {
                        LoggingUtility.WriteLog(ELogLevel.ERROR, "ProcessEmailNotificationsWithAttachments() | Error in sending emails : " + notificationId.ToString() + " " + ex.Message.ToString());
                        dbContext.UpdateEmailErrorLogs(notificationId, ex.Message.ToString(), IsConnectionSuccess);
                    }
                }
            }
            else
            {
                LoggingUtility.WriteLog(ELogLevel.INFO, "No pending emails with attachment for process");
            }
        }