git-svn-id: https://svn.coded.pt/svn/SIPRP@1573 bb69d46d-e84e-40c8-a05a-06db0d633741

lxbfYeaa
Diogo Neves 15 years ago
parent 14d90ae619
commit 03b8bb656b

@ -10559,10 +10559,8 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
return null;
}
public String butEnviar_action() {
// TODO: Process the button click action. Return value is a navigation
// case name where null will return to the same page.
public String butEnviar_action()
{
System.out.println("BUT ENVIAR 1");
//IE bugs
@ -10575,7 +10573,6 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
getSessionBean1().setSubmetido( true );
}
//
if ( getSessionBean1().getCurrentAnalise() == null ) //new analise
{
if ( validationOk() )
@ -10611,8 +10608,6 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
{
return "form_seguranca";
}
}
catch ( Exception ex )
{
@ -10734,7 +10729,6 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
{
return "form_medico";
}
}
catch ( Exception ex )
{
@ -10748,7 +10742,6 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
getSessionBean1().setSubmetido( false );
}
}
return null;
}
@ -14263,7 +14256,7 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
}
catch ( Exception ex )
{
ErrorLogger.logException( ex );
// ErrorLogger.logException( ex );
}
String texto_email = "<p style='text-align: justify; font-family: arial, sans-serif'>Caro(a) Colega,</p>";
@ -14342,7 +14335,8 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
return errorMessage;
}
private String sendEmailToRhFase4(AnaliseAcidente a) {
private String sendEmailToRhFase4(AnaliseAcidente a)
{
String errorMessage = "";
System.out.println("SEND EMAIL TO RH FASE 4");
@ -14432,54 +14426,51 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
private final String mail_bcc = "acidentes.auchan@siprp.pt";
private final String mail_bcc2 = "siprp.aat@evolute.pt";
private void sendEmail(String emailTo, String emailFrom, String assunto, String texto_email)
throws Exception
{
Properties props = new Properties();
//props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", SMTP_HOST );
props.put("mail.from", emailFrom);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.user", mail_username );
props.put("mail.smtp.password", mail_password );
// Authenticator auth = new SMTPAuthenticator();
// Session session = Session.getDefaultInstance(props, auth);
Session session = Session.getDefaultInstance( props );
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(emailFrom));
InternetAddress[] address = {new InternetAddress(emailTo)};
msg.setRecipients(Message.RecipientType.TO, address);
InternetAddress[] addressBCC = new InternetAddress[ 2 ];
addressBCC[ 0 ] = new InternetAddress( mail_bcc );
addressBCC[ 1 ] = new InternetAddress( mail_bcc2 );
msg.setRecipients( Message.RecipientType.BCC, addressBCC );
((MimeMessage)msg).setSubject(assunto, "UTF-8");
msg.setSentDate(new Date());
Multipart multipart = new MimeMultipart();
BodyPart msgBodyPart = new MimeBodyPart();
String html;
html="<html><head> <meta content='text/html;charset=ISO-8859-1' http-equiv='Content-Type'></head>";
html+="<body bgcolor='#ffffff' text='#000000'>";
html+= texto_email;
html+="<body></html>";
msgBodyPart.setContent(html, "text/html");
multipart.addBodyPart(msgBodyPart);
msg.setContent(multipart);
// Transport.send(msg);
Transport t;
t = session.getTransport( "smtp" );
t.connect( SMTP_HOST, SMTP_PORT, mail_username, mail_password );
t.sendMessage( msg, msg.getAllRecipients() );
t.close();
System.out.println("Email Enviado !!!!" );
}
// private void sendEmail(String emailTo, String emailFrom, String assunto, String texto_email)
// throws Exception
// {
// Properties props = new Properties();
// //props.put("mail.transport.protocol", "smtp");
// props.put("mail.smtp.host", SMTP_HOST );
// props.put("mail.from", emailFrom);
// props.put("mail.smtp.auth", "true");
// props.put("mail.smtp.user", mail_username );
// props.put("mail.smtp.password", mail_password );
//
// Session session = Session.getDefaultInstance( props );
//
// Message msg = new MimeMessage(session);
// msg.setFrom(new InternetAddress(emailFrom));
// InternetAddress[] address = {new InternetAddress(emailTo)};
// msg.setRecipients(Message.RecipientType.TO, address);
//
// InternetAddress[] addressBCC = new InternetAddress[ 2 ];
// addressBCC[ 0 ] = new InternetAddress( mail_bcc );
// addressBCC[ 1 ] = new InternetAddress( mail_bcc2 );
// msg.setRecipients( Message.RecipientType.BCC, addressBCC );
//
// ((MimeMessage)msg).setSubject(assunto, "UTF-8");
// msg.setSentDate(new Date());
// Multipart multipart = new MimeMultipart();
// BodyPart msgBodyPart = new MimeBodyPart();
// String html;
// html="<html><head> <meta content='text/html;charset=ISO-8859-1' http-equiv='Content-Type'></head>";
// html+="<body bgcolor='#ffffff' text='#000000'>";
// html+= texto_email;
// html+="<body></html>";
// msgBodyPart.setContent(html, "text/html");
// multipart.addBodyPart(msgBodyPart);
// msg.setContent(multipart);
//
// Transport t;
// t = session.getTransport( "smtp" );
//
// t.connect( SMTP_HOST, SMTP_PORT, mail_username, mail_password );
// t.sendMessage( msg, msg.getAllRecipients() );
//
// t.close();
// System.out.println("Email Enviado !!!!" );
// }
private void sendEmailWithPdf(AnaliseAcidente a, String emailTo, String emailFrom, String assunto, String texto_email)
throws Exception
@ -14488,9 +14479,9 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
System.out.println( "\temailTo : " + emailTo );
System.out.println( "\temailFrom : " + emailFrom );
System.out.println( "\tAnaliseAcidente : " + a );
System.out.println( "\t\tTecnicoSaudeID : " + (a == null ? "null" : "" + a.getTecnico_saude_id()) );
System.out.println( "\t\tMedicoID : " + (a == null ? "null" : "" + a.getMedico_id() ) );
System.out.println( "\tAnaliseAcidente : " + ( a == null ? "null" : a.getId() ) );
System.out.println( "\t\tTecnicoSaudeID : " + (a == null ? "a null" : "" + a.getTecnico_saude_id()) );
System.out.println( "\t\tMedicoID : " + (a == null ? "a null" : "" + a.getMedico_id() ) );
UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance();
@ -14576,8 +14567,6 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
msg.setContent( multipart );
// Transport.send(msg);
Transport t;
t = session.getTransport( "smtp" );
@ -14588,9 +14577,8 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
System.out.println("Email Pdf Enviado !!!! " + emailTo);
}
public String butImprimir_action() {
// TODO: Process the button click action. Return value is a navigation
// case name where null will return to the same page.
public String butImprimir_action()
{
// AnaliseAcidente a = getSessionBean1().getCurrentAnalise();
// if(a.getEstado().intValue() == ESTADO_IMPRESSAO)
// {
@ -14681,60 +14669,59 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
return null;
}
private void buildPdf(AnaliseAcidente a)
{
// create pdf folder
String pdf_folder = createPdfFolder(a.getId().toString());
if(pdf_folder != null)
{
hidDisableEnviar.setValue(a.getId().toString());
Pdf pdf = new Pdf();
pdf.generatePdf(pdf_folder, a);
}
}
// private void buildPdf(AnaliseAcidente a)
// {
//
// // create pdf folder
// String pdf_folder = createPdfFolder(a.getId().toString());
// if(pdf_folder != null)
// {
// hidDisableEnviar.setValue(a.getId().toString());
// Pdf pdf = new Pdf();
// pdf.generatePdf(pdf_folder, a);
// }
// }
private String createPdfFolder(String folderName)
{
ServletContext theApplicationsServletContext =
(ServletContext) this.getExternalContext().getContext();
String pdfFileFolder = theApplicationsServletContext.getRealPath(PDFS_FOLDER_URL + "/" + folderName);
try
{
//String imageFileFolderTmp = theApplicationsServletContext.getRealPath(IMAGE_URL + "/tmp" + getSessionBean1().getCurrentUser().getLogin());
File folder = new File(pdfFileFolder);
if(! folder.exists())
{
folder.mkdir();
}
else
{
//remove all existing files
File files[] = folder.listFiles();
// private String createPdfFolder(String folderName)
// {
// ServletContext theApplicationsServletContext =
// (ServletContext) this.getExternalContext().getContext();
// String pdfFileFolder = theApplicationsServletContext.getRealPath(PDFS_FOLDER_URL + "/" + folderName);
// try
// {
// //String imageFileFolderTmp = theApplicationsServletContext.getRealPath(IMAGE_URL + "/tmp" + getSessionBean1().getCurrentUser().getLogin());
// File folder = new File(pdfFileFolder);
// if(! folder.exists())
// {
// folder.mkdir();
// }
// else
// {
// //remove all existing files
// File files[] = folder.listFiles();
//
// for(int i=0;i<files.length;i++)
// {
// if(files[i].isFile())
// {
// // delete
// boolean success = files[i].delete();
// }
// }
// }
// return pdfFileFolder;
// }
// catch(Exception ex)
// {
// ErrorLogger.logException( ex );
// return null;
// }
//
// }
for(int i=0;i<files.length;i++)
{
if(files[i].isFile())
{
// delete
boolean success = files[i].delete();
}
}
}
return pdfFileFolder;
}
catch(Exception ex)
public String butProcurarTrab_action()
{
ErrorLogger.logException( ex );
return null;
}
}
public String butProcurarTrab_action() {
// TODO: Process the button click action. Return value is a navigation
// case name where null will return to the same page.
boolean booNrOk = false;
boolean booNomeOk = false;
String nr_mecano = null;

Loading…
Cancel
Save