/// <summary> /// Acknowledges the alert. /// </summary> /// <param name="currentLoanAlertId">The current loan alert id.</param> /// <param name="userId">The user id.</param> /// <returns></returns> public bool AcknowledgeAlert(int currentLoanAlertId, int userId) { string err = ""; bool logErr = false; DataSet ds = null; try { EmailManager.EmailMgr em = EmailManager.EmailMgr.Instance; bool status = false; ds = m_da.AcknowledgeAlert(currentLoanAlertId, userId, out status); if (status == false) { return(false); } //if ((ds == null) || (ds.Tables.Count <= 0) || (ds.Tables[0].Rows.Count <= 0)) //{ // err = MethodBase.GetCurrentMethod() + " failed to Acknowledge Rule Alert, AlertId=" + currentLoanAlertId; // logErr = true; // return false; //} if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < 1; i++) { int FileId = Convert.ToInt32(ds.Tables[0].Rows[i]["FileId"]); int EmailTemplId = Convert.ToInt32(ds.Tables[0].Rows[i]["AlertEmailTemplId"]); int LoanAlertId = Convert.ToInt32(ds.Tables[0].Rows[i]["LoanAlertId"]); var ereq = new EmailPreviewRequest { FileId = FileId, EmailTemplId = EmailTemplId, LoanAlertId = LoanAlertId }; try { EmailPreviewResponse epr = em.PreviewEmail(ereq); if (!epr.resp.Successful) { err = MethodBase.GetCurrentMethod() + ", failed to get email body from Email Manager. \r\nreason:" + epr.resp.StatusInfo; int Event_id = 4032; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return(false); } string emailBody = string.Empty; if (epr.EmailHtmlContent != null && epr.EmailHtmlContent.Length > 0) { emailBody = Encoding.UTF8.GetString(epr.EmailHtmlContent); } m_da.AcknowledgeAlertEmailQue(currentLoanAlertId, userId, emailBody, epr.EmailHtmlContent); return(true); } catch (Exception exception) { err = MethodBase.GetCurrentMethod() + "\r\n\r\nException: " + exception.Message + "\r\n\r\nStackTrace: " + exception.StackTrace; int Event_id = 4033; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return(false); } } } return(true); } catch (Exception e) { err = MethodBase.GetCurrentMethod() + "\r\n\r\nException: " + e.Message + "\r\n\r\nStackTrace: " + e.StackTrace; int Event_id = 4035; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return(false); } finally { if (logErr) { Trace.TraceError(err); int Event_id = 4037; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); } if (ds != null) { ds.Clear(); ds.Dispose(); ds = null; } } }