private void buildReport(int reportId) { if(checkConfigFlags() == false) return; if(checkDateInterval() == false) return; form.htmResult().setHTML(""); form.htmDownload().setHTML(""); form.htmDownload().setEnabled(false); String nlc; if(form.lblCode().getValue() == null || form.lblCode().getValue().length() == 0) nlc = "%"; else nlc = form.lblCode().getValue(); try { CDSResultVo res = domain.buildCDSReport(form.dteFrom().getValue(), form.dteTo().getValue(), nlc, reportId, engine.getSessionId(), engine.getRequestUrl()); if(Boolean.TRUE.equals(res.getSuccessful())) { if(res.getResultUrlIsNotNull()) { String url = res.getResultUrl(); int index = url.lastIndexOf('/'); if(index > -1) url = url.substring(index+1); form.htmDownload().setHTML("<b><a style=\"float: right\" href='" + res.getResultUrl() + "'><font color='blue'>" + url + "</font></a><span style=\"float: right\">Download file: </span></b>"); form.htmDownload().setEnabled(true); } form.htmResult().setHTML("<IFRAME id=\"ResultFrame123\" name=\"PostFrame\" width=\"100%\" height=\"100%\" frameborder=0 src='" + res.getLogUrl() + "'></IFRAME>"); } else { engine.showMessage(res.getErrorMessage()); } } catch (Exception e) { e.printStackTrace(); engine.showMessage(e.getMessage()); } }
private void saveErrorHistoryEntry(CDSHistoryVo histVo, CDSResultVo result) throws StaleObjectException { histVo.setErrorMessage(result.getErrorMessage()); histVo.setJobSuccessful(Boolean.FALSE); saveHistory(histVo); }
private int processCsvFile(String info, byte[] doc, String fileName, String fileNameLog, StringBuilder sbOutput, StringBuilder sbLog, MaxLine maxLine, CDSResultVo result) throws IOException { String strLine; ByteArrayInputStream fstream = new ByteArrayInputStream(doc); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); int recCount = 0; int maxl = maxLine.getMaxline(); // Read File Line By Line while ((strLine = br.readLine()) != null) { // Process current line from file if (strLine != null && strLine.trim().length() > 0) { strLine = strLine.trim(); if(!(strLine.startsWith("\"") && strLine.endsWith("\""))) { appendToFile(fileNameLog, "<br>The line below is not enclosed between double quotes ! Processing aborted."); appendToFile(fileNameLog, "<br>" + strLine); result.setErrorMessage("The input line doesn't have the correct format, see the log file. Processing aborted."); return 0; } strLine = strLine.substring(1, strLine.length() - 1); if(strLine.length() > maxl) maxl = strLine.length(); /* if(sbLog.length() > 0) sbLog.append("\r\n"); if(sbOutput.length() > 0) sbOutput.append("\r\n"); */ sbOutput.append(strLine); sbOutput.append("\r\n"); //WDEV-9893 if(maxLine.getRecords() < MAX_RECORDS_LOG) { sbLog.append("<SPAN style=\"background-color:#CCFFCC\">"); sbLog.append(strLine.replaceAll(" ", " ")); sbLog.append("</SPAN><BR>\r\n"); } recCount++; maxLine.incRecords(); if(recCount % BUFFER_LINES == 0) { appendToFile(fileNameLog, sbLog.toString()); appendToFile(fileName, sbOutput.toString()); sbLog.setLength(0); sbOutput.setLength(0); } } } if(sbLog.length() > 0) { appendToFile(fileNameLog, sbLog.toString()); sbLog.setLength(0); } if(sbOutput.length() > 0) { appendToFile(fileName, sbOutput.toString()); sbOutput.setLength(0); } maxLine.setMaxline(maxl); return recCount; }
private int processCsvFile(String info, byte[] doc, String fileName, String fileNameLog, StringBuilder sbOutput, StringBuilder sbLog, MaxLine maxLine, CDSResultVo result) throws IOException { String strLine; ByteArrayInputStream fstream = new ByteArrayInputStream(doc); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); int recCount = 0; int maxl = maxLine.getMaxline(); // Read File Line By Line while ((strLine = br.readLine()) != null) { // Process current line from file if (strLine != null && strLine.trim().length() > 0) { strLine = strLine.trim(); if(!(strLine.startsWith("\"") && strLine.endsWith("\""))) { appendToFile(fileNameLog, "<br>The line below is not enclosed between double quotes ! Processing aborted."); appendToFile(fileNameLog, "<br>" + strLine); result.setErrorMessage("The input line doesn't have the correct format, see the log file. Processing aborted."); return 0; } strLine = strLine.substring(1, strLine.length() - 1); if(strLine.length() > maxl) maxl = strLine.length(); /* if(sbLog.length() > 0) sbLog.append("\r\n"); if(sbOutput.length() > 0) sbOutput.append("\r\n"); */ sbOutput.append(strLine); sbOutput.append("\r\n"); //WDEV-9893 if(maxLine.getRecords() < MAX_RECORDS_LOG) { sbLog.append("<SPAN style=\"background-color:#CCFFCC\">"); sbLog.append(strLine.replaceAll(" ", " ").replaceAll("-", "−")); sbLog.append("</SPAN><BR>\r\n"); } recCount++; maxLine.incRecords(); if(recCount % BUFFER_LINES == 0) { appendToFile(fileNameLog, sbLog.toString()); appendToFile(fileName, sbOutput.toString()); sbLog.setLength(0); sbOutput.setLength(0); } } } if(sbLog.length() > 0) { appendToFile(fileNameLog, sbLog.toString()); sbLog.setLength(0); } if(sbOutput.length() > 0) { appendToFile(fileName, sbOutput.toString()); sbOutput.setLength(0); } maxLine.setMaxline(maxl); return recCount; }