Commit a7a9fb5b authored by Ketan Patil's avatar Ketan Patil

Replace ReportCreationSchedulerSfa.java

parent 4fd1a7fe
/* */ package ibase.webitm.ejb.sc; package ibase.webitm.ejb.sc;
/* */
/* */ import ibase.scheduler.utility.interfaces.Schedule; import java.io.File;
/* */ import ibase.system.config.ConnDriver; import java.io.FileWriter;
/* */ import ibase.utility.CommonConstants; import java.io.PrintWriter;
/* */ import ibase.utility.E12GenericUtility; import java.io.StringWriter;
/* */ import ibase.utility.EMail; import java.sql.Connection;
/* */ import ibase.utility.MailInfo; import java.sql.PreparedStatement;
/* */ import ibase.utility.UserInfoBean; import java.sql.ResultSet;
/* */ import ibase.webitm.reports.utility.JasperReportGenerator; import java.sql.ResultSetMetaData;
/* */ import ibase.webitm.reports.utility.ResourceConstants; import java.sql.SQLException;
/* */ import ibase.webitm.reports.utility.XSDParser; import java.sql.Types;
/* */ import ibase.webitm.utility.ITMException; import java.text.DateFormat;
/* */ import java.io.File; import java.text.SimpleDateFormat;
/* */ import java.io.FileWriter; import java.util.ArrayList;
/* */ import java.io.PrintStream; import java.util.Date;
/* */ import java.io.PrintWriter; import java.util.HashMap;
/* */ import java.io.StringWriter; import java.util.TreeMap;
/* */ import java.sql.Connection; import java.util.regex.Matcher;
/* */ import java.sql.PreparedStatement; import java.util.regex.Pattern;
/* */ import java.sql.ResultSet;
/* */ import java.sql.ResultSetMetaData;
/* */ import java.sql.SQLException;
/* */ import java.text.DateFormat;
/* */ import java.text.SimpleDateFormat;
/* */ import java.util.ArrayList;
/* */ import java.util.HashMap;
/* */ import java.util.TreeMap;
/* */ import java.util.regex.Matcher;
/* */ import java.util.regex.Pattern;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
/* */ import org.w3c.dom.Document; import org.w3c.dom.Document;
/* */ import org.w3c.dom.Node; import org.w3c.dom.Node;
/* */ import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
/* */
/* */ public class ReportCreationSchedulerSfa import ibase.scheduler.utility.interfaces.Schedule;
/* */ implements Schedule import ibase.system.config.ConnDriver;
/* */ { import ibase.utility.CommonConstants;
/* 41 */ String mailAddress = ""; import ibase.utility.E12GenericUtility;
/* 42 */ String userInfoXml = ""; import ibase.utility.EMail;
/* */ import ibase.utility.MailInfo;
/* 45 */ UserInfoBean userInfo = null; import ibase.utility.UserInfoBean;
/* */ import ibase.webitm.reports.utility.JasperReportGenerator;
/* */ public String schedule(HashMap arg0) import ibase.webitm.reports.utility.ResourceConstants;
/* */ throws Exception import ibase.webitm.reports.utility.XSDParser;
/* */ { import ibase.webitm.utility.ITMException;
/* 50 */ return null;
/* */ } public class ReportCreationSchedulerSfa implements Schedule{
/* */
/* */ public String schedule(String arg0) throws Exception String mailAddress="";
/* */ { String userInfoXml = "";
/* 55 */ System.out.println("Inside schedule " + arg0); //String userInfoXml = "";
/* 56 */ return performOp(arg0);
/* */ } UserInfoBean userInfo = null;
/* */
/* */ public String schedulePriority(String arg0) @Override
/* */ throws Exception public String schedule(HashMap arg0) throws Exception {
/* */ { // TODO Auto-generated method stub
/* 63 */ System.out.println("Inside schedule priority " + arg0); return null;
/* 64 */ return performOp(arg0); }
/* */ }
/* */ @Override
/* */ public String performOp(String scheduleParamXML) public String schedule(String arg0) throws Exception {
/* */ throws ITMException System.out.println("Inside schedule "+arg0);
/* */ { return this.performOp(arg0);
/* 70 */ String retString = "";
/* */ }
/* 73 */ ConnDriver connDriver = new ConnDriver();
/* 74 */ Connection conn = null; @Override
/* 75 */ PreparedStatement pstmt = null; PreparedStatement pstmt1 = null; public String schedulePriority(String arg0) throws Exception {
/* 76 */ ResultSet rs = null; // TODO Auto-generated method stub
/* */ System.out.println("Inside schedule priority "+arg0);
/* 78 */ boolean isError = false; return this.performOp(arg0);
/* */ try }
/* */ {
/* 89 */ this.userInfoXml = scheduleParamXML;
/* 90 */ System.out.println("userInfoXml:::[" + this.userInfoXml + "]" + "scheduleParamXML>> " + scheduleParamXML); public String performOp(String scheduleParamXML)throws ITMException
/* 91 */ this.userInfo = new UserInfoBean(this.userInfoXml); {
/* 92 */ System.out.println("userInfo > Amit > " + this.userInfo); String retString = "";
/* 93 */ String transDB = this.userInfo.getTransDB(); //Added By Amit Shrivastava [Start][11/08/20]
/* 94 */ System.out.println("get TransDB connection in updateStatus : " + transDB); /*Connection conn = null;*/
/* 95 */ if ((transDB != null) && (transDB.trim().length() > 0)) ConnDriver connDriver = new ConnDriver();
/* */ { Connection conn = null;
/* 97 */ conn = connDriver.getConnectDB(transDB); PreparedStatement pstmt = null,pstmt1=null;
/* */ } ResultSet rs=null;
/* */ else //Added By Amit Shrivastava [End...][11/08/20]
/* */ { boolean isError = false;
/* 101 */ conn = connDriver.getConnectDB("DriverITM"); try
/* */ } {
/* */
/* 105 */ retString = performOp(scheduleParamXML, conn); //printLog("STDOUT","ReportCreationScheduler : performOp => Scheduler Started");
/* */ } //printLog("STDOUT","ReportCreationScheduler : performOp : =>" + scheduleParamXML);
/* */ catch (Exception e)
/* */ { //Added By Amit Shrivastava[Start][11/08/20]
/* 109 */ isError = true; /*ConnDriver connDriver = new ConnDriver();
/* 110 */ e.printStackTrace(); conn = connDriver.getConnectDB();*/
/* 111 */ throw new ITMException(e);
/* */ } this.userInfoXml = scheduleParamXML;
/* */ finally System.out.println("userInfoXml:::[" + this.userInfoXml + "]"+"scheduleParamXML>> "+scheduleParamXML);
/* */ { userInfo = new UserInfoBean(this.userInfoXml);
/* */ try System.out.println("userInfo > Amit > " +userInfo);
/* */ { String transDB = userInfo.getTransDB();
/* 117 */ if (conn != null) System.out.println("get TransDB connection in updateStatus : " + transDB);
/* */ { if ((transDB != null) && (transDB.trim().length() > 0))
/* 119 */ if (isError) {
/* */ { conn = connDriver.getConnectDB(transDB);
/* 121 */ conn.rollback(); }
/* */ } else
/* */ else {
/* */ { conn = connDriver.getConnectDB("DriverITM");
/* 125 */ conn.commit(); }
/* */ } //Added By Amit Shrivastava[End....][11/08/20]
/* 127 */ conn.close();
/* 128 */ conn = null; retString = performOp(scheduleParamXML, conn);
/* */ } }
/* */ } catch(Exception e)
/* */ catch (Exception e) {
/* */ { isError = true;
/* 133 */ e.printStackTrace(); e.printStackTrace();
/* 134 */ throw new ITMException(e); throw new ITMException(e);
/* */ } }
/* */ } finally
/* 137 */ return retString; {
/* */ } try
/* */ {
/* */ public String performOp(String scheduleParamXML, Connection conn) throws ITMException, Exception if(conn != null)
/* */ { {
/* 142 */ String retString = ""; if(isError)
/* 143 */ String sql = ""; String objName = ""; String argumentString = ""; String jrxmlName = ""; {
/* 144 */ String sqlExpr = ""; String sqlExpr1 = ""; String sqlExpr2 = ""; String sqlExpr3 = ""; String sqlExpr4 = ""; String sqlExpr5 = ""; String sqlExpr6 = ""; String errfilePath = ""; conn.rollback();
/* 145 */ String compSql = ""; }
/* 146 */ PreparedStatement pstmt = null; else
/* 147 */ ResultSet rs = null; {
/* 148 */ ArrayList objtNamelist = new ArrayList(); conn.commit();
/* 149 */ String objtNames = ""; }
/* 150 */ String stateCode = ""; String reportGroup = null; conn.close();
/* */ conn = null;
/* 152 */ E12GenericUtility genericUtility = new E12GenericUtility(); }
/* 153 */ ArrayList valueContainer = new ArrayList(); }
/* 154 */ boolean mailSent = false; catch(Exception e)
/* 155 */ String transInfo = ""; {
/* */ e.printStackTrace();
/* 157 */ String mailFormat = ""; throw new ITMException(e);
/* */ }
/* 159 */ System.out.println("scheduler xml content:" + scheduleParamXML); }
/* */ return retString;
/* 161 */ String transDB = ""; }
/* 162 */ ConnDriver connDriver = new ConnDriver();
/* */ try public String performOp(String scheduleParamXML,Connection conn)throws ITMException, Exception
/* */ { {
/* 166 */ Document dom = genericUtility.parseString(scheduleParamXML); String retString="";
/* 167 */ System.out.println(" before add parameter userInfo>>>>>" + this.userInfo); String sql="",objName="",argumentString="",jrxmlName="";
/* 168 */ String chgUser = genericUtility.getColumnValue("empName", dom); String sqlExpr="",sqlExpr1="",sqlExpr2="",sqlExpr3="",sqlExpr4="",sqlExpr5="",sqlExpr6="",errfilePath="";
/* 169 */ String chgTerm = genericUtility.getColumnValue("hostIP", dom); String compSql="";
/* 170 */ String loginCode = genericUtility.getColumnValue("loginCode", dom); PreparedStatement pstmt = null;
/* 171 */ String loginEmpCode = genericUtility.getColumnValue("empCode", dom); ResultSet rs = null ;
/* 172 */ String loginSiteCode = genericUtility.getColumnValue("siteCode", dom); ArrayList<String> objtNamelist=new ArrayList<String>();
/* 173 */ System.out.println("chgUser>> " + chgUser + "chgTerm>>>" + chgTerm + "loginCode>>>" + loginCode + "loginEmpCode>>>" + loginEmpCode + "loginSiteCode>>>" + loginSiteCode); String objtNames="";
/* 174 */ this.userInfo.setEmpCode(loginEmpCode); String stateCode="",reportGroup = null;
/* 175 */ this.userInfo.setRemoteHost(chgTerm); //ibase.utility.UserInfoBean userInfo = null;
/* 176 */ this.userInfo.setSiteCode(loginSiteCode); E12GenericUtility genericUtility = new E12GenericUtility();
/* 177 */ this.userInfo.setLoginCode(loginCode); ArrayList<Object> valueContainer=new ArrayList<Object>();
/* 178 */ this.userInfo.setEntityCode(loginEmpCode); boolean mailSent = false;
/* 179 */ System.out.println(" add parameter userInfo>>>>>" + this.userInfo); String transInfo = "";
/* */ //Added By Amit Shrivastava on 04/16/19 for create a variable [Start]
/* 181 */ NodeList paramList = dom.getElementsByTagName("SCHEDULE"); String mailFormat="";
/* 182 */ Node currDetail = null; //Added By Amit Shrivastava on 04/16/19 for create a variable [End]
/* 183 */ int noOfParam = paramList.getLength(); System.out.println("scheduler xml content:"+scheduleParamXML);
/* 184 */ NodeList parentNodeList = null; NodeList childNodeList = null; //String reportGroup=scheduleParamXML.substring(scheduleParamXML.indexOf("<reportGroup>")+22, scheduleParamXML.indexOf("</reportGroup>")-3);
/* 185 */ Node parentNode = null; Node childNode = null; String transDB = "";
/* 186 */ String DisparmSites = ""; ConnDriver connDriver = new ConnDriver();
/* 187 */ int childNodeListLength = 0; try{
/* 188 */ String childNodeName = null; //userInfo = new ibase.utility.UserInfoBean( scheduleParamXML );
/* 189 */ int index = 0;
/* */ Document dom=genericUtility.parseString(scheduleParamXML);
/* 191 */ parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS"); System.out.println(" before add parameter userInfo>>>>>" + userInfo);
/* */ String chgUser = genericUtility.getColumnValue("empName", dom);
/* 193 */ parentNode = parentNodeList.item(0); String chgTerm = genericUtility.getColumnValue("hostIP", dom);
/* 194 */ childNodeList = parentNode.getChildNodes(); String loginCode = genericUtility.getColumnValue("loginCode", dom);
/* 195 */ childNodeListLength = childNodeList.getLength(); String loginEmpCode = genericUtility.getColumnValue("empCode", dom);
/* */ String loginSiteCode = genericUtility.getColumnValue("siteCode", dom);
/* 197 */ for (int ctr = 0; ctr < childNodeListLength; ctr++) System.out.println("chgUser>> " + chgUser + "chgTerm>>>" + chgTerm + "loginCode>>>" + loginCode + "loginEmpCode>>>" + loginEmpCode + "loginSiteCode>>>" + loginSiteCode);
/* */ { userInfo.setEmpCode(loginEmpCode);
/* 199 */ childNode = childNodeList.item(ctr); userInfo.setRemoteHost(chgTerm);
/* 200 */ childNodeName = childNode.getNodeName(); userInfo.setSiteCode(loginSiteCode);
/* */ userInfo.setLoginCode(loginCode);
/* 202 */ if ((childNodeName == null) || ("#text".equalsIgnoreCase(childNodeName))) userInfo.setEntityCode(loginEmpCode);
/* */ continue; System.out.println(" add parameter userInfo>>>>>" + userInfo);
/* 204 */ if (ctr == 0) //Dom related stuff goes here.....
/* */ { NodeList paramList = dom.getElementsByTagName( "SCHEDULE" );
/* 206 */ stateCode = checkNull(childNode.getFirstChild().getNodeValue()); Node currDetail = null ;
/* 207 */ System.out.println("StateCode::" + stateCode); int noOfParam = paramList.getLength();
/* */ } NodeList parentNodeList = null,childNodeList = null;
/* 209 */ else if (ctr == 1) Node parentNode = null,childNode = null;
/* */ { String DisparmSites = "";
/* 211 */ reportGroup = checkNull(childNode.getFirstChild().getNodeValue()); int childNodeListLength = 0;
/* 212 */ System.out.println("ReportGroup::" + reportGroup); String childNodeName = null;
/* */ } int index=0;
/* 215 */ else if (ctr == 2)
/* */ { parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS");
/* 217 */ mailFormat = checkNull(childNode.getFirstChild().getNodeValue());
/* 218 */ System.out.println("@ MailFormat::" + mailFormat); parentNode = parentNodeList.item(0);
/* */ } else { childNodeList = parentNode.getChildNodes();
/* 220 */ if (ctr != 3) childNodeListLength = childNodeList.getLength();
/* */ continue;
/* 222 */ transDB = checkNull(childNode.getFirstChild().getNodeValue()); for(int ctr = 0; ctr < childNodeListLength; ctr++)
/* 223 */ System.out.println("@ transDB::" + transDB); {
/* */ } childNode = childNodeList.item(ctr);
/* */ childNodeName = childNode.getNodeName();
/* */ }
/* */ if(childNodeName!=null && !"#text".equalsIgnoreCase(childNodeName))
/* 230 */ this.userInfo.setTransDB(transDB); {
/* 231 */ if ((transDB != null) && (transDB.trim().length() > 0)) if(ctr==0)
/* */ { {
/* 233 */ conn = connDriver.getConnectDB(transDB); stateCode=checkNull(childNode.getFirstChild().getNodeValue());
/* */ } System.out.println("StateCode::"+stateCode);
/* */ else }
/* */ { else if(ctr==1)
/* 237 */ conn = connDriver.getConnectDB("DriverITM"); {
/* */ } reportGroup=checkNull(childNode.getFirstChild().getNodeValue());
/* 239 */ sql = "select line_no,sql_expr,sql_input,sql_expr1,sql_expr2,sql_expr3,sql_expr4, sql_expr5,sql_expr6 from tax_bal_grp_det where bal_group=? "; System.out.println("ReportGroup::"+reportGroup);
/* */ }
/* 241 */ pstmt = conn.prepareStatement(sql); //Added By amit SHrivasatava on 04/06/19 for get the maol format value [Start]
/* 242 */ pstmt.setString(1, reportGroup); else if(ctr==2)
/* 243 */ rs = pstmt.executeQuery(); {
/* 244 */ while (rs.next()) { mailFormat=checkNull(childNode.getFirstChild().getNodeValue());
/* 245 */ sqlExpr = checkNull(rs.getString("sql_expr")); System.out.println("@ MailFormat::"+mailFormat);
/* 246 */ sqlExpr1 = checkNull(rs.getString("sql_expr1")); }
/* 247 */ sqlExpr2 = checkNull(rs.getString("sql_expr2")); else if(ctr==3)
/* 248 */ sqlExpr3 = checkNull(rs.getString("sql_expr3")); {
/* 249 */ sqlExpr4 = checkNull(rs.getString("sql_expr4")); transDB=checkNull(childNode.getFirstChild().getNodeValue());
/* 250 */ sqlExpr5 = checkNull(rs.getString("sql_expr5")); System.out.println("@ transDB::"+transDB);
/* 251 */ sqlExpr6 = checkNull(rs.getString("sql_expr6")); }
/* 252 */ objtNames = checkNull(rs.getString("sql_input")); //Added By amit SHrivasatava on 04/06/19 for get the maol format value [end]
/* */ }
/* 254 */ rs.close(); }
/* 255 */ rs = null; }
/* 256 */ pstmt.close();
/* 257 */ pstmt = null; userInfo.setTransDB(transDB);
/* */ if ((transDB != null) && (transDB.trim().length() > 0))
/* 259 */ compSql = sqlExpr + " " + sqlExpr1 + " " + sqlExpr2 + " " + sqlExpr3 + " " + sqlExpr4 + " " + sqlExpr5 + " " + sqlExpr6; {
/* 260 */ System.out.println("Combine SQL::::" + compSql); conn = connDriver.getConnectDB(transDB);
/* */ }
/* 262 */ String[] obj = objtNames.split(","); else
/* 263 */ for (String s : obj) { {
/* 264 */ objtNamelist.add(s); conn = connDriver.getConnectDB("DriverITM");
/* */ } }
/* 266 */ System.out.println("@narendra Obj name " + (String)objtNamelist.get(0) + " Jrxml Name: " + (String)objtNamelist.get(1)); sql="select line_no,sql_expr,sql_input,sql_expr1,sql_expr2,sql_expr3,sql_expr4,"
/* 267 */ objName = (String)objtNamelist.get(0); + " sql_expr5,sql_expr6 from tax_bal_grp_det where bal_group=? ";
/* 268 */ jrxmlName = (String)objtNamelist.get(1); pstmt=conn.prepareStatement(sql);
/* */ pstmt.setString(1, reportGroup);
/* 271 */ int count = 0; rs=pstmt.executeQuery();
/* 272 */ if ((compSql != null) && (compSql.trim().length() > 0)) while(rs.next()){
/* */ { sqlExpr= checkNull(rs.getString("sql_expr"));
/* 275 */ pstmt = conn.prepareStatement(compSql); sqlExpr1= checkNull(rs.getString("sql_expr1"));
/* 276 */ rs = pstmt.executeQuery(); sqlExpr2= checkNull(rs.getString("sql_expr2"));
/* */ sqlExpr3= checkNull( rs.getString("sql_expr3"));
/* 278 */ while (rs.next()) { sqlExpr4= checkNull(rs.getString("sql_expr4"));
/* 279 */ ResultSetMetaData rsmd = rs.getMetaData(); sqlExpr5= checkNull(rs.getString("sql_expr5"));
/* 280 */ for (int i = 1; i <= rsmd.getColumnCount(); i++) { sqlExpr6= checkNull(rs.getString("sql_expr6"));
/* 281 */ int type = rsmd.getColumnType(i); objtNames=checkNull(rs.getString("sql_input"));
/* 282 */ if ((type == 12) || (type == 1)) { }
/* 283 */ System.out.print("VARCHAR field:" + rs.getString(i)); rs.close();
/* 284 */ if (checkEmailAddress(rs.getString(i))) rs=null;
/* 285 */ System.out.println("Mail id found"); pstmt.close();
/* */ else { pstmt=null;
/* 287 */ valueContainer.add(rs.getString(i));
/* */ } compSql= sqlExpr+" "+sqlExpr1+" "+sqlExpr2+" "+sqlExpr3+" "+sqlExpr4+" "+sqlExpr5+" "+sqlExpr6;
/* */ } System.out.println("Combine SQL::::"+compSql);
/* 290 */ else if (type == 91) {
/* 291 */ System.out.print("DATE field:" + rs.getDate(i)); String[] obj=objtNames.split(",");
/* 292 */ String dateAsString = rs.getDate(i).toString(); for(String s:obj){
/* 293 */ DateFormat sourceFormat = new SimpleDateFormat("yyyy-MM-dd"); objtNamelist.add(s);
/* 294 */ SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yy"); }
/* 295 */ java.util.Date date = sourceFormat.parse(dateAsString); System.out.println("@narendra Obj name "+objtNamelist.get(0)+" Jrxml Name: "+objtNamelist.get(1));
/* 296 */ System.out.println(formatter.format(date)); objName=objtNamelist.get(0);
/* 297 */ valueContainer.add(formatter.format(date)); jrxmlName=objtNamelist.get(1);
/* */ }
/* 299 */ else if (type == 93) {
/* 300 */ System.out.print("TIMESTAMP field:" + rs.getDate(i)); int count=0;
/* 301 */ valueContainer.add(rs.getTimestamp(i)); if(compSql!=null && compSql.trim().length() > 0 )
/* */ } {
/* */ else {
/* 304 */ System.out.println("Exceptional case where data type may be different"); pstmt=conn.prepareStatement(compSql);
/* */ } rs=pstmt.executeQuery();
/* */
/* */ } while(rs.next()){
/* */ ResultSetMetaData rsmd = rs.getMetaData();
/* 309 */ System.out.println("Value container size:::" + valueContainer.size()); for (int i = 1; i <= rsmd.getColumnCount(); i++) {
/* */ int type = rsmd.getColumnType(i);
/* 311 */ count++; if (type == Types.VARCHAR || type == Types.CHAR) {
/* */ System.out.print("VARCHAR field:"+rs.getString(i));
/* 313 */ XSDParser xsdParser = new XSDParser(objName, this.userInfo); if(checkEmailAddress(rs.getString(i))){
/* */ System.out.println("Mail id found");
/* 315 */ argumentString = new ArgumentListGenerator().getDynamicArgumentList(xsdParser, valueContainer); }else{
/* */ valueContainer.add(rs.getString(i));
/* 317 */ valueContainer.clear(); }
/* 318 */ System.out.println("argumentString from dynamic ::==> [" + argumentString + "]"); }
/* */ else if(type==Types.DATE){
/* 320 */ JasperReportGenerator jasperReport = new JasperReportGenerator(this.userInfo); System.out.print("DATE field:"+rs.getDate(i));
/* 321 */ TreeMap argMap = jasperReport.createArgMap(argumentString); String dateAsString = rs.getDate(i).toString();
/* 322 */ System.out.println("Value Of argMap >>>> " + argMap); DateFormat sourceFormat = new SimpleDateFormat("yyyy-MM-dd");
/* 323 */ String allType = (String)argMap.get("report_save_type"); SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yy");
/* 324 */ allType = allType == null ? "" : allType.trim(); Date date = sourceFormat.parse(dateAsString);
/* 325 */ System.out.println("allType>>> Amit" + allType); System.out.println(formatter.format(date));
/* 326 */ if ("PDF".equalsIgnoreCase(allType)) valueContainer.add(formatter.format(date));
/* */ { }
/* 328 */ allType = "pdf"; else if(type==Types.TIMESTAMP){
/* */ } System.out.print("TIMESTAMP field:"+rs.getDate(i));
/* 330 */ else if (("EXCEL".equalsIgnoreCase(allType)) || ("EXCELDATA".equalsIgnoreCase(allType)) || ("EXCEL-DATA".equalsIgnoreCase(allType)) || ("EXCEL DATA".equalsIgnoreCase(allType)) || ("ODS".equalsIgnoreCase(allType))) valueContainer.add(rs.getTimestamp(i));
/* */ { }
/* 332 */ allType = "xls"; else {
/* */ } System.out.println("Exceptional case where data type may be different");
/* 334 */ else if (("CSV".equalsIgnoreCase(allType)) || ("CSVDATA".equalsIgnoreCase(allType))) //System.out.print(rs.getLong(i));
/* */ { }
/* 336 */ allType = "csv"; }
/* */ }
/* 338 */ else if ("HTML".equalsIgnoreCase(allType)) System.out.println("Value container size:::"+valueContainer.size());
/* */ {
/* 340 */ allType = "html"; count++;
/* */ } //argumentString=new ArgumentListGenerator().getArgumentList(objtNamelist.get(1),rs.getString(1));
/* 342 */ else if ("TEXT".equalsIgnoreCase(allType)) XSDParser xsdParser=new XSDParser(objName, userInfo);
/* */ { //argumentString=new ArgumentListGenerator().getDynamicArgumentList(xsdParser,rs.getString(1));
/* 344 */ allType = "txt"; argumentString=new ArgumentListGenerator().getDynamicArgumentList(xsdParser,valueContainer);
/* */ }
/* 346 */ else if ("EXCEL(XLSX)".equalsIgnoreCase(allType)) valueContainer.clear();
/* */ { System.out.println("argumentString from dynamic ::==> ["+argumentString+"]");
/* 348 */ allType = "xlsx";
/* */ } JasperReportGenerator jasperReport=new JasperReportGenerator(userInfo);
/* 350 */ else if ("DOCX".equalsIgnoreCase(allType)) TreeMap argMap = jasperReport.createArgMap(argumentString);
/* */ { System.out.println("Value Of argMap >>>> "+argMap);
/* 352 */ allType = "docx"; String allType=(String) argMap.get("report_save_type");
/* */ } allType = allType == null ? "" : allType.trim();
/* 354 */ else if ("RTF".equalsIgnoreCase(allType)) System.out.println("allType>>> Amit"+allType);
/* */ { if("PDF".equalsIgnoreCase(allType))
/* 356 */ allType = "rtf"; {
/* */ } allType = "pdf";
/* 358 */ else if ("ODT".equalsIgnoreCase(allType)) }
/* */ { else if("EXCEL".equalsIgnoreCase(allType) || "EXCELDATA".equalsIgnoreCase(allType) || "EXCEL-DATA".equalsIgnoreCase(allType) || "EXCEL DATA".equalsIgnoreCase(allType) || "ODS".equalsIgnoreCase(allType))
/* 360 */ allType = "odt"; {
/* */ } allType = "xls";
/* 362 */ System.out.println("allType>>> ::" + allType); }
/* 363 */ System.out.println("Getting argument metadata::" + xsdParser.getArgumentMetaDataString()); else if("CSV".equalsIgnoreCase(allType) || "CSVDATA".equalsIgnoreCase(allType))
/* 364 */ System.out.println("xsdParser::---->" + xsdParser); {
/* */ allType = "csv";
/* 374 */ System.out.println(" add parameter userInfo>>>>>" + this.userInfo); }
/* */ else if("HTML".equalsIgnoreCase(allType))
/* 376 */ jasperReport.createReport(jrxmlName, argMap, xsdParser, rs.getString("site_code"), rs.getString("tran_id") + "_" + count); {
/* */ allType = "html";
/* 378 */ String reportOutputFileName = jasperReport.getOutputFileName(); }
/* 379 */ System.out.println("[reportOutputFileName]:" + reportOutputFileName); else if("TEXT".equalsIgnoreCase(allType))
/* 380 */ String reportDestination = ResourceConstants.REPORTDESTINATION + File.separator + rs.getString("site_code") + File.separator + {
/* 381 */ reportOutputFileName + "." + allType; allType = "txt";
/* */ }
/* 383 */ transInfo = getDomString(rs.getString("email_addr")); else if("EXCEL(XLSX)".equalsIgnoreCase(allType))
/* */ {
/* 386 */ String copyPath = ResourceConstants.REPORTDESTINATION + File.separator + "TempFolder"; allType = "xlsx";
/* */ try }
/* */ { else if("DOCX".equalsIgnoreCase(allType))
/* 389 */ File copyFilePath = new File(copyPath); {
/* 390 */ if (!copyFilePath.exists()) { allType = "docx";
/* 391 */ copyFilePath.mkdir(); }
/* */ } else if("RTF".equalsIgnoreCase(allType))
/* 393 */ else if (copyFilePath.exists()) {
/* */ { allType = "rtf";
/* */ try }
/* */ { else if("ODT".equalsIgnoreCase(allType))
/* 397 */ if (count <= 1) {
/* */ { allType = "odt";
/* 399 */ FileUtils.cleanDirectory(copyFilePath); }
/* */ } System.out.println("allType>>> ::"+allType);
/* */ } System.out.println("Getting argument metadata::"+xsdParser.getArgumentMetaDataString());
/* */ catch (Exception exp) System.out.println("xsdParser::---->"+xsdParser);
/* */ { //argumnetMap get report_save_type value if report save type -- pdf ,xsl,//Amit
/* 404 */ exp.printStackTrace();
/* */ } /*
/* */ } if (argNodes.getLength() > 0) {
/* 407 */ File reportDestPath = new File(reportDestination); Element err = (Element)argNodes.item(0);
/* 408 */ FileUtils.copyFileToDirectory(reportDestPath, copyFilePath); System.out.println(err.getAttribute("value")+" "+err.getAttribute("name"));
/* */ try } else {
/* */ { // success
/* 411 */ mailSent = sendMail(reportDestination, transInfo, mailFormat, conn); }*/
/* */ } System.out.println(" add parameter userInfo>>>>>" + userInfo);
/* */ catch (Exception e)
/* */ { jasperReport.createReport(jrxmlName, argMap, xsdParser, rs.getString("site_code"), rs.getString("tran_id")+"_"+count);
/* 415 */ System.out.println("Mail sending failed");
/* */ } String reportOutputFileName = jasperReport.getOutputFileName();
/* */ } System.out.println("[reportOutputFileName]:"+reportOutputFileName);
/* */ catch (Exception e) String reportDestination = ResourceConstants.REPORTDESTINATION + File.separator + rs.getString("site_code") + File.separator
/* */ { + reportOutputFileName + "." +allType;
/* 420 */ e.printStackTrace();
/* */ } transInfo = getDomString(rs.getString("email_addr"));
/* */ //comment by amit shrivastava on 04/06/19 [Start]
/* 424 */ if (mailSent) { /*mailSent= sendMail(reportDestination,transInfo);*/
/* 425 */ printLog(rs.getString("email_addr"), rs.getString("tran_id"), reportOutputFileName, mailSent); String copyPath = ResourceConstants.REPORTDESTINATION + File.separator + "TempFolder";
/* 426 */ System.out.println("Succesfully send the mail"); try
/* */ } else { {
/* 428 */ printLog(rs.getString("email_addr"), rs.getString("tran_id"), reportOutputFileName, mailSent); File copyFilePath = new File(copyPath);
/* 429 */ System.out.println("failure while sending the mail"); if(!copyFilePath.exists()) {
/* */ } copyFilePath.mkdir();
/* 431 */ index++; }
/* */ } else if(copyFilePath.exists())
/* 433 */ if (index == 0) { {
/* 434 */ printLog("No Data Found", "Please Enter Valid Query to Return data"); try
/* */ } {
/* */ if(count <= 1)
/* 437 */ rs.close(); {
/* 438 */ rs = null; FileUtils.cleanDirectory(copyFilePath);
/* 439 */ pstmt.close(); }
/* 440 */ pstmt = null; }
/* */ } catch(Exception exp)
/* */ } {
/* */ catch (SQLException e1) exp.printStackTrace();
/* */ { }
/* 445 */ System.out.println("Error_Code::::" + e1.getErrorCode()); }
/* 446 */ System.out.println(e1); File reportDestPath = new File(reportDestination);
/* 447 */ String err = String.valueOf(e1.getErrorCode()); FileUtils.copyFileToDirectory(reportDestPath, copyFilePath);
/* 448 */ printLog("STDERR", "GENERIC REPORTS :: FAIL_SQL ==>" + compSql); try
/* 449 */ printLog("STDERR", "GENERIC REPORTS :: FAIL_SQL ==>" + e1); {
/* */ } mailSent= sendMail(reportDestination,transInfo ,mailFormat, conn);
/* */ catch (Exception e) }
/* */ { catch(Exception e)
/* 454 */ throw new Exception(e); {
/* */ } System.out.println("Mail sending failed");
/* */ finally }
/* */ { }
/* 458 */ if (rs != null) catch(Exception e)
/* */ { {
/* 460 */ rs.close(); e.printStackTrace();
/* 461 */ rs = null; }
/* */ }
/* 463 */ if (pstmt != null) //comment by amit shrivastava on 04/06/19 [End]
/* */ { if(mailSent){
/* 465 */ pstmt.close(); printLog(rs.getString("email_addr"), rs.getString("tran_id"), reportOutputFileName,mailSent);//GENERATE LOG
/* 466 */ pstmt = null; System.out.println("Succesfully send the mail");
/* */ } }else{
/* */ } printLog(rs.getString("email_addr"), rs.getString("tran_id"), reportOutputFileName,mailSent);//GENERATE LOG
/* 469 */ return retString; System.out.println("failure while sending the mail");
/* */ } }
/* */ index++;
/* */ private void printLog(String title, String msg) }
/* */ { if(index==0){
/* 480 */ String logFile = ""; printLog("No Data Found", "Please Enter Valid Query to Return data");
/* 481 */ String logDir = ""; }
/* 482 */ File logFileDir = null;
/* 483 */ FileWriter fileWriter = null; rs.close();
/* */ try rs=null;
/* */ { pstmt.close();
/* 487 */ String logFileName = ""; pstmt=null;
/* 488 */ SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); }
/* 489 */ logFileName = "ReportScheduler_" + sdf.format(new java.util.Date()); }
/* */ catch(SQLException e1)
/* 491 */ System.out.println("Inside the print log method"); {
/* */ System.out.println("Error_Code::::"+e1.getErrorCode());
/* 493 */ logDir = CommonConstants.JBOSSHOME + File.separator + "applnlog" + File.separator + "ReportScheduler_"; System.out.println(e1);
/* 494 */ System.out.println("Log direction: " + logDir); String err=String.valueOf(e1.getErrorCode());
/* */ printLog("STDERR", "GENERIC REPORTS :: FAIL_SQL ==>"+compSql);
/* 496 */ logFileDir = new File(logDir); printLog("STDERR", "GENERIC REPORTS :: FAIL_SQL ==>"+e1);
/* */
/* 498 */ if (!logFileDir.exists()) }
/* */ { catch(Exception e)
/* 500 */ logFileDir.mkdirs(); {
/* */ } throw new Exception(e);
/* */ }
/* 503 */ logFile = logDir + File.separator + logFileName + ".log"; finally
/* */ {
/* 505 */ SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); if(rs!=null)
/* 506 */ java.util.Date now = new java.util.Date(); {
/* 507 */ String strDate = sdfDate.format(now); rs.close();
/* */ rs = null;
/* 509 */ fileWriter = new FileWriter(logFile, true); }
/* */ if(pstmt !=null)
/* 511 */ fileWriter.write("\r\n"); {
/* 512 */ fileWriter.write("[ERROR] " + msg); pstmt.close();
/* */ } pstmt = null;
/* */ catch (Exception ex) }
/* */ { }
/* 516 */ ex.printStackTrace(); return retString;
/* 517 */ printLog("STDERR", ex); }
/* 518 */ printLog("STDOUT", "Inside Exception [getLog]>>" + ex.toString());
/* */ try
/* */ { /**
/* 524 */ if (fileWriter != null) * @param title
/* */ { * @param msg
/* 526 */ fileWriter.flush(); * This method is used for printing the logs in log file
/* 527 */ fileWriter.close(); */
/* */ } private void printLog(String title, String msg)
/* */ } {
/* */ catch (Exception e) String logFile = "";
/* */ { String logDir = "";
/* 532 */ e.printStackTrace(); File logFileDir = null;
/* 533 */ printLog("STDERR", e); FileWriter fileWriter = null;
/* */ }
/* */ } try
/* */ finally {
/* */ { String logFileName = "";
/* */ try SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
/* */ { logFileName = "ReportScheduler_"+sdf.format(new Date());
/* 524 */ if (fileWriter != null)
/* */ { System.out.println("Inside the print log method");
/* 526 */ fileWriter.flush();
/* 527 */ fileWriter.close(); logDir = CommonConstants.JBOSSHOME + File.separator + "applnlog" + File.separator + "ReportScheduler_";
/* */ } System.out.println("Log direction: "+logDir);
/* */ }
/* */ catch (Exception e) logFileDir = new File(logDir);
/* */ {
/* 532 */ e.printStackTrace(); if (!logFileDir.exists())
/* 533 */ printLog("STDERR", e); {
/* */ } logFileDir.mkdirs();
/* */ } }
/* */ }
/* */ logFile = logDir + File.separator + logFileName + ".log";
/* */ private void printLog(String maildId, String tranId, String fileName, boolean mailSent)
/* */ { SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
/* 540 */ String logFile = ""; java.util.Date now = new java.util.Date();
/* 541 */ String logDir = ""; String strDate = sdfDate.format(now);
/* 542 */ File logFileDir = null;
/* 543 */ FileWriter fileWriter = null; fileWriter = new FileWriter(logFile, true);
/* */ try
/* */ { fileWriter.write("\r\n");
/* 547 */ String logFileName = ""; fileWriter.write("[ERROR] "+msg);
/* 548 */ SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); }
/* 549 */ logFileName = "ReportScheduler_" + sdf.format(new java.util.Date()); catch (Exception ex)
/* */ {
/* 551 */ System.out.println("Inside the print log method"); ex.printStackTrace();
/* */ printLog("STDERR", ex);
/* 553 */ logDir = CommonConstants.JBOSSHOME + File.separator + "applnlog" + File.separator + "ReportScheduler_"; printLog("STDOUT","Inside Exception [getLog]>>" + ex.toString());
/* 554 */ System.out.println("Log direction: " + logDir); }
/* */ finally
/* 556 */ logFileDir = new File(logDir); {
/* */ try
/* 558 */ if (!logFileDir.exists()) {
/* */ { if (fileWriter != null)
/* 560 */ logFileDir.mkdirs(); {
/* */ } fileWriter.flush();
/* */ fileWriter.close();
/* 563 */ logFile = logDir + File.separator + logFileName + ".log"; }
/* */ }
/* 565 */ SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); catch (Exception e)
/* 566 */ java.util.Date now = new java.util.Date(); {
/* 567 */ String strDate = sdfDate.format(now); e.printStackTrace();
/* */ printLog("STDERR", e);
/* 569 */ fileWriter = new FileWriter(logFile, true); }
/* */ }
/* 571 */ fileWriter.write("\r\n"); }
/* 572 */ if (mailSent) {
/* 573 */ fileWriter.write("Succesfully Sent mail to [" + tranId + "] " + "With File Name" + " [" + fileName + "] on Mail Id " + "[" + maildId + "]"); private void printLog(String maildId, String tranId,String fileName,boolean mailSent)
/* */ } {
/* */ else { String logFile = "";
/* 576 */ fileWriter.write("Mail is not Sent to [" + tranId + "] " + "With File Name" + " [" + fileName + "] on Mail Id " + "[" + maildId + "]"); String logDir = "";
/* */ } File logFileDir = null;
/* */ } FileWriter fileWriter = null;
/* */ catch (Exception ex)
/* */ { try
/* 581 */ ex.printStackTrace(); {
/* 582 */ printLog("STDERR", ex); String logFileName = "";
/* 583 */ printLog("STDOUT", "Inside Exception [getLog]>>" + ex.toString()); SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
/* */ try logFileName = "ReportScheduler_"+sdf.format(new Date());
/* */ {
/* 589 */ if (fileWriter != null) System.out.println("Inside the print log method");
/* */ {
/* 591 */ fileWriter.flush(); logDir = CommonConstants.JBOSSHOME + File.separator + "applnlog" + File.separator + "ReportScheduler_";
/* 592 */ fileWriter.close(); System.out.println("Log direction: "+logDir);
/* */ }
/* */ } logFileDir = new File(logDir);
/* */ catch (Exception e)
/* */ { if (!logFileDir.exists())
/* 597 */ e.printStackTrace(); {
/* 598 */ printLog("STDERR", e); logFileDir.mkdirs();
/* */ } }
/* */ }
/* */ finally logFile = logDir + File.separator + logFileName + ".log";
/* */ {
/* */ try SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
/* */ { java.util.Date now = new java.util.Date();
/* 589 */ if (fileWriter != null) String strDate = sdfDate.format(now);
/* */ {
/* 591 */ fileWriter.flush(); fileWriter = new FileWriter(logFile, true);
/* 592 */ fileWriter.close();
/* */ } fileWriter.write("\r\n");
/* */ } if(mailSent){
/* */ catch (Exception e) fileWriter.write("Succesfully Sent mail to ["+tranId + "] " + "With File Name" + " ["+ fileName+"] on Mail Id "+"["+maildId+"]");
/* */ { }
/* 597 */ e.printStackTrace(); else{
/* 598 */ printLog("STDERR", e); fileWriter.write("Mail is not Sent to ["+tranId + "] " + "With File Name" + " ["+ fileName+"] on Mail Id "+"["+maildId+"]");
/* */ } }
/* */ } }
/* */ } catch (Exception ex)
/* */ {
/* */ private void printLog(String title, Exception e) ex.printStackTrace();
/* */ { printLog("STDERR", ex);
/* */ try printLog("STDOUT","Inside Exception [getLog]>>" + ex.toString());
/* */ { }
/* 608 */ StringWriter strError = new StringWriter(); finally
/* 609 */ e.printStackTrace(new PrintWriter(strError)); {
/* 610 */ String err = strError.toString(); try
/* 611 */ printLog(title, err); {
/* */ } if (fileWriter != null)
/* */ catch (Exception ex) {
/* */ { fileWriter.flush();
/* 615 */ ex.printStackTrace(); fileWriter.close();
/* 616 */ printLog("STDERR", "Inside Exception [getLog]>>" + ex.toString()); }
/* */ } }
/* */ } catch (Exception e)
/* */ {
/* */ private String checkNull(String input) e.printStackTrace();
/* */ { printLog("STDERR", e);
/* 622 */ if (input == null) { }
/* 623 */ input = ""; }
/* */ } }
/* 625 */ return input.trim();
/* */ }
/* */ private void printLog(String title, Exception e)
/* */ public boolean sendMail(String reportFilePath, String transInfo, String mailFormat, Connection conn) {
/* */ throws ITMException try
/* */ { {
/* 635 */ boolean sentMail = false; StringWriter strError = new StringWriter();
/* */ e.printStackTrace(new PrintWriter(strError));
/* 637 */ String lineNo = "1"; String err = strError.toString();
/* 638 */ String emailType = "page"; printLog(title, err);
/* 639 */ StringBuffer valueXmlString = null; }
/* 640 */ String retValue = ""; catch(Exception ex)
/* */ try {
/* */ { ex.printStackTrace();
/* 644 */ valueXmlString = new StringBuffer("<ROOT>"); printLog("STDERR","Inside Exception [getLog]>>" + ex.toString());
/* */ }
/* 667 */ valueXmlString.append("<MAILINFO>"); }
/* 668 */ valueXmlString.append("<EMAIL_TYPE>").append("page").append("</EMAIL_TYPE>");
/* */
/* 670 */ if ((mailFormat != null) && (mailFormat.trim().length() > 0)) private String checkNull(String input) {
/* */ { if (input == null) {
/* 672 */ valueXmlString.append("<FORMAT_CODE>").append("<![CDATA[" + mailFormat + "]]>").append("</FORMAT_CODE>"); input = "";
/* */ } }
/* */ else { return input.trim();
/* 675 */ valueXmlString.append("<FORMAT_CODE>").append("<![CDATA[GEN_REPORT]]>").append("</FORMAT_CODE>"); }
/* */ }
/* */ //Send mail method will send the mail to stockiest person
/* 680 */ valueXmlString.append("<XML_DATA_FILE_PATH>").append("<![CDATA[" + reportFilePath + "]]>").append("</XML_DATA_FILE_PATH>"); //Comment by amit shrivastava on 04/06/19 [start]
/* 681 */ valueXmlString.append("</MAILINFO>"); /*public boolean sendMail(String reportFilePath, String transInfo)throws ITMException*/
/* 682 */ valueXmlString.append("<XML_DATA>").append(transInfo).append("</XML_DATA>"); public boolean sendMail(String reportFilePath, String transInfo, String mailFormat, Connection conn)throws ITMException
/* 683 */ valueXmlString.append("</ROOT>"); ///Comment by amit shrivastava on 04/06/19 [end]
/* */ {
/* 686 */ String mailDomStr = valueXmlString.toString();
/* */ boolean sentMail = false;
/* 688 */ System.out.println("@@## [Generic Report] :sendMail mailDomStr :-->" + mailDomStr);
/* 689 */ EMail email = new EMail(); String lineNo = "1";
/* 690 */ MailInfo info = new MailInfo(); String emailType = "page";
/* 691 */ retValue = email.sendMail(mailDomStr, "ITM", conn); StringBuffer valueXmlString=null;
/* 692 */ if ("S".equalsIgnoreCase(retValue)) String retValue="";
/* */ {
/* 695 */ sentMail = true; try{
/* */ }
/* 697 */ System.out.println("[Pdf] mail delivered successfully"); valueXmlString = new StringBuffer("<ROOT>");
/* */ } /*valueXmlString = new StringBuffer("<ROOT><TRANS_INFO>");
/* */ catch (ITMException itme) valueXmlString.append("<OBJ_NAME>").append("<![CDATA[" + "" + "]]>").append("</OBJ_NAME>");
/* */ { valueXmlString.append("<REF_SER>").append("<![CDATA[" + "" + "]]>").append("</REF_SER>");
/* 701 */ System.out.println("@@## ITMException [[Generic Report]] :sendMail :sendMail :sendMail() :==>\n"); valueXmlString.append("<REF_ID>").append("<![CDATA[" + "" + "]]>").append("</REF_ID>");
/* 702 */ throw itme; valueXmlString.append("<LINE_NO>").append("<![CDATA[" + lineNo + "]]>").append("</LINE_NO>");
/* */ } valueXmlString.append("</TRANS_INFO>");
/* */ catch (Exception e)
/* */ { valueXmlString.append("<MAIL>");
/* 706 */ System.out.println("Exception :[[Generic Report]] :sendMail() :==>\n" + e.getMessage()); valueXmlString.append("<EMAIL_TYPE>").append("<![CDATA[" + emailType + "]]>").append("</EMAIL_TYPE>");
/* 707 */ throw new ITMException(e); valueXmlString.append("<ENTITY_CODE>").append("<![CDATA[" + "SUN" + "]]>").append("</ENTITY_CODE>");
/* */ } valueXmlString.append("<ENTITY_TYPE>").append("<![CDATA[" + "" + "]]>").append("</ENTITY_TYPE>");
/* 709 */ return sentMail; valueXmlString.append("<FORMAT_CODE>").append("<![CDATA[" + "E" +"]]>").append("</FORMAT_CODE>");
/* */ } valueXmlString.append("<TO_ADD>").append("<![CDATA[" +mailAddress +"]]>").append("</TO_ADD>");
/* */ valueXmlString.append("<CC_ADD>").append("<![CDATA[" + mailAddress+"]]>").append("</CC_ADD>");
/* */ public boolean checkEmailAddress(String emailValue) valueXmlString.append("<SUBJECT>").append("<![CDATA[" + "Reports" +"]]>").append("</SUBJECT>");
/* */ { valueXmlString.append("<BODY_TEXT>").append("<![CDATA[" + "PFA of Report(s)" +"]]>").append("</BODY_TEXT>");
/* 716 */ Pattern pattern = Pattern.compile("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"); valueXmlString.append("<MESSAGE>").append("<![CDATA[" + "PFA of Report(s)" +"]]>").append("</MESSAGE>");
/* 717 */ Matcher mat = pattern.matcher(emailValue); valueXmlString.append("<XML_DATA_FILE_PATH>").append("<![CDATA[" + reportFilePath + "]]>").append("</XML_DATA_FILE_PATH>");
/* 718 */ return mat.matches(); valueXmlString.append("</MAIL>");
/* */ } valueXmlString.append("</ROOT>");*/
/* */
/* */ private String getDomString(String emailIdPer) throws ITMException //valueXmlString.append("<ROOT>");
/* */ { valueXmlString.append("<MAILINFO>");
/* 723 */ String retString = ""; valueXmlString.append("<EMAIL_TYPE>").append("page").append("</EMAIL_TYPE>");
/* 724 */ StringBuffer valueXmlString = new StringBuffer(); //Added By amit Shrivastava on 04/06/19 for add mail format in send mail method.[Start]
/* */ try if(mailFormat !=null && mailFormat.trim().length()>0)
/* */ { {
/* 727 */ valueXmlString.append("<ROOT>"); valueXmlString.append("<FORMAT_CODE>").append("<![CDATA["+mailFormat+"]]>").append("</FORMAT_CODE>");
/* 728 */ valueXmlString.append("<Detail1>"); }else
/* 729 */ valueXmlString.append("<email_id_cust>").append("<![CDATA[" + emailIdPer + "]]>").append("</email_id_cust>"); {
/* 730 */ valueXmlString.append("</Detail1>"); valueXmlString.append("<FORMAT_CODE>").append("<![CDATA[GEN_REPORT]]>").append("</FORMAT_CODE>");
/* 731 */ valueXmlString.append("</ROOT>"); }
/* 732 */ retString = valueXmlString.toString(); /*valueXmlString.append("<FORMAT_CODE>").append("<![CDATA[GEN_REPORT]]>").append("</FORMAT_CODE>");*/
/* */ } //Added By amit Shrivastava on 04/06/19 for add mail format in send mail method.[End]
/* */ catch (Exception e) //commInfo.append("<TO_ADD>").append("<![CDATA[" + emailTo + "]]>").append("</TO_ADD>");
/* */ { valueXmlString.append("<XML_DATA_FILE_PATH>").append("<![CDATA[" + reportFilePath + "]]>").append("</XML_DATA_FILE_PATH>");
/* 736 */ e.printStackTrace(); valueXmlString.append("</MAILINFO>");
/* 737 */ printLog("ERROR", e); valueXmlString.append("<XML_DATA>").append(transInfo).append("</XML_DATA>");
/* */ } valueXmlString.append("</ROOT>");
/* 739 */ return retString;
/* */ }
/* */ } String mailDomStr = valueXmlString.toString();
/* Location: C:\Users\pravin.nevage\Desktop\ibase3-webitm-sc2-0-1-5.jar System.out.println("@@## [Generic Report] :sendMail mailDomStr :-->" + mailDomStr);
* Qualified Name: ibase.webitm.ejb.sc.ReportCreationSchedulerSfa EMail email = new EMail();
* JD-Core Version: 0.6.0 MailInfo info=new MailInfo();
*/ retValue=email.sendMail(mailDomStr, "ITM", conn);
\ No newline at end of file if("S".equalsIgnoreCase(retValue))
{
//printLog("STDOUT","ReportCreationScheduler : sendMail => Mail sent successfully" );
sentMail = true;
}
System.out.println("[Pdf] mail delivered successfully" );
}
catch (ITMException itme)
{
System.out.println("@@## ITMException [[Generic Report]] :sendMail :sendMail :sendMail() :==>\n");
throw itme;
}
catch (Exception e)
{
System.out.println("Exception :[[Generic Report]] :sendMail() :==>\n" + e.getMessage());
throw new ITMException(e);
}
return sentMail;
}
/**
* boolean method which will check whether string contains mail address or not
*/
public boolean checkEmailAddress(String emailValue){
Pattern pattern = Pattern.compile("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}");
Matcher mat = pattern.matcher(emailValue);
return mat.matches();
}
private String getDomString(String emailIdPer) throws ITMException
{
String retString = "";
StringBuffer valueXmlString = new StringBuffer();
try
{
valueXmlString.append("<ROOT>");
valueXmlString.append("<Detail1>");
valueXmlString.append("<email_id_cust>").append("<![CDATA[" + emailIdPer + "]]>").append("</email_id_cust>");
valueXmlString.append("</Detail1>");
valueXmlString.append("</ROOT>");
retString = valueXmlString.toString();
}
catch(Exception e)
{
e.printStackTrace();
printLog("ERROR", e);
}
return retString;
}
}
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