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