Commit b38836e6 authored by bpandey's avatar bpandey

modify code as per client requirement


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94225 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 56c0d2fc
......@@ -93,14 +93,14 @@ public class ProductionVsBudgetReportBean
public void generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID) throws RemoteException, ITMException
public String generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID) throws RemoteException, ITMException
{
String resultString="false";
try
{
budgetReportRemote.generatePDF(hashMap,exportPDFPath,exportImagePath,preyearMonth,rptTitle,userID);
resultString= budgetReportRemote.generatePDF(hashMap,exportPDFPath,exportImagePath,preyearMonth,rptTitle,userID);
}
catch (Exception e)
{
......@@ -108,7 +108,7 @@ public class ProductionVsBudgetReportBean
e.printStackTrace();
}
return resultString;
}
......
......@@ -4,17 +4,20 @@ import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.utility.ITMException;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.awt.Desktop;
import java.net.URI;
public class ProductionVsBudgetReportSchedule implements Schedule
{
public String schedule(HashMap map) throws Exception
{
System.out.println(schedule((String) map.get("PROCESS_NAME")));
......@@ -35,7 +38,6 @@ public class ProductionVsBudgetReportSchedule implements Schedule
private void runSchedule() throws ITMException
{
// Add new code on dated 10/01/2013
String sql = "";
ResultSet rs = null;
......@@ -46,24 +48,29 @@ public class ProductionVsBudgetReportSchedule implements Schedule
String uri = "";
String finalURI = "";
List<String> sendFinalURIList = null;
//add new variable on dated1/02/2013
String os = System.getProperty("os.name").toLowerCase();
String browserPathForLinex="";
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
sendFinalURIList = new ArrayList<String>();
sql = " select user_id,uri from dashboard_comp where uri like '%ProductionVsBudgetReportExport.jsp%'";
//sql = " select user_id,uri from dashboard_comp where uri like '%ProductionVsBudgetReportExport.jsp%'";
sql="select user_id,uri from dashboard_comp where uri like '%ExportExample/ProductionVsBudgetReportExport.jsp%'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
userID = checkNull(rs.getString("user_id"));
uri = checkNull(rs.getString("uri"));
// finalURI = CommonConstants.TOMCAT_HOME + uri + "&userID ="+userID;
finalURI = CommonConstants.TOMCAT_HOME + uri;
System.out.println("finalURI is =" + finalURI);
sendFinalURIList.add(finalURI);
finalURI = CommonConstants.TOMCAT_HOME+uri+"&userID="+userID;
System.out.println("direct uri from table ="+ uri);
System.out.println("User id is =" + userID);
System.out.println("modify url is =" + finalURI);
sendFinalURIList.add(finalURI);
}
......@@ -72,37 +79,60 @@ public class ProductionVsBudgetReportSchedule implements Schedule
pstmt = null;
rs = null;
//This URL comming from table as dashboard_comp as multiple types
//CommonConstants.TOMCAT_HOME+ibase/dashboard/mfg/jsp/ProductionVsBudgetReport.jsp?geoLocation=105,110,117,130 &unitForm=TAB,CAP,V01,A01&userID=E04111
/* if (os.indexOf( "win" ) >= 0)
{
for (String resourcePath : sendFinalURIList)
{
Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler"+ resourcePath);
Thread.sleep(25000);
}
} */
/*Added new code for windows palform*/
if (os.indexOf("win") >= 0)
{
System.out.println("Start Window Section part execution");
if (Desktop.isDesktopSupported())
{
Desktop desktop = Desktop.getDesktop();
for (String resourcePath : sendFinalURIList)
{
try
{
System.out.println("run on browser through window ");
desktop.browse(new URI(resourcePath));
} catch (Exception e)
Thread.sleep(2500);
System.out.println("End run on browser through window ");
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
} else
{
Runtime runtime = Runtime.getRuntime();
try
}
//Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler" + resourcePath);
//Thread.sleep(25000L);
}
System.out.println("End of Window Section part execution");
}
/* Ended Added new code for windows palform*/
if (os.indexOf( "nix") >=0 || os.indexOf( "nux") >=0)
{
runtime.exec("xdg-open " + resourcePath);
} catch (IOException e)
//browserPathForLinex ="/usr/lib/firefox/firefox";
browserPathForLinex ="/usr/lib/firefox/firefox";
for (String resourcePath : sendFinalURIList)
{
// TODO Auto-generated catch block
e.printStackTrace();
callURL(browserPathForLinex,resourcePath); //call synchronized method
//String[] b = {browserPath, resourcePath};
}
}
// String resourcePath = CommonConstants.TOMCAT_HOME + File.separator + "ibase" +File.separator + "dashboard" + File.separator + "mfg" +File.separator+"JSP"+File.separator+"ExportExample"+File.separator +"ProductionVsBudgetReport_export.jsp";
System.out.println("ProductionVsBudgetReportSchedule path =[" + resourcePath + "]");
}// end forloop
// end forloop
}// end try block
......@@ -133,8 +163,23 @@ public class ProductionVsBudgetReportSchedule implements Schedule
}
}
}
synchronized void callURL(String browserPath,String resourcePath)
{
try{
int second = (int)(System.currentTimeMillis() / 1000) % 60 ;
System.out.println("View for Time when next URL are comming==="+second);
Runtime.getRuntime().exec(new String[] {browserPath, resourcePath});
Thread.sleep(35000);
System.out.println("In Linex12");
}catch(Exception e){System.out.println("Exception Inside callURL by synchronization method "+e.getMessage());}
}
// This method call for check null
private String checkNull(String input)
{
......
package ibase.dashboard.mfg.bean;
import ibase.webitm.utility.ITMException;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.List;
import javax.servlet.ServletException;
......@@ -47,9 +52,19 @@ public class ProductionVsBudgetReportServlet extends HttpServlet
//System.out.println("preyearMonth====="+preyearMonth);
//System.out.println("rptTitle====="+rptTitle);
//call EJB method for PDF creation*******************
bean.generatePDF(gridDataMap, exportPDFPath, exportImagePath, preyearMonth, rptTitle,userID);
String resultString= bean.generatePDF(gridDataMap, exportPDFPath, exportImagePath, preyearMonth, rptTitle,userID);
response.setContentType("text/html");
response.getWriter().write("PDF Creation");
System.out.println("resultString is ="+resultString);
if(resultString.equals("false"))
{
response.getWriter().write("false");
}
else
{
response.getWriter().write("true");
}
}
catch (Exception e)
{
......@@ -65,7 +80,8 @@ public class ProductionVsBudgetReportServlet extends HttpServlet
}
finally
{
bean=null;
userID="";
}
}
......
package ibase.dashboard.mfg.ejb;
import ibase.system.config.ConnDriver;
import ibase.utility.EMail;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import ibase.utility.EMail;
import java.awt.Color;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
......@@ -21,10 +19,18 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.processing.FilerException;
import javax.ejb.Stateless;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Image;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
/**
* Session Bean implementation class ProductionVsBudgetReport
......@@ -569,7 +575,7 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
//end Role validation
//start method for PDF generate
public void generatePDF(HashMap<String, List<String>> hashMap, String exportPDFPath, String exportImagePath, String preyearMonth, String rptTitle,String userID) throws RemoteException, ITMException
public String generatePDF(HashMap<String, List<String>> hashMap, String exportPDFPath, String exportImagePath, String preyearMonth, String rptTitle,String userID) throws RemoteException, ITMException
{
@SuppressWarnings("unused")
......@@ -589,14 +595,22 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
File existImgFile =null;
int seconds =0;
String pdfFileName =null;
String toMailId ="";
String ccMailId ="";
String bccAddress ="";
String subject ="";
String userWiseBodytext="";
String resultFlage ="false";
System.out.print("Call for PDF created");
try
{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MMM-yy");
Calendar calendar = Calendar.getInstance();
String currDate = simpleDateFormat.format(calendar.getTime());
System.out.println("Current date is="+currDate);
document = new Document();
seconds = (int) (System.currentTimeMillis() / 1000) % 60 ;
pdfFileName = exportPDFPath+"ProductionVsBudget-"+userID+"-"+seconds+".pdf";
pdfFileName = exportPDFPath+"ProductionVsBudgetReport-"+userID+"-"+currDate+".pdf";
file = new FileOutputStream(new File(pdfFileName));
writer = PdfWriter.getInstance(document, file);
document.open();
......@@ -607,6 +621,8 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
preface.add(new Paragraph(" "));
document.add(preface);
System.out.println(" size of HashMap is="+hashMap.size());
ArrayList<String> keyList=new ArrayList<String>();
ArrayList<List<String>> valueList=new ArrayList<List<String>>();
......@@ -660,8 +676,6 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
}
image.scaleAbsolute(320f, 250f);// image width,height
image.setAlignment(5);
......@@ -739,10 +753,7 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
childtable.addCell(table);
cell = new PdfPCell(childtable);
cell.setBorder(Rectangle.NO_BORDER);
parentTable.addCell(cell);
......@@ -766,24 +777,22 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
}
document.close();
file.close();
System.out.println("PDF Created succesfully");
System.out.println("System goes to connected database table:users");
System.out.println("PDF Created succesfully");
conn = connDriver.getConnectDB("DriverITM");
connDriver =null;
String toMailId ="";
String ccMailId ="";
String bccAddress ="";
String subject ="Regarding:ProductionVsBudgetReport as PDF ";
String userWiseBodytext = "Plase find attachment of Production Vs BudgetReport PDF";
toMailId ="";
ccMailId ="";
bccAddress ="";
subject ="Production Vs Budget Report-PDF ";
userWiseBodytext ="Dear Sir, Please find attached herewith is the Production Vs Budget Report in PDF format.";
String sql = "select name,user_type,email_id FROM users WHERE code='"+userID+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
toMailId = checkNull(rs.getString("email_id"));
System.out.println("EMAIL ID from table :users=="+toMailId);
System.out.println("No of Users ="+userID +"AND According to Email ID======="+toMailId);
}
pstmt.close();
pstmt = null;
......@@ -805,12 +814,9 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
mailInfo.add(userWiseBodytext);
mailInfo.add(attachFile.getPath());
this.sendingMail(mailInfo);
resultFlage="true";
}
System.out.println("All Activity have been completed(PDF,Mail Sending) :Thanks you");
System.out.println("*********** Pdf and sending mail done succesfully (Final)**************");
} catch (Exception e)
{
System.out.println("Exception :ProductionVsBudgetReport :generatePDF(HashMap<String, List<String>>,String,String,String,String"+e.getMessage());
......@@ -831,6 +837,7 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
}
}
return resultFlage;
}
//end method for PDF generate
......@@ -851,12 +858,11 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
commInfo.append("</ROOT>");
EMail email = new EMail();
try
{
System.out.println(" calling sendMail method()");
email.sendMail(commInfo.toString(), "ITM", null);
System.out.println(" Email send succesfully ***********");
System.out.println(" ********Email send succesfully ***********");
} catch (Exception e)
{
e.printStackTrace();
......@@ -865,5 +871,4 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
email = null;
}
//End method for sending mail*******
}
\ No newline at end of file
......@@ -15,6 +15,6 @@ public interface ProductionVsBudgetReportLocal extends ValidatorLocal{
public String getGeoLoCodeXmlData() throws RemoteException, ITMException;
public String getUnitFormXmlData() throws RemoteException, ITMException;
public boolean getRoleValid(String userCode, String roleCode) throws RemoteException, ITMException;
public void generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID) throws RemoteException, ITMException;
public String generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID) throws RemoteException, ITMException;
}
......@@ -16,6 +16,6 @@ public interface ProductionVsBudgetReportRemote extends ValidatorRemote
public String getGeoLoCodeXmlData() throws RemoteException, ITMException;
public String getUnitFormXmlData() throws RemoteException, ITMException;
public boolean getRoleValid(String userCode, String roleCode) throws RemoteException, ITMException;
public void generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID) throws RemoteException, ITMException;
public String generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID) throws RemoteException, ITMException;
}
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