Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mytime
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Narendar Vakiti
mytime
Commits
9c90c6a1
Commit
9c90c6a1
authored
Jun 03, 2019
by
Vijay Akula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handled the exceptions raising while getting functionalOrgs
parent
b368a146
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
32 deletions
+24
-32
LeaveNotificationScheduler.java
...om/nisum/myteam/schedular/LeaveNotificationScheduler.java
+6
-8
MailService.java
src/main/java/com/nisum/myteam/service/impl/MailService.java
+18
-24
No files found.
src/main/java/com/nisum/myteam/schedular/LeaveNotificationScheduler.java
View file @
9c90c6a1
...
@@ -14,7 +14,6 @@ import com.nisum.myteam.statuscodes.EmployeeStatus;
...
@@ -14,7 +14,6 @@ import com.nisum.myteam.statuscodes.EmployeeStatus;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.constants.EmpSubStatus
;
import
com.nisum.myteam.utils.constants.EmpSubStatus
;
import
com.nisum.myteam.utils.constants.Shifts
;
import
com.nisum.myteam.utils.constants.Shifts
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -60,7 +59,7 @@ public class LeaveNotificationScheduler {
...
@@ -60,7 +59,7 @@ public class LeaveNotificationScheduler {
// private final String SHIFT5_CRON_EXP=environment.getProperty("email.leave.notification.shift5.cron");
// private final String SHIFT5_CRON_EXP=environment.getProperty("email.leave.notification.shift5.cron");
//
@Scheduled(cron = "0 * * * * ?")
//
@Scheduled(cron = "0 * * * * ?")
@Scheduled
(
cron
=
"00 00 15 * * 1-5"
)
@Scheduled
(
cron
=
"00 00 15 * * 1-5"
)
public
void
scheduleLeaveMailForShift1Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
public
void
scheduleLeaveMailForShift1Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
//Shift 1(9:00 AM - 6:00 PM)
//Shift 1(9:00 AM - 6:00 PM)
...
@@ -132,14 +131,13 @@ public class LeaveNotificationScheduler {
...
@@ -132,14 +131,13 @@ public class LeaveNotificationScheduler {
logger
.
info
(
"Mail Notification is sending to:"
+
absentee
.
getEmployeeName
()
+
"::"
+
absentee
.
getEmailId
());
logger
.
info
(
"Mail Notification is sending to:"
+
absentee
.
getEmployeeName
()
+
"::"
+
absentee
.
getEmailId
());
mail
.
setEmpName
(
absentee
.
getEmployeeName
());
mail
.
setEmpName
(
absentee
.
getEmployeeName
());
mail
.
setTo
(
absentee
.
getEmailId
());
mail
.
setTo
(
absentee
.
getEmailId
());
//mail.setEmpName("Prayas");//mail.setTo("pjain@nisum.com");
//mail.setEmpName("Prayas");
//mail.setTo("pjain@nisum.com");
functionalGroup
=
functionalGroupService
.
getFunctionalGroup
(
employee
.
getFunctionalGroup
());
functionalGroup
=
functionalGroupService
.
getFunctionalGroup
(
employee
.
getFunctionalGroup
());
mail
.
setCc
(
new
String
[]{
functionalGroup
.
getGroupHeadEmailId
()});
//mail.setCc(new String[]{"prayasjain21@gmail.com"});
if
(
functionalGroup
!=
null
)
{
mail
.
setCc
(
new
String
[]{
functionalGroup
.
getGroupHeadEmailId
()});
//mail.setCc(new String[]{"prayasjain21@gmail.com"});
}
mailService
.
sendLeaveNotification
(
mail
);
mailService
.
sendLeaveNotification
(
mail
);
}
}
...
...
src/main/java/com/nisum/myteam/service/impl/MailService.java
View file @
9c90c6a1
...
@@ -3,38 +3,34 @@
...
@@ -3,38 +3,34 @@
*/
*/
package
com
.
nisum
.
myteam
.
service
.
impl
;
package
com
.
nisum
.
myteam
.
service
.
impl
;
import
java.io.File
;
import
com.nisum.myteam.model.EmailDomain
;
import
java.io.IOException
;
import
com.nisum.myteam.model.Mail
;
import
java.util.Date
;
import
com.nisum.myteam.service.IMailService
;
import
lombok.extern.slf4j.Slf4j
;
import
javax.mail.MessagingException
;
import
javax.mail.internet.MimeMessage
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.io.FileSystemResource
;
import
org.springframework.core.io.FileSystemResource
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.mail.javamail.JavaMailSender
;
import
org.springframework.mail.javamail.JavaMailSender
;
import
org.springframework.mail.javamail.MimeMessageHelper
;
import
org.springframework.mail.javamail.MimeMessageHelper
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.nisum.myteam.model.EmailDomain
;
import
com.nisum.myteam.service.IMailService
;
import
com.nisum.myteam.model.Mail
;
import
org.springframework.util.ResourceUtils
;
import
org.springframework.util.ResourceUtils
;
import
org.thymeleaf.context.Context
;
import
org.thymeleaf.spring4.SpringTemplateEngine
;
import
org.thymeleaf.spring4.SpringTemplateEngine
;
import
java.nio.charset.StandardCharsets
;
import
org.springframework.core.io.ClassPathResource
;
import
javax.mail.MessagingException
;
import
javax.mail.internet.MimeMessage
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
org.springframework.core.env.Environment
;
import
java.util.Date
;
/**
/**
* @author nisum
* @author nisum
*
*
*/
*/
@Service
@Service
@Slf4j
public
class
MailService
implements
IMailService
{
public
class
MailService
implements
IMailService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MailService
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MailService
.
class
);
...
@@ -92,9 +88,7 @@ public class MailService implements IMailService {
...
@@ -92,9 +88,7 @@ public class MailService implements IMailService {
}
}
public
void
sendLeaveNotification
(
Mail
mail
)
throws
MessagingException
,
IOException
{
public
void
sendLeaveNotification
(
Mail
mail
)
throws
MessagingException
,
IOException
{
MimeMessage
message
=
emailSender
.
createMimeMessage
();
MimeMessage
message
=
emailSender
.
createMimeMessage
();
//MimeMessageHelper helper = new MimeMessageHelper(message,MimeMessageHelper.MULTIPART_MODE_MIXED_RELATED,StandardCharsets.UTF_8.name());
//MimeMessageHelper helper = new MimeMessageHelper(message,MimeMessageHelper.MULTIPART_MODE_MIXED_RELATED,StandardCharsets.UTF_8.name());
//Context context = new Context();
//Context context = new Context();
...
@@ -103,20 +97,20 @@ public class MailService implements IMailService {
...
@@ -103,20 +97,20 @@ public class MailService implements IMailService {
MimeMessageHelper
helper
=
new
MimeMessageHelper
(
message
);
MimeMessageHelper
helper
=
new
MimeMessageHelper
(
message
);
File
file
=
ResourceUtils
.
getFile
(
"classpath:"
+
environment
.
getProperty
(
"email.leave.notification.template.file.path"
));
File
file
=
ResourceUtils
.
getFile
(
"classpath:"
+
environment
.
getProperty
(
"email.leave.notification.template.file.path"
));
//Read File Content
//Read File Content
String
content
=
new
String
(
Files
.
readAllBytes
(
file
.
toPath
()));
String
content
=
new
String
(
Files
.
readAllBytes
(
file
.
toPath
()));
content
=
content
.
replaceAll
(
"employeeName"
,
mail
.
getEmpName
());
content
=
content
.
replaceAll
(
"employeeName"
,
mail
.
getEmpName
());
//System.out.println(content);
helper
.
setTo
(
mail
.
getTo
());
helper
.
setTo
(
mail
.
getTo
());
helper
.
setText
(
content
,
true
);
helper
.
setText
(
content
,
true
);
helper
.
setSubject
(
mail
.
getSubject
());
helper
.
setSubject
(
mail
.
getSubject
());
helper
.
setFrom
(
mail
.
getFrom
());
helper
.
setFrom
(
mail
.
getFrom
());
helper
.
setCc
(
mail
.
getCc
());
if
(
mail
.
getCc
()
!=
null
)
{
//helper.setBcc(mail.getBcc());
helper
.
setCc
(
mail
.
getCc
());
//helper.setBcc(mail.getBcc());//log.info("Mail Content::"+content);//log.info("The Mail Object::"+mail);
}
emailSender
.
send
(
message
);
emailSender
.
send
(
message
);
}
}
...
...
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