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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Diogo Neves 15 years ago
parent 14d90ae619
commit 03b8bb656b

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

Loading…
Cancel
Save