Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Component Sharing
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gagandeep Singh Bhatia
Component Sharing
Commits
56ddd64c
Commit
56ddd64c
authored
Sep 16, 2024
by
Ajit Deshmukh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace MarketingCampaignPreSend.java
parent
b546e501
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
21 deletions
+31
-21
Task/Marketing Campaign/Java/MarketingCampaignPreSend.java
Task/Marketing Campaign/Java/MarketingCampaignPreSend.java
+31
-21
No files found.
Task/Marketing Campaign/Java/MarketingCampaignPreSend.java
View file @
56ddd64c
//Created by Ajit - 13/09/24
package
ibase
.
webitm
.
ejb
.
wsfa
.
transactions
;
import
java.rmi.RemoteException
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
...
...
@@ -12,7 +10,6 @@ import java.util.ArrayList;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
java.util.List
;
import
ibase.utility.BaseLogger
;
import
ibase.utility.E12GenericUtility
;
import
ibase.utility.EMail
;
...
...
@@ -21,11 +18,10 @@ import ibase.webitm.ejb.ActionHandlerEJB;
import
ibase.webitm.ejb.ValidatorEJB
;
import
ibase.webitm.ejb.ITMDBAccessEJB
;
import
ibase.webitm.utility.ITMException
;
public
class
MarketingCampaignPreSend
extends
ActionHandlerEJB
{
ValidatorEJB
validatorEJB
=
new
ValidatorEJB
();
E12GenericUtility
genericUtility
=
new
E12GenericUtility
();
ITMDBAccessEJB
itmDBAccessEJB
=
new
ITMDBAccessEJB
();
private
String
buildMailXMLStr
(
HashMap
<
String
,
Object
>
mailFormatDetails
,
UserInfoBean
userInfo
)
{
...
...
@@ -263,12 +259,12 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
PreparedStatement
pstmt
=
null
;
ResultSet
rs
=
null
;
String
sql
=
""
;
String
fromEmailId
=
""
,
retString
=
""
;
String
fromEmailId
=
""
,
retString
=
""
;
String
status
=
""
;
ITMDBAccessEJB
itmDBAccessEJB
=
new
ITMDBAccessEJB
();
List
<
String
>
mailListForMailSend
;
boolean
updateFlag
=
false
;
try
{
conn
=
getConnection
();
conn
.
setAutoCommit
(
false
);
// Begin transaction
...
...
@@ -307,34 +303,35 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
try
{
emailStatus
=
email
.
sendMail
(
mailXMLStr
,
"ITM"
,
userInfo
);
BaseLogger
.
log
(
"3"
,
null
,
null
,
"Email status for ["
+
emailId
+
"]: "
+
emailStatus
);
status
=
"S"
;
}
catch
(
Exception
e
)
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"Error sending email to ["
+
emailId
+
"]: "
+
e
.
getMessage
());
continue
;
// Proceed to the next email
status
=
"E"
;
}
// Update the log
sql
=
"UPDATE mktg_campaign_log SET status =
'S'
WHERE email_id = ? AND campaign_id = ?"
;
sql
=
"UPDATE mktg_campaign_log SET status =
?
WHERE email_id = ? AND campaign_id = ?"
;
try
(
PreparedStatement
updatePstmt
=
conn
.
prepareStatement
(
sql
))
{
updatePstmt
.
setString
(
1
,
emailId
);
updatePstmt
.
setString
(
2
,
tranId
);
updatePstmt
.
setString
(
1
,
status
);
updatePstmt
.
setString
(
2
,
emailId
);
updatePstmt
.
setString
(
3
,
tranId
);
int
affectedRows
=
updatePstmt
.
executeUpdate
();
BaseLogger
.
log
(
"3"
,
null
,
null
,
"Rows affected by update for emailId ["
+
emailId
+
"]: "
+
affectedRows
);
}
catch
(
SQLException
e
)
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"Error updating log for emailId ["
+
emailId
+
"]: "
+
e
.
getMessage
());
conn
.
rollback
();
// Rollback on error
conn
.
rollback
();
}
conn
.
commit
();
// Commit the transaction
conn
.
commit
();
}
}
}
if
(
updateFlag
)
{
retString
=
itmDBAccessEJB
.
getErrorString
(
""
,
"VTMAILSUCC"
,
""
,
""
,
conn
);
if
(
updateFlag
)
{
retString
=
itmDBAccessEJB
.
getErrorString
(
""
,
"VTMAILSUCC"
,
""
,
""
,
conn
);
return
retString
;
}
}
catch
(
Exception
e
)
{
...
...
@@ -342,7 +339,7 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
BaseLogger
.
log
(
"0"
,
null
,
null
,
"Exception during email processing: "
+
e
.
getMessage
());
if
(
conn
!=
null
)
{
try
{
conn
.
rollback
();
// Rollback on exception
conn
.
rollback
();
BaseLogger
.
log
(
"0"
,
null
,
null
,
"Transaction rolled back due to exception."
);
}
catch
(
SQLException
se
)
{
se
.
printStackTrace
();
...
...
@@ -364,6 +361,8 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
String
formatCode
=
""
;
String
subject
=
""
;
String
bodyText
=
""
;
// boolean updateFlag = false;
String
retString
=
""
;
UserInfoBean
userInfo
=
getUserInfo
();
System
.
out
.
println
(
"********************userinfo****************"
+
userInfo
);
...
...
@@ -388,6 +387,12 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
pstmt
.
close
();
pstmt
=
null
;
}
//Check weather email id present or not against loged in user
if
(
userEmail
==
null
)
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"In null condition ["
+
userEmail
+
"]"
);
retString
=
itmDBAccessEJB
.
getErrorString
(
""
,
"NULEMAILID"
,
""
,
""
,
conn
);
return
retString
;
}
BaseLogger
.
log
(
"3"
,
null
,
null
,
"user email ["
+
userEmail
+
"]"
);
sql
=
"select campaign_template from mktg_campaign where campaign_id = ?"
;
...
...
@@ -438,13 +443,18 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
String
mailXMLStr
=
buildMailXMLStr
(
mailFormatDetails
,
userInfo
);
String
emailStatus
=
email
.
sendMail
(
mailXMLStr
,
"ITM"
,
userInfo
);
System
.
out
.
println
(
"emailStatus....::"
+
emailStatus
);
String
msg
=
emailStatus
.
equals
(
"S"
)
?
"VTMAILSUCC"
:
"MAILFAILED"
;
retString
=
itmDBAccessEJB
.
getErrorString
(
""
,
msg
,
""
,
""
,
conn
);
return
retString
;
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Exception :SfaTime :itemChanged(Document,String):"
+
e
.
getMessage
()
+
":"
);
e
.
printStackTrace
();
}
finally
{
closeResources
(
rs
,
pstmt
,
conn
);
}
return
"<tran_id>"
+
tranId
+
"</tran_id>"
;
return
retString
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment