Commit 1d2bb2d0 authored by Ajit Deshmukh's avatar Ajit Deshmukh

Update in process of fetching mailing list using campaign_id.

parent 5fbcbf35
......@@ -43,35 +43,35 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
BaseLogger.log("2", null, null,
"sendEmailToMe calling buildMailXMLStr-----------------[" + mailFormatDetails + " ]");
String mailXMLStr = "";
String mailXMLStr = "";
// Fetch mail format details from the database
String emailID = mailFormatDetails.get("SEND_TO").toString();
BaseLogger.log("3", null, null, "buildMailXMLStr emailID [" + emailID + "]");
/*
* Changes by Gagan B. on 08-OCT-24 to upload HTML to alfresco server in MAIL_FORMAT object and store the doc ID in MAIL_FORMAT.BODY_TEXT and use the same doc ID to retrieve
* the document and use it to display data in template and while sending the mail. -- START
* Changes by Gagan B. on 08-OCT-24 to upload HTML to alfresco server in
* MAIL_FORMAT object and store the doc ID in MAIL_FORMAT.BODY_TEXT and use the
* same doc ID to retrieve the document and use it to display data in template
* and while sending the mail. -- START
*/
String getDocumentURL = CommonConstants.TOMCAT_HOME +
"/ibase/rest/E12ExtService/getDocumentStream";
String getDocumentURL = CommonConstants.TOMCAT_HOME + "/ibase/rest/E12ExtService/getDocumentStream";
Unirest.setTimeouts(0, 0);
HttpResponse<String> getDocumentResponse = null;
try {
getDocumentResponse = Unirest.post(getDocumentURL)
.header("TOKEN_ID", userInfo.getTokenID())
.field("DOC_ID", mailFormatDetails.get("BODY").toString())
.asString();
getDocumentResponse = Unirest.post(getDocumentURL).header("TOKEN_ID", userInfo.getTokenID())
.field("DOC_ID", mailFormatDetails.get("BODY").toString()).asString();
} catch (Exception e) {
BaseLogger.log("3", null, null, "Exception in MktgCmpgnPreSend.buildXMLStr [" + E12GenericUtility.getStackTrace(e) + "]");
BaseLogger.log("3", null, null,
"Exception in MktgCmpgnPreSend.buildXMLStr [" + E12GenericUtility.getStackTrace(e) + "]");
}
String statusText = getDocumentResponse.getStatusText();
int statusCode = getDocumentResponse.getStatus();
String responseString = getDocumentResponse.getBody().toString();
BaseLogger.log("3", null, null, "Inside saveNewEmailTemplate getSelectedEmailXmlData [" + statusText + "]");
BaseLogger.log("3", null, null, "Inside saveNewEmailTemplate getSelectedEmailXmlData [" + statusCode + "]");
BaseLogger.log("3", null, null, "Inside saveNewEmailTemplate getSelectedEmailXmlData [" + responseString + "]");
......@@ -82,14 +82,16 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
// body = readHtmlFile(bodyFilePath);
body = responseString;
} catch (Exception e) {
mailXMLStr = "NULLHTML";
mailXMLStr = "NULLHTML";
BaseLogger.log("3", null, null, "Exception in readHtmlFile method [" + e.getMessage() + "]");
e.printStackTrace();
return mailXMLStr;
}
/*
* Changes by Gagan B. on 08-OCT-24 to upload HTML to alfresco server in MAIL_FORMAT object and store the doc ID in MAIL_FORMAT.BODY_TEXT and use the same doc ID to retrieve
* the document and use it to display data in template and while sending the mail. -- END
* Changes by Gagan B. on 08-OCT-24 to upload HTML to alfresco server in
* MAIL_FORMAT object and store the doc ID in MAIL_FORMAT.BODY_TEXT and use the
* same doc ID to retrieve the document and use it to display data in template
* and while sending the mail. -- END
*/
String formatCode = "";
......@@ -142,7 +144,7 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
String formatCode = "";
String subject = "";
String bodyText = "";
String mailListName = "";
List<String> mailListName = new ArrayList<>();
String retString = "";
int batchCount = 0;
DateFormat dtFormat = new SimpleDateFormat("dd-MMM-yy");
......@@ -151,8 +153,6 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
List<String> mailList = new ArrayList<String>();
UserInfoBean userInfo = getUserInfo();
System.out.println("********************userinfo****************" + userInfo);
BaseLogger.log("3", null, null, "sendEmail : xtraParams [" + xtraParams + "]");
try {
conn = getConnection();
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
......@@ -163,28 +163,33 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next()) {
mailListName = rs.getString("mailing_list");
while (rs.next()) {
mailListName.add(rs.getString("mailing_list"));
BaseLogger.log("3", null, null, "mail list name updated[" + mailListName + "]");
}
System.out.println(mailListName + "MailListName List");
closeResources(rs, pstmt);
BaseLogger.log("3", null, null, "mail list name [" + mailListName + "]");
// Used to get all email Id against the mail_list_id(campaign_template) from
// mailing_list_det and store it in Logs table
sql = "select email_id from mailing_list_det where mail_list_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mailListName);
rs = pstmt.executeQuery();
while (rs.next()) {
mailList.add(rs.getString("email_id"));
for(int i = 0; i < mailListName.size() ; i++) {
sql = "select email_id from mailing_list_det where mail_list_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mailListName.get(i));
rs = pstmt.executeQuery();
while (rs.next()) {
mailList.add(rs.getString("email_id"));
}
closeResources(rs, pstmt);
BaseLogger.log("3", null, null, "mail list updated[" + mailList + "]");
}
closeResources(rs, pstmt);
BaseLogger.log("3", null, null, "mail list [" + mailList + "]");
// To check weather email Id present or not in mailing_list
if (mailList.isEmpty()) {
retString = itmDBAccessEJB.getErrorString("", "NMAILIST", "", "", conn);
return retString;
}
// if (mailList.isEmpty()) {
// retString = itmDBAccessEJB.getErrorString("", "NMAILIST", "", "", conn);
// return retString;
// }
conn.setAutoCommit(false);
// To add entries in mktg_cmpaign_log table
for (String emilId : mailList) {
......@@ -307,7 +312,7 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
int totalMails = mailListForMailSend.size();
int totalBatches = (int) Math.ceil((double) totalMails / batchCount);
for (int i = 0; i < totalBatches; i++) {
for (int i = 0; i < totalBatches; i++) {
int start = i * batchCount;
int end = Math.min(start + batchCount, totalMails);
List<String> batchList = mailListForMailSend.subList(start, end);
......@@ -326,7 +331,7 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
BaseLogger.log("3", null, null, "Mail from [" + fromEmailId + "]");
String mailXMLStr = buildMailXMLStr(mailFormatDetails, userInfo);
if(mailXMLStr.equals("NULLHTML")) {
if (mailXMLStr.equals("NULLHTML")) {
BaseLogger.log("3", null, null, "mailXMLStr string[" + mailXMLStr + "]");
retString = itmDBAccessEJB.getErrorString("", mailXMLStr, "", "", conn);
return retString;
......@@ -394,29 +399,29 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
String formatCode = "";
String subject = "";
String bodyText = "", msg = "";
//boolean updateFlag = false;
// boolean updateFlag = false;
String retString = "";
UserInfoBean userInfo = getUserInfo();
System.out.println("********************userinfo****************" + userInfo);
BaseLogger.log("3", null, null, "sendEmailToMe : xtraParams [" + xtraParams + "]");
System.out.println("********************xtraParams***********[" + xtraParams + "]");
try {
conn = getConnection();
//userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
userEmail = userInfo.getLoginEmailId();
BaseLogger.log("3", null, null, "sendEmailToMe : user Email ID [" + userEmail + "]");
// userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
userId = userInfo.getLoginCode();
BaseLogger.log("3", null, null, "user id [" + userId + "]");
BaseLogger.log("3", null, null, "tran id [" + tranId + "]");
// sql = "select email_id from users where code = ?";
// pstmt = conn.prepareStatement(sql);
// pstmt.setString(1, userId);
// rs = pstmt.executeQuery();
// if (rs.next()) {
// userEmail = rs.getString("email_id");
// }
// closeResources(rs, pstmt);
sql = "select email_id from users where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, userId);
rs = pstmt.executeQuery();
if (rs.next()) {
userEmail = rs.getString("email_id");
}
closeResources(rs, pstmt);
// Check weather email id present or not against loged in user
if (userEmail == null ) {
if (userEmail == null) {
BaseLogger.log("3", null, null, "In null condition [" + userEmail + "]");
retString = itmDBAccessEJB.getErrorString("", "NULEMAILID", "", "", conn);
return retString;
......@@ -454,7 +459,7 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
email.setMailFrom(mailFormatDetails.get("MAIL_SERVER").toString()); // Set the email sender address
System.out.println("getMailFrom1....::" + email.getMailFrom());
String mailXMLStr = buildMailXMLStr(mailFormatDetails, userInfo);
if(mailXMLStr.equals("NULLHTML")) {
if (mailXMLStr.equals("NULLHTML")) {
BaseLogger.log("3", null, null, "mailXMLStr string[" + mailXMLStr + "]");
retString = itmDBAccessEJB.getErrorString("", mailXMLStr, "", "", conn);
return retString;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment