Java tutorial
/** * <p>Description:create excel report,bridge pattern</p> * <p>Company: dhcc.com</p> * @author afunms * @project afunms * @date 2006-11-18 */ package com.afunms.report.abstraction; import java.awt.Color; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Vector; import javax.servlet.http.HttpServletRequest; import jxl.CellView; import jxl.Workbook; import jxl.format.Alignment; import jxl.format.Colour; import jxl.format.VerticalAlignment; import jxl.write.Label; import jxl.write.WritableCellFormat; import jxl.write.WritableFont; import jxl.write.WritableImage; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; import jxl.write.WriteException; import jxl.write.biff.RowsExceededException; import org.jfree.chart.ChartUtilities; import com.afunms.application.dao.DBDao; import com.afunms.application.dao.DBTypeDao; import com.afunms.application.dao.Db2spaceconfigDao; import com.afunms.application.dao.InformixspaceconfigDao; import com.afunms.application.dao.OraspaceconfigDao; import com.afunms.application.dao.SqldbconfigDao; import com.afunms.application.dao.SybspaceconfigDao; import com.afunms.application.dao.WeblogicConfigDao; import com.afunms.application.manage.IISManager; import com.afunms.application.manage.WeblogicManager; import com.afunms.application.model.DBTypeVo; import com.afunms.application.model.DBVo; import com.afunms.application.model.Db2spaceconfig; import com.afunms.application.model.IISVo; import com.afunms.application.model.Informixspaceconfig; import com.afunms.application.model.MonitorDBDTO; import com.afunms.application.model.MonitorMiddlewareDTO; import com.afunms.application.model.Oraspaceconfig; import com.afunms.application.model.Sqldbconfig; import com.afunms.application.model.SybaseVO; import com.afunms.application.model.Sybspaceconfig; import com.afunms.application.model.TablesVO; import com.afunms.application.model.WebConfig; import com.afunms.application.model.WeblogicConfig; import com.afunms.application.util.AssetHelper; import com.afunms.application.weblogicmonitor.WeblogicHeap; import com.afunms.application.weblogicmonitor.WeblogicJdbc; import com.afunms.application.weblogicmonitor.WeblogicNormal; import com.afunms.application.weblogicmonitor.WeblogicQueue; import com.afunms.application.weblogicmonitor.WeblogicServer; import com.afunms.application.weblogicmonitor.WeblogicSnmp; import com.afunms.cabinet.model.Cabinet; import com.afunms.cabinet.model.EquipmentReport; import com.afunms.cabinet.model.OperCabinet; import com.afunms.capreport.model.StatisNumer; import com.afunms.common.util.Arith; import com.afunms.common.util.CEIString; import com.afunms.common.util.ShareData; import com.afunms.common.util.SysLogger; import com.afunms.config.dao.BusinessDao; import com.afunms.config.dao.DistrictDao; import com.afunms.config.model.Business; import com.afunms.config.model.DistrictConfig; import com.afunms.config.model.Macconfig; import com.afunms.event.model.EventList; import com.afunms.event.model.NetSyslog; import com.afunms.event.model.NetSyslogEvent; import com.afunms.event.model.NetSyslogViewer; import com.afunms.initialize.ResourceCenter; import com.afunms.polling.PollingEngine; import com.afunms.polling.base.Node; import com.afunms.polling.node.IIS; import com.afunms.polling.node.Tomcat; import com.afunms.polling.node.Weblogic; import com.afunms.polling.om.Devicecollectdata; import com.afunms.polling.om.IpMac; import com.afunms.polling.om.IpRouter; import com.afunms.polling.om.Portconfig; import com.afunms.polling.om.Softwarecollectdata; import com.afunms.polling.om.Storagecollectdata; import com.afunms.portscan.model.PortConfig; import com.afunms.report.base.AbstractionReport1; import com.afunms.report.base.ImplementorReport1; import com.afunms.system.model.User; import com.afunms.temp.model.FdbNodeTemp; import com.afunms.temp.model.RouterNodeTemp; import com.afunms.topology.dao.HostNodeDao; import com.afunms.topology.dao.LinkDao; import com.afunms.topology.dao.NodeMonitorDao; import com.afunms.topology.model.HostNode; import com.afunms.topology.model.Link; import com.afunms.topology.model.MonitorNodeDTO; import com.afunms.topology.model.NetDistrictIpDetail; import com.afunms.topology.model.NodeMonitor; import com.lowagie.text.BadElementException; import com.lowagie.text.Cell; import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text.Element; import com.lowagie.text.Font; import com.lowagie.text.Image; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.Phrase; import com.lowagie.text.Table; import com.lowagie.text.pdf.BaseFont; import com.lowagie.text.pdf.PdfPCell; import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfWriter; import com.lowagie.text.rtf.RtfWriter2; public class ExcelReport1 extends AbstractionReport1 { private HttpServletRequest request; private Hashtable dataHash; public Hashtable getDataHash() { return dataHash; } public void setDataHash(Hashtable dataHash) { this.dataHash = dataHash; } public void setRequest(HttpServletRequest request) { this.request = request; } // I_MonitorIpList monitorManager=new MonitoriplistManager(); String[] chlName = { "", "", "1", "2", "1", "2", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "1", "2", "1", "2", "", "", "", "", "", "", "", "", "1", "2", "3", "" }; public ExcelReport1(ImplementorReport1 impReport) { super(impReport); } public ExcelReport1(ImplementorReport1 impReport, Hashtable hash) { super(impReport); reportHash = hash; } public void createReport() { if (impReport.getTable() == null) { fileName = null; return; } if (impReport.getColWidth().length != impReport.getTableHead().length) { SysLogger.error("colWidth[].length != tableHead[].length"); return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + "temp/dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/dhcnms_report.xls"; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); Label tmpLabel = null; tmpLabel = new Label(1, 0, impReport.getHead(), labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, impReport.getNote()); sheet.addCell(tmpLabel); int row = impReport.getTable().length; int col = impReport.getTableHead().length; for (int i = 0; i < col; i++) { Label label = new Label(i, 3, impReport.getTableHead()[i], labelFormat); sheet.addCell(label); } for (int i = 0; i < row; i++) for (int j = 0; j < col; j++) { Label label = new Label(j, i + 4, impReport.getTable()[i][j]); sheet.addCell(label); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, row + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("Error in ExcelReport.createReport()", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } public void createWordReport_hardware(String filename) { try { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Document document = new Document(PageSize.A4); RtfWriter2.getInstance(document, new FileOutputStream(filename)); fileName = filename; document.open(); BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); Font titleFont = new Font(bfChinese, 12, Font.BOLD); Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(""); title.setAlignment(Element.ALIGN_CENTER); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Table aTable = new Table(4); float[] widths = { 100f, 100f, 300f, 100f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); aTable.addCell(""); aTable.addCell(""); aTable.addCell(""); aTable.addCell(""); Vector deviceV = (Vector) reportHash.get("deviceV"); for (int m = 0; m < deviceV.size(); m++) { Devicecollectdata devicedata = (Devicecollectdata) deviceV.get(m); String name = devicedata.getName(); String type = devicedata.getType(); String status = devicedata.getStatus(); aTable.addCell(m + 1 + ""); aTable.addCell(type); aTable.addCell(name); aTable.addCell(status); } document.add(aTable); document.close(); // System.out.println("abcdefg"); } catch (Exception e) { SysLogger.error("", e); } } /** * @author sunqichang/ * @param filename * */ public void createExcelReport_hardwareNew(String filename) { WritableWorkbook wb = null; int x = 3; try { wb = Workbook.createWorkbook(new File(filename)); fileName = filename; WritableSheet sheet = wb.createSheet("", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 14, WritableFont.BOLD, false); WritableFont labelFont1 = new WritableFont(WritableFont.createFont(""), 12, WritableFont.NO_BOLD, false); WritableCellFormat labelFormatTitle = new WritableCellFormat(labelFont); labelFormatTitle.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK); labelFormatTitle.setAlignment(Alignment.CENTRE); labelFormatTitle.setVerticalAlignment(VerticalAlignment.CENTRE); labelFormatTitle.setBackground(jxl.format.Colour.GREY_25_PERCENT); labelFormatTitle.setShrinkToFit(true); WritableCellFormat labelFormat = new WritableCellFormat(labelFont1); labelFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK); labelFormat.setAlignment(Alignment.CENTRE); labelFormat.setVerticalAlignment(VerticalAlignment.CENTRE); labelFormat.setShrinkToFit(true); int diskcount = Integer.parseInt(request.getParameter("diskcount")); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); List networkList = (List) reportHash.get("networkList"); List serverList = (List) reportHash.get("serverList"); List dbList = (List) reportHash.get("dbList"); List midwareList = (List) reportHash.get("midwareList"); fileName = filename; Label tmpLabel = null; tmpLabel = new Label(0, 0, "", labelFormatTitle); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormatTitle); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormatTitle); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 8, 0); sheet.mergeCells(0, 1, 8, 1); sheet.mergeCells(0, 2, 8, 2); Iterator networkIt = null; if (networkList != null) { networkIt = networkList.iterator(); } Iterator serverIt = null; if (serverList != null) { serverIt = serverList.iterator(); } Iterator dbIt = null; if (dbList != null) { dbIt = dbList.iterator(); } Iterator midwareIt = null; if (midwareList != null) { midwareIt = midwareList.iterator(); } String[] networkTitle = { "", "", "", "", "IP", "" }; String[] serverTitle = { "", "", "", "", "IP", "", "" }; String[] dbTitle = { "", "", "", "IP" }; String[] midwareTitle = { "", "", "", "IP" }; Label cell = null; cell = new Label(0, x, networkTitle[0], labelFormatTitle); sheet.addCell(cell); cell = new Label(1, x, networkTitle[1], labelFormatTitle); sheet.addCell(cell); cell = new Label(2, x, networkTitle[2], labelFormatTitle); sheet.addCell(cell); cell = new Label(3, x, networkTitle[3], labelFormatTitle); sheet.addCell(cell); cell = new Label(5, x, networkTitle[4], labelFormatTitle); sheet.addCell(cell); cell = new Label(7, x, networkTitle[5], labelFormatTitle); sheet.addCell(cell); sheet.mergeCells(3, x, 4, x); sheet.mergeCells(5, x, 6, x); sheet.mergeCells(7, x, 8, x); x++; if (networkIt != null) { while (networkIt.hasNext()) { MonitorNodeDTO monitorNodeDTO = (MonitorNodeDTO) networkIt.next(); Label cell1 = new Label(1, x, monitorNodeDTO.getAlias(), labelFormat); Label cell2 = new Label(2, x, monitorNodeDTO.getCategory(), labelFormat); Label cell3 = new Label(3, x, monitorNodeDTO.getType(), labelFormat); Label cell4 = new Label(5, x, monitorNodeDTO.getIpAddress(), labelFormat); Label cell5 = new Label(7, x, String.valueOf(monitorNodeDTO.getEntityNumber()), labelFormat); sheet.addCell(cell1); sheet.addCell(cell2); sheet.addCell(cell3); sheet.addCell(cell4); sheet.addCell(cell5); sheet.mergeCells(3, x, 4, x); sheet.mergeCells(5, x, 6, x); sheet.mergeCells(7, x, 8, x); x++; } sheet.mergeCells(0, x - networkList.size() - 1, 0, x - 1); } cell = new Label(0, x, serverTitle[0], labelFormatTitle); sheet.addCell(cell); sheet.mergeCells(0, x, 0, x + diskcount + serverList.size()); cell = new Label(1, x, serverTitle[1], labelFormatTitle); sheet.addCell(cell); cell = new Label(2, x, serverTitle[2], labelFormatTitle); sheet.addCell(cell); cell = new Label(3, x, serverTitle[3], labelFormatTitle); sheet.addCell(cell); cell = new Label(4, x, serverTitle[4], labelFormatTitle); sheet.addCell(cell); cell = new Label(5, x, serverTitle[5], labelFormatTitle); sheet.addCell(cell); cell = new Label(7, x, serverTitle[6], labelFormatTitle); sheet.addCell(cell); sheet.mergeCells(5, x, 6, x); sheet.mergeCells(7, x, 8, x); x++; if (serverIt != null) { while (serverIt.hasNext()) { MonitorNodeDTO monitorNodeDTO = (MonitorNodeDTO) serverIt.next(); AssetHelper helper = new AssetHelper(); List<StatisNumer> diskList = helper.getAssetList(monitorNodeDTO.getIpAddress(), "Disk"); List<StatisNumer> memList = helper.getAssetList(monitorNodeDTO.getIpAddress(), "Memory"); Label cell1 = new Label(1, x, monitorNodeDTO.getAlias(), labelFormat); Label cell2 = new Label(2, x, monitorNodeDTO.getCategory(), labelFormat); Label cell3 = new Label(3, x, monitorNodeDTO.getType(), labelFormat); Label cell4 = new Label(4, x, monitorNodeDTO.getIpAddress(), labelFormat); sheet.addCell(cell1); sheet.addCell(cell2); sheet.addCell(cell3); sheet.addCell(cell4); sheet.mergeCells(1, x, 1, x + diskList.size() + 1); sheet.mergeCells(2, x, 2, x + diskList.size() + 1); sheet.mergeCells(3, x, 3, x + diskList.size() + 1); sheet.mergeCells(4, x, 4, x + diskList.size() + 1); Iterator<StatisNumer> diskIt = diskList.iterator(); int flag = 0; int b = x; int rowspan = (diskList.size() + 1) / 2; double sum = 0; while (diskIt.hasNext()) { if (flag == 0) { sheet.addCell(new Label(5, x, "", labelFormat)); sheet.addCell(new Label(6, x, "", labelFormat)); flag++; } else { StatisNumer numer = diskIt.next(); sheet.addCell(new Label(5, x, numer.getName(), labelFormat)); sheet.addCell(new Label(6, x, numer.getCurrent(), labelFormat)); sum = Arith.add(sum, Double.parseDouble(numer.getCurrent().replaceAll("[a-zA-Z]", ""))); } x++; } sheet.addCell(new Label(5, x, "", labelFormat)); sheet.addCell(new Label(6, x, Arith.round(sum, 2) + "G", labelFormat)); x++; for (int i = 0; i < memList.size(); i++) { StatisNumer numer = memList.get(i); sheet.addCell(new Label(7, b, numer.getName(), labelFormat)); sheet.addCell(new Label(8, b, numer.getCurrent(), labelFormat)); if (i == memList.size() - 1) { sheet.mergeCells(7, b, 7, diskList.size() - rowspan + b + 1); sheet.mergeCells(8, b, 8, diskList.size() - rowspan + b + 1); } else { sheet.mergeCells(7, b, 7, b + rowspan - 1); sheet.mergeCells(8, b, 8, b + rowspan - 1); } b += rowspan; } } } cell = new Label(0, x, dbTitle[0], labelFormatTitle); sheet.addCell(cell); cell = new Label(1, x, dbTitle[1], labelFormatTitle); sheet.addCell(cell); cell = new Label(3, x, dbTitle[2], labelFormatTitle); sheet.addCell(cell); cell = new Label(5, x, dbTitle[3], labelFormatTitle); sheet.addCell(cell); sheet.mergeCells(1, x, 2, x); sheet.mergeCells(3, x, 4, x); sheet.mergeCells(5, x, 8, x); x++; if (dbIt != null) { while (dbIt.hasNext()) { MonitorDBDTO monitorNodeDTO = (MonitorDBDTO) dbIt.next(); Label cell2 = new Label(1, x, monitorNodeDTO.getAlias(), labelFormat); Label cell3 = new Label(3, x, monitorNodeDTO.getDbtype(), labelFormat); Label cell4 = new Label(5, x, monitorNodeDTO.getIpAddress(), labelFormat); sheet.addCell(cell2); sheet.addCell(cell3); sheet.addCell(cell4); sheet.mergeCells(1, x, 2, x); sheet.mergeCells(3, x, 4, x); sheet.mergeCells(5, x, 8, x); x++; } sheet.mergeCells(0, x - dbList.size() - 1, 0, x - 1); } cell = new Label(0, x, midwareTitle[0], labelFormatTitle); sheet.addCell(cell); cell = new Label(1, x, midwareTitle[1], labelFormatTitle); sheet.addCell(cell); cell = new Label(3, x, midwareTitle[2], labelFormatTitle); sheet.addCell(cell); cell = new Label(5, x, midwareTitle[3], labelFormatTitle); sheet.addCell(cell); sheet.mergeCells(1, x, 2, x); sheet.mergeCells(3, x, 4, x); sheet.mergeCells(5, x, 8, x); x++; if (midwareIt != null) { while (midwareIt.hasNext()) { MonitorMiddlewareDTO monitorNodeDTO = (MonitorMiddlewareDTO) midwareIt.next(); Label cell2 = new Label(1, x, monitorNodeDTO.getAlias(), labelFormat); Label cell3 = new Label(3, x, monitorNodeDTO.getCategory(), labelFormat); Label cell4 = new Label(5, x, monitorNodeDTO.getIpAddress(), labelFormat); sheet.addCell(cell2); sheet.addCell(cell3); sheet.addCell(cell4); sheet.mergeCells(1, x, 2, x); sheet.mergeCells(3, x, 4, x); sheet.mergeCells(5, x, 8, x); x++; } sheet.mergeCells(0, x - midwareList.size() - 1, 0, x - 1); } // for (int i = 0; i < 8; i++) { // CellView cv = new CellView(); // cv.setAutosize(true); // sheet.setColumnView(i, cv); // } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) { wb.close(); } } catch (Exception e) { SysLogger.error("", e); } } } /** * @author sunqichang/ * @param filename * * @param type * pdfdoc */ public void createReport_hardwareNew(String filename, String type) { try { int diskcount = Integer.parseInt(request.getParameter("diskcount")); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); List networkList = (List) reportHash.get("networkList"); List serverList = (List) reportHash.get("serverList"); List dbList = (List) reportHash.get("dbList"); List midwareList = (List) reportHash.get("midwareList"); Document document = new Document(PageSize.A4); if ("doc".equalsIgnoreCase(type)) { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } else { PdfWriter.getInstance(document, new FileOutputStream(filename)); } BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); Font fontChineseTitle = new Font(bfChinese, 14, Font.BOLD); Font fontChineseRow = new Font(bfChinese, 12, Font.NORMAL); fileName = filename; document.open(); Paragraph title = new Paragraph("", fontChineseTitle); title.setAlignment(Element.ALIGN_CENTER); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, fontChineseTitle); context.setAlignment(Element.ALIGN_CENTER); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Iterator networkIt = null; if (networkList != null) { networkIt = networkList.iterator(); } Iterator serverIt = null; if (serverList != null) { serverIt = serverList.iterator(); } Iterator dbIt = null; if (dbList != null) { dbIt = dbList.iterator(); } Iterator midwareIt = null; if (midwareList != null) { midwareIt = midwareList.iterator(); } String[] networkTitle = { "", "", "", "", "IP", "" }; String[] serverTitle = { "", "", "", "", "IP", "", "" }; String[] dbTitle = { "", "", "", "IP" }; String[] midwareTitle = { "", "", "", "IP" }; Table table = new Table(9); table.setWidth(100); table.setAlignment(Element.ALIGN_CENTER);// table.setAutoFillEmptyCells(true); // table.setBorderWidth(1); // table.setBorderColor(new Color(0, 125, 255)); // table.setPadding(2);// table.setSpacing(0);// table.setBorder(2);// for (int i = 0; i < networkTitle.length; i++) { Cell cell = new Cell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.addElement(new Paragraph(networkTitle[i], fontChineseTitle)); if (i == 0) { cell.setRowspan(networkList.size() + 1); } if (i == 1 || i == 4 || i == 3) { cell.setColspan(2); } cell.setBackgroundColor(Color.LIGHT_GRAY); table.addCell(cell); } if (networkIt != null) { while (networkIt.hasNext()) { Cell cell1 = new Cell(); Cell cell2 = new Cell(); Cell cell3 = new Cell(); Cell cell4 = new Cell(); Cell cell5 = new Cell(); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); cell4.setVerticalAlignment(Element.ALIGN_MIDDLE); cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); MonitorNodeDTO monitorNodeDTO = (MonitorNodeDTO) networkIt.next(); cell1.addElement(new Paragraph(monitorNodeDTO.getAlias(), fontChineseRow)); cell2.addElement(new Paragraph(monitorNodeDTO.getCategory(), fontChineseRow)); cell3.addElement(new Paragraph(monitorNodeDTO.getType(), fontChineseRow)); cell4.addElement(new Paragraph(monitorNodeDTO.getIpAddress(), fontChineseRow)); cell5.addElement( new Paragraph(String.valueOf(monitorNodeDTO.getEntityNumber()), fontChineseRow)); cell1.setColspan(2); // cell2.setColspan(2); cell3.setColspan(2); cell4.setColspan(2); // cell5.setColspan(2); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); table.addCell(cell5); } } for (int i = 0; i < serverTitle.length; i++) { Cell cell = new Cell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.addElement(new Paragraph(serverTitle[i], fontChineseTitle)); if (i == 0) { cell.setRowspan(diskcount + 1 + serverList.size()); } if (i == 5 || i == 6) { cell.setColspan(2); } cell.setBackgroundColor(Color.LIGHT_GRAY); table.addCell(cell); } if (serverIt != null) { while (serverIt.hasNext()) { Cell cell1 = new Cell(); Cell cell2 = new Cell(); Cell cell3 = new Cell(); Cell cell44 = new Cell(); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); cell44.setVerticalAlignment(Element.ALIGN_MIDDLE); MonitorNodeDTO monitorNodeDTO = (MonitorNodeDTO) serverIt.next(); AssetHelper helper = new AssetHelper(); List<StatisNumer> diskList = helper.getAssetList(monitorNodeDTO.getIpAddress(), "Disk"); List<StatisNumer> memList = helper.getAssetList(monitorNodeDTO.getIpAddress(), "Memory"); cell1.addElement(new Paragraph(monitorNodeDTO.getAlias(), fontChineseRow)); cell2.addElement(new Paragraph(monitorNodeDTO.getCategory(), fontChineseRow)); cell3.addElement(new Paragraph(monitorNodeDTO.getType(), fontChineseRow)); cell44.addElement(new Paragraph(monitorNodeDTO.getIpAddress(), fontChineseRow)); cell1.setRowspan(diskList.size() + 2); cell2.setRowspan(diskList.size() + 2); cell3.setRowspan(diskList.size() + 2); cell44.setRowspan(diskList.size() + 2); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); table.addCell(cell44); Iterator<StatisNumer> diskIt = diskList.iterator(); int flag = 0; int rowspan = diskList.size() + 2; double sum = 0; while (diskIt.hasNext()) { if (flag == 0 || flag == rowspan / 2) { if (flag == 0) { Cell cellt1 = new Cell(); Cell cellt2 = new Cell(); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); cellt1.add(new Paragraph("", fontChineseRow)); cellt2.add(new Paragraph("", fontChineseRow)); table.addCell(cellt1); table.addCell(cellt2); } Iterator<StatisNumer> memIt = memList.iterator(); while (memIt.hasNext()) { StatisNumer numer = memIt.next(); if (flag == rowspan / 2) { flag++; continue; } Cell cell6 = new Cell(); Cell cell7 = new Cell(); cell6.setVerticalAlignment(Element.ALIGN_MIDDLE); cell7.setVerticalAlignment(Element.ALIGN_MIDDLE); cell6.addElement(new Paragraph(numer.getName(), fontChineseRow)); cell7.addElement(new Paragraph(numer.getCurrent(), fontChineseRow)); if (flag == 0) { cell6.setRowspan(rowspan / 2); cell7.setRowspan(rowspan / 2); table.addCell(cell6); table.addCell(cell7); break; } else { cell6.setRowspan(rowspan - rowspan / 2); cell7.setRowspan(rowspan - rowspan / 2); table.addCell(cell6); table.addCell(cell7); } } } Cell cell4 = new Cell(); Cell cell5 = new Cell(); cell4.setVerticalAlignment(Element.ALIGN_MIDDLE); cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); StatisNumer numer = diskIt.next(); cell4.addElement(new Paragraph(numer.getName(), fontChineseRow)); cell5.addElement(new Paragraph(numer.getCurrent(), fontChineseRow)); table.addCell(cell4); table.addCell(cell5); sum = Arith.add(sum, Double.parseDouble(numer.getCurrent().replaceAll("[a-zA-Z]", ""))); flag++; } Cell cell6 = new Cell(); Cell cell7 = new Cell(); cell6.setVerticalAlignment(Element.ALIGN_MIDDLE); cell7.setVerticalAlignment(Element.ALIGN_MIDDLE); cell6.addElement(new Paragraph("", fontChineseRow)); cell7.addElement(new Paragraph(Arith.round(sum, 2) + "G", fontChineseRow)); table.addCell(cell6); table.addCell(cell7); } } for (int i = 0; i < dbTitle.length; i++) { Cell cell = new Cell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.addElement(new Paragraph(dbTitle[i], fontChineseTitle)); if (i == 0) { cell.setRowspan(dbList.size() + 1); } if (i == 3) { cell.setColspan(4); } else if (i != 0) { cell.setColspan(2); } cell.setBackgroundColor(Color.LIGHT_GRAY); table.addCell(cell); } if (dbIt != null) { while (dbIt.hasNext()) { Cell cell2 = new Cell(); Cell cell3 = new Cell(); Cell cell4 = new Cell(); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); cell4.setVerticalAlignment(Element.ALIGN_MIDDLE); MonitorDBDTO monitorNodeDTO = (MonitorDBDTO) dbIt.next(); cell2.addElement(new Paragraph(monitorNodeDTO.getAlias(), fontChineseRow)); cell3.addElement(new Paragraph(monitorNodeDTO.getDbtype(), fontChineseRow)); cell4.addElement(new Paragraph(monitorNodeDTO.getIpAddress(), fontChineseRow)); cell2.setColspan(2); cell3.setColspan(2); cell4.setColspan(4); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); } } for (int i = 0; i < midwareTitle.length; i++) { Cell cell = new Cell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.addElement(new Paragraph(midwareTitle[i], fontChineseTitle)); if (i == 0) { cell.setRowspan(midwareList.size() + 1); } if (i == 3) { cell.setColspan(4); } else if (i != 0) { cell.setColspan(2); } cell.setBackgroundColor(Color.LIGHT_GRAY); table.addCell(cell); } if (midwareIt != null) { while (midwareIt.hasNext()) { Cell cell2 = new Cell(); Cell cell3 = new Cell(); Cell cell4 = new Cell(); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); cell4.setVerticalAlignment(Element.ALIGN_MIDDLE); MonitorMiddlewareDTO monitorNodeDTO = (MonitorMiddlewareDTO) midwareIt.next(); cell2.addElement(new Paragraph(monitorNodeDTO.getAlias(), fontChineseRow)); cell3.addElement(new Paragraph(monitorNodeDTO.getCategory(), fontChineseRow)); cell4.addElement(new Paragraph(monitorNodeDTO.getIpAddress(), fontChineseRow)); cell2.setColspan(2); cell3.setColspan(2); cell4.setColspan(4); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); } } document.add(table); document.close(); } catch (Exception e) { SysLogger.error("", e); } } public void createExcelReport_hardware(String filename) { WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); wb = Workbook.createWorkbook(new File(filename)); fileName = filename; WritableSheet sheet = wb.createSheet("", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); Vector deviceV = (Vector) reportHash.get("deviceV"); for (int m = 0; m < deviceV.size(); m++) { Devicecollectdata devicedata = (Devicecollectdata) deviceV.get(m); String name = devicedata.getName(); String type = devicedata.getType(); String status = devicedata.getStatus(); tmpLabel = new Label(0, 5 + m, m + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + m, type, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + m, name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + m, status, p_labelFormat); sheet.addCell(tmpLabel); } // /* * File file = new File(ResourceCenter.getInstance().getSysPath() + * "/resource/image/jfreechart/" + newip + "ConnectUtilization" + * ".png"); // sheet,0,0,5,1,,, // * allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, * file)); // allRow = allRow+7; */ wb.write(); System.out.println("this is a test2.xls"); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createPdfReport_hardware(String filename) { try { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); fileName = filename; document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph("", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Phrase("\n")); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); PdfPTable aTable = new PdfPTable(4); float[] widths = { 100f, 100f, 300f, 100f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); Vector deviceV = (Vector) reportHash.get("deviceV"); for (int m = 0; m < deviceV.size(); m++) { Devicecollectdata devicedata = (Devicecollectdata) deviceV.get(m); String name = devicedata.getName(); String type = devicedata.getType(); String status = devicedata.getStatus(); aTable.addCell(new Phrase(m + 1 + "", contextFont)); aTable.addCell(new Phrase(type, contextFont)); aTable.addCell(new Phrase(name, contextFont)); aTable.addCell(new Phrase(status, contextFont)); } /* * Image img = * Image.getInstance(ResourceCenter.getInstance().getSysPath() + * "/resource/image/jfreechart/" + newip + "ConnectUtilization" + * ".png"); * * img.setAlignment(Image.LEFT);// img.scalePercent(75); * document.add(aTable); document.add(img); */ document.add(aTable); document.close(); } catch (Exception e) { SysLogger.error("", e); } } public void createExcelReport_pingWithClose(String filename, WritableWorkbook wb, int count) { if (impReport.getTable() == null) { fileName = null; return; } try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); // System.out.println("----------------------"+hostname + "" + // count); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, Ping + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } /* * finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } */ } public void createExcelReport_ping(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, Ping + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createExcelReport_capacity(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); // sheet,0,0,5,1,,, // allRow = allRow+2; File file = null; // sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = ""; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); tmpLabel = new Label(0, 4, "CPU", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, cpu + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, cpumax, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, avgcpu, p_labelFormat); sheet.addCell(tmpLabel); int allRow = 5; // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); allRow = allRow + 6; if (Memory != null && Memory.size() > 0) { allRow = allRow + 2; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // allRow = allRow; Label label = new Label(1, allRow, "", _labelFormat); sheet.addCell(label); for (int i = 0; i < memoryItemch.length; i++) { label = new Label(i + 2, allRow, memoryItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < Memory.size(); i++) { Hashtable mhash = (Hashtable) (Memory.get(new Integer(i))); String name = (String) mhash.get("name"); allRow = allRow + 1; label = new Label(1, allRow, name); sheet.addCell(label); for (int j = 0; j < memoryItem.length; j++) { String value = ""; if (mhash.get(memoryItem[j]) != null) { value = (String) mhash.get(memoryItem[j]); } label = new Label(j + 2, allRow, value, p_labelFormat); sheet.addCell(label); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); label = new Label(memoryItem.length + 2, allRow, value, p_labelFormat); sheet.addCell(label); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); label = new Label(memoryItem.length + 3, allRow, avgvalue, p_labelFormat); sheet.addCell(label); } } // end // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); } else { allRow = allRow + 2; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // allRow = allRow; Label label = new Label(1, allRow, "", _labelFormat); sheet.addCell(label); for (int i = 0; i < memoryItemch.length; i++) { label = new Label(i + 2, allRow, memoryItemch[i], _labelFormat); sheet.addCell(label); } // String[] names = null; HostNodeDao dao = new HostNodeDao(); HostNode node = (HostNode) dao.findByCondition("ip_address", ip).get(0); // Monitoriplist monitor = monitorManager.getByIpaddress(ip); if (node.getSysOid().startsWith("1.3.6.1.4.1.311")) { names = new String[] { "PhysicalMemory", "VirtualMemory" }; } else { names = new String[] { "PhysicalMemory", "SwapMemory" }; } for (int i = 0; i < names.length; i++) { // Hashtable mhash = (Hashtable)(Memory.get(new // Integer(i))); String name = names[i]; // String[] unixs = {"PhysicalMemory","VirtualMemory"}; allRow = allRow + 1; label = new Label(1, allRow, names[i]); sheet.addCell(label); for (int j = 0; j < memoryItem.length; j++) { // String value = ""; label = new Label(j + 2, allRow, value, p_labelFormat); sheet.addCell(label); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); label = new Label(memoryItem.length + 2, allRow, value, p_labelFormat); sheet.addCell(label); } else { label = new Label(memoryItem.length + 2, allRow, value, p_labelFormat); sheet.addCell(label); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); label = new Label(memoryItem.length + 3, allRow, avgvalue, p_labelFormat); sheet.addCell(label); } else { label = new Label(memoryItem.length + 3, allRow, avgvalue, p_labelFormat); sheet.addCell(label); } } // end // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createExcelReport_disk(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); // Calendar colTime = (Calendar) reportHash.get("time"); // Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; // sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; int allRow = 4; if (Disk != null && Disk.size() > 0) { // memoryRow = Disk.size(); // allRow = allRow + 1 + 7; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // allRow = allRow; Label label = new Label(1, allRow, "", _labelFormat); // CellFormat cf = new CellFormat(); // label.setCellFormat(cf) sheet.addCell(label); for (int i = 0; i < diskItemch.length; i++) { label = new Label(i + 2, allRow, diskItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < Disk.size(); i++) { Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i))); String name = (String) diskhash.get("name"); allRow = allRow + 1; label = new Label(1, allRow, name); sheet.addCell(label); for (int j = 0; j < diskItem.length; j++) { String value = ""; if (diskhash.get(diskItem[j]) != null) { value = (String) diskhash.get(diskItem[j]); } label = new Label(j + 2, allRow, value, p_labelFormat); sheet.addCell(label); } } // end // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "disk" + ".png"); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, allRow + 2, 9, 9, file)); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /* * guzhiming ,, */ public void createReport_hostWithoutClose(String filename, WritableWorkbook wb) { if (impReport.getTable() == null) { fileName = null; return; } try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; // wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, Ping + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = ""; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); tmpLabel = new Label(0, 14, "CPU", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 15, cpu + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15, cpumax, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15, avgcpu, p_labelFormat); sheet.addCell(tmpLabel); int allRow = 15; // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); allRow = allRow + 6; if (Memory != null && Memory.size() > 0) { allRow = allRow + 2; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // allRow = allRow; Label label = new Label(1, allRow, "", _labelFormat); sheet.addCell(label); for (int i = 0; i < memoryItemch.length; i++) { label = new Label(i + 2, allRow, memoryItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < Memory.size(); i++) { Hashtable mhash = (Hashtable) (Memory.get(new Integer(i))); String name = (String) mhash.get("name"); allRow = allRow + 1; label = new Label(1, allRow, name); sheet.addCell(label); for (int j = 0; j < memoryItem.length; j++) { String value = ""; if (mhash.get(memoryItem[j]) != null) { value = (String) mhash.get(memoryItem[j]); } label = new Label(j + 2, allRow, value, p_labelFormat); sheet.addCell(label); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); label = new Label(memoryItem.length + 2, allRow, value, p_labelFormat); sheet.addCell(label); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); label = new Label(memoryItem.length + 3, allRow, avgvalue, p_labelFormat); sheet.addCell(label); } } // end // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); } else { allRow = allRow + 2; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // allRow = allRow; Label label = new Label(1, allRow, "", _labelFormat); sheet.addCell(label); for (int i = 0; i < memoryItemch.length; i++) { label = new Label(i + 2, allRow, memoryItemch[i], _labelFormat); sheet.addCell(label); } // String[] names = null; HostNodeDao dao = new HostNodeDao(); HostNode node = (HostNode) dao.findByCondition("ip_address", ip).get(0); // Monitoriplist monitor = monitorManager.getByIpaddress(ip); if (node.getSysOid().startsWith("1.3.6.1.4.1.311")) { names = new String[] { "PhysicalMemory", "VirtualMemory" }; } else { names = new String[] { "PhysicalMemory", "SwapMemory" }; } for (int i = 0; i < names.length; i++) { // Hashtable mhash = (Hashtable)(Memory.get(new // Integer(i))); String name = names[i]; // String[] unixs = {"PhysicalMemory","VirtualMemory"}; allRow = allRow + 1; label = new Label(1, allRow, names[i]); sheet.addCell(label); for (int j = 0; j < memoryItem.length; j++) { // String value = ""; label = new Label(j + 2, allRow, value, p_labelFormat); sheet.addCell(label); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); label = new Label(memoryItem.length + 2, allRow, value, p_labelFormat); sheet.addCell(label); } else { label = new Label(memoryItem.length + 2, allRow, value, p_labelFormat); sheet.addCell(label); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); label = new Label(memoryItem.length + 3, allRow, avgvalue, p_labelFormat); sheet.addCell(label); } else { label = new Label(memoryItem.length + 3, allRow, avgvalue, p_labelFormat); sheet.addCell(label); } } // end // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); } if (Disk != null && Disk.size() > 0) { // memoryRow = Disk.size(); allRow = allRow + 1 + 7; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // allRow = allRow; Label label = new Label(1, allRow, "", _labelFormat); // CellFormat cf = new CellFormat(); // label.setCellFormat(cf) sheet.addCell(label); for (int i = 0; i < diskItemch.length; i++) { label = new Label(i + 2, allRow, diskItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < Disk.size(); i++) { Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i))); String name = (String) diskhash.get("name"); allRow = allRow + 1; label = new Label(1, allRow, name); sheet.addCell(label); for (int j = 0; j < diskItem.length; j++) { String value = ""; if (diskhash.get(diskItem[j]) != null) { value = (String) diskhash.get(diskItem[j]); } label = new Label(j + 2, allRow, value, p_labelFormat); sheet.addCell(label); } } // end // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "disk" + ".png"); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, allRow + 2, 9, 9, file)); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } // wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } /* * finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } */ } public void createReport_host(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet(hostname + "", 0); createReportTitle(sheet, reportHash); createPingAndCpu(sheet, ip, reportHash); createMemory(sheet, ip, reportHash); createDisk(sheet, ip, reportHash); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { SysLogger.error("", ioe); } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } public void createReport_tomcat(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); Hashtable maxjvm = (Hashtable) reportHash.get("maxjvm"); String jvmnow = (String) reportHash.get("jvmnow"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 9, 0); sheet.mergeCells(0, 1, 9, 1); sheet.mergeCells(0, 2, 9, 2); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 4, 0, 15); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 4, 3, 4); sheet.mergeCells(4, 4, 6, 4); sheet.mergeCells(7, 4, 9, 4); tmpLabel = new Label(1, 5, Ping + "%", p_labelFormat); sheet.addCell(tmpLabel); if (maxping != null) { tmpLabel = new Label(4, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); } sheet.mergeCells(1, 5, 3, 5); sheet.mergeCells(4, 5, 6, 5); sheet.mergeCells(7, 5, 9, 5); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "TomcatPing" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 9, 10, file)); // jvm------------------- tmpLabel = new Label(0, 16, "JVM", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 16, 0, 27); tmpLabel = new Label(1, 16, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 16, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 16, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 16, 3, 16); sheet.mergeCells(4, 16, 6, 16); sheet.mergeCells(7, 16, 9, 16); tmpLabel = new Label(1, 17, jvmnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 17, (String) maxjvm.get("max_tomcat_jvm"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 17, (String) maxjvm.get("avg_tomcat_jvm"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 17, 3, 17); sheet.mergeCells(4, 17, 6, 17); sheet.mergeCells(7, 17, 9, 17); /* * tmpLabel = new Label(0, 13, "JVM", b_labelFormat); * sheet.addCell(tmpLabel); */ // File file1 = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "tomcat_jvm" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 18, 9, 10, file1)); // allRow = allRow+7; wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } /** * @author sqc * @param filename */ public void createReport_tomcatAll(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreport_has = new Hashtable(); allreport_has = reportHash; if (allreport_has != null && allreport_has.size() > 0) { Iterator keys = allreport_has.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreport_has.get(ip); reportHash = report_has; fileName = ResourceCenter.getInstance().getSysPath() + filename; String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); WritableSheet sheet = wb.createSheet(hostname + "", sheetNum); sheetNum++; Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) { CPU = new Hashtable(); } String Ping = (String) reportHash.get("Ping"); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); Hashtable maxjvm = (Hashtable) reportHash.get("maxjvm"); String jvmnow = (String) reportHash.get("jvmnow"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new // WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new // WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new // WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 9, 0); sheet.mergeCells(0, 1, 9, 1); sheet.mergeCells(0, 2, 9, 2); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 4, 0, 15); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 4, 3, 4); sheet.mergeCells(4, 4, 6, 4); sheet.mergeCells(7, 4, 9, 4); tmpLabel = new Label(1, 5, Ping + "%", p_labelFormat); sheet.addCell(tmpLabel); if (maxping != null) { tmpLabel = new Label(4, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); } sheet.mergeCells(1, 5, 3, 5); sheet.mergeCells(4, 5, 6, 5); sheet.mergeCells(7, 5, 9, 5); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "TomcatPing" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 9, 10, file)); // jvm------------------- tmpLabel = new Label(0, 16, "JVM", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 16, 0, 27); tmpLabel = new Label(1, 16, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 16, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 16, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 16, 3, 16); sheet.mergeCells(4, 16, 6, 16); sheet.mergeCells(7, 16, 9, 16); tmpLabel = new Label(1, 17, jvmnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 17, (String) maxjvm.get("max_tomcat_jvm"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 17, (String) maxjvm.get("avg_tomcat_jvm"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 17, 3, 17); sheet.mergeCells(4, 17, 6, 17); sheet.mergeCells(7, 17, 9, 17); /* * tmpLabel = new Label(0, 13, "JVM", b_labelFormat); * sheet.addCell(tmpLabel); */ // File file1 = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "tomcat_jvm" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 18, 9, 10, file1)); // allRow = allRow+7; } } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } // public void createReport_ora(String filename) // { // if(impReport.getTable()==null) // { // fileName = null; // return; // } // WritableWorkbook wb = null; // try // { // //fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // //fileName = CommonAppUtil.getAppName() + "/temp/hostnms_report.xls"; // fileName = ResourceCenter.getInstance().getSysPath() + filename; // wb = Workbook.createWorkbook(new File(fileName)); // // String hostname = (String)reportHash.get("dbname"); // String ip = (String)reportHash.get("ip"); // String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname+"",0); // String Ping = (String)reportHash.get("Ping"); // String starttime = (String)reportHash.get("starttime"); // String totime = (String)reportHash.get("totime"); // // Hashtable maxping = (Hashtable)reportHash.get("ping"); // // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // // WritableFont labelFont = new WritableFont(WritableFont.createFont(""), // 12, WritableFont.BOLD, false); // WritableCellFormat labelFormat = new WritableCellFormat (labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat (); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat (); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat (); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); // // Label tmpLabel = null; // tmpLabel = new Label(1, 0, hostname+"",labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 2, ": " + starttime+" "+totime); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 4, "",b_labelFormat); // sheet.addCell(tmpLabel); // // tmpLabel = new Label(1, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // // tmpLabel = new Label(1, 5, (String)maxping.get("pingmax"),p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 5, // (String)maxping.get("avgpingcon"),p_labelFormat); // sheet.addCell(tmpLabel); // // // // File file = new // File(ResourceCenter.getInstance().getSysPath()+"/resource/image/jfreechart/"+newip+"ConnectUtilization"+".png"); // //sheet,0,0,5,1,,, // //allRow = allRow+2; // sheet.addImage(new WritableImage(1,6,7,7,file)); // //allRow = allRow+7; // // tmpLabel = new Label(0, 14, "",b_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 14, "",b_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 14, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, 14, "MB",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(4, 14, "MB",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(5, 14, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(6, 14, "",_labelFormat); // sheet.addCell(tmpLabel); // int row = 14; // // // Vector tableinfo_v = (Vector)reportHash.get("tableinfo_v"); // for(int i=0;i<tableinfo_v.size();i++){ // Hashtable ht = (Hashtable)tableinfo_v.get(i); // String _filename = ht.get("file_name").toString(); // String tablespace = ht.get("tablespace").toString(); // String size = ht.get("size mb").toString(); // String free = ht.get("free mb").toString(); // String percent = ht.get("percent free").toString(); // String status = ht.get("status").toString(); // // row = row + (i); // tmpLabel = new Label(0, 15+i, i+1+"",p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 15+i, _filename,p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 15+i, tablespace,p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, 15+i, size,p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(4, 15+i, free,p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(5, 15+i, percent,p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(6, 15+i, status,p_labelFormat); // sheet.addCell(tmpLabel); // // } // // if(impReport.getChart()!=null){ // ByteArrayOutputStream baos = new ByteArrayOutputStream(); // try // { // ChartUtilities.writeChartAsPNG(baos, // impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); // } // catch (IOException ioe){} // WritableImage wi = new WritableImage(2,10000 + 5, 8, 12, // baos.toByteArray()); // sheet.addImage(wi); // } // wb.write(); // } // catch(Exception e) // { // //SysLogger.error("Error in ExcelReport.createReport()",e); // SysLogger.error("", e); // } // finally // { // try // { // if(wb!= null) wb.close(); // } // catch(Exception e){} // } // } public void createReport_hostcpu(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("CPU", 0); List cpulist = (List) reportHash.get("cpulist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "CPU", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 5, 0); sheet.mergeCells(0, 1, 5, 1); sheet.mergeCells(0, 2, 5, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "(%)", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "(%)", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (cpulist != null && cpulist.size() > 0) { for (int i = 0; i < cpulist.size(); i++) { p_labelFormat = super.colorChange(i); Hashtable cpuhash = (Hashtable) cpulist.get(i); String ip = (String) cpuhash.get("ipaddress"); if (cpuhash == null) cpuhash = new Hashtable(); String cpumax = ""; String avgcpu = ""; if (cpuhash.get("max") != null) { cpumax = (String) cpuhash.get("max"); } if (cpuhash.get("avgcpucon") != null) { avgcpu = (String) cpuhash.get("avgcpucon"); } HostNodeDao dao = new HostNodeDao(); HostNode node = (HostNode) dao.findByCondition("ip_address", ip).get(0); // Monitoriplist monitoriplist = // monitorManager.getByIpaddress(ip); String equname = node.getAlias(); String osname = node.getType(); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, equname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, osname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, avgcpu, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, cpumax, p_labelFormat); sheet.addCell(tmpLabel); } } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } //cpu public void createReport_hostbusytimecpu(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("CPU", 0); List cpulist = (List) reportHash.get("cpulist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "CPU", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 6, 0); sheet.mergeCells(0, 1, 6, 1); sheet.mergeCells(0, 2, 6, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "(%)", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "(%)", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "()", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (cpulist != null && cpulist.size() > 0) { for (int i = 0; i < cpulist.size(); i++) { p_labelFormat = super.colorChange(i); Hashtable cpuhash = (Hashtable) cpulist.get(i); String ip = (String) cpuhash.get("ip"); String busytime = (String) cpuhash.get("busytime"); if (cpuhash == null) cpuhash = new Hashtable(); String cpumax = ""; String avgcpu = ""; if (cpuhash.get("max") != null) { cpumax = (String) cpuhash.get("max"); } if (cpuhash.get("avgcpucon") != null) { avgcpu = (String) cpuhash.get("avgcpucon"); } HostNodeDao dao = new HostNodeDao(); HostNode node = (HostNode) dao.findByCondition("ip_address", ip).get(0); // Monitoriplist monitoriplist = // monitorManager.getByIpaddress(ip); String equname = node.getAlias(); String osname = node.getType(); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, equname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, osname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, avgcpu, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, cpumax, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, busytime, p_labelFormat); sheet.addCell(tmpLabel); } } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_hostmem(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("memlist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 9, 0); sheet.mergeCells(0, 1, 9, 1); sheet.mergeCells(0, 2, 9, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { p_labelFormat = super.colorChange(i); List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, (String) mlist.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, (String) mlist.get(4), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, (String) mlist.get(5), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5 + i, (String) mlist.get(6), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 5 + i, (String) mlist.get(7), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 5 + i, (String) mlist.get(8), p_labelFormat); sheet.addCell(tmpLabel); } } /* * if(impReport.getChart()!=null){ ByteArrayOutputStream baos = new * ByteArrayOutputStream(); try { * ChartUtilities.writeChartAsPNG(baos, * impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); } * catch (IOException ioe){} WritableImage wi = new * WritableImage(2,10000 + 5, 8, 12, baos.toByteArray()); * sheet.addImage(wi); } */ wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_hostdisk(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("disklist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 7, 0); sheet.mergeCells(0, 1, 7, 1); sheet.mergeCells(0, 2, 7, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { p_labelFormat = super.colorChange(i); List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, (String) mlist.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, (String) mlist.get(4), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, (String) mlist.get(5), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5 + i, (String) mlist.get(6), p_labelFormat); sheet.addCell(tmpLabel); } } /* * if(impReport.getChart()!=null){ ByteArrayOutputStream baos = new * ByteArrayOutputStream(); try { * ChartUtilities.writeChartAsPNG(baos, * impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); } * catch (IOException ioe){} WritableImage wi = new * WritableImage(2,10000 + 5, 8, 12, baos.toByteArray()); * sheet.addImage(wi); } */ wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_hostdiskin(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("disklist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 8, 0); sheet.mergeCells(0, 1, 8, 1); sheet.mergeCells(0, 2, 8, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { p_labelFormat = super.colorChange(i); List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, (String) mlist.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, (String) mlist.get(4), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, (String) mlist.get(5), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5 + i, (String) mlist.get(6), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 5 + i, (String) mlist.get(7), p_labelFormat); sheet.addCell(tmpLabel); } } /* * if(impReport.getChart()!=null){ ByteArrayOutputStream baos = new * ByteArrayOutputStream(); try { * ChartUtilities.writeChartAsPNG(baos, * impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); } * catch (IOException ioe){} WritableImage wi = new * WritableImage(2,10000 + 5, 8, 12, baos.toByteArray()); * sheet.addImage(wi); } */ wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_hostping(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("pinglist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 5, 0); sheet.mergeCells(0, 1, 5, 1); sheet.mergeCells(0, 2, 5, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { p_labelFormat = super.colorChange(i); List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, (String) mlist.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, (String) mlist.get(4), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, (String) mlist.get(5), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5 + i, (String) mlist.get(6) + "", p_labelFormat); sheet.addCell(tmpLabel); } row = row + memlist.size() + 2; } // String pingpath = (String) reportHash.get("pingpath"); File file = new File(pingpath); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, row, 7, 7, file)); row += 10; String responsetimepath = (String) reportHash.get("responsetimepath"); file = new File(responsetimepath); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, row, 7, 7, file)); wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } public void createReport_netping(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("pinglist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 7, 0); sheet.mergeCells(0, 1, 7, 1); sheet.mergeCells(0, 2, 7, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { p_labelFormat = super.colorChange(i); List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, (String) mlist.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, (String) mlist.get(4), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, (String) mlist.get(5), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5 + i, (String) mlist.get(6), p_labelFormat); sheet.addCell(tmpLabel); } row = row + memlist.size() + 2; } // String pingpath = (String) reportHash.get("pingpath"); File file = new File(pingpath); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, row, 7, 7, file)); // row = row + 9; String responsetimepath = (String) reportHash.get("responsetimepath"); file = new File(responsetimepath); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, row, 7, 7, file)); // String ipaddress = (String)request.getParameter("ipaddress"); // String newip = doip(ipaddress); // File file = new File(ResourceCenter.getInstance().getSysPath() // + "/resource/image/jfreechart/" + newip // + "ConnectUtilization" + ".png"); // // sheet,0,0,5,1,,, // // allRow = allRow+2; // sheet.addImage(new WritableImage(1, 6, 7, 7, file)); /* * if(impReport.getChart()!=null){ ByteArrayOutputStream baos = new * ByteArrayOutputStream(); try { * ChartUtilities.writeChartAsPNG(baos, * impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); } * catch (IOException ioe){} WritableImage wi = new * WritableImage(2,10000 + 5, 8, 12, baos.toByteArray()); * sheet.addImage(wi); } */ wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } public void createReport_tomcatping(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("TOMCAT", 0); List memlist = (List) reportHash.get("pinglist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, "TOMCAT", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) mlist.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, (String) mlist.get(4), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, (String) mlist.get(5), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, (String) mlist.get(6), p_labelFormat); sheet.addCell(tmpLabel); } } /* * if(impReport.getChart()!=null){ ByteArrayOutputStream baos = new * ByteArrayOutputStream(); try { * ChartUtilities.writeChartAsPNG(baos, * impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); } * catch (IOException ioe){} WritableImage wi = new * WritableImage(2,10000 + 5, 8, 12, baos.toByteArray()); * sheet.addImage(wi); } */ wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // public void createReport_dbping(String filename) // { // if(impReport.getTable()==null) // { // fileName = null; // return; // } // WritableWorkbook wb = null; // try // { // fileName = ResourceCenter.getInstance().getSysPath()+ filename; // wb = Workbook.createWorkbook(new File(fileName)); // // String starttime = (String)reportHash.get("starttime"); // String totime = (String)reportHash.get("totime"); // WritableSheet sheet = wb.createSheet("",0); // List memlist = (List)reportHash.get("pinglist"); // // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // // WritableFont labelFont = new WritableFont(WritableFont.createFont(""), // 12, WritableFont.BOLD, false); // WritableCellFormat labelFormat = new WritableCellFormat (labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat (); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat (); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); // // Label tmpLabel = null; // tmpLabel = new Label(1, 0, "",labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 2, ": " + starttime+" "+totime); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 4, "IP",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(4, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(5, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(6, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // //I_MonitorIpList monitorManager=new MonitoriplistManager(); // int row = 5; // if(memlist != null && memlist.size()>0){ // for(int i=0;i<memlist.size();i++){ // List mlist = (List)memlist.get(i); // row = row + (i); // tmpLabel = new Label(0, 5+i, i+1+"",p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 5+i, (String)mlist.get(0),p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 5+i, (String)mlist.get(1),p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, 5+i, (String)mlist.get(2),p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(4, 5+i, (String)mlist.get(3),p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(5, 5+i, (String)mlist.get(4),p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(6, 5+i, (String)mlist.get(5),p_labelFormat); // sheet.addCell(tmpLabel); // } // } // // /* // if(impReport.getChart()!=null){ // ByteArrayOutputStream baos = new ByteArrayOutputStream(); // try // { // ChartUtilities.writeChartAsPNG(baos, // impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); // } // catch (IOException ioe){} // WritableImage wi = new WritableImage(2,10000 + 5, 8, 12, // baos.toByteArray()); // sheet.addImage(wi); // } // */ // wb.write(); // } // catch(Exception e) // { // //SysLogger.error("Error in ExcelReport.createReport()",e); // SysLogger.error("", e); // } // finally // { // try // { // if(wb!= null) wb.close(); // } // catch(Exception e){} // } // } // public void createReport_dbevent(String filename) // { // if(impReport.getTable()==null) // { // fileName = null; // return; // } // WritableWorkbook wb = null; // try // { // fileName = ResourceCenter.getInstance().getSysPath() + filename; // wb = Workbook.createWorkbook(new File(fileName)); // // String starttime = (String)reportHash.get("starttime"); // String totime = (String)reportHash.get("totime"); // WritableSheet sheet = wb.createSheet("",0); // List memlist = (List)reportHash.get("eventlist"); // // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // // WritableFont labelFont = new WritableFont(WritableFont.createFont(""), // 12, WritableFont.BOLD, false); // WritableCellFormat labelFormat = new WritableCellFormat (labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat (); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat (); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); // // Label tmpLabel = null; // tmpLabel = new Label(1, 0, "",labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 2, ": " + starttime+" "+totime); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 4, "IP",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(4, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(5, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(6, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // //I_MonitorIpList monitorManager=new MonitoriplistManager(); // int row = 5; // if(memlist != null && memlist.size()>0){ // for(int i=0;i<memlist.size();i++){ // List mlist = (List)memlist.get(i); // row = row + (i); // tmpLabel = new Label(0, 5+i, i+1+"",p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 5+i, (String)mlist.get(0),p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 5+i, (String)mlist.get(1),p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, 5+i, (String)mlist.get(2),p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(4, 5+i, (String)mlist.get(3),p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(5, 5+i, (String)mlist.get(4),p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(6, 5+i, (String)mlist.get(5),p_labelFormat); // sheet.addCell(tmpLabel); // } // } // // // if(impReport.getChart()!=null){ // ByteArrayOutputStream baos = new ByteArrayOutputStream(); // try // { // ChartUtilities.writeChartAsPNG(baos, // impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); // } // catch (IOException ioe){} // WritableImage wi = new WritableImage(2,10000 + 5, 8, 12, // baos.toByteArray()); // sheet.addImage(wi); // } // // wb.write(); // } // catch(Exception e) // { // //SysLogger.error("Error in ExcelReport.createReport()",e); // SysLogger.error("", e); // } // finally // { // try // { // if(wb!= null) wb.close(); // } // catch(Exception e){} // } // } public void createReport_hostevent(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("eventlist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 11, 0); sheet.mergeCells(0, 1, 11, 1); sheet.mergeCells(0, 2, 11, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, 4, "CPU", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { p_labelFormat = super.colorChange(i); List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, (String) mlist.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, (String) mlist.get(4), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, (String) mlist.get(5), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5 + i, (String) mlist.get(6), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 5 + i, (String) mlist.get(7), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 5 + i, (String) mlist.get(8), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 5 + i, (String) mlist.get(9), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, 5 + i, (String) mlist.get(10), p_labelFormat); sheet.addCell(tmpLabel); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_netlocationevent(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("eventlist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, (String) mlist.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, (String) mlist.get(4), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, (String) mlist.get(5), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5 + i, (String) mlist.get(6), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 5 + i, (String) mlist.get(7), p_labelFormat); sheet.addCell(tmpLabel); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_operatorevent(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("eventlist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, (String) mlist.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, (String) mlist.get(4), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, (String) mlist.get(5), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5 + i, (String) mlist.get(6), p_labelFormat); sheet.addCell(tmpLabel); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_netevent(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("eventlist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 11, 0); sheet.mergeCells(0, 1, 11, 1); sheet.mergeCells(0, 2, 11, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 4, "CPU", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { p_labelFormat = super.colorChange(i); List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, (String) mlist.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, (String) mlist.get(4), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, (String) mlist.get(5), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5 + i, (String) mlist.get(6), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 5 + i, (String) mlist.get(7), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 5 + i, (String) mlist.get(8), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 5 + i, (String) mlist.get(9), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, 5 + i, (String) mlist.get(10), p_labelFormat); sheet.addCell(tmpLabel); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_hostall(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("equipname"); WritableSheet sheet = wb.createSheet(hostname + "", sheetNum); this.createReportTitle(sheet, report_has); this.createPingAndCpu(sheet, ip, report_has); this.createMemory(sheet, ip, report_has); this.createDisk(sheet, ip, report_has); sheetNum++; } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // public void createReport_oraall(String filename) // { // if(impReport.getTable()==null) // { // fileName = null; // return; // } // WritableWorkbook wb = null; // try // { // //fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = ResourceCenter.getInstance().getSysPath() + filename; // wb = Workbook.createWorkbook(new File(fileName)); // Hashtable allreporthash = new Hashtable(); // allreporthash = reportHash; // if (allreporthash != null && allreporthash.size()>0){ // Iterator keys=allreporthash.keySet().iterator(); // String ip=""; // int sheetNum = 0; // while(keys.hasNext()){ // ip=keys.next().toString(); // String newip=doip(ip); // Hashtable report_has = (Hashtable)allreporthash.get(ip); // String dbname = (String)report_has.get("dbname"); // WritableSheet sheet = wb.createSheet(dbname+"", sheetNum); // sheetNum = sheetNum +1; // Vector tableinfo_v = new Vector(); // if(report_has.get("tableinfo_v") != null) // tableinfo_v = (Vector)report_has.get("tableinfo_v"); // //Hashtable CPU = (Hashtable)report_has.get("CPU"); // String Ping = (String)report_has.get("Ping"); // // // //Calendar colTime = (Calendar)report_has.get("time"); // //Date cc = colTime.getTime(); // //Hashtable Memory = (Hashtable)report_has.get("Memory"); // //Hashtable Disk = (Hashtable)report_has.get("Disk"); // // //Hashtable memMaxHash = (Hashtable)report_has.get("memmaxhash"); // //Hashtable memAvgHash = (Hashtable)report_has.get("memavghash"); // Hashtable maxping = (Hashtable)report_has.get("ping"); // // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // // // // WritableFont labelFont = new WritableFont(WritableFont.createFont(""), // 12, WritableFont.BOLD, false); // WritableCellFormat labelFormat = new WritableCellFormat (labelFont); // WritableCellFormat _labelFormat = new WritableCellFormat (); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat (); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat (); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); // // Label tmpLabel = null; // tmpLabel = new Label(1, 0, dbname+"",labelFormat); // sheet.addCell(tmpLabel); // String reporttime = (String)report_has.get("reporttime"); // if (reporttime == null || reporttime.trim().length()==0){ // tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); // }else{ // tmpLabel = new Label(0, 1, ":" + reporttime); // } // // sheet.addCell(tmpLabel); // String starttime = (String)report_has.get("starttime"); // String totime = (String)report_has.get("totime"); // tmpLabel = new Label(0, 2, ": " + starttime+" "+totime); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 4, "",b_labelFormat); // sheet.addCell(tmpLabel); // // tmpLabel = new Label(2, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // // tmpLabel = new Label(1, 5, (String)maxping.get("pingmax"),p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 5, // (String)maxping.get("avgpingcon"),p_labelFormat); // sheet.addCell(tmpLabel); // File file =null; // try{ // // // file = new // File(ResourceCenter.getInstance().getSysPath()+"/resource/image/jfreechart/"+newip+"ConnectUtilization"+".png"); // //sheet,0,0,5,1,,, // //allRow = allRow+2; // sheet.addImage(new WritableImage(1,6,7,7,file)); // //allRow = allRow+7; // }catch(Exception ex){ // ex.printStackTrace(); // } // // tmpLabel = new Label(0, 14, "",b_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 14, "",b_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 14, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, 14, "MB",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(4, 14, "MB",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(5, 14, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(6, 14, "",_labelFormat); // sheet.addCell(tmpLabel); // int row = 14; // // // //Vector tableinfo_v = (Vector)reportHash.get("tableinfo_v"); // for(int i=0;i<tableinfo_v.size();i++){ // Hashtable ht = (Hashtable)tableinfo_v.get(i); // String _filename = ht.get("file_name").toString(); // String tablespace = ht.get("tablespace").toString(); // String size = ht.get("size mb").toString(); // String free = ht.get("free mb").toString(); // String percent = ht.get("percent free").toString(); // String status = ht.get("status").toString(); // // row = row + (i); // tmpLabel = new Label(0, 15+i, i+1+"",p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 15+i, _filename,p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 15+i, tablespace,p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, 15+i, size,p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(4, 15+i, free,p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(5, 15+i, percent,p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(6, 15+i, status,p_labelFormat); // sheet.addCell(tmpLabel); // // } // } // wb.write(); // } // // } // catch(Exception e) // { // //SysLogger.error("Error in ExcelReport.createReport()",e); // SysLogger.error("", e); // } // finally // { // try // { // if(wb!= null) wb.close(); // } // catch(Exception e){} // } // } public void createReport_monthhostall(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("equipname"); WritableSheet sheet = wb.createSheet(hostname + "", sheetNum); sheetNum = sheetNum + 1; Hashtable CPU = (Hashtable) report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); Calendar colTime = Calendar.getInstance(); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) report_has.get("Memory"); Hashtable Disk = (Hashtable) report_has.get("Disk"); Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) report_has.get("memavghash"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "" }; String[] memoryItem = { "Capability" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); String reporttime = (String) report_has.get("reporttime"); if (reporttime == null || reporttime.trim().length() == 0) { tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); } else { tmpLabel = new Label(0, 1, ":" + reporttime); } sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ":" + sdf.format(cc)); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ping_month" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "CPU", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", _labelFormat); sheet.addCell(tmpLabel); if (CPU == null) { tmpLabel = new Label(1, 15, "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15, "", p_labelFormat); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(1, 15, (String) CPU.get("cpumax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15, (String) CPU.get("avgcpu"), p_labelFormat); sheet.addCell(tmpLabel); } int allRow = 15; // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu_month" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); allRow = allRow + 6; int memoryRow = 0; if (Memory != null && Memory.size() > 0) { memoryRow = Memory.size(); allRow = allRow + 2; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // allRow = allRow; Label label = new Label(1, allRow, "", _labelFormat); sheet.addCell(label); for (int i = 0; i < memoryItemch.length; i++) { label = new Label(i + 2, allRow, memoryItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < Memory.size(); i++) { Hashtable mhash = (Hashtable) (Memory.get(new Integer(i))); String name = (String) mhash.get("name"); allRow = allRow + 1; label = new Label(1, allRow, name); sheet.addCell(label); for (int j = 0; j < memoryItem.length; j++) { String value = ""; if (mhash != null) { if (mhash.get(memoryItem[j]) != null) { value = (String) mhash.get(memoryItem[j]); } } label = new Label(j + 2, allRow, value, p_labelFormat); sheet.addCell(label); } String value = ""; if (memMaxHash != null) { if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); label = new Label(memoryItem.length + 2, allRow, value, p_labelFormat); sheet.addCell(label); } } else { label = new Label(memoryItem.length + 2, allRow, value, p_labelFormat); sheet.addCell(label); } String avgvalue = ""; if (memAvgHash != null) { if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); label = new Label(memoryItem.length + 3, allRow, avgvalue, p_labelFormat); sheet.addCell(label); } } else { label = new Label(memoryItem.length + 3, allRow, avgvalue, p_labelFormat); sheet.addCell(label); } } // end // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory_month" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); } if (Disk != null && Disk.size() > 0) { // memoryRow = Disk.size(); allRow = allRow + 1 + 7; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // allRow = allRow; Label label = new Label(1, allRow, "", _labelFormat); // CellFormat cf = new CellFormat(); // label.setCellFormat(cf) sheet.addCell(label); for (int i = 0; i < diskItemch.length; i++) { label = new Label(i + 2, allRow, diskItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < Disk.size(); i++) { Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i))); if (diskhash != null && diskhash.size() > 0) { String name = (String) diskhash.get("name"); if (name == null) name = ""; allRow = allRow + 1; label = new Label(1, allRow, name); sheet.addCell(label); for (int j = 0; j < diskItem.length; j++) { String value = ""; if (diskhash.get(diskItem[j]) != null) { value = (String) diskhash.get(diskItem[j]); } label = new Label(j + 2, allRow, value, p_labelFormat); sheet.addCell(label); } } } // end // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "disk" + ".png"); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, allRow + 2, 9, 9, file)); /* * if(impReport.getChart()!=null){ ByteArrayOutputStream * baos = new ByteArrayOutputStream(); try { * ChartUtilities.writeChartAsPNG(baos, * impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); } * catch (IOException ioe){} WritableImage wi = new * WritableImage(2,40, 8, 12, baos.toByteArray()); * sheet.addImage(wi); } */ } } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_weball(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String urlid = ""; int sheetNum = 0; while (keys.hasNext()) { urlid = keys.next().toString(); Hashtable report_has = (Hashtable) allreporthash.get(urlid); WritableSheet sheet = wb.createSheet((String) report_has.get("urlname") + "", sheetNum); sheetNum = sheetNum + 1; Calendar colTime = Calendar.getInstance(); Date cc = colTime.getTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, (String) report_has.get("urlname") + "", labelFormat); sheet.addCell(tmpLabel); String reporttime = (String) report_has.get("reporttime"); if (reporttime == null || reporttime.trim().length() == 0) { tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); } else { tmpLabel = new Label(0, 1, ":" + reporttime); } sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ":" + sdf.format(cc)); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 3, ":" + (String) report_has.get("urlstr")); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, "", b_labelFormat); sheet.addCell(tmpLabel); /* * tmpLabel = new Label(1, 5, "",_labelFormat); * sheet.addCell(tmpLabel); */ tmpLabel = new Label(1, 5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, "", _labelFormat); sheet.addCell(tmpLabel); /* * tmpLabel = new Label(1, 5, Ping+"%",p_labelFormat); * sheet.addCell(tmpLabel); */ tmpLabel = new Label(1, 6, (String) report_has.get("minconn"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 6, (String) report_has.get("avgconn"), p_labelFormat); sheet.addCell(tmpLabel); // "../images/jfreechart/"+conn_name+".png" File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + (String) report_has.get("wave_name") + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 7, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 15, "()", b_labelFormat); sheet.addCell(tmpLabel); /* * tmpLabel = new Label(1, 14, "",_labelFormat); * sheet.addCell(tmpLabel); */ tmpLabel = new Label(1, 15, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15, "", _labelFormat); sheet.addCell(tmpLabel); /* * if((String)report_has.get("condelay") == null){ tmpLabel = * new Label(1, 15, "%",p_labelFormat); * sheet.addCell(tmpLabel); }else{ tmpLabel = new Label(1, * 15, (String)CPU.get("condelay")+"%",p_labelFormat); * sheet.addCell(tmpLabel); } */ if ((String) report_has.get("maxcondelay") == null) { tmpLabel = new Label(1, 16, "", p_labelFormat); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(1, 16, (String) report_has.get("maxcondelay"), p_labelFormat); sheet.addCell(tmpLabel); } if ((String) report_has.get("avgcondelay") == null) { tmpLabel = new Label(2, 16, "", p_labelFormat); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(2, 16, (String) report_has.get("avgcondelay"), p_labelFormat); sheet.addCell(tmpLabel); } int allRow = 16; // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + report_has.get("delay_name") + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); allRow = allRow + 8; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + report_has.get("conn_name") + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 4, 5, file)); } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_monthweball(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String urlid = ""; int sheetNum = 0; while (keys.hasNext()) { urlid = keys.next().toString(); Hashtable report_has = (Hashtable) allreporthash.get(urlid); WritableSheet sheet = wb.createSheet((String) report_has.get("urlname") + "", sheetNum); sheetNum = sheetNum + 1; Calendar colTime = Calendar.getInstance(); Date cc = colTime.getTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, (String) report_has.get("urlname") + "", labelFormat); sheet.addCell(tmpLabel); String reporttime = (String) report_has.get("reporttime"); if (reporttime == null || reporttime.trim().length() == 0) { tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); } else { tmpLabel = new Label(0, 1, ":" + reporttime); } sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ":" + sdf.format(cc)); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 3, ":" + (String) report_has.get("urlstr")); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, "", b_labelFormat); sheet.addCell(tmpLabel); /* * tmpLabel = new Label(1, 5, "",_labelFormat); * sheet.addCell(tmpLabel); */ tmpLabel = new Label(1, 5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, "", _labelFormat); sheet.addCell(tmpLabel); /* * tmpLabel = new Label(1, 5, Ping+"%",p_labelFormat); * sheet.addCell(tmpLabel); */ tmpLabel = new Label(1, 6, (String) report_has.get("minconn"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 6, (String) report_has.get("avgconn"), p_labelFormat); sheet.addCell(tmpLabel); // "../images/jfreechart/"+conn_name+".png" File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + (String) report_has.get("wave_name") + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 7, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 15, "()", b_labelFormat); sheet.addCell(tmpLabel); /* * tmpLabel = new Label(1, 14, "",_labelFormat); * sheet.addCell(tmpLabel); */ tmpLabel = new Label(1, 15, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15, "", _labelFormat); sheet.addCell(tmpLabel); /* * if((String)report_has.get("condelay") == null){ tmpLabel = * new Label(1, 15, "%",p_labelFormat); * sheet.addCell(tmpLabel); }else{ tmpLabel = new Label(1, * 15, (String)CPU.get("condelay")+"%",p_labelFormat); * sheet.addCell(tmpLabel); } */ if ((String) report_has.get("maxcondelay") == null) { tmpLabel = new Label(1, 16, "", p_labelFormat); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(1, 16, (String) report_has.get("maxcondelay"), p_labelFormat); sheet.addCell(tmpLabel); } if ((String) report_has.get("avgcondelay") == null) { tmpLabel = new Label(2, 16, "", p_labelFormat); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(2, 16, (String) report_has.get("avgcondelay"), p_labelFormat); sheet.addCell(tmpLabel); } int allRow = 16; // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + report_has.get("delay_name") + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); allRow = allRow + 8; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + report_has.get("conn_name") + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 4, 5, file)); } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_networkWithoutClose(String filename, WritableWorkbook wb) { if (impReport.getTable() == null) { fileName = null; return; } String hostname = (String) reportHash.get("equipname"); try { fileName = ResourceCenter.getInstance().getSysPath() + filename; // wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); String Ping = (String) reportHash.get("Ping"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Vector netifVector = (Vector) reportHash.get("netifVector"); Hashtable portconfigHash = (Hashtable) reportHash.get("portconfigHash"); List reportports = (List) reportHash.get("reportports"); Vector iprouterVector = (Vector) reportHash.get("iprouterVector"); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] netIfItemch = { "", "", "", "(M)", "", "", "" }; String[] ipRouterItemch = { "", "", "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization", "INodeUsedSize", "INodeUtilization" }; String[] diskItemch = { "", "", "", "i-node", "i-node" }; String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" }; String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)", "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)", "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" }; WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ":" + sdf.format(cc)); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, Ping + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "CPU", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 15, (String) CPU.get("cpu") + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15, (String) CPU.get("cpumax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15, (String) CPU.get("avgcpu"), p_labelFormat); sheet.addCell(tmpLabel); int allRow = 15; // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); allRow = allRow + 7; if (netifVector != null && netifVector.size() > 0) { allRow = allRow + 1; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // // allRow = allRow; for (int i = 0; i < netIfItemch.length; i++) { Label label = new Label(i + 1, allRow, netIfItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < netifVector.size(); i++) { allRow = allRow + 1; String[] strs = (String[]) netifVector.get(i); String ifname = strs[1]; String index = strs[0]; for (int j = 0; j < strs.length; j++) { if (j == 1) { String linkuse = ""; if (portconfigHash != null && portconfigHash.size() > 0) { if (portconfigHash.get(ip + ":" + index) != null) linkuse = (String) portconfigHash.get(ip + ":" + index); } Label label = new Label(j + 1, allRow, strs[j], p_labelFormat); sheet.addCell(label); label = new Label(j + 2, allRow, linkuse, p_labelFormat); sheet.addCell(label); } else if (j > 1) { Label label = new Label(j + 2, allRow, strs[j], p_labelFormat); sheet.addCell(label); } else { Label label = new Label(j + 1, allRow, strs[j], p_labelFormat); sheet.addCell(label); } } // end } } if (iprouterVector != null && iprouterVector.size() > 0) { allRow = allRow + 2; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // // allRow = allRow+1; for (int i = 0; i < ipRouterItemch.length; i++) { Label label = new Label(i + 1, allRow, ipRouterItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < iprouterVector.size(); i++) { allRow = allRow + 1; IpRouter iprouter = (IpRouter) iprouterVector.get(i); Label label = new Label(1, allRow, iprouter.getIfindex(), p_labelFormat); sheet.addCell(label); label = new Label(2, allRow, iprouter.getDest(), p_labelFormat); sheet.addCell(label); label = new Label(3, allRow, iprouter.getNexthop(), p_labelFormat); sheet.addCell(label); label = new Label(4, allRow, iproutertype[Integer.parseInt(iprouter.getType().longValue() + "")], p_labelFormat); sheet.addCell(label); label = new Label(5, allRow, iprouterproto[Integer.parseInt(iprouter.getProto().longValue() + "")], p_labelFormat); sheet.addCell(label); label = new Label(6, allRow, iprouter.getMask(), p_labelFormat); sheet.addCell(label); } } allRow = allRow + 2; if (reportports != null && reportports.size() > 0) { // for (int i = 0; i < reportports.size(); i++) { // SysLogger.info(reportports.get(i).getClass()+"============================================="); com.afunms.config.model.Portconfig portconfig = (com.afunms.config.model.Portconfig) reportports .get(i); tmpLabel = new Label(0, allRow, "" + portconfig.getPortindex() + "(" + portconfig.getName() + ")", b_labelFormat); sheet.addCell(tmpLabel); if (portconfig.getLinkuse() == null) portconfig.setLinkuse(""); tmpLabel = new Label(1, allRow, ":" + portconfig.getLinkuse()); sheet.addCell(tmpLabel); // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + portconfig.getPortindex() + "ifspeed_day.png"); // sheet,0,0,5,1,,, allRow = allRow + 1; sheet.addImage(new WritableImage(1, allRow, 8, 7, file)); allRow = allRow + 8; } } /* * if ( reportports != null && reportports.size()>0){ // * for(int i =0;i<reportports.size();i++){ Portconfig portconfig = * (Portconfig)reportports.get(i); // file = new * File(CommonAppUtil.getAppName()+"/images/jfreechart/"+newip+portconfig.getPortindex()+"ifspeed_day.png"); * //sheet,0,0,5,1,,, allRow = * allRow+2; sheet.addImage(new WritableImage(1,allRow,8,7,file)); * allRow = allRow+7; } } */ if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } // wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } /* * finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } */ } /* * (non-Javadoc) * * @see com.afunms.report.base.AbstractionReport1#createReport_network(java.lang.String) */ public void createReport_network(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String runmodel = PollingEngine.getCollectwebflag(); // WritableSheet sheet = wb.createSheet("", 0); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Vector netifVector = (Vector) reportHash.get("netifVector"); Hashtable portconfigHash = (Hashtable) reportHash.get("portconfigHash"); List reportports = (List) reportHash.get("reportports"); Vector iprouterVector = (Vector) reportHash.get("iprouterVector"); String hostname = (String) reportHash.get("equipname"); String[] netIfItemch = { "", "", "", "(M)", "", "", "" }; String[] ipRouterItemch = { "", "", "", "", "", "" }; String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" }; String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)", "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)", "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" }; createReportTitle(sheet, reportHash); createPingAndCpu(sheet, ip, reportHash); Label tmpLabel = null; int allRow = 23; if (netifVector != null && netifVector.size() > 0) { allRow = allRow + 1; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, allRow, 0, allRow + netifVector.size()); // // allRow = allRow; Label label = null; label = new Label(1, allRow, netIfItemch[0], _labelFormat); sheet.addCell(label); label = new Label(2, allRow, netIfItemch[1], _labelFormat); sheet.mergeCells(2, allRow, 3, allRow); sheet.addCell(label); label = new Label(4, allRow, netIfItemch[2], _labelFormat); sheet.addCell(label); sheet.mergeCells(4, allRow, 5, allRow); label = new Label(6, allRow, netIfItemch[3], _labelFormat); sheet.addCell(label); label = new Label(7, allRow, netIfItemch[4], _labelFormat); sheet.addCell(label); label = new Label(8, allRow, netIfItemch[5], _labelFormat); sheet.addCell(label); label = new Label(9, allRow, netIfItemch[6], _labelFormat); sheet.addCell(label); // for (int i = 0; i < netifVector.size(); i++) { allRow = allRow + 1; String[] strs = (String[]) netifVector.get(i); String ifname = strs[1]; String index = strs[0]; p_labelFormat = super.colorChange(i); for (int j = 0; j < strs.length; j++) { if (j == 1) { String linkuse = ""; if (portconfigHash != null && portconfigHash.size() > 0) { if (portconfigHash.get(ip + ":" + index) != null) linkuse = (String) portconfigHash.get(ip + ":" + index); } label = new Label(j + 1, allRow, strs[j], p_labelFormat); sheet.addCell(label); sheet.mergeCells(j + 1, allRow, j + 2, allRow); label = new Label(j + 3, allRow, linkuse, p_labelFormat); sheet.addCell(label); sheet.mergeCells(j + 3, allRow, j + 3 + 1, allRow); } else if (j > 1) { label = new Label(j + 4, allRow, strs[j], p_labelFormat); sheet.addCell(label); } else { label = new Label(j + 1, allRow, strs[j], p_labelFormat); sheet.addCell(label); } } // end } } if ("0".equals(runmodel)) { if (iprouterVector != null && iprouterVector.size() > 0) { allRow = allRow + 2; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, allRow, 0, allRow + iprouterVector.size()); // // allRow = allRow+1; for (int i = 0; i < ipRouterItemch.length; i++) { Label label = new Label(i + 1, allRow, ipRouterItemch[i], _labelFormat); sheet.addCell(label); if (i == 2) { break; } } Label label = new Label(4, allRow, ipRouterItemch[3], _labelFormat); sheet.addCell(label); label = new Label(6, allRow, ipRouterItemch[4], _labelFormat); sheet.addCell(label); label = new Label(8, allRow, ipRouterItemch[5], _labelFormat); sheet.addCell(label); sheet.mergeCells(4, allRow, 5, allRow); sheet.mergeCells(6, allRow, 7, allRow); sheet.mergeCells(8, allRow, 9, allRow); // for (int i = 0; i < iprouterVector.size(); i++) { p_labelFormat = super.colorChange(i); allRow = allRow + 1; IpRouter iprouter = (IpRouter) iprouterVector.get(i); label = new Label(1, allRow, iprouter.getIfindex(), p_labelFormat); sheet.addCell(label); label = new Label(2, allRow, iprouter.getDest(), p_labelFormat); sheet.addCell(label); label = new Label(3, allRow, iprouter.getNexthop(), p_labelFormat); sheet.addCell(label); label = new Label(4, allRow, iproutertype[Integer.parseInt(iprouter.getType().longValue() + "")], p_labelFormat); sheet.addCell(label); label = new Label(6, allRow, iprouterproto[Integer.parseInt(iprouter.getProto().longValue() + "")], p_labelFormat); sheet.addCell(label); label = new Label(8, allRow, iprouter.getMask(), p_labelFormat); sheet.addCell(label); sheet.mergeCells(4, allRow, 5, allRow); sheet.mergeCells(6, allRow, 7, allRow); sheet.mergeCells(8, allRow, 9, allRow); } } } else { // // allRow = allRow+1; List routeList = (ArrayList) reportHash.get("routerList"); if (routeList != null) { allRow = allRow + 2; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, allRow, 0, allRow + routeList.size()); for (int i = 0; i < routeList.size(); i++) { allRow = allRow + 1; RouterNodeTemp iprouter = (RouterNodeTemp) routeList.get(i); Label label = new Label(1, allRow, iprouter.getIfindex(), p_labelFormat); sheet.addCell(label); label = new Label(2, allRow, iprouter.getDest(), p_labelFormat); sheet.addCell(label); label = new Label(3, allRow, iprouter.getNexthop(), p_labelFormat); sheet.addCell(label); label = new Label(4, allRow, iprouter.getType(), p_labelFormat); sheet.addCell(label); label = new Label(6, allRow, iprouter.getProto(), p_labelFormat); sheet.addCell(label); label = new Label(8, allRow, iprouter.getMask(), p_labelFormat); sheet.addCell(label); sheet.mergeCells(4, allRow, 5, allRow); sheet.mergeCells(6, allRow, 7, allRow); sheet.mergeCells(8, allRow, 9, allRow); } } } allRow = allRow + 2; if (reportports != null && reportports.size() > 0) { // for (int i = 0; i < reportports.size(); i++) { // SysLogger.info(reportports.get(i).getClass()+"============================================="); com.afunms.config.model.Portconfig portconfig = (com.afunms.config.model.Portconfig) reportports .get(i); tmpLabel = new Label(0, allRow, "" + portconfig.getPortindex() + "(" + portconfig.getName() + ")", b_labelFormat); sheet.addCell(tmpLabel); if (portconfig.getLinkuse() == null) portconfig.setLinkuse(""); tmpLabel = new Label(1, allRow, ":" + portconfig.getLinkuse()); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + portconfig.getPortindex() + "ifspeed_day.png"); // sheet,0,0,5,1,,, allRow = allRow + 1; sheet.addImage(new WritableImage(1, allRow, 8, 7, file)); allRow = allRow + 8; } } /* * if ( reportports != null && reportports.size()>0){ // * for(int i =0;i<reportports.size();i++){ Portconfig portconfig = * (Portconfig)reportports.get(i); // file = new * File(CommonAppUtil.getAppName()+"/images/jfreechart/"+newip+portconfig.getPortindex()+"ifspeed_day.png"); * //sheet,0,0,5,1,,, allRow = * allRow+2; sheet.addImage(new WritableImage(1,allRow,8,7,file)); * allRow = allRow+7; } } */ if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } public void createReport_networkall(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; CellView cv = new CellView(); cv.setAutosize(true); while (keys.hasNext()) { ip = keys.next().toString(); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("equipname"); WritableSheet sheet = wb.createSheet(hostname + "", sheetNum); // for (int i = 0; i < 8; i++) { // // // sheet.setColumnView(i, cv); // } sheetNum = sheetNum + 1; Hashtable CPU = (Hashtable) report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); String newip = doip(ip); Calendar colTime = Calendar.getInstance(); Date cc = colTime.getTime(); Vector netifVector = (Vector) report_has.get("netifVector"); int netiSize = 0; int iprouterSize = 0; if (netifVector != null) { netiSize = netifVector.size(); } Hashtable portconfigHash = (Hashtable) report_has.get("portconfigHash"); List reportports = (List) report_has.get("reportports"); Vector iprouterVector = (Vector) report_has.get("iprouterVector"); if (iprouterVector != null) { iprouterSize = iprouterVector.size(); } // Hashtable Memory = (Hashtable)report_has.get("Memory"); // Hashtable Disk = (Hashtable)report_has.get("Disk"); // String hostname = (String)report_has.get("equipname"); Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] netIfItemch = { "", "", "", "(M)", "", "", "" }; String[] ipRouterItemch = { "", "", "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization", "INodeUsedSize", "INodeUtilization" }; String[] diskItemch = { "", "", "", "i-node", "i-node" }; String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" }; String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)", "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)", "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" }; WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); labelFormat.setAlignment(Alignment.CENTRE); labelFormat.setBackground(Colour.GREY_25_PERCENT); labelFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); _labelFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // p_labelFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK); WritableCellFormat p_labelFormat1 = new WritableCellFormat(); // p_labelFormat1.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK); WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setAlignment(Alignment.CENTRE); // b_labelFormat.setVerticalAlignment(VerticalAlignment.CENTRE); b_labelFormat.setBackground(jxl.format.Colour.GREY_25_PERCENT); b_labelFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, jxl.format.Colour.BLACK); Label tmpLabel = null; tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); String reporttime = (String) report_has.get("reporttime"); if (reporttime == null || reporttime.trim().length() == 0) { tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); } else { tmpLabel = new Label(0, 1, ":" + reporttime); } sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ":" + sdf.format(cc)); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, Ping + "%", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 4, 2, 4); sheet.mergeCells(3, 4, 4, 4); sheet.mergeCells(5, 4, 7, 4); sheet.mergeCells(1, 5, 2, 5); if (maxping != null) { tmpLabel = new Label(3, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, 5, 4, 5); sheet.mergeCells(5, 5, 7, 5); } // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "CPU", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 15, (String) CPU.get("cpu") + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15, (String) CPU.get("cpumax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 15, (String) CPU.get("avgcpu"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 14, 2, 14); sheet.mergeCells(3, 14, 4, 14); sheet.mergeCells(5, 14, 7, 14); sheet.mergeCells(1, 15, 2, 15); sheet.mergeCells(3, 15, 4, 15); sheet.mergeCells(5, 15, 7, 15); int allRow = 15; // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 1; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); allRow = allRow + 7; if (netifVector != null && netifVector.size() > 0) { allRow = allRow + 1; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // // allRow = allRow; for (int i = 0; i < netIfItemch.length; i++) { Label label = new Label(i + 1, allRow, netIfItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < netifVector.size(); i++) { allRow = allRow + 1; String[] strs = (String[]) netifVector.get(i); String ifname = strs[1]; String index = strs[0]; for (int j = 0; j < strs.length; j++) { if (j == 1) { String linkuse = ""; if (portconfigHash != null && portconfigHash.size() > 0) { if (portconfigHash.get(ip + ":" + index) != null) linkuse = (String) portconfigHash.get(ip + ":" + index); } Label label = new Label(j + 1, allRow, strs[j], i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); label = new Label(j + 2, allRow, linkuse, i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); } else if (j > 1) { Label label = new Label(j + 2, allRow, strs[j], i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); } else { Label label = new Label(j + 1, allRow, strs[j], i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); } } // end } } if (iprouterVector != null && iprouterVector.size() > 0) { allRow = allRow + 2; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // // allRow = allRow+1; for (int i = 0; i < ipRouterItemch.length; i++) { Label label = new Label(i + 1, allRow, ipRouterItemch[i], _labelFormat); sheet.addCell(label); if (i == ipRouterItemch.length - 1) { Label labeledn = new Label(i + 1, allRow, ipRouterItemch[i], _labelFormat); sheet.addCell(labeledn); } sheet.mergeCells(ipRouterItemch.length, allRow, ipRouterItemch.length + 1, allRow); } // for (int i = 0; i < iprouterVector.size(); i++) { allRow = allRow + 1; IpRouter iprouter = (IpRouter) iprouterVector.get(i); Label label = new Label(1, allRow, iprouter.getIfindex(), i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); label = new Label(2, allRow, iprouter.getDest(), i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); label = new Label(3, allRow, iprouter.getNexthop(), i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); label = new Label(4, allRow, iproutertype[Integer.parseInt(iprouter.getType().longValue() + "")], i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); label = new Label(5, allRow, iprouterproto[Integer.parseInt(iprouter.getProto().longValue() + "")], i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); label = new Label(6, allRow, iprouter.getMask(), i % 2 == 0 ? p_labelFormat : p_labelFormat1); sheet.addCell(label); sheet.mergeCells(6, allRow, 7, allRow); } } allRow = allRow + 2; if (reportports != null && reportports.size() > 0) { // for (int i = 0; i < reportports.size(); i++) { com.afunms.config.model.Portconfig portconfig = (com.afunms.config.model.Portconfig) reportports .get(i); tmpLabel = new Label(0, allRow, "" + portconfig.getPortindex() + "(" + portconfig.getName() + ")", b_labelFormat); sheet.addCell(tmpLabel); if (portconfig.getLinkuse() == null) portconfig.setLinkuse(""); tmpLabel = new Label(1, allRow, ":" + portconfig.getLinkuse()); sheet.addCell(tmpLabel); // file = new File( ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + portconfig.getPortindex() + "ifspeed_day.png"); // sheet,0,0,5,1,,, allRow = allRow + 1; sheet.addImage(new WritableImage(1, allRow, 8, 7, file)); allRow = allRow + 8; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } // sheet.mergeCells(0, 0, 7, 0); sheet.mergeCells(0, 1, 7, 1); sheet.mergeCells(0, 2, 7, 2); sheet.mergeCells(0, 4, 0, 12); sheet.mergeCells(0, 14, 0, 22); sheet.mergeCells(0, 24, 0, 24 + netiSize); sheet.mergeCells(0, 24 + netiSize + 1 + 1, 0, 24 + netiSize + 1 + 1 + iprouterSize); } wb.write(); } } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_monthnetworkall(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("equipname"); WritableSheet sheet = wb.createSheet(hostname + "", sheetNum); sheetNum = sheetNum + 1; Hashtable CPU = (Hashtable) report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); String newip = doip(ip); Calendar colTime = Calendar.getInstance(); Date cc = colTime.getTime(); Vector netifVector = (Vector) report_has.get("netifVector"); Hashtable portconfigHash = (Hashtable) report_has.get("portconfigHash"); List reportports = (List) report_has.get("reportports"); Vector iprouterVector = (Vector) report_has.get("iprouterVector"); // Hashtable Memory = (Hashtable)report_has.get("Memory"); // Hashtable Disk = (Hashtable)report_has.get("Disk"); // String hostname = (String)report_has.get("equipname"); Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] netIfItemch = { "", "", "", "(M)", "", "", "" }; String[] ipRouterItemch = { "", "", "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" }; String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)", "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)", "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" }; WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); String reporttime = (String) report_has.get("reporttime"); if (reporttime == null || reporttime.trim().length() == 0) { tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); } else { tmpLabel = new Label(0, 1, ":" + reporttime); } sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ":" + sdf.format(cc)); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "CPU", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 15, (String) CPU.get("cpumax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15, (String) CPU.get("avgcpu"), p_labelFormat); sheet.addCell(tmpLabel); int allRow = 15; // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 2; sheet.addImage(new WritableImage(1, allRow, 7, 7, file)); allRow = allRow + 7; if (netifVector != null && netifVector.size() > 0) { allRow = allRow + 1; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // // allRow = allRow; for (int i = 0; i < netIfItemch.length; i++) { Label label = new Label(i + 1, allRow, netIfItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < netifVector.size(); i++) { allRow = allRow + 1; String[] strs = (String[]) netifVector.get(i); String ifname = strs[1]; String index = strs[0]; for (int j = 0; j < strs.length; j++) { if (j == 1) { String linkuse = ""; if (portconfigHash != null && portconfigHash.size() > 0) { if (portconfigHash.get(ip + ":" + index) != null) linkuse = (String) portconfigHash.get(ip + ":" + index); } Label label = new Label(j + 1, allRow, strs[j], p_labelFormat); sheet.addCell(label); label = new Label(j + 2, allRow, linkuse, p_labelFormat); sheet.addCell(label); } else if (j > 1) { Label label = new Label(j + 2, allRow, strs[j], p_labelFormat); sheet.addCell(label); } else { Label label = new Label(j + 1, allRow, strs[j], p_labelFormat); sheet.addCell(label); } } // end } } if (iprouterVector != null && iprouterVector.size() > 0) { allRow = allRow + 2; tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); // // allRow = allRow+1; for (int i = 0; i < ipRouterItemch.length; i++) { Label label = new Label(i + 1, allRow, ipRouterItemch[i], _labelFormat); sheet.addCell(label); } // for (int i = 0; i < iprouterVector.size(); i++) { allRow = allRow + 1; IpRouter iprouter = (IpRouter) iprouterVector.get(i); Label label = new Label(1, allRow, iprouter.getIfindex(), p_labelFormat); sheet.addCell(label); label = new Label(2, allRow, iprouter.getDest(), p_labelFormat); sheet.addCell(label); label = new Label(3, allRow, iprouter.getNexthop(), p_labelFormat); sheet.addCell(label); label = new Label(4, allRow, iproutertype[Integer.parseInt(iprouter.getType().longValue() + "")], p_labelFormat); sheet.addCell(label); label = new Label(5, allRow, iprouterproto[Integer.parseInt(iprouter.getProto().longValue() + "")], p_labelFormat); sheet.addCell(label); label = new Label(6, allRow, iprouter.getMask(), p_labelFormat); sheet.addCell(label); } } allRow = allRow + 2; if (reportports != null && reportports.size() > 0) { // for (int i = 0; i < reportports.size(); i++) { Portconfig portconfig = (Portconfig) reportports.get(i); tmpLabel = new Label(0, allRow, "" + portconfig.getPortindex() + "(" + portconfig.getName() + ")", b_labelFormat); sheet.addCell(tmpLabel); if (portconfig.getLinkuse() == null) portconfig.setLinkuse(""); tmpLabel = new Label(1, allRow, ":" + portconfig.getLinkuse()); sheet.addCell(tmpLabel); // file = new File( ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + portconfig.getPortindex() + "ifspeed_day.png"); // sheet,0,0,5,1,,, allRow = allRow + 1; sheet.addImage(new WritableImage(1, allRow, 8, 7, file)); allRow = allRow + 8; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // quzhi public void createReport_syball(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); String dbname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(dbname + "", sheetNum); sheetNum = sheetNum + 1; String Ping = (String) report_has.get("Ping"); // Calendar colTime = (Calendar)report_has.get("time"); // Date cc = colTime.getTime(); // Hashtable Memory = (Hashtable)report_has.get("Memory"); // Hashtable Disk = (Hashtable)report_has.get("Disk"); // Hashtable memMaxHash = // (Hashtable)report_has.get("memmaxhash"); // Hashtable memAvgHash = // (Hashtable)report_has.get("memavghash"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, dbname + "", labelFormat); sheet.addCell(tmpLabel); String reporttime = (String) report_has.get("reporttime"); if (reporttime == null || reporttime.trim().length() == 0) { tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); } else { tmpLabel = new Label(0, 1, ":" + reporttime); } sheet.addCell(tmpLabel); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); File file = null; try { // file = new File(ResourceCenter.getInstance().getSysPath() + "/images/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; } catch (Exception ex) { ex.printStackTrace(); } tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 14, "", _labelFormat); sheet.addCell(tmpLabel); int row = 14; // SybaseVO sysbaseVO = (SybaseVO) report_has.get("sysbaseVO"); if (sysbaseVO == null) sysbaseVO = new SybaseVO(); List dbsizelist = (List) sysbaseVO.getDbInfo(); if (dbsizelist != null && dbsizelist.size() > 0) { for (int i = 0; i < dbsizelist.size(); i++) { TablesVO tablesVO = (TablesVO) dbsizelist.get(i); String _dbname = tablesVO.getDb_name(); String dbsize = tablesVO.getDb_size(); String freesize = tablesVO.getDb_freesize(); String userdperc = tablesVO.getDb_usedperc(); row = row + 1; tmpLabel = new Label(0, 15 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 15 + i, _dbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15 + i, dbsize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15 + i, freesize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 15 + i, userdperc, p_labelFormat); sheet.addCell(tmpLabel); } } } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_syball2(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) report_has.get("Ping"); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); Hashtable mems = (Hashtable) report_has.get("mems");// Hashtable sysValue = (Hashtable) report_has.get("sysValue");// String typename = (String) report_has.get("typename"); String runstr = (String) report_has.get("runstr"); String grade = (String) report_has.get("grade"); String pingnow = (String) report_has.get("pingnow"); String pingmin = (String) report_has.get("pingmin"); String pingconavg = (String) report_has.get("pingconavg"); DBVo vo = (DBVo) report_has.get("vo"); Hashtable maxping = (Hashtable) report_has.get("ping"); SybaseVO sysbaseVO = (SybaseVO) report_has.get("sysbaseVO"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); // ip tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, typename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, runstr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, grade, p_labelFormat); sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 8, pingmin + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 8, pingconavg + "%", p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 9, 7, 7, file)); // allRow = allRow+7; int row = 15; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(%)", b_labelFormat); sheet.addCell(tmpLabel); row++; List dbInfo = (ArrayList) sysbaseVO.getDbInfo(); if (dbInfo != null && dbInfo.size() > 0) { for (int i = 0; i < dbInfo.size(); i++) { TablesVO tempSpace = (TablesVO) dbInfo.get(i); String db_name = (String) tempSpace.getDb_name(); String db_size = (String) tempSpace.getDb_size(); String db_freesize = (String) tempSpace.getDb_freesize(); String db_usedperc = (String) tempSpace.getDb_usedperc(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, db_size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, db_freesize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, db_usedperc, p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "(MB)", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "(MB) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "Metadata(MB)", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "(MB) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(MB) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "(%)", b_labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, sysbaseVO.getTotal_dataCache(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, sysbaseVO.getTotal_physicalMemory(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, sysbaseVO.getMetadata_cache(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysbaseVO.getProcedure_cache(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, sysbaseVO.getTotal_logicalMemory(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, sysbaseVO.getData_hitrate(), p_labelFormat); sheet.addCell(tmpLabel); row++; // Sysbase tmpLabel = new Label(0, row, "Sysbase ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List serverlist = (List) sysbaseVO.getServersInfo(); if (serverlist != null && serverlist.size() > 0) { for (int k = 0; k < serverlist.size(); k++) { TablesVO tVO = (TablesVO) serverlist.get(k); tmpLabel = new Label(0, row, (k + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tVO.getServer_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tVO.getServer_network_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tVO.getServer_class(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tVO.getServer_status(), p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // Sysbase tmpLabel = new Label(0, row, "Sysbase ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "id ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List userlist = (List) sysbaseVO.getUserInfo(); if (userlist != null && userlist.size() > 0) { for (int k = 0; k < userlist.size(); k++) { TablesVO tVO = (TablesVO) userlist.get(k); tmpLabel = new Label(0, row, (k + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tVO.getUsers_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tVO.getID_in_db(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tVO.getGroup_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tVO.getLogin_name(), p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // Sysbase tmpLabel = new Label(0, row, "Sysbase ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List devicelist = (List) sysbaseVO.getDeviceInfo(); if (devicelist != null && devicelist.size() > 0) { for (int k = 0; k < devicelist.size(); k++) { TablesVO tVO = (TablesVO) devicelist.get(k); tmpLabel = new Label(0, row, (k + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tVO.getDevice_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tVO.getDevice_physical_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tVO.getDevice_description(), p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, (String) report_has.get("downnum"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, report_has.get("count") + "", p_labelFormat); sheet.addCell(tmpLabel); // WritableCellFormat red_labelFormat = new WritableCellFormat(); WritableCellFormat orange_labelFormat = new WritableCellFormat(); WritableCellFormat yellow_labelFormat = new WritableCellFormat(); red_labelFormat.setBackground(jxl.format.Colour.RED); orange_labelFormat.setBackground(jxl.format.Colour.ORANGE); yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW); row = row + 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); row++; int index = 0; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); List list = (ArrayList) report_has.get("list"); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { index++; EventList eventlist = (EventList) list.get(i); Date cc = eventlist.getRecordtime().getTime(); Integer eventid = eventlist.getId(); String eventlocation = eventlist.getEventlocation(); String content = eventlist.getContent(); String level = String.valueOf(eventlist.getLevel1()); String status = String.valueOf(eventlist.getManagesign()); String s = status; String showlevel = null; String act = ""; if ("1".equals(level)) { showlevel = ""; } else if ("2".equals(level)) { showlevel = ""; } else { showlevel = ""; } if ("0".equals(status)) { status = ""; } if ("1".equals(status)) { status = ""; } if ("2".equals(status)) { status = ""; } String rptman = eventlist.getReportman(); String rtime1 = _sdf.format(cc); tmpLabel = new Label(0, row, String.valueOf(index), p_labelFormat); sheet.addCell(tmpLabel); if ("3".equals(level)) { tmpLabel = new Label(1, row, showlevel, red_labelFormat); sheet.addCell(tmpLabel); } else if ("2".equals(level)) { tmpLabel = new Label(1, row, showlevel, orange_labelFormat); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(1, row, showlevel, yellow_labelFormat); sheet.addCell(tmpLabel); } tmpLabel = new Label(2, row, content, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rtime1, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, rptman, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, status, p_labelFormat); sheet.addCell(tmpLabel); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_informixall(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) report_has.get("Ping"); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) report_has.get("dbValue"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.dbTitlePing(sheet, ip, report_has); int row = 18; Label tmpLabel = null; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; // ArrayList dbspaces = new ArrayList(); if (dbinfo != null) { dbspaces = (ArrayList) dbinfo.get("informixspaces");// } if (dbspaces != null) { if (dbspaces.size() > 0) { DecimalFormat df = new DecimalFormat("#.###"); for (int i = 0; i < dbspaces.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable tablesVO = (Hashtable) dbspaces.get(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, (String) tablesVO.get("dbspace"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) tablesVO.get("owner"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, (String) tablesVO.get("fname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } } row = row + 2; // Informix tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; List dbsession = (ArrayList) dbinfo.get("sessionList");// if (dbsession != null && dbsession.size() > 0) { for (int i = 0; i < dbsession.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable tablesVO = (Hashtable) dbsession.get(i); String seqscans = String.valueOf(tablesVO.get("seqscans")); if ("null".equals(seqscans)) { seqscans = ""; } String total_sorts = String.valueOf(tablesVO.get("total_sorts")); if ("null".equals(total_sorts)) { total_sorts = ""; } String dsksorts = String.valueOf(tablesVO.get("dsksorts")); if ("null".equals(dsksorts)) { dsksorts = ""; } tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, (String) tablesVO.get("username"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) tablesVO.get("hostname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tablesVO.get("access") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tablesVO.get("locksheld") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, seqscans, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, total_sorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, dsksorts, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } row = row + 2; // Informix tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; List dblock = (ArrayList) dbinfo.get("lockList");// if (dblock != null && dblock.size() > 0) { for (int i = 0; i < dblock.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable tablesVO = (Hashtable) dblock.get(i); String type = (String) tablesVO.get("type"); String desc = ""; if ("B".equals(type)) { desc = ""; } else if ("IS".equals(type)) { desc = ""; } else if ("S".equals(type)) { desc = ""; } else if ("XS".equals(type)) { desc = ""; } else if ("U".equals(type)) { desc = ""; } else if ("IX".equals(type)) { desc = ""; } else if ("SIX".equals(type)) { desc = ""; } else if ("X".equals(type)) { desc = ""; } else if ("XR".equals(type)) { desc = ""; } tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, (String) tablesVO.get("username"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, (String) tablesVO.get("hostname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, tablesVO.get("dbsname") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, tablesVO.get("tabname") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, desc, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } row = row + 2; // Informix tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "ID ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; List dblog = (ArrayList) dbinfo.get("informixlog");// if (dblog != null && dblog.size() > 0) { for (int i = 0; i < dblog.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable tablesVO = (Hashtable) dblog.get(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, String.valueOf(tablesVO.get("uniqid")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, String.valueOf(tablesVO.get("size")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, String.valueOf(tablesVO.get("used")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, String.valueOf(tablesVO.get("is_used")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, String.valueOf(tablesVO.get("is_current")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, String.valueOf(tablesVO.get("is_backed_up")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, String.valueOf(tablesVO.get("is_archived")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, String.valueOf(tablesVO.get("is_temp")), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } row = row + 2; // InformixIO tmpLabel = new Label(0, row, "IO ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; List dbio = (ArrayList) dbinfo.get("iolist");// IO if (dbio != null && dbio.size() > 0) { for (int i = 0; i < dbio.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable tablesVO = (Hashtable) dbio.get(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, String.valueOf(tablesVO.get("chunknum")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, String.valueOf(tablesVO.get("reads")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, String.valueOf(tablesVO.get("pagesread")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, String.valueOf(tablesVO.get("writes")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, String.valueOf(tablesVO.get("pageswritten")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, String.valueOf(tablesVO.get("mreads")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, String.valueOf(tablesVO.get("mpagesread")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, String.valueOf(tablesVO.get("mwrites")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, String.valueOf(tablesVO.get("mpageswritten")), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; } } row = row + 2; // this.addEventReport(sheet, report_has, row); row += 2; // this.addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { SysLogger.error("", ioe); } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * mysql xls * * @param filename */ public void createReport_mysqlall(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) report_has.get("Ping"); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); String typename = (String) report_has.get("typename"); String runstr = (String) report_has.get("runstr"); String grade = (String) report_has.get("grade"); String pingnow = (String) report_has.get("pingnow"); String pingmin = (String) report_has.get("pingmin"); String pingconavg = (String) report_has.get("pingconavg"); DBVo vo = (DBVo) report_has.get("vo"); Vector val = (Vector) report_has.get("Val"); if (val == null) { val = new Vector(); } List sessionlist = (ArrayList) report_has.get("sessionlist"); if (sessionlist == null) { sessionlist = new ArrayList(); } Hashtable tablesHash = (Hashtable) report_has.get("tablesHash"); if (tablesHash == null) { tablesHash = new Hashtable(); } Vector tableinfo_v = (Vector) report_has.get("tableinfo_v"); if (tableinfo_v == null) { tableinfo_v = new Vector(); } Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, // false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new // WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new // WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new // WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 6, 0); sheet.mergeCells(0, 1, 6, 1); sheet.mergeCells(0, 2, 6, 2); // ip tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, 4, 4, 4); sheet.mergeCells(5, 4, 6, 4); tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, typename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, runstr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5, grade, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, 5, 4, 5); sheet.mergeCells(5, 5, 6, 5); // tmpLabel = new Label(0, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 7, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 7, 1, 7); sheet.mergeCells(2, 7, 4, 7); sheet.mergeCells(5, 7, 6, 7); tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 8, pingmin + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 8, pingconavg + "%", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 8, 1, 8); sheet.mergeCells(2, 8, 4, 8); sheet.mergeCells(5, 8, 6, 8); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(0, 9, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 18, " ", b_labelFormat); sheet.mergeCells(0, 18, 6, 18); sheet.addCell(tmpLabel); int row = 19; if (val != null && val.size() > 0) { for (int i = 0; i < val.size(); i++) { Hashtable return_value = (Hashtable) val.get(i); if (return_value != null && return_value.size() > 0) { String name = return_value.get("variable_name").toString(); String value = return_value.get("value").toString(); if (name.equalsIgnoreCase("Max_used_connections")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_first")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_key")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_next")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_prev")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_rnd")) { name = "H"; } if (name.equalsIgnoreCase("Handler_read_rnd_next")) { name = ""; } if (name.equalsIgnoreCase("Open_tables")) { name = ""; } if (name.equalsIgnoreCase("Opened_tables")) { name = ""; } if (name.equalsIgnoreCase("Threads_cached")) { name = ""; } if (name.equalsIgnoreCase("Threads_connected")) { name = ""; } if (name.equalsIgnoreCase("Threads_created")) { name = ""; } if (name.equalsIgnoreCase("Threads_running")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_immediate")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_waited")) { name = ""; } if (name.equalsIgnoreCase("Key_read_requests")) { name = ""; } if (name.equalsIgnoreCase("Key_reads")) { name = ""; } if (name.equalsIgnoreCase("log_slow_queries")) { name = ""; } if (name.equalsIgnoreCase("slow_launch_time")) { name = "Slow_launch_threads"; } p_labelFormat = super.colorChange(i); tmpLabel = new Label(0, row, name, p_labelFormat); sheet.mergeCells(0, row, 4, row); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, value, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(5, row, 6, row); row++; } } } // row = row + 2; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 6, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.mergeCells(3, row, 4, row); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; if (sessionlist != null && sessionlist.size() > 0) { for (int i = 0; i < sessionlist.size(); i++) { List ipsessionlist = (List) sessionlist.get(i); if (ipsessionlist != null && ipsessionlist.size() > 0) { for (int k = 0; k < ipsessionlist.size(); k++) { String[] sessions = (String[]) ipsessionlist.get(k); if (sessions != null && sessions.length == 5) { p_labelFormat = super.colorChange(k); tmpLabel = new Label(0, row, String.valueOf(k + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, sessions[4], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, sessions[0], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sessions[1], p_labelFormat); sheet.mergeCells(3, row, 4, row); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, sessions[2], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, sessions[3], p_labelFormat); sheet.addCell(tmpLabel); row++; } } } } } // row = row + 2; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 6, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.mergeCells(1, row, 2, row); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.mergeCells(5, row, 6, row); sheet.addCell(tmpLabel); row++; String[] dbs = vo.getDbName().split(","); if (dbs != null && dbs.length > 0) { for (int i = 0; i < dbs.length; i++) { String dbStr = dbs[i]; // System.out.println(dbStr+"====="+tablesHash.size()); if (tablesHash.containsKey(dbStr)) { List tableslist = (List) tablesHash.get(dbStr); if (tableslist != null && tableslist.size() > 0) { for (int k = 0; k < tableslist.size(); k++) { String[] tables = (String[]) tableslist.get(k); if (tables != null && tables.length == 4) { p_labelFormat = super.colorChange(k); tmpLabel = new Label(0, row, String.valueOf(k + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tables[0], p_labelFormat); sheet.mergeCells(1, row, 2, row); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tables[1], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tables[2], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, tables[3], p_labelFormat); sheet.mergeCells(5, row, 6, row); sheet.addCell(tmpLabel); row++; } } } } } } // row = row + 2; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(0, row, 6, row); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.mergeCells(1, row, 3, row); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.mergeCells(4, row, 6, row); sheet.addCell(tmpLabel); row++; if (tableinfo_v != null) {// HONGLILI for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String size = ht.get("variable_name").toString(); String free = ht.get("value").toString(); if (size.equalsIgnoreCase("auto_increment_increment")) { size = ""; } if (size.equalsIgnoreCase("auto_increment_offset")) { size = "AUTO_INCREMENT"; } if (size.equalsIgnoreCase("automatic_sp_privileges")) { size = "automatic_sp_privileges"; } if (size.equalsIgnoreCase("back_log")) { size = ""; } if (size.equalsIgnoreCase("basedir")) { size = "MySQL"; } if (size.equalsIgnoreCase("binlog_cache_size")) { size = "SQL"; } if (size.equalsIgnoreCase("bulk_insert_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("character_set_client")) { size = ""; } if (size.equalsIgnoreCase("character_set_connection")) { size = ""; } if (size.equalsIgnoreCase("character_set_database")) { size = ""; } if (size.equalsIgnoreCase("character_set_filesystem")) { size = "character_set_filesystem"; } if (size.equalsIgnoreCase("character_set_results")) { size = ""; } if (size.equalsIgnoreCase("character_set_server")) { size = ""; } if (size.equalsIgnoreCase("character_set_system")) { size = ""; } if (size.equalsIgnoreCase("character_sets_dir")) { size = ""; } if (size.equalsIgnoreCase("collation_connection")) { size = ""; } if (size.equalsIgnoreCase("collation_database")) { size = ""; } if (size.equalsIgnoreCase("collation_server")) { size = ""; } if (size.equalsIgnoreCase("completion_type")) { size = ""; } if (size.equalsIgnoreCase("concurrent_insert")) { size = ""; } if (size.equalsIgnoreCase("connect_timeout")) { size = "Bad handshake"; } if (size.equalsIgnoreCase("datadir")) { size = "MySQL"; } if (size.equalsIgnoreCase("date_format")) { size = "date_format()"; } if (size.equalsIgnoreCase("datetime_format")) { size = "datetime_format()"; } if (size.equalsIgnoreCase("default_week_format")) { size = "WEEK() "; } if (size.equalsIgnoreCase("delay_key_write")) { size = "DELAY_KEY_WRITE"; } if (size.equalsIgnoreCase("delayed_insert_limit")) { size = "INSERT DELAYEDSELECT"; } if (size.equalsIgnoreCase("delayed_insert_timeout")) { size = "INSERT DELAYEDINSERT"; } if (size.equalsIgnoreCase("delayed_queue_size")) { size = "INSERT DELAYED"; } if (size.equalsIgnoreCase("div_precision_increment")) { size = "/"; } if (size.equalsIgnoreCase("engine_condition_pushdown")) { size = "NDB"; } if (size.equalsIgnoreCase("expire_logs_days")) { size = ""; } if (size.equalsIgnoreCase("flush")) { size = "flushmysqld"; } if (size.equalsIgnoreCase("flush_time")) { size = ""; } if (size.equalsIgnoreCase("ft_boolean_syntax")) { size = "IN BOOLEAN MODE"; } if (size.equalsIgnoreCase("ft_max_word_len")) { size = "FULLTEXT"; } if (size.equalsIgnoreCase("ft_min_word_len")) { size = "FULLTEXT"; } if (size.equalsIgnoreCase("ft_query_expansion_limit")) { size = "WITH QUERY EXPANSION"; } if (size.equalsIgnoreCase("ft_stopword_file")) { size = ""; } if (size.equalsIgnoreCase("group_concat_max_len")) { size = "GROUP_CONCAT()"; } if (size.equalsIgnoreCase("have_archive")) { size = "mysqldARCHIVE"; } if (size.equalsIgnoreCase("have_bdb")) { size = "mysqldBDB"; } if (size.equalsIgnoreCase("have_blackhole_engine")) { size = "mysqldBLACKHOLE"; } if (size.equalsIgnoreCase("have_compress")) { size = "zlib"; } if (size.equalsIgnoreCase("have_crypt")) { size = "crypt()"; } if (size.equalsIgnoreCase("have_csv")) { size = "mysqldARCHIVE"; } if (size.equalsIgnoreCase("have_example_engine")) { size = "mysqldEXAMPLE"; } if (size.equalsIgnoreCase("have_federated_engine")) { size = "mysqldFEDERATED"; } if (size.equalsIgnoreCase("have_geometry")) { size = ""; } if (size.equalsIgnoreCase("have_innodb")) { size = "mysqldInnoDB"; } if (size.equalsIgnoreCase("have_isam")) { size = ""; } if (size.equalsIgnoreCase("have_ndbcluster")) { size = "mysqldNDB CLUSTER"; } if (size.equalsIgnoreCase("have_openssl")) { size = "mysqld/SSL()"; } if (size.equalsIgnoreCase("have_query_cache")) { size = "mysqld"; } if (size.equalsIgnoreCase("have_raid")) { size = "mysqldRAID"; } if (size.equalsIgnoreCase("have_rtree_keys")) { size = "RTREE"; } if (size.equalsIgnoreCase("have_symlink")) { size = ""; } if (size.equalsIgnoreCase("init_connect")) { size = ""; } if (size.equalsIgnoreCase("init_file")) { size = "--init-file"; } if (size.equalsIgnoreCase("init_slave")) { size = "SQL"; } if (size.equalsIgnoreCase("innodb_additional_mem_pool_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_autoextend_increment")) { size = ""; } if (size.equalsIgnoreCase("innodb_buffer_pool_awe_mem_mb")) { size = "32WindowsAWE"; } if (size.equalsIgnoreCase("innodb_buffer_pool_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_checksums")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_commit_concurrency")) { size = "innodb_commit_concurrency"; } if (size.equalsIgnoreCase("innodb_concurrency_tickets")) { size = "innodb_concurrency_tickets"; } if (size.equalsIgnoreCase("innodb_data_file_path")) { size = ""; } if (size.equalsIgnoreCase("innodb_data_home_dir")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_doublewrite")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_fast_shutdown")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_file_io_threads")) { size = "InnoDBI/O"; } if (size.equalsIgnoreCase("innodb_file_per_table")) { size = "InnoDB.ibd"; } if (size.equalsIgnoreCase("innodb_flush_log_at_trx_commit")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_flush_method")) { size = "InnoDBfsync()"; } if (size.equalsIgnoreCase("innodb_force_recovery")) { size = ""; } if (size.equalsIgnoreCase("innodb_lock_wait_timeout")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_locks_unsafe_for_binlog")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_log_arch_dir")) { size = " "; } if (size.equalsIgnoreCase("innodb_log_archive")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_buffer_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_log_file_size")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_files_in_group")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_group_home_dir")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_max_dirty_pages_pct")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_max_purge_lag")) { size = "INSERT,UPDATEDELETE"; } if (size.equalsIgnoreCase("innodb_mirrored_log_groups")) { size = ""; } if (size.equalsIgnoreCase("innodb_open_files")) { size = "InnoDB.ibd"; } if (size.equalsIgnoreCase("innodb_support_xa")) { size = "InnoDBXA"; } if (size.equalsIgnoreCase("innodb_sync_spin_loops")) { size = "innodb_sync_spin_loops"; } if (size.equalsIgnoreCase("innodb_table_locks")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_thread_concurrency")) { size = "InnoDBInnoDB"; } if (size.equalsIgnoreCase("innodb_thread_sleep_delay")) { size = "InnoDBSHOW INNODB STATUS<datadir>/innodb_status"; } if (size.equalsIgnoreCase("interactive_timeout")) { size = ""; } if (size.equalsIgnoreCase("join_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("key_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("key_cache_age_threshold")) { size = "(sub-chain)(sub-chain)"; } if (size.equalsIgnoreCase("key_cache_block_size")) { size = ""; } if (size.equalsIgnoreCase("key_cache_division_limit")) { size = ""; } if (size.equalsIgnoreCase("language")) { size = ""; } if (size.equalsIgnoreCase("large_files_support")) { size = "mysqld"; } if (size.equalsIgnoreCase("large_page_size")) { size = "large_page_size"; } if (size.equalsIgnoreCase("large_pages")) { size = ""; } if (size.equalsIgnoreCase("license")) { size = ""; } if (size.equalsIgnoreCase("local_infile")) { size = "LOCALLOAD DATA INFILE"; } if (size.equalsIgnoreCase("log")) { size = ""; } if (size.equalsIgnoreCase("log_bin")) { size = ""; } if (size.equalsIgnoreCase("log_bin_trust_function_creators")) { size = ""; } if (size.equalsIgnoreCase("log_error")) { size = ""; } if (size.equalsIgnoreCase("log_slave_updates")) { size = ""; } if (size.equalsIgnoreCase("log_slow_queries")) { size = ""; } if (size.equalsIgnoreCase("log_warnings")) { size = ""; } if (size.equalsIgnoreCase("long_query_time")) { size = "Slow_queries"; } if (size.equalsIgnoreCase("low_priority_updates")) { size = "sqlSELECTLOCK TABLE READ"; } if (size.equalsIgnoreCase("lower_case_file_system")) { size = ""; } if (size.equalsIgnoreCase("lower_case_table_names")) { size = "1"; } if (size.equalsIgnoreCase("max_allowed_packet")) { size = "/"; } if (size.equalsIgnoreCase("max_binlog_cache_size")) { size = ""; } if (size.equalsIgnoreCase("max_binlog_size")) { size = ""; } if (size.equalsIgnoreCase("max_connect_errors")) { size = ""; } if (size.equalsIgnoreCase("max_connections")) { size = ""; } if (size.equalsIgnoreCase("max_delayed_threads")) { size = "INSERT DELAYED"; } if (size.equalsIgnoreCase("max_error_count")) { size = "SHOW ERRORSSHOW WARNINGS"; } if (size.equalsIgnoreCase("max_heap_table_size")) { size = "MEMORY (HEAP)"; } if (size.equalsIgnoreCase("max_insert_delayed_threads")) { size = "INSERT DELAYED(max_delayed_threads)"; } if (size.equalsIgnoreCase("max_join_size")) { size = "max_join_size"; } if (size.equalsIgnoreCase("max_length_for_sort_data")) { size = "filesort"; } if (size.equalsIgnoreCase("max_prepared_stmt_count")) { size = "max_prepared_stmt_count"; } if (size.equalsIgnoreCase("max_relay_log_size")) { size = ""; } if (size.equalsIgnoreCase("max_seeks_for_key")) { size = ""; } if (size.equalsIgnoreCase("max_sort_length")) { size = "BLOBTEXT"; } if (size.equalsIgnoreCase("max_sp_recursion_depth")) { size = "max_sp_recursion_depth"; } if (size.equalsIgnoreCase("max_tmp_tables")) { size = ""; } if (size.equalsIgnoreCase("max_user_connections")) { size = "MySQL"; } if (size.equalsIgnoreCase("max_write_lock_count")) { size = ""; } if (size.equalsIgnoreCase("multi_range_count")) { size = "multi_range_count"; } if (size.equalsIgnoreCase("myisam_data_pointer_size")) { size = ""; } if (size.equalsIgnoreCase("myisam_max_sort_file_size")) { size = "MyISAMMySQL"; } if (size.equalsIgnoreCase("myisam_recover_options")) { size = "myisam-recover"; } if (size.equalsIgnoreCase("myisam_repair_threads")) { size = "1Repair by sortingMyISAM"; } if (size.equalsIgnoreCase("myisam_sort_buffer_size")) { size = "REPAIR TABLECREATE INDEXALTER TABLEMyISAM"; } if (size.equalsIgnoreCase("myisam_stats_method")) { size = "MyISAMNULL"; } if (size.equalsIgnoreCase("named_pipe")) { size = ""; } if (size.equalsIgnoreCase("net_buffer_length")) { size = ""; } if (size.equalsIgnoreCase("net_read_timeout")) { size = ""; } if (size.equalsIgnoreCase("net_retry_count")) { size = ""; } if (size.equalsIgnoreCase("net_write_timeout")) { size = ""; } if (size.equalsIgnoreCase("new")) { size = "MySQL 4.04.1"; } if (size.equalsIgnoreCase("old_passwords")) { size = "MySQLpre-4.1-style"; } if (size.equalsIgnoreCase("open_files_limit")) { size = "mysqld"; } if (size.equalsIgnoreCase("optimizer_prune_level")) { size = " 0"; } if (size.equalsIgnoreCase("optimizer_search_depth")) { size = ""; } if (size.equalsIgnoreCase("pid_file")) { size = "ID (PID)"; } if (size.equalsIgnoreCase("prepared_stmt_count")) { size = "prepared_stmt_count"; } if (size.equalsIgnoreCase("port")) { size = "TCP/IP"; } if (size.equalsIgnoreCase("preload_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("protocol_version")) { size = "MySQL/"; } if (size.equalsIgnoreCase("query_alloc_block_size")) { size = ""; } if (size.equalsIgnoreCase("query_cache_limit")) { size = ""; } if (size.equalsIgnoreCase("query_cache_min_res_unit")) { size = "()"; } if (size.equalsIgnoreCase("query_cache_size")) { size = ""; } if (size.equalsIgnoreCase("query_cache_type")) { size = ""; } if (size.equalsIgnoreCase("query_cache_wlock_invalidate")) { size = "WRITE"; } if (size.equalsIgnoreCase("query_prealloc_size")) { size = ""; } if (size.equalsIgnoreCase("range_alloc_block_size")) { size = ""; } if (size.equalsIgnoreCase("read_buffer_size")) { size = "()"; } if (size.equalsIgnoreCase("read_only")) { size = "ON"; } if (size.equalsIgnoreCase("read_only")) { size = "ON"; } if (size.equalsIgnoreCase("relay_log_purge")) { size = ""; } if (size.equalsIgnoreCase("read_rnd_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("secure_auth")) { size = "--secure-authMySQL(4.1)"; } if (size.equalsIgnoreCase("shared_memory")) { size = "(Windows)"; } if (size.equalsIgnoreCase("shared_memory_base_name")) { size = "(Windows)"; } if (size.equalsIgnoreCase("server_id")) { size = ""; } if (size.equalsIgnoreCase("skip_external_locking")) { size = "mysqld"; } if (size.equalsIgnoreCase("skip_networking")) { size = "(TCP/IP)"; } if (size.equalsIgnoreCase("skip_show_database")) { size = "SHOW DATABASESSHOW DATABASES"; } if (size.equalsIgnoreCase("slave_compressed_protocol")) { size = "/"; } if (size.equalsIgnoreCase("slave_load_tmpdir")) { size = "LOAD DATA INFILE"; } if (size.equalsIgnoreCase("slave_net_timeout")) { size = "/"; } if (size.equalsIgnoreCase("slave_skip_errors")) { size = "()"; } if (size.equalsIgnoreCase("slave_transaction_retries")) { size = "SQLslave_transaction_retries"; } if (size.equalsIgnoreCase("slow_launch_time")) { size = "Slow_launch_threads"; } if (size.equalsIgnoreCase("sort_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("sql_mode")) { size = "SQL"; } if (size.equalsIgnoreCase("storage_engine")) { size = "table_typeisMySQL 5.1,storage_engine"; } if (size.equalsIgnoreCase("sync_binlog")) { size = "sync_binlog'thMySQL"; } if (size.equalsIgnoreCase("sync_frm")) { size = "1,.frm"; } if (size.equalsIgnoreCase("system_time_zone")) { size = ""; } if (size.equalsIgnoreCase("table_cache")) { size = ""; } if (size.equalsIgnoreCase("table_type")) { size = "()"; } if (size.equalsIgnoreCase("thread_cache_size")) { size = ""; } if (size.equalsIgnoreCase("thread_stack")) { size = ""; } if (size.equalsIgnoreCase("time_format")) { size = ""; } if (size.equalsIgnoreCase("time_zone")) { size = ""; } if (size.equalsIgnoreCase("tmp_table_size")) { size = "MySQLMyISAM"; } if (size.equalsIgnoreCase("tmpdir")) { size = ""; } if (size.equalsIgnoreCase("transaction_alloc_block_size")) { size = "()"; } if (size.equalsIgnoreCase("transaction_prealloc_size")) { size = "transaction_alloc_blocks"; } if (size.equalsIgnoreCase("tx_isolation")) { size = ""; } if (size.equalsIgnoreCase("updatable_views_with_limit")) { size = "LIMIT"; } if (size.equalsIgnoreCase("version")) { size = ""; } if (size.equalsIgnoreCase("version_bdb")) { size = "BDB"; } if (size.equalsIgnoreCase("version_comment")) { size = "configure--with-commentMySQL"; } if (size.equalsIgnoreCase("version_compile_machine")) { size = "MySQL"; } if (size.equalsIgnoreCase("version_compile_os")) { size = "MySQL"; } if (size.equalsIgnoreCase("wait_timeout")) { size = ""; } p_labelFormat = super.colorChange(i); tmpLabel = new Label(0, row, String.valueOf(i + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, size, p_labelFormat); sheet.mergeCells(1, row, 3, row); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, free, p_labelFormat); sheet.mergeCells(4, row, 6, row); sheet.addCell(tmpLabel); row++; } } // row = row + 2; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 6, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 2, row); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 6, row); row++; tmpLabel = new Label(0, row, (String) report_has.get("downnum"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 2, row); tmpLabel = new Label(3, row, report_has.get("count") + "", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 6, row); // // WritableCellFormat red_labelFormat = new WritableCellFormat(); WritableCellFormat orange_labelFormat = new WritableCellFormat(); WritableCellFormat yellow_labelFormat = new WritableCellFormat(); red_labelFormat.setBackground(jxl.format.Colour.RED); orange_labelFormat.setBackground(jxl.format.Colour.ORANGE); yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW); row = row + 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 6, row); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(2, row, 3, row); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, "", b_labelFormat); sheet.addCell(tmpLabel); row++; int index = 0; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); List list = (ArrayList) report_has.get("list"); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { p_labelFormat = super.colorChange(i); index++; EventList eventlist = (EventList) list.get(i); Date cc = eventlist.getRecordtime().getTime(); Integer eventid = eventlist.getId(); String eventlocation = eventlist.getEventlocation(); String content = eventlist.getContent(); String level = String.valueOf(eventlist.getLevel1()); String status = String.valueOf(eventlist.getManagesign()); String s = status; String showlevel = null; String act = ""; if ("1".equals(level)) { showlevel = ""; } else if ("2".equals(level)) { showlevel = ""; } else { showlevel = ""; } if ("0".equals(status)) { status = ""; } if ("1".equals(status)) { status = ""; } if ("2".equals(status)) { status = ""; } String rptman = eventlist.getReportman(); String rtime1 = _sdf.format(cc); tmpLabel = new Label(0, row, String.valueOf(index), p_labelFormat); sheet.addCell(tmpLabel); if ("3".equals(level)) { tmpLabel = new Label(1, row, showlevel, red_labelFormat); sheet.addCell(tmpLabel); } else if ("2".equals(level)) { tmpLabel = new Label(1, row, showlevel, orange_labelFormat); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(1, row, showlevel, yellow_labelFormat); sheet.addCell(tmpLabel); } tmpLabel = new Label(2, row, content, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(2, row, 3, row); tmpLabel = new Label(4, row, rtime1, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, rptman, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, status, p_labelFormat); sheet.addCell(tmpLabel); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_dbping(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("pinglist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 6, 0); sheet.mergeCells(0, 1, 6, 1); sheet.mergeCells(0, 2, 6, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { p_labelFormat = super.colorChange(i); List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, (String) mlist.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, (String) mlist.get(4), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, (String) mlist.get(5), p_labelFormat); sheet.addCell(tmpLabel); } row += memlist.size(); } row += 2; /* * if(impReport.getChart()!=null){ ByteArrayOutputStream baos = new * ByteArrayOutputStream(); try { * ChartUtilities.writeChartAsPNG(baos, * impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); } * catch (IOException ioe){} WritableImage wi = new * WritableImage(2,10000 + 5, 8, 12, baos.toByteArray()); * sheet.addImage(wi); } */ // String pingpath = (String) reportHash.get("pingpath"); File file = new File(pingpath); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, row, 7, 7, file)); wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_dbevent(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("eventlist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 9, 0); sheet.mergeCells(0, 1, 9, 1); sheet.mergeCells(0, 2, 9, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { p_labelFormat = super.colorChange(i); List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, (String) mlist.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, String.valueOf(mlist.get(8)), // p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, String.valueOf(mlist.get(5)), // p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5 + i, String.valueOf(mlist.get(6)), // p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 5 + i, String.valueOf(mlist.get(7)), // p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 5 + i, (String) mlist.get(4), p_labelFormat); sheet.addCell(tmpLabel); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } // jhl add // sqlserver event report public void createReport_SQLServerevent(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("eventlist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) memlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) memlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, (String) memlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, "afunms", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5, (String) memlist.get(2), p_labelFormat); sheet.addCell(tmpLabel); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // ora event report public void createReportOra_event(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("eventlist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); String ipaddress = (String) memlist.get(0); String typevo = (String) memlist.get(1); String dbname = (String) memlist.get(2); String pingvalue = memlist.get(3) + ""; tmpLabel = new Label(0, 5, 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, ipaddress, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, typevo, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, dbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, dbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5, pingvalue, p_labelFormat); sheet.addCell(tmpLabel); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // ora event report // public void createReportusa_ora(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, 6, 7, 7, file)); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // pdf public void createReportusa_oraPDF(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 11, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont1); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); PdfPTable aTable = new PdfPTable(4); float[] widths = { 220f, 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell = new PdfPCell(new Phrase((String) maxping.get("pingnow")));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new PdfPCell(new Phrase((String) maxping.get("ping"))); cell = new PdfPCell(new Phrase((String) maxping.get("pingmin")));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.MIDDLE);// img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } // doc public void createReportusa_oraDoc(String filename) throws DocumentException, IOException { try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // System.out.println("newi ========================"+newip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n" + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Table aTable = new Table(4); float[] widths = { 220f, 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(""); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(new Phrase((String) // maxping.get("pingmax"),contextFont)); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(new Phrase((String) // maxping.get("ping"),contextFont)); cell = new Cell(new Phrase((String) maxping.get("pingmin"), contextFont));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); document.add(aTable); document.add(img); document.close(); } catch (Exception e) { SysLogger.error("", e); } } // xls public void createReportusa_oraXls(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 5, (String) // maxping.get("pingmax"),p_labelFormat); tmpLabel = new Label(1, 5, (String) maxping.get("pingnow"), p_labelFormat);// HONGLI // MODIFY sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 5, (String) // maxping.get("ping"),p_labelFormat); tmpLabel = new Label(2, 5, (String) maxping.get("pingmin"), p_labelFormat);// HONGLI // MODIFY sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, 6, 7, 7, file)); wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // //jhl end // public void createReport_ora(String filename) { // if (impReport.getTable() == null) { // fileName = null; // return; // } // WritableWorkbook wb = null; // try { // // fileName = ResourceCenter.getInstance().getSysPath() + // // "temp\\dhcnms_report.xls"; // // fileName = CommonAppUtil.getAppName() + // // "/temp/hostnms_report.xls"; // fileName = ResourceCenter.getInstance().getSysPath() + filename; // wb = Workbook.createWorkbook(new File(fileName)); // // String hostname = (String) reportHash.get("dbname"); // String ip = (String) reportHash.get("ip"); // String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); // String Ping = (String) reportHash.get("Ping"); // String starttime = (String) reportHash.get("starttime"); // String totime = (String) reportHash.get("totime"); // // Hashtable maxping = (Hashtable) reportHash.get("ping"); // // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // // WritableFont labelFont = new WritableFont(WritableFont // .createFont(""), 12, WritableFont.BOLD, false); // WritableCellFormat labelFormat = new WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); // // Label tmpLabel = null; // tmpLabel = new Label(1, 0, hostname + "", labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 4, "", b_labelFormat); // sheet.addCell(tmpLabel); // // tmpLabel = new Label(1, 4, "", _labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 4, "", _labelFormat); // sheet.addCell(tmpLabel); // // tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), // p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), // p_labelFormat); // sheet.addCell(tmpLabel); // // // // File file = new File(ResourceCenter.getInstance().getSysPath() // + "/resource/image/jfreechart/" + newip // + "ConnectUtilization" + ".png"); // // sheet,0,0,5,1,,, // // allRow = allRow+2; // sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // // allRow = allRow+7; // // tmpLabel = new Label(0, 14, "", b_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 14, "", b_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 14, "", b_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, 14, "", _labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(4, 14, "MB", _labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(5, 14, "MB", _labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(6, 14, "", _labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(7, 14, "", _labelFormat); // sheet.addCell(tmpLabel); // int row = 14; // // // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // for (int i = 0; i < tableinfo_v.size(); i++) { // Hashtable ht = (Hashtable) tableinfo_v.get(i); // String _filename = ht.get("file_name").toString(); // String tablespace = ht.get("tablespace").toString(); // String size = ht.get("size_mb").toString(); // String free = ht.get("free_mb").toString(); // String percent = ht.get("percent_free").toString(); // String status = ht.get("status").toString(); // // row = row + (i); // tmpLabel = new Label(1, 15 + i, i + 1 + "", p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 15 + i, _filename, p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, 15 + i, tablespace, p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(4, 15 + i, size, p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(5, 15 + i, free, p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(6, 15 + i, percent, p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(7, 15 + i, status, p_labelFormat); // sheet.addCell(tmpLabel); // // } // // if (impReport.getChart() != null) { // ByteArrayOutputStream baos = new ByteArrayOutputStream(); // try { // ChartUtilities.writeChartAsPNG(baos, impReport.getChart() // .getChart(), impReport.getChart().getWidth(), // impReport.getChart().getHeight()); // } catch (IOException ioe) { // } // WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, // baos.toByteArray()); // sheet.addImage(wi); // } // wb.write(); // } catch (Exception e) { // // SysLogger.error("Error in ExcelReport.createReport()",e); // SysLogger.error("", e); // } finally { // try { // if (wb != null) // wb.close(); // } catch (Exception e) { // } // } // } // jhl end /** * modify HONG 2010-10-27 */ public void createReport_ora(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, (String) maxping.get("pingnow"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 14, "", _labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START1 tmpLabel = new Label(7, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 14, "", _labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END1 // HONGLI MODIFY START1 tmpLabel = new Label(11, 14, "", _labelFormat); // HONGLI MODIFY END1 sheet.addCell(tmpLabel); int row = 14; // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 row = row + (i); tmpLabel = new Label(1, 15 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15 + i, _filename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15 + i, tablespace, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 15 + i, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 15 + i, free, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 15 + i, percent, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START4 tmpLabel = new Label(7, 15 + i, pyr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 15 + i, pbr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 15 + i, pyw, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 15 + i, pbw, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END4 tmpLabel = new Label(11, 15 + i, status, p_labelFormat); sheet.addCell(tmpLabel); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_db2(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String servername = (String) reportHash.get("servername"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); Hashtable returnhash = (Hashtable) reportHash.get("returnhash"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; // Hashtable returnhash = (Hashtable)reportHash.get("db2space"); Enumeration dbs = returnhash.keys(); // List retList = new ArrayList(); int row = 15; int num = 0; List retList = new ArrayList(); while (dbs.hasMoreElements()) { String obj = (String) dbs.nextElement(); retList = (List) returnhash.get(obj); // row = row; tmpLabel = new Label(0, row - 1, "DB2:" + obj + "(" + "IP:" + ip + ")", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(%)", _labelFormat); sheet.addCell(tmpLabel); // String obj = (String)dbs.nextElement(); // retList = (List)returnhash.get(obj); Hashtable tableinfo_v = (Hashtable) reportHash.get("tableinfo_v"); String[] dbs1 = servername.split(","); /* * for(int i=0;i<tableinfo_v.size();i++){ List list= * (List)tableinfo_v.get(dbs1[i]); for(int k=0;k<list.size();k++){ * * row = row+1; Hashtable ht = (Hashtable)list.get(k); if(ht == * null)continue; String spacename = ""; if * (ht.get("tablespace_name")!=null)spacename=ht.get("tablespace_name").toString(); * String size = ""; * if(ht.get("totalspac")!=null)size=ht.get("totalspac").toString(); * String free = ""; * if(ht.get("usablespac")!=null)free=ht.get("usablespac").toString(); * String percent = ""; if(ht.get("usableper")!= * null)percent=ht.get("usableper").toString(); */ for (int i = 0; i < retList.size(); i++) { row = row + 1; Hashtable ht = (Hashtable) retList.get(i); if (ht == null) continue; String spacename = ""; if (ht.get("tablespace_name") != null) spacename = ht.get("tablespace_name").toString(); String size = ""; if (ht.get("totalspac") != null) size = ht.get("totalspac").toString(); String free = ""; if (ht.get("usablespac") != null) free = ht.get("usablespac").toString(); String percent = ""; if (ht.get("usableper") != null) percent = ht.get("usableper").toString(); // row = row + (i); tmpLabel = new Label(0, row, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, spacename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, free, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, percent, p_labelFormat); sheet.addCell(tmpLabel); } row = row + 2; } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // public void createReport_sql(String filename) // { // if(impReport.getTable()==null) // { // fileName = null; // return; // } // WritableWorkbook wb = null; // try // { // //fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // //fileName = CommonAppUtil.getAppName() + "/temp/hostnms_report.xls"; // fileName = ResourceCenter.getInstance().getSysPath() + filename; // wb = Workbook.createWorkbook(new File(fileName)); // // String hostname = (String)reportHash.get("dbname"); // String ip = (String)reportHash.get("ip"); // String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname+"",0); // String Ping = (String)reportHash.get("Ping"); // String starttime = (String)reportHash.get("starttime"); // String totime = (String)reportHash.get("totime"); // // Hashtable maxping = (Hashtable)reportHash.get("ping"); // // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // // WritableFont labelFont = new WritableFont(WritableFont.createFont(""), // 12, WritableFont.BOLD, false); // WritableCellFormat labelFormat = new WritableCellFormat (labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat (); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat (); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat (); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); // // Label tmpLabel = null; // tmpLabel = new Label(1, 0, hostname+"",labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 2, ": " + starttime+" "+totime); // sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 4, "",b_labelFormat); // sheet.addCell(tmpLabel); // // tmpLabel = new Label(1, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 4, "",_labelFormat); // sheet.addCell(tmpLabel); // // tmpLabel = new Label(1, 5, (String)maxping.get("pingmax"),p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 5, // (String)maxping.get("avgpingcon"),p_labelFormat); // sheet.addCell(tmpLabel); // // // // File file = new // File(ResourceCenter.getInstance().getSysPath()+"/images/jfreechart/"+newip+"ConnectUtilization"+".png"); // //sheet,0,0,5,1,,, // //allRow = allRow+2; // sheet.addImage(new WritableImage(1,6,7,7,file)); // //allRow = allRow+7; // // tmpLabel = new Label(0, 14, "",b_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 14, "",b_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 14, "MB",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, 14, "MB",_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(4, 14, "",_labelFormat); // sheet.addCell(tmpLabel); // // int row = 14; // // // Hashtable dbValue = (Hashtable)reportHash.get("tableinfo_v"); // Hashtable alldatabase = new Hashtable(); // if(dbValue.get("database") != null) // alldatabase = (Hashtable)dbValue.get("database"); // Vector names = new Vector(); // if(dbValue.get("names") != null) // names = (Vector)dbValue.get("names"); // // if(alldatabase != null && alldatabase.size()>0){ // if (names == null) names = new Vector(); // for(int i=0;i<names.size();i++){ // String key = (String)names.get(i); // if(alldatabase.get(key) == null)continue; // Hashtable data=(Hashtable)alldatabase.get(key); // String dbname = data.get("dbname").toString(); // String size = data.get("size").toString(); // String usedsize = ""; // if (data.get("usedsize") != null){ // usedsize= data.get("usedsize").toString(); // } // String usedperc = ""; // if(data.get("usedperc")!=null) // usedperc= data.get("usedperc").toString(); // row = row + 1; // tmpLabel = new Label(0, row, i+1+"",p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(1, row, dbname,p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, row, size,p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, row, usedsize,p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(4, row, usedperc,p_labelFormat); // sheet.addCell(tmpLabel); // } // } // // if(impReport.getChart()!=null){ // ByteArrayOutputStream baos = new ByteArrayOutputStream(); // try // { // ChartUtilities.writeChartAsPNG(baos, // impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); // } // catch (IOException ioe){} // WritableImage wi = new WritableImage(2,10000 + 5, 8, 12, // baos.toByteArray()); // sheet.addImage(wi); // } // wb.write(); // } // catch(Exception e) // { // //SysLogger.error("Error in ExcelReport.createReport()",e); // SysLogger.error("", e); // } // finally // { // try // { // if(wb!= null) wb.close(); // } // catch(Exception e){} // } // } public void createReport_syb(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "", _labelFormat); sheet.addCell(tmpLabel); int row = 14; // SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); if (sysbaseVO == null) sysbaseVO = new SybaseVO(); List dbsizelist = (List) sysbaseVO.getDbInfo(); if (dbsizelist != null && dbsizelist.size() > 0) { for (int i = 0; i < dbsizelist.size(); i++) { TablesVO tablesVO = (TablesVO) dbsizelist.get(i); String dbname = tablesVO.getDb_name(); String dbsize = tablesVO.getDb_size(); String freesize = tablesVO.getDb_freesize(); String userdperc = tablesVO.getDb_usedperc(); row = row + 1; tmpLabel = new Label(0, 15 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 15 + i, dbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15 + i, dbsize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15 + i, freesize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 15 + i, userdperc, p_labelFormat); sheet.addCell(tmpLabel); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_oraall(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); String dbname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(dbname + "", sheetNum); sheetNum = sheetNum + 1; Vector tableinfo_v = new Vector(); if (report_has.get("tableinfo_v") != null) tableinfo_v = (Vector) report_has.get("tableinfo_v"); // Hashtable CPU = (Hashtable)report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); Hashtable maxping = (Hashtable) report_has.get("ping"); // SysLogger.info("?????????????????pingmax????????????="+maxping.get("pingmax")); // SysLogger.info("?????????????????avgpingcon????????????="+maxping.get("avgpingcon")); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, dbname + "", labelFormat); sheet.addCell(tmpLabel); String reporttime = (String) report_has.get("reporttime"); if (reporttime == null || reporttime.trim().length() == 0) { tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); } else { tmpLabel = new Label(0, 1, ":" + reporttime); } sheet.addCell(tmpLabel); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); File file = null; try { // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; } catch (Exception ex) { ex.printStackTrace(); } tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 14, "", _labelFormat); sheet.addCell(tmpLabel); int row = 14; // // Vector tableinfo_v = // (Vector)reportHash.get("tableinfo_v"); for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); row = row + (i); tmpLabel = new Label(0, 15 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 15 + i, _filename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15 + i, tablespace, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15 + i, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 15 + i, free, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 15 + i, percent, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 15 + i, status, p_labelFormat); sheet.addCell(tmpLabel); } } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_oraall2(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreport_has = new Hashtable(); allreport_has = reportHash; if (allreport_has != null && allreport_has.size() > 0) { Iterator keys = allreport_has.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreport_has.get(ip); reportHash = report_has; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String[] sysItemch1 = { "", "", "", "Java" }; String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated" }; String[] sysItemch2 = { "PGA", "PGA", "PGA" }; String hostname = (String) reportHash.get("dbname"); // String ip = (String) reportHash.get("ip"); // String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String buffercache = "0";// String dictionarycache = "0";// String librarycache = "0";// String pctmemorysorts = "0";// String pctbufgets = "0";// 10 String opencurstr = "0";// Hashtable memPerfValue = (Hashtable) reportHash.get("memPerfValue"); Hashtable memValue = (Hashtable) reportHash.get("memValue"); Hashtable cursors = (Hashtable) reportHash.get("cursors"); if (cursors == null) { cursors = new Hashtable(); } if (memPerfValue == null) memPerfValue = new Hashtable(); if (memPerfValue != null) { if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) { buffercache = (String) memPerfValue.get("buffercache") + "%"; } if (memPerfValue.containsKey("dictionarycache") && memPerfValue.get("dictionarycache") != null) { dictionarycache = (String) memPerfValue.get("dictionarycache") + "%"; } if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) { librarycache = (String) memPerfValue.get("librarycache") + "%"; } if (memPerfValue.containsKey("pctmemorysorts") && memPerfValue.get("pctmemorysorts") != null) { pctmemorysorts = (String) memPerfValue.get("pctmemorysorts") + "%"; } if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) { pctbufgets = (String) memPerfValue.get("pctbufgets") + "%"; } if (cursors.containsKey("opencur") && cursors.get("opencur") != null) { opencurstr = (String) cursors.get("opencur"); } } Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new // WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new // WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new // WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; // ip this.dbTitlePing(sheet, ip, reportHash); int row = 18; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "10", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; tmpLabel = new Label(0, row, buffercache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, dictionarycache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, librarycache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, pctmemorysorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, pctbufgets, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, opencurstr, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); // row += 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, sysItemch2[0], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, sysItemch2[1], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, sysItemch2[2], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysItemch1[0], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, sysItemch1[1], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, sysItemch1[2], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, sysItemch1[3], b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; tmpLabel = new Label(0, row, memValue.get(sysItem2[0]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, memValue.get(sysItem2[1]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, memValue.get(sysItem2[2]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, memValue.get(sysItem1[0]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, memValue.get(sysItem1[1]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, memValue.get(sysItem1[2]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, memValue.get(sysItem1[3]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); // row += 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START1 tmpLabel = new Label(6, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "", b_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END1 // HONGLI MODIFY START1 tmpLabel = new Label(10, row, "", b_labelFormat); // HONGLI MODIFY END1 sheet.addCell(tmpLabel); // row = row++; Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 for (int i = 0; i < tableinfo_v.size(); i++) { p_labelFormat = super.colorChange(i); Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 tmpLabel = new Label(0, row, String.valueOf(i + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, _filename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tablespace, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, free, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, percent, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START4 tmpLabel = new Label(6, row, pyr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, pbr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, pyw, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, pbw, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END4 tmpLabel = new Label(10, row, status, p_labelFormat); sheet.addCell(tmpLabel); row++; } // row++; this.addEventReport(sheet, report_has, row); row += 2; // addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { SysLogger.error("", ioe); } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } sheetNum++; } wb.write(); } } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } public void createReport_db2all(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); String dbname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(dbname + "", sheetNum); sheetNum = sheetNum + 1; // Hashtable CPU = (Hashtable)report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); // Calendar colTime = (Calendar)report_has.get("time"); // Date cc = colTime.getTime(); // Hashtable Memory = (Hashtable)report_has.get("Memory"); // Hashtable Disk = (Hashtable)report_has.get("Disk"); // Hashtable memMaxHash = // (Hashtable)report_has.get("memmaxhash"); // Hashtable memAvgHash = // (Hashtable)report_has.get("memavghash"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, dbname + "", labelFormat); sheet.addCell(tmpLabel); String reporttime = (String) report_has.get("reporttime"); if (reporttime == null || reporttime.trim().length() == 0) { tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); } else { tmpLabel = new Label(0, 1, ":" + reporttime); } String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); File file = null; try { // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; } catch (Exception ex) { ex.printStackTrace(); } Hashtable returnhash = new Hashtable(); if (report_has.get("db2space") != null) returnhash = (Hashtable) report_has.get("db2space"); Enumeration dbs = returnhash.keys(); List retList = new ArrayList(); int row = 14; while (dbs.hasMoreElements()) { row = row + 1; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(%)", _labelFormat); sheet.addCell(tmpLabel); String obj = (String) dbs.nextElement(); retList = (List) returnhash.get(obj); for (int i = 0; i < retList.size(); i++) { row = row + 1; Hashtable ht = (Hashtable) retList.get(i); if (ht == null) continue; String spacename = ""; if (ht.get("tablespace_name") != null) spacename = ht.get("tablespace_name").toString(); String size = ""; if (ht.get("totalspac") != null) size = ht.get("totalspac").toString(); String free = ""; if (ht.get("usablespac") != null) free = ht.get("usablespac").toString(); String percent = ""; if (ht.get("usableper") != null) percent = ht.get("usableper").toString(); row = row + (i); tmpLabel = new Label(0, row, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, spacename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, free, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, percent, p_labelFormat); sheet.addCell(tmpLabel); } } } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_db2all2(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); reportHash = report_has; String hostname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) report_has.get("Ping"); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); Hashtable mems = (Hashtable) report_has.get("mems");// Hashtable sysValue = (Hashtable) report_has.get("sysValue");// String typename = (String) report_has.get("typename"); String runstr = (String) report_has.get("runstr"); String grade = (String) report_has.get("grade"); String pingnow = (String) report_has.get("pingnow"); String pingmin = (String) report_has.get("pingmin"); String pingconavg = (String) report_has.get("pingconavg"); DBVo vo = (DBVo) report_has.get("vo"); Hashtable conn = (Hashtable) report_has.get("conn");// if (conn == null) conn = new Hashtable(); Hashtable poolInfo = (Hashtable) report_has.get("poolInfo");// if (poolInfo == null) poolInfo = new Hashtable(); Hashtable log = (Hashtable) report_has.get("log");// if (log == null) log = new Hashtable(); Hashtable spaceInfo = (Hashtable) report_has.get("spaceInfo");// if (spaceInfo == null) spaceInfo = new Hashtable(); String[] sysDbStatus = { "", "", "", "" }; Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, // false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new // WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new // WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new // WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); // WritableCellFormat red_labelFormat = new WritableCellFormat(); red_labelFormat.setBackground(jxl.format.Colour.RED); WritableCellFormat orange_labelFormat = new WritableCellFormat(); orange_labelFormat.setBackground(jxl.format.Colour.ORANGE); WritableCellFormat yellow_labelFormat = new WritableCellFormat(); yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW); Label tmpLabel = null; // ip this.dbTitlePing(sheet, ip, report_has); // tmpLabel = new Label(0, 18, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 18, 10, 18); tmpLabel = new Label(0, 19, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 19, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 19, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 19, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 19, " %", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 19, 4, 19); sheet.mergeCells(5, 19, 6, 19); sheet.mergeCells(7, 19, 8, 19); sheet.mergeCells(9, 19, 10, 19); List toolsdb = (ArrayList) spaceInfo.get("toolsdb"); int row = 20; if (toolsdb != null && toolsdb.size() > 0) { for (int i = 0; i < toolsdb.size(); i++) { Hashtable tempSpace = new Hashtable(); tempSpace = (Hashtable) toolsdb.get(i); String tablespace_name = (String) tempSpace.get("tablespace_name"); String totalspac = (String) tempSpace.get("totalspac"); String usablespac = (String) tempSpace.get("usablespac"); String usableper = (String) tempSpace.get("usableper"); if (usableper == null || "0".equals(totalspac.trim())) { usableper = "100"; } p_labelFormat = this.colorChange(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tablespace_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, totalspac, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, usablespac, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, usableper, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } row++; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "SQL ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "SQL", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; Enumeration dbs = conn.keys(); Hashtable<String, Object> allhash = new Hashtable(); List poolList = new ArrayList(); while (dbs.hasMoreElements()) { String obj = (String) dbs.nextElement(); List connList = (List) conn.get(obj); for (int i = 0; i < connList.size(); i++) { Hashtable ht = (Hashtable) connList.get(i); String db_name = ht.get("db_name").toString(); String db_path = ht.get("db_path").toString(); String db_status = ht.get("db_status").toString(); String sqlm_elm_last_backup = ht.get("sqlm_elm_last_backup").toString(); String total_cons = ht.get("total_cons").toString(); String connections_top = ht.get("connections_top").toString(); String appls_cur_cons = ht.get("appls_cur_cons").toString(); String failedsql = ht.get("failedsql").toString(); String commitsql = ht.get("commitsql").toString(); p_labelFormat = this.colorChange(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, db_path, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysDbStatus[Integer.parseInt(db_status)], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, sqlm_elm_last_backup, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, total_cons, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, connections_top, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, appls_cur_cons, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, failedsql, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, commitsql, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; } } // row++; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); row++; Enumeration dbs2 = poolInfo.keys(); Hashtable<String, Object> allhash2 = new Hashtable(); List poolList2 = new ArrayList(); while (dbs2.hasMoreElements()) { String obj = (String) dbs2.nextElement(); allhash = (Hashtable) poolInfo.get(obj); poolList = (List) allhash.get("poolValue"); List lockList = (List) allhash.get("lockValue"); List readList = (List) allhash.get("readValue"); List writeList = (List) allhash.get("writeValue"); for (int i = 0; i < poolList.size(); i++) { Hashtable ht = (Hashtable) poolList.get(i); String bp_name = ht.get("bp_name").toString(); String data_hit_ratio = ht.get("data_hit_ratio").toString(); String index_hit_ratio = ht.get("index_hit_ratio").toString(); String BP_hit_ratio = ht.get("BP_hit_ratio").toString(); String Async_read_pct = ht.get("Async_read_pct").toString(); String Direct_RW_Ratio = ht.get("Direct_RW_Ratio").toString(); p_labelFormat = this.colorChange(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, bp_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, data_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, index_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, BP_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, Async_read_pct, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, row, Direct_RW_Ratio, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); row++; } } // row++; tmpLabel = new Label(0, row, " ", labelFormat); sheet.mergeCells(0, row, 10, row); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; Enumeration dbs3 = poolInfo.keys(); Hashtable<String, Object> allhash3 = new Hashtable(); List poolList3 = new ArrayList(); while (dbs3.hasMoreElements()) { String obj = (String) dbs3.nextElement(); allhash3 = (Hashtable) poolInfo.get(obj); poolList3 = (List) allhash3.get("poolValue"); // System.out.println("poolList size === // "+poolList.size()); List lockList = (List) allhash3.get("lockValue"); List readList = (List) allhash3.get("readValue"); List writeList = (List) allhash3.get("writeValue"); for (int i = 0; i < lockList.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable ht = (Hashtable) lockList.get(i); String db_name = ht.get("db_name").toString(); String rows_read = ht.get("rows_read").toString(); String rows_selected = ht.get("rows_selected").toString(); String lock_waits = ht.get("lock_waits").toString(); String lock_wait_time = ht.get("lock_wait_time").toString(); String deadlocks = ht.get("deadlocks").toString(); String lock_escals = ht.get("lock_escals").toString(); String total_sorts = ht.get("total_sorts").toString(); String total_sort_time = ht.get("total_sort_time").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_selected, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, lock_waits, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, lock_wait_time, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, deadlocks, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, lock_escals, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, total_sorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, total_sort_time, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; } } // row++; tmpLabel = new Label(0, row, " ", labelFormat); sheet.mergeCells(0, row, 10, row); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "(%) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "/ ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; Enumeration dbs4 = log.keys(); Hashtable<String, Object> allhash4 = new Hashtable(); List poolList4 = new ArrayList(); int cc = 0; while (dbs4.hasMoreElements()) { String obj = (String) dbs4.nextElement(); List logList = (List) log.get(obj); p_labelFormat = this.colorChange(cc); cc++; for (int i = 0; i < logList.size(); i++) { Hashtable ht = (Hashtable) logList.get(i); String logused = ht.get("logused").toString(); String logspacefree = ht.get("logspacefree").toString(); String pctused = ht.get("pctused").toString(); String maxlogused = ht.get("maxlogused").toString(); String maxsecused = ht.get("maxsecused").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, obj, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, logused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, logspacefree, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, pctused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, maxlogused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, maxsecused, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } // 10 row++; tmpLabel = new Label(0, row, "10 ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; Enumeration dbs5 = poolInfo.keys(); Hashtable<String, Object> allhash5 = new Hashtable(); List poolList5 = new ArrayList(); String obj = null; Hashtable allhash6 = null; List lockList = null; List readList = null; List writeList = null; while (dbs5.hasMoreElements()) { obj = (String) dbs5.nextElement(); allhash6 = (Hashtable) poolInfo.get(obj); poolList = (List) allhash6.get("poolValue"); // System.out.println("poolList size === // "+poolList.size()); lockList = (List) allhash6.get("lockValue"); readList = (List) allhash6.get("readValue"); writeList = (List) allhash6.get("writeValue"); } if (readList != null && readList.size() > 0) { for (int i = 0; i < readList.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable ht = (Hashtable) readList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tbschema, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, rows_written, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, overflow_accesses, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, page_reorgs, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } // 10 row++; tmpLabel = new Label(0, row, "10 ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; if (writeList != null && writeList.size() > 0) { for (int i = 0; i < writeList.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable ht = (Hashtable) writeList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tbschema, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, rows_written, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, overflow_accesses, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, page_reorgs, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } // row++; this.addEventReport(sheet, report_has, row); row += 2; // this.addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } } wb.write(); } } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } public void createReport_sqlall(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); String dbname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(dbname + "", sheetNum); sheetNum = sheetNum + 1; Hashtable dbValue = new Hashtable(); // Vector tableinfo_v = new Vector(); if (report_has.get("dbValue") != null) dbValue = (Hashtable) report_has.get("dbValue"); // Hashtable CPU = (Hashtable)report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); // Calendar colTime = (Calendar)report_has.get("time"); // Date cc = colTime.getTime(); // Hashtable Memory = (Hashtable)report_has.get("Memory"); // Hashtable Disk = (Hashtable)report_has.get("Disk"); // Hashtable memMaxHash = // (Hashtable)report_has.get("memmaxhash"); // Hashtable memAvgHash = // (Hashtable)report_has.get("memavghash"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, dbname + "", labelFormat); sheet.addCell(tmpLabel); String reporttime = (String) report_has.get("reporttime"); if (reporttime == null || reporttime.trim().length() == 0) { tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); } else { tmpLabel = new Label(0, 1, ":" + reporttime); } sheet.addCell(tmpLabel); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); File file = null; try { // file = new File(ResourceCenter.getInstance().getSysPath() + "/images/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; } catch (Exception ex) { ex.printStackTrace(); } // tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "", _labelFormat); sheet.addCell(tmpLabel); int row = 14; // // Hashtable dbValue = (Hashtable)reportHash.get("dbValue"); Hashtable alldatabase = new Hashtable(); if (reportHash.get("database") != null) alldatabase = (Hashtable) dbValue.get("database"); Vector names = new Vector(); if (dbValue.get("names") != null) names = (Vector) dbValue.get("names"); if (alldatabase != null && alldatabase.size() > 0) { if (names == null) names = new Vector(); for (int i = 0; i < names.size(); i++) { String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String _dbname = data.get("dbname").toString(); String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); row = row + 1; tmpLabel = new Label(0, row, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, _dbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, usedperc, p_labelFormat); sheet.addCell(tmpLabel); } } } wb.write(); } } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_sqlall2(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); // reportHash = report_has; String hostname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(hostname + "", sheetNum); sheetNum++; String Ping = (String) report_has.get("Ping"); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); Hashtable mems = (Hashtable) report_has.get("mems");// Hashtable sysValue = (Hashtable) report_has.get("sysValue");// String typename = (String) report_has.get("typename"); String runstr = (String) report_has.get("runstr"); String grade = (String) report_has.get("grade"); String pingnow = (String) report_has.get("pingnow"); String pingmin = (String) report_has.get("pingmin"); String pingconavg = (String) report_has.get("pingconavg"); DBVo vo = (DBVo) report_has.get("vo"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Label tmpLabel = null; this.dbTitlePing(sheet, ip, report_has); int row = 18; // tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, "SQL", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); sheet.mergeCells(8, row, 10, row); row++; tmpLabel = new Label(0, row, (String) mems.get("totalMemory"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) mems.get("optMemory"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, (String) mems.get("conMemory"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, (String) mems.get("sqlMem"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, (String) mems.get("lockMem"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); sheet.mergeCells(8, row, 10, row); row += 2; // tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 4, row); sheet.mergeCells(5, row, 7, row); sheet.mergeCells(8, row, 10, row); row++; tmpLabel = new Label(0, row, (String) sysValue.get("productlevel"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) sysValue.get("IsIntegratedSecurityOnly"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, (String) sysValue.get("IsSingleUser"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, (String) sysValue.get("IsClustered"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 4, row); sheet.mergeCells(5, row, 7, row); sheet.mergeCells(8, row, 10, row); row += 2; // tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(MB)", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, "(MB)", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "(%)", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); sheet.mergeCells(8, row, 10, row); // Hashtable dbValue = (Hashtable) report_has.get("tableinfo_v"); Hashtable alldatabase = new Hashtable(); if (dbValue.get("database") != null) alldatabase = (Hashtable) dbValue.get("database"); Vector names = new Vector(); if (dbValue.get("names") != null) names = (Vector) dbValue.get("names"); if (alldatabase != null && alldatabase.size() > 0) { if (names == null) names = new Vector(); for (int i = 0; i < names.size(); i++) { String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); row = row + 1; p_labelFormat = this.colorChange(i); tmpLabel = new Label(0, row, i + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, dbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, usedsize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, usedperc, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); sheet.mergeCells(8, row, 10, row); } } // row = row + 2; this.addEventReport(sheet, report_has, row); row += 2; // this.addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { SysLogger.error("", ioe); } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } } wb.write(); } } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } // zhushouzhiword public void createReport_networkDoc(String file) throws DocumentException, IOException { String runmodel = PollingEngine.getCollectwebflag(); Hashtable CPU = (Hashtable) reportHash.get("CPU"); String Ping = (String) reportHash.get("Ping"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Vector netifVector = (Vector) reportHash.get("netifVector"); Hashtable portconfigHash = (Hashtable) reportHash.get("portconfigHash"); List reportports = (List) reportHash.get("reportports"); Vector iprouterVector = (Vector) reportHash.get("iprouterVector"); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); String hostname = (String) reportHash.get("equipname"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] netIfItemch = { "", "", "", "(M)", "", "", "" }; String[] ipRouterItemch = { "", "", "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization", "INodeUsedSize", "INodeUtilization" }; String[] diskItemch = { "", "", "", "i-node", "i-node" }; String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" }; String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)", "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)", "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + sdf.format(cc); Paragraph context = new Paragraph(contextString, titleFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); // Table Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(4); float[] widths = { 220f, 300f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cellt0 = new Cell(""); cellt0.setBackgroundColor(Color.LIGHT_GRAY); cellt0.setHorizontalAlignment(Element.ALIGN_CENTER); cellt0.setVerticalAlignment(Element.ALIGN_MIDDLE); cellt0.setRowspan(2); Cell cellt1 = new Cell(""); cellt1.setBackgroundColor(Color.LIGHT_GRAY); Cell cellt2 = new Cell(""); cellt2.setBackgroundColor(Color.LIGHT_GRAY); Cell cellt3 = new Cell(""); cellt3.setBackgroundColor(Color.LIGHT_GRAY); aTable.addCell(cellt0); aTable.addCell(cellt1); aTable.addCell(cellt2); aTable.addCell(cellt3); // aTable.addCell("3.2",Ping+"%"); // Cell cellt4 = new Cell(""); // cellt4.setBackgroundColor(Color.LIGHT_GRAY); // aTable.addCell(cellt4); aTable.addCell(Ping + "%"); aTable.addCell((String) maxping.get("pingmax")); aTable.addCell((String) maxping.get("avgpingcon")); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(aTable); document.add(img); // document.add(new Paragraph("\n")); // document.close(); Table aTable1 = new Table(4); float[] width = { 220f, 300f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// aTable1.endHeaders(); cellt0 = new Cell("CPU"); cellt0.setBackgroundColor(Color.LIGHT_GRAY); cellt0.setHorizontalAlignment(Element.ALIGN_CENTER); cellt0.setVerticalAlignment(Element.ALIGN_MIDDLE); cellt1 = new Cell(""); cellt1.setBackgroundColor(Color.LIGHT_GRAY); cellt2 = new Cell(""); cellt2.setBackgroundColor(Color.LIGHT_GRAY); cellt3 = new Cell(""); cellt3.setBackgroundColor(Color.LIGHT_GRAY); aTable1.addCell(cellt0); aTable1.addCell(cellt1); aTable1.addCell(cellt2); aTable1.addCell(cellt3); // aTable.addCell("3.2",Ping+"%"); aTable1.addCell(""); aTable1.addCell((String) CPU.get("cpu") + "%"); aTable1.addCell((String) CPU.get("cpumax")); aTable1.addCell((String) CPU.get("avgcpu")); cellt0.setRowspan(2); Image img1 = Image.getInstance( ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.MIDDLE);// document.add(aTable1); document.add(img1); if (netifVector != null && netifVector.size() > 0) { Table aTable2 = new Table(8); float[] width2 = { 300f, 220f, 220f, 180f, 300f, 180f, 220f, 220f }; aTable2.setWidths(width2); aTable2.setWidth(100); // 100% aTable2.setAlignment(Element.ALIGN_CENTER);// aTable2.setAutoFillEmptyCells(true); // aTable2.setBorderWidth(1); // aTable2.setBorderColor(new Color(0, 125, 255)); // aTable2.setPadding(2);// aTable2.setSpacing(0);// aTable2.setBorder(2);// aTable2.endHeaders(); Cell c = new Cell(""); c.setBackgroundColor(Color.LIGHT_GRAY); c.setRowspan(netifVector.size() + 1); c.setHorizontalAlignment(Element.ALIGN_CENTER); c.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(c); // // allRow = allRow; for (int i = 0; i < netIfItemch.length; i++) { Cell cell = new Cell(netIfItemch[i]); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable2.addCell(cell); } Color color = new Color(204, 204, 255); // for (int i = 0; i < netifVector.size(); i++) { // aTable2.addCell(""); String[] strs = (String[]) netifVector.get(i); String ifname = strs[1]; String index = strs[0]; for (int j = 0; j < strs.length; j++) { if (j == 1) { String linkuse = ""; if (portconfigHash != null && portconfigHash.size() > 0) { if (portconfigHash.get(ip + ":" + index) != null) linkuse = (String) portconfigHash.get(ip + ":" + index); } Cell cell1 = new Cell(strs[j]); Cell cell2 = new Cell(linkuse); if (i % 2 != 0) { cell1.setBackgroundColor(color); cell2.setBackgroundColor(color); } aTable2.addCell(cell1); aTable2.addCell(cell2); } else if (j > 1) { Cell cell3 = new Cell(strs[j]); if (i % 2 != 0) { cell3.setBackgroundColor(color); } aTable2.addCell(cell3); } else { Cell cell4 = new Cell(strs[j]); if (i % 2 != 0) { cell4.setBackgroundColor(color); } aTable2.addCell(cell4); } } // end } document.add(aTable2); } if ("0".equals(runmodel)) { // if (iprouterVector != null && iprouterVector.size() > 0) { Table aTable3 = new Table(7); float[] width2 = { 240f, 200f, 300f, 300f, 220f, 180f, 300f }; aTable3.setWidths(width2); aTable3.setWidth(100); // 100% aTable3.setAlignment(Element.ALIGN_CENTER);// aTable3.setAutoFillEmptyCells(true); // aTable3.setBorderWidth(1); // aTable3.setBorderColor(new Color(0, 125, 255)); // aTable3.setPadding(2);// aTable3.setSpacing(0);// aTable3.setBorder(2);// aTable3.endHeaders(); aTable3.addCell(""); // // allRow = allRow+1; for (int i = 0; i < ipRouterItemch.length; i++) { Cell cell = new Cell(ipRouterItemch[i]); aTable3.addCell(cell); } // for (int i = 0; i < iprouterVector.size(); i++) { aTable3.addCell(""); /* allRow = allRow + 1; */ IpRouter iprouter = (IpRouter) iprouterVector.get(i); Cell cell = new Cell(iprouter.getIfindex()); aTable3.addCell(cell); Cell cell1 = new Cell(iprouter.getDest()); aTable3.addCell(cell1); Cell cell2 = new Cell(iprouter.getNexthop()); aTable3.addCell(cell2); Cell cell3 = new Cell(iproutertype[Integer.parseInt(iprouter.getType().longValue() + "")]); aTable3.addCell(cell3); Cell cell4 = new Cell(iprouterproto[Integer.parseInt(iprouter.getProto().longValue() + "")]); aTable3.addCell(cell4); Cell cell5 = new Cell(iprouter.getMask()); aTable3.addCell(cell5); } document.add(aTable3); } } else { // List routerList = (ArrayList) reportHash.get("routerList"); Table aTable3 = new Table(7); float[] width2 = { 240f, 200f, 300f, 300f, 220f, 180f, 300f }; aTable3.setWidths(width2); aTable3.setWidth(100); // 100% aTable3.setAlignment(Element.ALIGN_CENTER);// aTable3.setAutoFillEmptyCells(true); // aTable3.setBorderWidth(1); // aTable3.setBorderColor(new Color(0, 125, 255)); // aTable3.setPadding(2);// aTable3.setSpacing(0);// aTable3.setBorder(2);// aTable3.endHeaders(); aTable3.addCell(""); // // allRow = allRow+1; for (int i = 0; i < ipRouterItemch.length; i++) { Cell cell = new Cell(ipRouterItemch[i]); aTable3.addCell(cell); } if (routerList != null) { for (int i = 0; i < routerList.size(); i++) { aTable3.addCell(""); RouterNodeTemp iprouter = (RouterNodeTemp) routerList.get(i); Cell cell = new Cell(iprouter.getIfindex()); aTable3.addCell(cell); Cell cell1 = new Cell(iprouter.getDest()); aTable3.addCell(cell1); Cell cell2 = new Cell(iprouter.getNexthop()); aTable3.addCell(cell2); Cell cell3 = new Cell(iprouter.getType()); aTable3.addCell(cell3); Cell cell4 = new Cell(iprouter.getProto()); aTable3.addCell(cell4); Cell cell5 = new Cell(iprouter.getMask()); aTable3.addCell(cell5); } document.add(aTable3); } } // doc if (reportports != null && reportports.size() > 0) { // // aTable4.addCell(""); for (int i = 0; i < reportports.size(); i++) { Table aTable4 = new Table(2); float[] width2 = { 300f, 300f }; aTable4.setWidths(width2); aTable4.setWidth(100); // 100% aTable4.setAlignment(Element.ALIGN_CENTER);// aTable4.setAutoFillEmptyCells(true); // aTable4.setBorderWidth(1); // aTable4.setBorderColor(new Color(0, 125, 255)); // aTable4.setPadding(2);// aTable4.setSpacing(0);// aTable4.setBorder(2);// aTable4.endHeaders(); // SysLogger.info(reportports.get(i).getClass()+"============================================="); com.afunms.config.model.Portconfig portconfig = (com.afunms.config.model.Portconfig) reportports .get(i); /* * tmpLabel = new Label(0, allRow, "" + * portconfig.getPortindex() + "(" + portconfig.getName() + * ")", b_labelFormat); * * sheet.addCell(tmpLabel); */ Cell cell = new Cell("" + portconfig.getPortindex() + "(" + portconfig.getName() + ")"); aTable4.addCell(cell); if (portconfig.getLinkuse() == null) portconfig.setLinkuse(""); Cell cell1 = new Cell(":" + portconfig.getLinkuse()); aTable4.addCell(cell1); document.add(aTable4); // Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + portconfig.getPortindex() + "ifspeed_day.png"); img2.setAbsolutePosition(0, 0); img2.setAlignment(Image.LEFT);// // sheet,0,0,5,1,,, img2.scalePercent(67); document.add(img2); } } // if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } /* * WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos * .toByteArray()); */ Image img2 = Image.getInstance(baos.toByteArray()); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// img.scalePercent(67); document.add(img2); } document.close(); } // zhushouzhi // zhushouzhi-------------------------star public void createReport_hostNewDoc(String file) throws DocumentException, IOException { Hashtable Memory = (Hashtable) reportHash.get("Memory"); // EventListDao eventListDao = new EventListDao(); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable CPU = (Hashtable) reportHash.get("CPU"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; if (CPU == null) CPU = new Hashtable(); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = "0.0%"; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String hostnameDoc = (String) reportHash.get("equipnameDoc"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String startdate = (String) reportHash.get("startdate"); int cpuvalue = ((Integer) reportHash.get("cpuvalue")).intValue(); int memvalue = ((Integer) reportHash.get("memvalue")).intValue(); int diskvalue = ((Integer) reportHash.get("diskvalue")).intValue(); int pingvalue = ((Integer) reportHash.get("pingvalue")).intValue(); /* String type = (String)request.getAttribute("type"); */ Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable.addCell(cell); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell = new Cell(new Phrase("\n" + starttime + " " + totime + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnameDoc, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase("\n" + grade + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "CPU" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(avgcpu, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("CPU", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cpumax, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String avgvalue = "0.0%"; cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); if (memAvgHash.get("PhysicalMemory") != null) { avgvalue = (String) memAvgHash.get("PhysicalMemory"); cell = new Cell(new Phrase(avgvalue, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } else { cell = new Cell(new Phrase(avgvalue, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String value = "0.0%"; if (memMaxHash.get("PhysicalMemory") != null) { value = (String) memMaxHash.get("PhysicalMemory"); cell = new Cell(new Phrase(value, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } else { cell = new Cell(new Phrase(value, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } // end // end } cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "CPU" + cpuvalue + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + memvalue + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + pingvalue + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + diskvalue + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String strcpu = ""; String strmem = ""; String strping = ""; String strdisk = ""; if (cpuvalue > 0) { strcpu = " 2 " + cpuvalue + "CPU" + "\n" + "\n"; } else { strcpu = " 2 CPU" + " \n" + "\n"; } if (memvalue > 0) { strmem = " 3 " + memvalue + "" + "\n" + "\n"; } else { strmem = " 3 " + "\n" + "\n"; } if (pingvalue > 0) { strping = " 4 " + pingvalue + "" + "\n" + "\n"; } else { strping = " 4 " + "\n" + "\n"; } if (diskvalue > 0) { strdisk = " 5 " + diskvalue + ""; } else { strdisk = " 5 "; } cell = new Cell(new Phrase(" 1 " + " \n" + "\n" + strcpu + strmem + strping + strdisk + "\n" + "\n" + "\n", contextFont) ); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } // zhushouzhi---------------------end // ------------------------------------------------------------------------- // zhushouzhi-------------------------star public void createReport_hostNewPDF(String file) throws DocumentException, IOException { Hashtable Memory = (Hashtable) reportHash.get("Memory"); // EventListDao eventListDao = new EventListDao(); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable CPU = (Hashtable) reportHash.get("CPU"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; if (CPU == null) CPU = new Hashtable(); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = "0.0%"; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String hostnameDoc = (String) reportHash.get("equipnameDoc"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String startdate = (String) reportHash.get("startdate"); int cpuvalue = ((Integer) reportHash.get("cpuvalue")).intValue(); int memvalue = ((Integer) reportHash.get("memvalue")).intValue(); int diskvalue = ((Integer) reportHash.get("diskvalue")).intValue(); int pingvalue = ((Integer) reportHash.get("pingvalue")).intValue(); /* String type = (String)request.getAttribute("type"); */ Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 10, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable.addCell(cell); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell = new Cell(new Phrase("\n" + starttime + " " + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnameDoc, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase("\n" + grade + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "CPU" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(avgcpu)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("CPU", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cpumax)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String avgvalue = "0.0%"; cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); if (memAvgHash.get("PhysicalMemory") != null) { avgvalue = (String) memAvgHash.get("PhysicalMemory"); cell = new Cell(new Phrase(avgvalue)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } else { cell = new Cell(new Phrase(avgvalue)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String value = "0.0%"; if (memMaxHash.get("PhysicalMemory") != null) { value = (String) memMaxHash.get("PhysicalMemory"); cell = new Cell(new Phrase(value)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } else { cell = new Cell(new Phrase(value)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } // end // end } cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "CPU" + cpuvalue + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + memvalue + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + pingvalue + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + diskvalue + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String strcpu = ""; String strmem = ""; String strping = ""; String strdisk = ""; if (cpuvalue > 0) { strcpu = " 2 " + cpuvalue + "CPU" + "\n" + "\n"; } else { strcpu = " 2 CPU" + " \n" + "\n"; } if (memvalue > 0) { strmem = " 3 " + memvalue + "" + "\n" + "\n"; } else { strmem = " 3 " + "\n" + "\n"; } if (pingvalue > 0) { strping = " 4 " + pingvalue + "" + "\n" + "\n"; } else { strping = " 4 " + "\n" + "\n"; } if (diskvalue > 0) { strdisk = " 5 " + diskvalue + ""; } else { strdisk = " 5 "; } cell = new Cell(new Phrase(" 1 " + " \n" + "\n" + strcpu + strmem + strping + strdisk + "\n" + "\n" + "\n", contextFont) ); /* * cell = new Cell(new Phrase(" 1 " + " \n" + * "\n" + " 2 " + cpuvalue + "CPU" + "\n" + * "\n" + " 3 "+memvalue+"" + "\n" + * "\n" + " 4 "+pingvalue+"" + "\n" + * "\n"+" 5 "+diskvalue+"" + "\n" + "\n"+ * "\n",contextFont) ); */ cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } /** * xls * * @param filename * @throws DocumentException * @throws IOException */ public void createReport_hostNewXls(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { wb = Workbook.createWorkbook(new File(filename)); Hashtable Memory = (Hashtable) reportHash.get("Memory"); // EventListDao eventListDao = new EventListDao(); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable CPU = (Hashtable) reportHash.get("CPU"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; if (CPU == null) CPU = new Hashtable(); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = "0.0%"; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String hostnameDoc = (String) reportHash.get("equipnameDoc"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String startdate = (String) reportHash.get("startdate"); int cpuvalue = ((Integer) reportHash.get("cpuvalue")).intValue(); int memvalue = ((Integer) reportHash.get("memvalue")).intValue(); int diskvalue = ((Integer) reportHash.get("diskvalue")).intValue(); int pingvalue = ((Integer) reportHash.get("pingvalue")).intValue(); String grade = (String) reportHash.get("grade"); WritableSheet sheet = wb.createSheet(hostname + "", 0); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); int row = 0; Label tmpLabel = null; tmpLabel = new Label(1, row, hostname + " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, hostnameDoc); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, ip); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, typename); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, grade); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 5, row); row++; tmpLabel = new Label(0, row, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "CPU", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); tmpLabel = new Label(3, row, avgcpu); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "CPU", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, cpumax); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(1, row, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); String avgvalue = "0.0%"; if (memAvgHash.get("PhysicalMemory") != null) { avgvalue = (String) memAvgHash.get("PhysicalMemory"); tmpLabel = new Label(3, row, avgvalue); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(3, row, avgvalue); sheet.addCell(tmpLabel); } tmpLabel = new Label(4, row, "", _labelFormat); sheet.addCell(tmpLabel); String value = "0.0%"; if (memMaxHash.get("PhysicalMemory") != null) { value = (String) memMaxHash.get("PhysicalMemory"); tmpLabel = new Label(5, row, value); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(5, row, value); sheet.addCell(tmpLabel); } row++; tmpLabel = new Label(0, row, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "CPU" + cpuvalue + ""); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 5, row); row++; tmpLabel = new Label(1, row, "" + memvalue + ""); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 5, row); row++; tmpLabel = new Label(1, row, "" + pingvalue + ""); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 5, row); row++; tmpLabel = new Label(1, row, "" + diskvalue + ""); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 5, row); row++; tmpLabel = new Label(0, row, "", _labelFormat); sheet.addCell(tmpLabel); String strcpu = ""; String strmem = ""; String strping = ""; String strdisk = ""; if (cpuvalue > 0) { strcpu = " 2 " + cpuvalue + "CPU" + "\n" + "\n"; } else { strcpu = " 2 CPU" + " \n" + "\n"; } if (memvalue > 0) { strmem = " 3 " + memvalue + "" + "\n" + "\n"; } else { strmem = " 3 " + "\n" + "\n"; } if (pingvalue > 0) { strping = " 4 " + pingvalue + "" + "\n" + "\n"; } else { strping = " 4 " + "\n" + "\n"; } if (diskvalue > 0) { strdisk = " 5 " + diskvalue + ""; } else { strdisk = " 5 "; } tmpLabel = new Label(1, row, " 1 "); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 5, row); row++; tmpLabel = new Label(1, row, strcpu); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 5, row); row++; tmpLabel = new Label(1, row, strmem); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 5, row); row++; tmpLabel = new Label(1, row, strping); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 5, row); row++; tmpLabel = new Label(1, row, strdisk); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 5, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // zhushouzhi---------------------end // ----------------------------------------------------------------------------- // doc public void createReport_hostDoc(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, titleFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(4); float[] widths = { 220f, 300f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable.addCell(cell); aTable.addCell(Ping + "%"); aTable.addCell((String) maxping.get("pingmax")); aTable.addCell((String) maxping.get("avgpingcon")); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(aTable); document.add(img); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = ""; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); Table aTable1 = new Table(4); float[] width = { 220f, 300f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// aTable1.endHeaders(); cell = new Cell(); cell.addElement(new Paragraph("CPU", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable1.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable1.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable1.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable1.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable1.addCell(cell); aTable1.addCell(cpu + "%"); aTable1.addCell(cpumax); aTable1.addCell(avgcpu); Image img1 = Image.getInstance( ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.MIDDLE);// document.add(aTable1); document.add(img1); if (Memory != null && Memory.size() > 0) { Table aTable2 = new Table(6); float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f }; aTable2.setWidths(widthss); aTable2.setWidth(100); // 90% aTable2.setAlignment(Element.ALIGN_CENTER);// aTable2.setAutoFillEmptyCells(true); // aTable2.setBorderWidth(1); // aTable2.setBorderColor(new Color(0, 125, 255)); // aTable2.setPadding(2);// aTable2.setSpacing(0);// aTable2.setBorder(2);// aTable2.endHeaders(); cell = new Cell(""); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable2.addCell(cell); cell = new Cell(""); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable2.addCell(cell); // for (int i = 0; i < memoryItemch.length; i++) { cell = new Cell(memoryItemch[i]); cell.setBackgroundColor(Color.LIGHT_GRAY); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); aTable2.addCell(cell); } // for (int i = 0; i < Memory.size(); i++) { aTable2.addCell(""); Hashtable mhash = (Hashtable) (Memory.get(new Integer(i))); String name = (String) mhash.get("name"); Cell cell1 = new Cell(name); aTable2.addCell(cell1); for (int j = 0; j < memoryItem.length; j++) { String value = ""; if (mhash.get(memoryItem[j]) != null) { value = (String) mhash.get(memoryItem[j]); } Cell cell2 = new Cell(value); aTable2.addCell(cell2); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); Cell cell3 = new Cell(value); aTable2.addCell(cell3); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); aTable2.addCell(avgvalue); } } // end // Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.MIDDLE);// document.add(aTable2); document.add(img2); } else { Table aTable2 = new Table(6); float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f }; aTable2.setWidths(widthss); aTable2.setWidth(100); // 90% aTable2.setAlignment(Element.ALIGN_CENTER);// aTable2.setAutoFillEmptyCells(true); // aTable2.setBorderWidth(1); // aTable2.setBorderColor(new Color(0, 125, 255)); // aTable2.setPadding(2);// aTable2.setSpacing(0);// aTable2.setBorder(2);// aTable2.endHeaders(); cell = new Cell(""); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable2.addCell(cell); cell = new Cell(""); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable2.addCell(cell); // for (int i = 0; i < memoryItemch.length; i++) { cell = new Cell(memoryItemch[i]); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable2.addCell(cell); } // String[] names = null; HostNodeDao dao = new HostNodeDao(); HostNode node = (HostNode) dao.findByCondition("ip_address", ip).get(0); // Monitoriplist monitor = monitorManager.getByIpaddress(ip); if (node.getSysOid().startsWith("1.3.6.1.4.1.311")) { names = new String[] { "PhysicalMemory", "VirtualMemory" }; } else { names = new String[] { "PhysicalMemory", "SwapMemory" }; } for (int i = 0; i < names.length; i++) { String name = names[i]; aTable2.addCell(""); cell = new Cell(names[i]); aTable2.addCell(cell); for (int j = 0; j < memoryItem.length; j++) { // String value = ""; Cell cell1 = new Cell(value); aTable2.addCell(cell1); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); Cell cell2 = new Cell(value); aTable2.addCell(cell2); } else { Cell cell3 = new Cell(value); aTable2.addCell(cell3); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); Cell cell4 = new Cell(avgvalue); aTable2.addCell(cell4); } else { Cell cell5 = new Cell(avgvalue); aTable2.addCell(cell5); } } // end // Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.MIDDLE);// document.add(aTable2); document.add(img2); } Table aTable3 = new Table(5); float[] widthss1 = { 220f, 440f, 150f, 150f, 220f }; aTable3.setWidths(widthss1); aTable3.setWidth(100); // 90% aTable3.setAlignment(Element.ALIGN_CENTER);// aTable3.setAutoFillEmptyCells(true); // aTable3.setBorderWidth(1); // aTable3.setBorderColor(new Color(0, 125, 255)); // aTable3.setPadding(2);// aTable3.setSpacing(0);// aTable3.setBorder(2);// aTable3.endHeaders(); if (Disk != null && Disk.size() > 0) { cell = new Cell(""); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable3.addCell(cell); cell = new Cell(""); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable3.addCell(cell); for (int i = 0; i < diskItemch.length; i++) { cell = new Cell(diskItemch[i]); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable3.addCell(cell); } // for (int i = 0; i < Disk.size(); i++) { aTable3.addCell(""); Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i))); String name = (String) diskhash.get("name"); cell = new Cell(name); aTable3.addCell(cell); for (int j = 0; j < diskItem.length; j++) { String value = ""; if (diskhash.get(diskItem[j]) != null) { value = (String) diskhash.get(diskItem[j]); } Cell cell1 = new Cell(value); // System.out.println(value+"================value==============="); aTable3.addCell(cell1); } } // end // Image img3 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "disk" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.MIDDLE);// document.add(aTable3); document.add(img3); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img3 = Image.getInstance(baos.toByteArray()); img.setAbsolutePosition(0, 0); img.setAlignment(Image.MIDDLE);// document.add(img3); } document.close(); } public void createReport_pingDoc(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + ""); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(4); float[] widths = { 220f, 300f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); aTable.addCell(""); aTable.addCell(""); aTable.addCell(""); aTable.addCell(""); // aTable.addCell("3.2",Ping+"%"); aTable.addCell(""); aTable.addCell(Ping + "%"); aTable.addCell((String) maxping.get("pingmax")); aTable.addCell((String) maxping.get("avgpingcon")); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(aTable); document.add(img); document.close(); } // word public void createReport_ServicePingDoc(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String servicename = (String) reportHash.get("servicename"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); String Ping = (String) reportHash.get("Ping"); Hashtable ping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(servicename + ""); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(4); float[] widths = { 220f, 300f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); aTable.addCell(""); aTable.addCell(""); aTable.addCell(""); aTable.addCell(""); aTable.addCell(""); aTable.addCell(Ping + "%"); aTable.addCell((String) ping.get("minPing") + "%"); aTable.addCell((String) ping.get("avgPing") + "%"); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "pingConnect" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(aTable); document.add(img); document.close(); } // Excel public void createReport_ServicePingExc(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String servicename = (String) reportHash.get("servicename"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(servicename + "", 0); String Ping = (String) reportHash.get("Ping"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, servicename + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, Ping + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("minPing") + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, (String) maxping.get("avgPing") + "%", p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "pingConnect" + ".png"); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, 6, 7, 7, file)); wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // PDF public void createReport_ServicePingPDF(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String servicename = (String) reportHash.get("servicename"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(servicename + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Phrase("\n")); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); PdfPTable aTable = new PdfPTable(4); float[] widths = { 220f, 300f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(""); aTable.addCell(Ping + "%"); aTable.addCell((String) maxping.get("minPing") + "%"); aTable.addCell((String) maxping.get("avgPing") + "%"); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "pingConnect" + ".png"); img.setAlignment(Image.LEFT);// img.scalePercent(75); document.add(aTable); document.add(img); document.close(); } /** * @author wxy word * @param filename * @date 2010-3-28 */ public void createReport_ServiceEventDoc(String filename) throws IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); List list = new ArrayList(); list = (List) reportHash.get("eventlist"); String ip = ""; String servicename = ""; String sum = ""; String levelone = ""; String leveltwo = ""; String levelthree = ""; if (list != null && list.size() > 0) { List _eventlist = (List) list.get(0); if (_eventlist != null && _eventlist.size() > 0) { ip = (String) _eventlist.get(0); servicename = (String) _eventlist.get(1); sum = (String) _eventlist.get(2); levelone = (String) _eventlist.get(3); leveltwo = (String) _eventlist.get(4); levelthree = (String) _eventlist.get(5); } } Paragraph title = new Paragraph(servicename + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); // Table dbTable = new Table(6); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidth(100); // 90% dbTable.setAlignment(Element.ALIGN_CENTER);// dbTable.setAutoFillEmptyCells(true); // dbTable.setBorderWidth(1); // dbTable.setBorderColor(new Color(0, 125, 255)); // dbTable.setPadding(2);// dbTable.setSpacing(0);// dbTable.setBorder(2);// dbTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("() ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("() ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(servicename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(sum, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(levelone, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(leveltwo, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(levelthree, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); document.add(dbTable); addEventListToDoc(document, titleFont, contextFont); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author wxy Excel * @param filename * @date 2010-3-27 */ public void createReport_ServiceEventExc(String filename) throws IOException { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); List eventlist = new ArrayList(); eventlist = (List) reportHash.get("eventlist"); String ip = ""; String servicename = ""; String sum = ""; String levelone = ""; String leveltwo = ""; String levelthree = ""; if (eventlist != null && eventlist.size() > 0) { List _eventlist = (List) eventlist.get(0); if (_eventlist != null && _eventlist.size() > 0) { ip = (String) _eventlist.get(0); servicename = (String) _eventlist.get(1); sum = (String) _eventlist.get(2); levelone = (String) _eventlist.get(3); leveltwo = (String) _eventlist.get(4); levelthree = (String) _eventlist.get(5); } } String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; WritableSheet sheet = wb.createSheet(servicename + "", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); WritableCellFormat red_labelFormat = new WritableCellFormat(); red_labelFormat.setBackground(jxl.format.Colour.RED); WritableCellFormat orange_labelFormat = new WritableCellFormat(); orange_labelFormat.setBackground(jxl.format.Colour.ORANGE); WritableCellFormat yellow_labelFormat = new WritableCellFormat(); yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW); Label tmpLabel = null; tmpLabel = new Label(1, 0, servicename + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); // ip tmpLabel = new Label(0, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "()", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "()", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "()", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "()", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, servicename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, sum, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, levelone, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, leveltwo, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5, levelthree, p_labelFormat); sheet.addCell(tmpLabel); // int row = 7; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); row++; int index = 0; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); List list = (ArrayList) reportHash.get("list"); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { index++; EventList event = (EventList) list.get(i); Date cc = event.getRecordtime().getTime(); Integer eventid = event.getId(); String eventlocation = event.getEventlocation(); String content = event.getContent(); String level = String.valueOf(event.getLevel1()); String status = String.valueOf(event.getManagesign()); String s = status; String showlevel = null; String act = ""; if ("1".equals(level)) { showlevel = ""; } else if ("2".equals(level)) { showlevel = ""; } else { showlevel = ""; } if ("0".equals(status)) { status = ""; } if ("1".equals(status)) { status = ""; } if ("2".equals(status)) { status = ""; } String rptman = event.getReportman(); String rtime1 = _sdf.format(cc); tmpLabel = new Label(0, row, String.valueOf(index), p_labelFormat); sheet.addCell(tmpLabel); if ("3".equals(level)) { tmpLabel = new Label(1, row, showlevel, red_labelFormat); sheet.addCell(tmpLabel); } else if ("2".equals(level)) { tmpLabel = new Label(1, row, showlevel, orange_labelFormat); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(1, row, showlevel, yellow_labelFormat); sheet.addCell(tmpLabel); } tmpLabel = new Label(2, row, content, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rtime1, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, rptman, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, status, p_labelFormat); sheet.addCell(tmpLabel); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { if (wb != null) { try { wb.close(); } catch (WriteException e) { SysLogger.error("", e); } } } } /** * @author wxy pdf * @param filename * @date 2010-3-27 */ public void createReport_ServiceEventPdf(String filename) throws IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); List eventlist = new ArrayList(); eventlist = (List) reportHash.get("eventlist"); String ip = ""; String sum = ""; String levelone = ""; String leveltwo = ""; String levelthree = ""; String servicename = ""; if (eventlist != null && eventlist.size() > 0) { List _eventlist = (List) eventlist.get(0); if (_eventlist != null && _eventlist.size() > 0) { ip = (String) _eventlist.get(0); servicename = (String) _eventlist.get(1); sum = (String) _eventlist.get(2); levelone = (String) _eventlist.get(3); leveltwo = (String) _eventlist.get(4); levelthree = (String) _eventlist.get(5); } } Paragraph title = new Paragraph(servicename + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(6); // context.setFirstLineIndent(6); document.add(context); document.add(new Paragraph("\n")); PdfPTable servTable = new PdfPTable(6); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; servTable.setWidths(cellWidths); servTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // servTable.addCell(cell); cell = new PdfPCell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // servTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // servTable.addCell(cell); cell = new PdfPCell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // servTable.addCell(cell); cell = new PdfPCell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // servTable.addCell(cell); cell = new PdfPCell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // servTable.addCell(cell); cell = new PdfPCell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // servTable.addCell(cell); cell = new PdfPCell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // servTable.addCell(cell); cell = new PdfPCell(new Phrase(servicename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // servTable.addCell(cell); cell = new PdfPCell(new Phrase(sum, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // servTable.addCell(cell); cell = new PdfPCell(new Phrase(levelone, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // servTable.addCell(cell); cell = new PdfPCell(new Phrase(leveltwo, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // servTable.addCell(cell); cell = new PdfPCell(new Phrase(levelthree, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // servTable.addCell(cell); document.add(servTable); document.add(new Paragraph("\n")); // PdfPTable eventTable = new PdfPTable(6); float[] eventWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; eventTable.setWidths(eventWidths); eventTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); int index = 0; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); List list = (ArrayList) reportHash.get("list"); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { index++; EventList event = (EventList) list.get(i); Date cc = event.getRecordtime().getTime(); Integer eventid = event.getId(); String eventlocation = event.getEventlocation(); String content = event.getContent(); String level = String.valueOf(event.getLevel1()); String status = String.valueOf(event.getManagesign()); String s = status; String showlevel = null; String act = ""; if ("1".equals(level)) { showlevel = ""; } else if ("2".equals(level)) { showlevel = ""; } else { showlevel = ""; } if ("0".equals(status)) { status = ""; } if ("1".equals(status)) { status = ""; } if ("2".equals(status)) { status = ""; } String rptman = event.getReportman(); String rtime1 = _sdf.format(cc); cell = new PdfPCell(new Phrase(String.valueOf(index), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); if ("3".equals(level)) { cell = new PdfPCell(new Phrase(showlevel, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setBackgroundColor(Color.red); eventTable.addCell(cell); } else if ("2".equals(level)) { cell = new PdfPCell(new Phrase(showlevel, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setBackgroundColor(Color.orange); eventTable.addCell(cell); } else { cell = new PdfPCell(new Phrase(showlevel, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setBackgroundColor(Color.yellow); eventTable.addCell(cell); } cell = new PdfPCell(new Phrase(content, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(rtime1, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(rptman, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(status, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); } } document.add(eventTable); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author wxy word * @param filename * @throws IOException * @throws DocumentException * @date 2010-3-27 */ public void createReport_ServiceCompDoc(String filename) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String servicename = (String) reportHash.get("servicename"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); String Ping = (String) reportHash.get("Ping"); Hashtable ping = (Hashtable) reportHash.get("ping"); WebConfig config = (WebConfig) reportHash.get("webconfig"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); List comInfo = (List) reportHash.get("comInfo"); String type = (String) reportHash.get("type"); // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(servicename + ""); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); StringBuffer sb = new StringBuffer(); sb.append(":" + impReport.getTimeStamp() + " \n"); sb.append(":" + starttime + " " + totime + " \n"); if (comInfo != null) { for (int i = 0; i < comInfo.size(); i++) { sb.append(comInfo.get(i)); } } Paragraph context = new Paragraph(sb.toString()); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(4); float[] widths = { 220f, 300f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); aTable.addCell(""); aTable.addCell(""); aTable.addCell(""); aTable.addCell(""); aTable.addCell(""); aTable.addCell(Ping + "%"); aTable.addCell((String) ping.get("minPing") + "%"); aTable.addCell((String) ping.get("avgPing") + "%"); document.add(aTable); Image img1 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "pingConnect" + ".png"); if (type != null && type.equals("web")) { Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "delayConnect" + ".png"); Image img3 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "pageConnect" + ".png"); Image img4 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "changeConnect" + ".png"); document.add(img1); document.add(img2); document.add(img3); document.add(img4); } else { document.add(img1); } // img1.setAbsolutePosition(0, 0); // img1.setAlignment(Image.LEFT);// document.close(); } /** * @author Wxy add * @param filename * web */ public void createReport_ServiceCompExc(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String servicename = (String) reportHash.get("servicename"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(servicename + "", 0); String Ping = (String) reportHash.get("Ping"); Hashtable maxping = (Hashtable) reportHash.get("ping"); WebConfig config = (WebConfig) reportHash.get("webconfig"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); List comInfo = (List) reportHash.get("comInfo"); String type = (String) reportHash.get("type"); StringBuffer sb = new StringBuffer(); sb.append(":" + impReport.getTimeStamp() + " \n"); sb.append(":" + starttime + " " + totime + " \n"); if (comInfo != null) { for (int i = 0; i < comInfo.size(); i++) { sb.append(comInfo.get(i)); } } Label tmpLabel = null; tmpLabel = new Label(1, 0, servicename + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 3, sb.toString()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, Ping + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("minPing") + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, (String) maxping.get("avgPing") + "%", p_labelFormat); sheet.addCell(tmpLabel); // File file1 = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "pingConnect" + ".png"); sheet.addImage(new WritableImage(1, 6, 7, 7, file1)); if (type != null && type.equals("web")) { File file2 = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "delayConnect" + ".png"); File file3 = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "pageConnect" + ".png"); File file4 = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "changeConnect" + ".png"); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, 13, 7, 7, file2)); sheet.addImage(new WritableImage(1, 20, 7, 7, file3)); sheet.addImage(new WritableImage(1, 27, 7, 7, file4)); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * @author wxy add web * @param file * @throws DocumentException * @throws IOException */ public void createReport_ServiceCompPdf(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String servicename = (String) reportHash.get("servicename"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WebConfig config = (WebConfig) reportHash.get("webconfig"); String Ping = (String) reportHash.get("Ping"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(servicename + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); List comInfo = (List) reportHash.get("comInfo"); String type = (String) reportHash.get("type"); StringBuffer sb = new StringBuffer(); sb.append(":" + impReport.getTimeStamp() + " \n"); sb.append(":" + starttime + " " + totime + " \n"); if (comInfo != null) { for (int i = 0; i < comInfo.size(); i++) { sb.append(comInfo.get(i)); } } Paragraph context = new Paragraph(sb.toString(), contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Phrase("\n")); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); PdfPTable aTable = new PdfPTable(4); float[] widths = { 220f, 300f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(""); aTable.addCell(Ping + "%"); aTable.addCell((String) maxping.get("minPing") + "%"); aTable.addCell((String) maxping.get("avgPing") + "%"); document.add(aTable); Image img1 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "pingConnect" + ".png"); img1.setAlignment(Image.LEFT);// img1.scalePercent(75); document.add(img1); if (type != null && type.equals("web")) { Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "delayConnect" + ".png"); Image img3 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "pageConnect" + ".png"); Image img4 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "changeConnect" + ".png"); img2.setAlignment(Image.LEFT);// img2.scalePercent(75); img3.setAlignment(Image.LEFT);// img3.scalePercent(75); img4.setAlignment(Image.LEFT);// img4.scalePercent(75); document.add(img2); document.add(img3); document.add(img4); } document.close(); } public void createReport_capacityDoc(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + ""); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); // Image img = // Image.getInstance(ResourceCenter.getInstance().getSysPath() // + "/resource/image/jfreechart/" + newip + "ConnectUtilization" // + ".png"); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = ""; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); Table aTable1 = new Table(4); float[] width = { 220f, 300f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// aTable1.endHeaders(); aTable1.addCell("CPU"); aTable1.addCell(""); aTable1.addCell(""); aTable1.addCell(""); // aTable.addCell("3.2",Ping+"%"); aTable1.addCell(""); aTable1.addCell(cpu + "%"); aTable1.addCell(cpumax); aTable1.addCell(avgcpu); Image img1 = Image.getInstance( ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(aTable1); document.add(img1); if (Memory != null && Memory.size() > 0) { Table aTable2 = new Table(6); float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f }; aTable2.setWidths(widthss); aTable2.setWidth(100); // 90% aTable2.setAlignment(Element.ALIGN_CENTER);// aTable2.setAutoFillEmptyCells(true); // aTable2.setBorderWidth(1); // aTable2.setBorderColor(new Color(0, 125, 255)); // aTable2.setPadding(2);// aTable2.setSpacing(0);// aTable2.setBorder(2);// aTable2.endHeaders(); aTable2.addCell(""); aTable2.addCell(""); // for (int i = 0; i < memoryItemch.length; i++) { Cell cell = new Cell(memoryItemch[i]); aTable2.addCell(cell); } // for (int i = 0; i < Memory.size(); i++) { aTable2.addCell(""); Hashtable mhash = (Hashtable) (Memory.get(new Integer(i))); String name = (String) mhash.get("name"); Cell cell1 = new Cell(name); aTable2.addCell(cell1); for (int j = 0; j < memoryItem.length; j++) { String value = ""; if (mhash.get(memoryItem[j]) != null) { value = (String) mhash.get(memoryItem[j]); } Cell cell2 = new Cell(value); aTable2.addCell(cell2); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); Cell cell3 = new Cell(value); aTable2.addCell(cell3); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); aTable2.addCell(avgvalue); } } // end // Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); img2.setAbsolutePosition(0, 0); img2.setAlignment(Image.MIDDLE);// document.add(aTable2); document.add(img2); } else { Table aTable2 = new Table(6); float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f }; aTable2.setWidths(widthss); aTable2.setWidth(100); // 90% aTable2.setAlignment(Element.ALIGN_CENTER);// aTable2.setAutoFillEmptyCells(true); // aTable2.setBorderWidth(1); // aTable2.setBorderColor(new Color(0, 125, 255)); // aTable2.setPadding(2);// aTable2.setSpacing(0);// aTable2.setBorder(2);// aTable2.endHeaders(); aTable2.addCell(""); aTable2.addCell(""); // for (int i = 0; i < memoryItemch.length; i++) { Cell cell = new Cell(memoryItemch[i]); aTable2.addCell(cell); } // String[] names = null; HostNodeDao dao = new HostNodeDao(); HostNode node = (HostNode) dao.findByCondition("ip_address", ip).get(0); // Monitoriplist monitor = monitorManager.getByIpaddress(ip); if (node.getSysOid().startsWith("1.3.6.1.4.1.311")) { names = new String[] { "PhysicalMemory", "VirtualMemory" }; } else { names = new String[] { "PhysicalMemory", "SwapMemory" }; } for (int i = 0; i < names.length; i++) { String name = names[i]; aTable2.addCell(""); Cell cell = new Cell(names[i]); aTable2.addCell(cell); for (int j = 0; j < memoryItem.length; j++) { // String value = ""; Cell cell1 = new Cell(value); aTable2.addCell(cell1); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); Cell cell2 = new Cell(value); aTable2.addCell(cell2); } else { Cell cell3 = new Cell(value); aTable2.addCell(cell3); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); Cell cell4 = new Cell(avgvalue); aTable2.addCell(cell4); } else { Cell cell5 = new Cell(avgvalue); aTable2.addCell(cell5); } } // end // Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); img2.setAbsolutePosition(0, 0); img2.setAlignment(Image.MIDDLE);// document.add(aTable2); document.add(img2); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img3 = Image.getInstance(baos.toByteArray()); img3.setAbsolutePosition(0, 0); img3.setAlignment(Image.MIDDLE);// document.add(img3); } document.close(); } public void createReport_diskDoc(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); // Calendar colTime = (Calendar) reportHash.get("time"); // Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + ""); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); // Image img = // Image.getInstance(ResourceCenter.getInstance().getSysPath() // + "/resource/image/jfreechart/" + newip + "ConnectUtilization" // + ".png"); // img.setAbsolutePosition(0, 0); // img.setAlignment(Image.LEFT);// Table aTable3 = new Table(5); float[] widthss1 = { 220f, 440f, 150f, 150f, 220f }; aTable3.setWidths(widthss1); aTable3.setWidth(100); // 90% aTable3.setAlignment(Element.ALIGN_CENTER);// aTable3.setAutoFillEmptyCells(true); // aTable3.setBorderWidth(1); // aTable3.setBorderColor(new Color(0, 125, 255)); // aTable3.setPadding(2);// aTable3.setSpacing(0);// aTable3.setBorder(2);// aTable3.endHeaders(); if (Disk != null && Disk.size() > 0) { aTable3.addCell(""); aTable3.addCell(""); for (int i = 0; i < diskItemch.length; i++) { Cell cell = new Cell(diskItemch[i]); aTable3.addCell(cell); } // for (int i = 0; i < Disk.size(); i++) { aTable3.addCell(""); Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i))); String name = (String) diskhash.get("name"); Cell cell = new Cell(name); aTable3.addCell(cell); for (int j = 0; j < diskItem.length; j++) { String value = ""; if (diskhash.get(diskItem[j]) != null) { value = (String) diskhash.get(diskItem[j]); } Cell cell1 = new Cell(value); // System.out.println(value+"================value==============="); aTable3.addCell(cell1); } } // end // Image img3 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "disk" + ".png"); img3.setAbsolutePosition(0, 0); img3.setAlignment(Image.MIDDLE);// document.add(aTable3); document.add(img3); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img3 = Image.getInstance(baos.toByteArray()); img3.setAbsolutePosition(0, 0); img3.setAlignment(Image.MIDDLE);// document.add(img3); } document.close(); } public void createReport_analyseDoc(String file) throws DocumentException, IOException { } // zhushouzhidoc // --------------------------------------------------------------------------------- // PDF public void createReport_hostPDF(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Phrase("\n")); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(4); aTable.setAutoFillEmptyCells(true); aTable.setWidth(100); // float[] widths = { 220f, 300f, 220f, 220f }; // aTable.setWidths(widths); aTable.setPadding(5); // aTable.setWidthPercentage(100); Cell cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable.addCell(cell); aTable.addCell(Ping + "%"); aTable.addCell((String) maxping.get("pingmax")); aTable.addCell((String) maxping.get("avgpingcon")); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// img.scalePercent(75); document.add(aTable); document.add(img); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = ""; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); Table aTable1 = new Table(4); aTable1.setAutoFillEmptyCells(true); aTable1.setWidth(100); aTable1.setPadding(5); // float[] width = { 220f, 300f, 220f, 220f }; // aTable1.setWidths(width); // aTable1.setWidthPercentage(100); cell = new Cell(); cell.addElement(new Paragraph("CPU", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable1.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable1.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable1.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable1.addCell(cell); cell = new Cell(); cell.addElement(new Paragraph("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable1.addCell(cell); aTable1.addCell(cpu + "%"); aTable1.addCell(cpumax); aTable1.addCell(avgcpu); Image img1 = Image.getInstance( ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); img.setAlignment(Image.MIDDLE);// img1.scalePercent(75); document.add(aTable1); document.add(img1); if (Memory != null && Memory.size() > 0) { Table aTable2 = new Table(6); aTable2.setPadding(5); aTable2.setAutoFillEmptyCells(true); aTable2.setWidth(100); // float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f }; // aTable2.setWidths(widthss); // aTable2.setWidthPercentage(100); cell = new Cell(new Phrase("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable2.addCell(cell); // for (int i = 0; i < memoryItemch.length; i++) { cell = new Cell(new Phrase(memoryItemch[i], contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable2.addCell(cell); } // for (int i = 0; i < Memory.size(); i++) { aTable2.addCell(""); Hashtable mhash = (Hashtable) (Memory.get(new Integer(i))); String name = (String) mhash.get("name"); cell = new Cell(new Phrase(name)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(cell); for (int j = 0; j < memoryItem.length; j++) { String value = ""; if (mhash.get(memoryItem[j]) != null) { value = (String) mhash.get(memoryItem[j]); } cell = new Cell(new Phrase(value)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(cell); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); Cell cell3 = new Cell(new Phrase(value)); cell3.setHorizontalAlignment(Element.ALIGN_CENTER); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(cell3); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); cell = new Cell(new Phrase(avgvalue)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(cell); } } // end // Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); img.setAlignment(Image.MIDDLE);// img2.scalePercent(75); document.add(aTable2); document.add(img2); } else { Table aTable2 = new Table(6); float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f }; aTable2.setWidths(widthss); // aTable2.setWidthPercentage(100); /* * aTable2.setWidth(100); // 90% * aTable2.setAlignment(Element.ALIGN_CENTER);// * aTable2.setAutoFillEmptyCells(true); // * aTable2.setBorderWidth(1); // aTable2.setBorderColor(new * Color(0, 125, 255)); // aTable2.setPadding(2);// * aTable2.setSpacing(0);// * aTable2.setBorder(2);// aTable2.endHeaders(); */ cell = new Cell(new Phrase("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable2.addCell(cell); // for (int i = 0; i < memoryItemch.length; i++) { cell = new Cell(new Phrase(memoryItemch[i], contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(cell); } // String[] names = null; HostNodeDao dao = new HostNodeDao(); HostNode node = (HostNode) dao.findByCondition("ip_address", ip).get(0); // Monitoriplist monitor = monitorManager.getByIpaddress(ip); if (node.getSysOid().startsWith("1.3.6.1.4.1.311")) { names = new String[] { "PhysicalMemory", "VirtualMemory" }; } else { names = new String[] { "PhysicalMemory", "SwapMemory" }; } for (int i = 0; i < names.length; i++) { String name = names[i]; aTable2.addCell(""); cell = new Cell(new Phrase(names[i])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(cell); for (int j = 0; j < memoryItem.length; j++) { // String value = ""; cell = new Cell(new Phrase(value)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(cell); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); Cell cell2 = new Cell(new Phrase(value)); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(cell2); } else { Cell cell3 = new Cell(new Phrase(value)); cell3.setHorizontalAlignment(Element.ALIGN_CENTER); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(cell3); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); Cell cell4 = new Cell(new Phrase(avgvalue)); cell4.setHorizontalAlignment(Element.ALIGN_CENTER); cell4.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(cell4); } else { Cell cell5 = new Cell(new Phrase(avgvalue)); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(cell5); } } // end // Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); img.setAlignment(Image.MIDDLE);// img2.scalePercent(75); document.add(aTable2); document.add(img2); } Table aTable3 = new Table(5); aTable3.setAutoFillEmptyCells(true); aTable3.setPadding(5); aTable3.setWidth(100); // float[] widthss1 = { 220f, 440f, 150f, 150f, 220f }; // aTable3.setWidths(widthss1); // aTable3.setWidthPercentage(100); if (Disk != null && Disk.size() > 0) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable3.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable3.addCell(cell); for (int i = 0; i < diskItemch.length; i++) { cell = new Cell(new Phrase(diskItemch[i], contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable3.addCell(cell); } // for (int i = 0; i < Disk.size(); i++) { aTable3.addCell(""); Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i))); String name = (String) diskhash.get("name"); cell = new Cell(new Phrase(name)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable3.addCell(cell); for (int j = 0; j < diskItem.length; j++) { String value = ""; if (diskhash.get(diskItem[j]) != null) { value = (String) diskhash.get(diskItem[j]); } cell = new Cell(new Phrase(value)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable3.addCell(cell); } } // end // Image img3 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "disk" + ".png"); img3.setAlignment(Image.MIDDLE);// img3.scalePercent(78); document.add(aTable3); // document.add(new Paragraph("\n")); document.add(img3); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img3 = Image.getInstance(baos.toByteArray()); img3.setAlignment(Image.MIDDLE);// img3.scalePercent(76); document.add(new Paragraph("\n")); // document.add(aTable3); document.add(img3); } document.close(); } public void createReport_pingPDF(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Phrase("\n")); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); PdfPTable aTable = new PdfPTable(4); float[] widths = { 220f, 300f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); // aTable.addCell("3.2",Ping+"%"); aTable.addCell(""); aTable.addCell(Ping + "%"); aTable.addCell((String) maxping.get("pingmax")); aTable.addCell((String) maxping.get("avgpingcon")); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// img.scalePercent(75); document.add(aTable); document.add(img); document.close(); } public void createReport_capacityPDF(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Phrase("\n")); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = ""; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); PdfPTable aTable1 = new PdfPTable(4); float[] width = { 220f, 300f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); aTable1.addCell(new Phrase("CPU", contextFont)); aTable1.addCell(new Phrase("", contextFont)); aTable1.addCell(new Phrase("", contextFont)); aTable1.addCell(new Phrase("", contextFont)); // aTable.addCell("3.2",Ping+"%"); aTable1.addCell(""); aTable1.addCell(cpu + "%"); aTable1.addCell(cpumax); aTable1.addCell(avgcpu); Image img1 = Image.getInstance( ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); // img.setAlignment(Image.MIDDLE);// img1.scalePercent(75); document.add(aTable1); document.add(img1); if (Memory != null && Memory.size() > 0) { PdfPTable aTable2 = new PdfPTable(6); float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f }; aTable2.setWidths(widthss); aTable2.setWidthPercentage(100); aTable2.addCell(new Phrase("", contextFont)); aTable2.addCell(new Phrase("", contextFont)); // for (int i = 0; i < memoryItemch.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(memoryItemch[i], contextFont)); aTable2.addCell(cell); } // for (int i = 0; i < Memory.size(); i++) { aTable2.addCell(""); Hashtable mhash = (Hashtable) (Memory.get(new Integer(i))); String name = (String) mhash.get("name"); PdfPCell cell1 = new PdfPCell(new Phrase(name)); aTable2.addCell(cell1); for (int j = 0; j < memoryItem.length; j++) { String value = ""; if (mhash.get(memoryItem[j]) != null) { value = (String) mhash.get(memoryItem[j]); } PdfPCell cell2 = new PdfPCell(new Phrase(value)); aTable2.addCell(cell2); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); PdfPCell cell3 = new PdfPCell(new Phrase(value)); aTable2.addCell(cell3); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); aTable2.addCell(new Phrase(avgvalue)); } } // end // Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); // img.setAlignment(Image.MIDDLE);// img2.scalePercent(75); document.add(aTable2); document.add(img2); } else { PdfPTable aTable2 = new PdfPTable(6); float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f }; aTable2.setWidths(widthss); aTable2.setWidthPercentage(100); /* * aTable2.setWidth(100); // 90% * aTable2.setAlignment(Element.ALIGN_CENTER);// * aTable2.setAutoFillEmptyCells(true); // * aTable2.setBorderWidth(1); // aTable2.setBorderColor(new * Color(0, 125, 255)); // aTable2.setPadding(2);// * aTable2.setSpacing(0);// * aTable2.setBorder(2);// aTable2.endHeaders(); */ aTable2.addCell(new Phrase("", contextFont)); aTable2.addCell(new Phrase("", contextFont)); // for (int i = 0; i < memoryItemch.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(memoryItemch[i], contextFont)); aTable2.addCell(cell); } // String[] names = null; HostNodeDao dao = new HostNodeDao(); HostNode node = (HostNode) dao.findByCondition("ip_address", ip).get(0); // Monitoriplist monitor = monitorManager.getByIpaddress(ip); if (node.getSysOid().startsWith("1.3.6.1.4.1.311")) { names = new String[] { "PhysicalMemory", "VirtualMemory" }; } else { names = new String[] { "PhysicalMemory", "SwapMemory" }; } for (int i = 0; i < names.length; i++) { String name = names[i]; aTable2.addCell(""); PdfPCell cell = new PdfPCell(new Phrase(names[i])); aTable2.addCell(cell); for (int j = 0; j < memoryItem.length; j++) { // String value = ""; PdfPCell cell1 = new PdfPCell(new Phrase(value)); aTable2.addCell(cell1); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); PdfPCell cell2 = new PdfPCell(new Phrase(value)); aTable2.addCell(cell2); } else { PdfPCell cell3 = new PdfPCell(new Phrase(value)); aTable2.addCell(cell3); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); PdfPCell cell4 = new PdfPCell(new Phrase(avgvalue)); aTable2.addCell(cell4); } else { PdfPCell cell5 = new PdfPCell(new Phrase(avgvalue)); aTable2.addCell(cell5); } } // end // Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); // img.setAlignment(Image.MIDDLE);// img2.scalePercent(75); document.add(aTable2); document.add(img2); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img3 = Image.getInstance(baos.toByteArray()); img3.setAlignment(Image.MIDDLE);// img3.scalePercent(76); document.add(new Paragraph("\n")); // document.add(aTable3); document.add(img3); } document.close(); } public void createReport_diskPDF(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); // Calendar colTime = (Calendar) reportHash.get("time"); // Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Phrase("\n")); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); PdfPTable aTable = new PdfPTable(4); float[] widths = { 220f, 300f, 220f, 220f }; PdfPTable aTable3 = new PdfPTable(5); float[] widthss1 = { 220f, 440f, 150f, 150f, 220f }; aTable3.setWidths(widthss1); aTable3.setWidthPercentage(100); if (Disk != null && Disk.size() > 0) { aTable3.addCell(new Phrase("", contextFont)); aTable3.addCell(new Phrase("", contextFont)); for (int i = 0; i < diskItemch.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(diskItemch[i], contextFont)); aTable3.addCell(cell); } // for (int i = 0; i < Disk.size(); i++) { aTable3.addCell(""); Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i))); String name = (String) diskhash.get("name"); PdfPCell cell = new PdfPCell(new Phrase(name)); aTable3.addCell(cell); for (int j = 0; j < diskItem.length; j++) { String value = ""; if (diskhash.get(diskItem[j]) != null) { value = (String) diskhash.get(diskItem[j]); } PdfPCell cell1 = new PdfPCell(new Phrase(value)); aTable3.addCell(cell1); } } // end // Image img3 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "disk" + ".png"); img3.setAlignment(Image.MIDDLE);// img3.scalePercent(78); document.add(aTable3); // document.add(new Paragraph("\n")); document.add(img3); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img3 = Image.getInstance(baos.toByteArray()); img3.setAlignment(Image.MIDDLE);// img3.scalePercent(76); document.add(new Paragraph("\n")); // document.add(aTable3); document.add(img3); } document.close(); } // zhushouzhipdfs // ------------------------------------------------------------------------- // zhushouzhi------------------------------------------------start public void createReport_networkNewDoc(String file) throws DocumentException, IOException { Hashtable Memory = (Hashtable) reportHash.get("Memory"); // EventListDao eventListDao = new EventListDao(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable CPU = (Hashtable) reportHash.get("CPU"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; if (CPU == null) CPU = new Hashtable(); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = ""; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String equipnameNetDoc = (String) reportHash.get("equipnameNetDoc"); String startdate = (String) reportHash.get("startdate"); String todate = (String) reportHash.get("todate"); String starttime = (String) reportHash.get("starttime"); String avginput = (String) reportHash.get("avginput"); String avgoutput = (String) reportHash.get("avgoutput"); String maxinput = (String) reportHash.get("maxinput"); String maxoutput = (String) reportHash.get("maxoutput"); int updownvalue = ((Integer) reportHash.get("updownvalue")).intValue(); int utilvalue = ((Integer) reportHash.get("utilvalue")).intValue(); int pingvalue = ((Integer) reportHash.get("pingvalue")).intValue(); int cpuvalue = ((Integer) reportHash.get("cpuvalue")).intValue(); Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.BOLD); Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); /* cell.setVerticalAlignment(Element.ALIGN_CENTER); */ aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable.addCell(cell); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell = new Cell(new Phrase("\n" + starttime + " " + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipnameNetDoc, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase("\n" + grade + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "CPU" + "\n", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell.setBackgroundColor(Color.LIGHT_GRAY); cell = new Cell(new Phrase(avgcpu, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("CPU", contextFont)); cell.setColspan(2); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cpumax, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "(KB/S)" + "\n", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + avginput.replace(".0", ""), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(KB/S)", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + maxinput.replace(".0", ""), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + avgoutput.replace(".0", ""), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + maxoutput.replace(".0", ""), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + pingvalue + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "CPU" + cpuvalue + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + updownvalue + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + utilvalue + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String strcpu = ""; String strutil = ""; String strping = ""; String strupdown = ""; if (cpuvalue > 0) { strcpu = " 2 " + cpuvalue + "CPU" + "\n" + "\n"; } else { strcpu = " 2 CPU" + " \n" + "\n"; } if (utilvalue > 0) { strutil = "3 " + utilvalue + "" + "\n" + "\n"; } else { strutil = " 3 " + "\n" + "\n"; } if (updownvalue > 0) { strupdown = " 4 " + updownvalue + "" + "\n" + "\n"; } else { strupdown = " 4 " + "\n" + "\n"; } if (pingvalue > 0) { strping = " 5 " + pingvalue + ""; } else { strping = " 5 "; } cell = new Cell(new Phrase(" 1 " + " \n" + "\n" + strcpu + strutil + strupdown + strping + "\n" + "\n" + "\n", contextFont1) ); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } // ---------------------------------------------- // zhushouzhi------------------------------------------------start public void createReport_networkNewPdf(String file) throws DocumentException, IOException { Hashtable Memory = (Hashtable) reportHash.get("Memory"); // EventListDao eventListDao = new EventListDao(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable CPU = (Hashtable) reportHash.get("CPU"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; if (CPU == null) CPU = new Hashtable(); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = ""; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String equipnameNetDoc = (String) reportHash.get("equipnameNetDoc"); String startdate = (String) reportHash.get("startdate"); String todate = (String) reportHash.get("todate"); String starttime = (String) reportHash.get("starttime"); String avginput = (String) reportHash.get("avginput"); String avgoutput = (String) reportHash.get("avgoutput"); String maxinput = (String) reportHash.get("maxinput"); String maxoutput = (String) reportHash.get("maxoutput"); int updownvalue = ((Integer) reportHash.get("updownvalue")).intValue(); int utilvalue = ((Integer) reportHash.get("utilvalue")).intValue(); int pingvalue = ((Integer) reportHash.get("pingvalue")).intValue(); int cpuvalue = ((Integer) reportHash.get("cpuvalue")).intValue(); Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont2 = new Font(bfChinese, 10, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); aTable.setWidths(widths); Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); /* cell.setVerticalAlignment(Element.ALIGN_CENTER); */ aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable.addCell(cell); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell = new Cell(new Phrase("\n" + starttime + " " + totime + "\n", contextFont2)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipnameNetDoc, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase("\n" + grade + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "CPU" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(avgcpu, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("CPU", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cpumax, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "(KB/S)" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + avginput.replace(".0", ""), contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(KB/S)", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + maxinput.replace(".0", ""), contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + avgoutput.replace(".0", ""), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + maxoutput.replace(".0", ""), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + pingvalue + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "CPU" + cpuvalue + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + updownvalue + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + utilvalue + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String strcpu = ""; String strutil = ""; String strping = ""; String strupdown = ""; if (cpuvalue > 0) { strcpu = " 2 " + cpuvalue + "CPU" + "\n" + "\n"; } else { strcpu = " 2 CPU" + " \n" + "\n"; } if (utilvalue > 0) { strutil = "3 " + utilvalue + "" + "\n" + "\n"; } else { strutil = " 3 " + "\n" + "\n"; } if (updownvalue > 0) { strupdown = " 4 " + updownvalue + "" + "\n" + "\n"; } else { strupdown = " 4 " + "\n" + "\n"; } if (pingvalue > 0) { strping = " 5 " + pingvalue + ""; } else { strping = " 5 "; } cell = new Cell(new Phrase(" 1 " + " \n" + "\n" + strcpu + strutil + strupdown + strping + "\n" + "\n" + "\n", contextFont) ); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } // zhushouzhi-----------------------end // -------------------------------------------------------------------- // zhushouzhiPDF public void createReport_networkPDF(String file) throws DocumentException, IOException { String runmodel = PollingEngine.getCollectwebflag(); Hashtable CPU = (Hashtable) reportHash.get("CPU"); String Ping = (String) reportHash.get("Ping"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Vector netifVector = (Vector) reportHash.get("netifVector"); Hashtable portconfigHash = (Hashtable) reportHash.get("portconfigHash"); List reportports = (List) reportHash.get("reportports"); Vector iprouterVector = (Vector) reportHash.get("iprouterVector"); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); String hostname = (String) reportHash.get("equipname"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] netIfItemch = { "", "", "", "(M)(KB/S)", "", "(KB/S)", "(KB/S)" }; String[] ipRouterItemch = { "", "", "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization", "INodeUsedSize", "INodeUtilization" }; String[] diskItemch = { "", "", "", "i-node", "i-node" }; String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" }; String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)", "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)", "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); BaseFont bfChinese1 = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + sdf.format(cc); Paragraph context = new Paragraph(new Phrase(contextString, titleFont)); // context.setAlignment(Element.ALIGN_CENTER); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); // Table Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(4); // PdfPTable pdfPTable = new PdfPTable(aTable); // float[] widths = { 220f, 300f, 220f, 220f }; // aTable.setWidths(widths); // aTable.setWidthPercentage(100); aTable.setWidth(100); // aTable.setPadding(5); aTable.setAutoFillEmptyCells(true); Cell pc1 = new Cell(new Phrase("", contextFont)); // pc1.setRowspan(2); Cell pc2 = new Cell(new Phrase("", contextFont)); Cell pc3 = new Cell(new Phrase("", contextFont)); Cell pc4 = new Cell(new Phrase("", contextFont)); pc1.setBackgroundColor(Color.LIGHT_GRAY); pc2.setBackgroundColor(Color.LIGHT_GRAY); pc3.setBackgroundColor(Color.LIGHT_GRAY); pc4.setBackgroundColor(Color.LIGHT_GRAY); aTable.addCell(pc1); aTable.addCell(pc2); aTable.addCell(pc3); aTable.addCell(pc4); // aTable.addCell("3.2",Ping+"%"); aTable.addCell(""); aTable.addCell(Ping + "%"); aTable.addCell((String) maxping.get("pingmax")); aTable.addCell((String) maxping.get("avgpingcon")); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // document.add(new Paragraph("\n")); // document.close(); Table aTable1 = new Table(4); aTable1.setWidth(100); // aTable1.setPadding(5); aTable1.setAutoFillEmptyCells(true); // float[] width = { 220f, 300f, 220f, 220f }; // aTable1.setWidths(width); // aTable1.setWidthPercentage(100); // aTable.addCell("3.2",Ping+"%"); pc1 = new Cell(new Phrase("CPU", contextFont)); // pc1.setRowspan(2); pc2 = new Cell(new Phrase("", contextFont)); pc3 = new Cell(new Phrase("", contextFont)); pc4 = new Cell(new Phrase("", contextFont)); pc1.setBackgroundColor(Color.LIGHT_GRAY); pc2.setBackgroundColor(Color.LIGHT_GRAY); pc3.setBackgroundColor(Color.LIGHT_GRAY); pc4.setBackgroundColor(Color.LIGHT_GRAY); aTable1.addCell(pc1); aTable1.addCell(pc2); aTable1.addCell(pc3); aTable1.addCell(pc4); aTable1.addCell(""); aTable1.addCell((String) CPU.get("cpu") + "%"); aTable1.addCell((String) CPU.get("cpumax")); aTable1.addCell((String) CPU.get("avgcpu")); Image img1 = Image.getInstance( ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); // img.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// img1.scalePercent(76); document.add(aTable1); document.add(img1); document.add(new Paragraph("\n")); if (netifVector != null && netifVector.size() > 0) { Table aTable2 = new Table(8); aTable2.setWidth(100); // aTable2.setPadding(5); aTable2.setAutoFillEmptyCells(true); // float[] width2 = { 300f, 220f, 220f, 180f, 300f, 180f, 220f, 220f // }; // aTable2.setWidths(width2); // aTable2.setWidthPercentage(100); // aTable2.setHeaderRows(1); Cell ct = new Cell(new Phrase("", contextFont)); // ct.setRowspan(netifVector.size() + 1); ct.setBackgroundColor(Color.lightGray); ct.setHorizontalAlignment(Element.ALIGN_CENTER); ct.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(ct); // // allRow = allRow; Color color = new Color(204, 204, 255); for (int i = 0; i < netIfItemch.length; i++) { Cell cell = new Cell(new Paragraph(netIfItemch[i], contextFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable2.addCell(cell); } // for (int i = 0; i < netifVector.size(); i++) { aTable2.addCell(""); String[] strs = (String[]) netifVector.get(i); String ifname = strs[1]; String index = strs[0]; for (int j = 0; j < strs.length; j++) { if (j == 1) { String linkuse = ""; if (portconfigHash != null && portconfigHash.size() > 0) { if (portconfigHash.get(ip + ":" + index) != null) linkuse = (String) portconfigHash.get(ip + ":" + index); } Cell cell1 = new Cell(new Phrase(strs[j], contextFont)); Cell cell2 = new Cell(new Phrase(linkuse, contextFont)); cell1.setLeading(6); cell2.setLeading(6); if (i % 2 != 0) { cell1.setBackgroundColor(color); cell2.setBackgroundColor(color); } aTable2.addCell(cell1); aTable2.addCell(cell2); } else if (j > 1) { Cell cell3 = new Cell(new Phrase(strs[j].replace("KB/", ""), contextFont)); cell3.setLeading(6); if (i % 2 != 0) { cell3.setBackgroundColor(color); } aTable2.addCell(cell3); } else { Cell cell4 = new Cell(new Phrase(strs[j].replace("KB/", ""), contextFont)); cell4.setLeading(6); if (i % 2 != 0) { cell4.setBackgroundColor(color); } aTable2.addCell(cell4); } } // end } document.add(aTable2); document.add(new Paragraph("\n")); } if ("0".equals(runmodel)) { // if (iprouterVector != null && iprouterVector.size() > 0) { PdfPTable aTable3 = new PdfPTable(7); float[] width2 = { 240f, 170f, 310f, 300f, 220f, 180f, 330f }; aTable3.setWidths(width2); aTable3.setWidthPercentage(100); aTable3.setHeaderRows(1); aTable3.addCell(new Phrase("", contextFont)); // // allRow = allRow+1; for (int i = 0; i < ipRouterItemch.length; i++) { aTable3.addCell(new Phrase(ipRouterItemch[i], contextFont)); } // for (int i = 0; i < iprouterVector.size(); i++) { aTable3.addCell(" "); IpRouter iprouter = (IpRouter) iprouterVector.get(i); aTable3.addCell(iprouter.getIfindex()); aTable3.addCell(iprouter.getDest()); aTable3.addCell(iprouter.getNexthop()); aTable3.addCell(iproutertype[Integer.parseInt(iprouter.getType().longValue() + "")]); aTable3.addCell(iprouterproto[Integer.parseInt(iprouter.getProto().longValue() + "")]); aTable3.addCell(iprouter.getMask()); } document.add(aTable3); document.add(new Paragraph("\n")); } } else { // List routerList = (ArrayList) reportHash.get("routerList"); if (routerList != null) { PdfPTable aTable3 = new PdfPTable(7); float[] width2 = { 240f, 170f, 310f, 300f, 220f, 180f, 330f }; aTable3.setWidths(width2); aTable3.setWidthPercentage(100); aTable3.setHeaderRows(1); aTable3.addCell(new Phrase("", contextFont)); // // allRow = allRow+1; for (int i = 0; i < ipRouterItemch.length; i++) { aTable3.addCell(new Phrase(ipRouterItemch[i], contextFont)); } for (int i = 0; i < routerList.size(); i++) { RouterNodeTemp iprouter = (RouterNodeTemp) routerList.get(i); aTable3.addCell(" "); aTable3.addCell(iprouter.getIfindex()); aTable3.addCell(iprouter.getDest()); aTable3.addCell(iprouter.getNexthop()); aTable3.addCell(iprouter.getType()); aTable3.addCell(iprouter.getProto()); aTable3.addCell(iprouter.getMask()); } document.add(aTable3); document.add(new Paragraph("\n")); } } // doc if (reportports != null && reportports.size() > 0) { // // aTable4.addCell(""); for (int i = 0; i < reportports.size(); i++) { PdfPTable aTable4 = new PdfPTable(2); float[] width2 = { 600f, 300f }; aTable4.setWidths(width2); aTable4.setWidthPercentage(100); com.afunms.config.model.Portconfig portconfig = (com.afunms.config.model.Portconfig) reportports .get(i); Phrase phrase = new Phrase("", contextFont); Phrase phrase1 = new Phrase(portconfig.getPortindex() + "(" + portconfig.getName() + ")"); Phrase phrase2 = new Phrase("", contextFont); aTable4.addCell(new Phrase("" + portconfig.getPortindex() + "(" + portconfig.getName() + ")", contextFont)); // aTable4.addCell(new Phrase(phrase++ portconfig.getPortindex() // + "("+ portconfig.getName() +phrase2)); if (portconfig.getLinkuse() == null) portconfig.setLinkuse(""); /* * Cell cell1 = new Cell(new Phrase(":"+ * portconfig.getLinkuse(),contextFont)); */ aTable4.addCell(new Phrase(":" + portconfig.getLinkuse(), contextFont)); document.add(aTable4); // Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + portconfig.getPortindex() + "ifspeed_day.png"); // img2.setAbsolutePosition(0, 0); img2.setAlignment(Image.LEFT);// // sheet,0,0,5,1,,, img2.scalePercent(67); document.add(img2); } } // if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); Image img2 = Image.getInstance(baos.toByteArray()); // img.setAbsolutePosition(0, 0); img2.setAlignment(Image.LEFT);// img2.scalePercent(67); document.add(img2); } document.close(); } // ------------------------------------------ public void createReport_networkchoce(String starttime, String totime, String file, String username, String positionname) throws DocumentException, IOException { Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; /* * String starttime = (String) reportHash.get("starttime"); String * totime = (String) reportHash.get("totime"); */ Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont1 = new Font(bfChinese, 14, Font.BOLD); Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); String runAppraise = ""; if (dataHash.containsKey("runAppraise")) { runAppraise = (String) dataHash.get("runAppraise"); } try { fileName = ResourceCenter.getInstance().getSysPath() + file; Table aTable = new Table(15); float[] widths = { 60f, 60f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont1)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(15); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(""); cell = new Cell("" + starttime + "" + totime); cell.setColspan(14); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(username, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setColspan(3); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(positionname, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setColspan(3); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); aTable.addCell(cell); cell = new Cell(runAppraise); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setColspan(4); aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(3 + allreporthash.size()); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("CPU(%)", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(KB/S)", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); fileName = ResourceCenter.getInstance().getSysPath() + file; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; while (keys.hasNext()) { ip = keys.next().toString(); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("equipname"); // WritableSheet sheet = wb.createSheet(hostname+"", // sheetNum); Hashtable CPU = (Hashtable) report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); // Hashtable maxping = (Hashtable) // report_has.get("maxping"); String newip = doip(ip); Calendar colTime = Calendar.getInstance(); Date cc = colTime.getTime(); Vector netifVector = (Vector) report_has.get("netifVector"); Hashtable portconfigHash = (Hashtable) report_has.get("portconfigHash"); List reportports = (List) report_has.get("reportports"); Vector iprouterVector = (Vector) report_has.get("iprouterVector"); Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] netIfItemch = { "", "", "", "(M)", "", "", "" }; String[] ipRouterItemch = { "", "", "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization", "INodeUsedSize", "INodeUtilization" }; String[] diskItemch = { "", "", "", "i-node", "i-node" }; String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" }; String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)", "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)", "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" }; String avginput = (String) report_has.get("avginput"); String avgoutput = (String) report_has.get("avgoutput"); String maxinput = (String) report_has.get("maxinput"); String maxoutput = (String) report_has.get("maxoutput"); String levelone = (String) report_has.get("levelone"); String levletwo = (String) report_has.get("levletwo"); String levelthree = (String) report_has.get("levelthree"); /* * String starttime = (String)report_has.get("starttime"); * String totime = (String)report_has.get("totime"); */ cell = new Cell(ip); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(hostname); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(""); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell((String) CPU.get("avgcpu")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell((String) CPU.get("cpumax")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(""); aTable.addCell(cell); cell = new Cell(""); aTable.addCell(cell); cell = new Cell(avgoutput.replace(".0", "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(maxoutput.replace(".0", "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(avginput.replace(".0", "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(maxinput.replace(".0", "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(levelone); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(levletwo); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(levelthree); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); /* * cell = (Cell)aTable.getElement(1, 1); cell.add(new * Phrase(""+starttime+""+totime,contextFont)); */ } } cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setColspan(15); aTable.addCell(cell); String businessAnalytics = ""; if (dataHash.containsKey("businessAnalytics")) { businessAnalytics = (String) dataHash.get("businessAnalytics"); } cell = new Cell(businessAnalytics); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setColspan(15); cell.setRowspan(6); aTable.addCell(cell); document.add(aTable); document.close(); } catch (Exception e) { SysLogger.error("", e); } } // zhushouzhi // zhushouzhi--------------------------------host-choce public void createReport_hostchoce(String starttime, String totime, String file, String username, String positionname) throws DocumentException, IOException { Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont1 = new Font(bfChinese, 14, Font.BOLD); Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 14, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); fileName = ResourceCenter.getInstance().getSysPath() + file; Table aTable = new Table(13); float[] widths = { 60f, 100f, 30f, 30f, 30f, 30f, 30f, 30f, 50f, 50f, 30f, 30f, 30f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont1)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(13); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(""); cell = new Cell(new Phrase("" + starttime + "" + totime, contextFont)); cell.setColspan(12); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(new Phrase(username,contextFont)); cell = new Cell(new Phrase(username, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setColspan(4); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(new Phrase(positionname,contextFont)); cell = new Cell(new Phrase(positionname, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setColspan(4); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String runAppraise = ""; if (dataHash.containsKey("runAppraise")) { runAppraise = (String) dataHash.get("runAppraise"); } // cell = new Cell(new Phrase(positionname,contextFont)); cell = new Cell(new Phrase(runAppraise, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(2 + allreporthash.size()); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("CPU(%)", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("TOP", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(2); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); java.text.NumberFormat formate = java.text.NumberFormat.getNumberInstance(); formate.setMaximumFractionDigits(0);// fileName = ResourceCenter.getInstance().getSysPath() + file; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); String hostname = (String) report_has.get("equipname"); Hashtable CPU = (Hashtable) report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); Calendar colTime = (Calendar) report_has.get("time"); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) report_has.get("Memory"); Hashtable Disk = (Hashtable) report_has.get("Disk"); Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) report_has.get("memavghash"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "c" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization", "Utilizationvalue" }; String[] diskItemch = { "", "", "" }; String levelone = (String) report_has.get("levelone"); String levletwo = (String) report_has.get("levletwo"); String levelthree = (String) report_has.get("levelthree"); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ======= String string1 = ((String) maxping.get("pingmax")).replace("%", ""); String string2 = ((String) maxping.get("avgpingcon")).replace("%", ""); // formate.format(Double.valueOf(string1)); // System.out.println(formate.format(Double.valueOf(string))+"@@@@@@@0000000000"); cell = new Cell(new Phrase(formate.format(Double.valueOf(string1)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formate.format(Double.valueOf(string2)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = ""; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); String string3 = avgcpu.replace("%", ""); String string4 = cpumax.replace("%", ""); cell = new Cell(new Phrase(formate.format(Double.valueOf(string3)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formate.format(Double.valueOf(string4)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String avgvalue = "0.0%"; if (memAvgHash.get("PhysicalMemory") != null) { avgvalue = (String) memAvgHash.get("PhysicalMemory"); String string5 = avgvalue.replace("%", ""); cell = new Cell(new Phrase(formate.format(Double.valueOf(string5)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } else { String string5 = avgvalue.replace("%", ""); cell = new Cell(new Phrase(formate.format(Double.valueOf(string5)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } String value = "0.0%"; if (memMaxHash.get("PhysicalMemory") != null) { value = (String) memMaxHash.get("PhysicalMemory"); String string6 = value.replace("%", ""); cell = new Cell(new Phrase(formate.format(Double.valueOf(string6)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } else { String string6 = value.replace("%", ""); cell = new Cell(new Phrase(formate.format(Double.valueOf(string6)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } String value1 = "0"; String name = ""; String Utilization = ""; if (Disk != null && Disk.size() > 0) { for (int i = 0; i < Disk.size(); i++) { Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i))); if (diskhash.get(diskItem[3]) != null) { if (value1.compareTo((String) diskhash.get(diskItem[3])) < 0) { value1 = (String) diskhash.get(diskItem[3]); name = (String) diskhash.get("name"); Utilization = (String) diskhash.get(diskItem[2]); } } } cell = new Cell(name + " " + Utilization); cell.setColspan(2); aTable.addCell(cell); } else { cell = new Cell("---"); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase(levelone, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(levletwo, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(levelthree, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } cell = new Cell(new Phrase("", titleFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(13); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String businessAnalytics = ""; if (dataHash.containsKey("businessAnalytics")) { businessAnalytics = (String) dataHash.get("businessAnalytics"); } cell = new Cell(businessAnalytics); cell.setColspan(13); cell.setRowspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); document.add(aTable); document.close(); } // ==============================ora public void createReport_oraDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // HONGLI MODIFY START1 Table aTable1 = new Table(12); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START1 cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END1 cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 aTable1.addCell(""); row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase(rowStr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(_filename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(tablespace, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(size, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(free, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(percent, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START4 cell = new Cell(new Phrase(pyr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pyw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END4 cell = new Cell(new Phrase(status, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author HONGLI oracleword * @param filename * @throws DocumentException * @throws IOException */ public void createReportOracleCldDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidth(100); // 90% dbTable.setAlignment(Element.ALIGN_CENTER);// dbTable.setAutoFillEmptyCells(true); // dbTable.setBorderWidth(1); // dbTable.setBorderColor(new Color(0, 125, 255)); // dbTable.setPadding(2);// dbTable.setSpacing(0);// dbTable.setBorder(2);// dbTable.endHeaders(); Cell dbCell = null; dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("IP", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(vo.getDbName(), contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(ip, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(typename, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(runstr, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(grade, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingnow + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingmin + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingconavg + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(dbTable); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // Table dbInfoTable = new Table(6); float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; dbInfoTable.setWidths(dbInfoWidths); dbInfoTable.setWidth(100); // 90% dbInfoTable.setAlignment(Element.ALIGN_CENTER);// dbInfoTable.setAutoFillEmptyCells(true); // dbInfoTable.setBorderWidth(1); // dbInfoTable.setBorderColor(new Color(0, 125, 255)); // dbInfoTable.setPadding(2);// dbInfoTable.setSpacing(0);// dbInfoTable.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); String buffercache = "0";// String dictionarycache = "0";// String librarycache = "0";// String pctmemorysorts = "0";// String pctbufgets = "0";// 10 String opencurstr = "0";// Hashtable memPerfValue = (Hashtable) reportHash.get("memPerfValue"); Hashtable memValue = (Hashtable) reportHash.get("memValue"); Hashtable cursors = (Hashtable) reportHash.get("cursors"); if (cursors == null) { cursors = new Hashtable(); } if (memPerfValue == null) memPerfValue = new Hashtable(); if (memPerfValue != null) { if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) { buffercache = (String) memPerfValue.get("buffercache") + "%"; } if (memPerfValue.containsKey("dictionarycache") && memPerfValue.get("dictionarycache") != null) { dictionarycache = (String) memPerfValue.get("dictionarycache") + "%"; } if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) { librarycache = (String) memPerfValue.get("librarycache") + "%"; } if (memPerfValue.containsKey("pctmemorysorts") && memPerfValue.get("pctmemorysorts") != null) { pctmemorysorts = (String) memPerfValue.get("pctmemorysorts") + "%"; } if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) { pctbufgets = (String) memPerfValue.get("pctbufgets") + "%"; } if (cursors.containsKey("opencur") && cursors.get("opencur") != null) { opencurstr = (String) cursors.get("opencur"); } } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase("10", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(buffercache, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(dictionarycache, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(librarycache, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(pctmemorysorts, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(pctbufgets, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(opencurstr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); document.add(dbInfoTable); // String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String[] sysItemch1 = { "", "", "", "Java" }; String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated" }; String[] sysItemch2 = { "PGA", "PGA", "PGA" }; Table ncTable = new Table(7); float[] ncWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 ncTable.setWidths(ncWidths); ncTable.setWidth(100); // 90% ncTable.setAlignment(Element.ALIGN_CENTER);// ncTable.setAutoFillEmptyCells(true); // ncTable.setBorderWidth(1); // ncTable.setBorderColor(new Color(0, 125, 255)); // ncTable.setPadding(2);// ncTable.setSpacing(0);// ncTable.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[0], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[1], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[2], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[0], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[1], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[2], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[3], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[0]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[1]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[2]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[0]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[1]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[2]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[3]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); document.add(ncTable); // HONGLI MODIFY START1 Table aTable1 = new Table(11); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(11); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START1 cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END1 cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase(rowStr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(_filename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(tablespace, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(size, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(free, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(percent, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START4 cell = new Cell(new Phrase(pyr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pyw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END4 cell = new Cell(new Phrase(status, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } document.add(aTable1); // Table evenInfoTable = new Table(2); float[] evenInfoWidths = { 220f, 220f }; evenInfoTable.setWidths(evenInfoWidths); evenInfoTable.setWidth(100); // 90% evenInfoTable.setAlignment(Element.ALIGN_CENTER);// evenInfoTable.setAutoFillEmptyCells(true); // evenInfoTable.setBorderWidth(1); // evenInfoTable.setBorderColor(new Color(0, 125, 255)); // evenInfoTable.setPadding(2);// evenInfoTable.setSpacing(0);// evenInfoTable.setBorder(2);// String downnum = (String) reportHash.get("downnum"); String count = String.valueOf(reportHash.get("count")); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase(downnum, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase(count, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); document.add(evenInfoTable); addEventListToDoc(document, titleFont, contextFont); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author HONGLI oraclepdf * @param filename * @throws DocumentException * @throws IOException */ public void createReportOracleCldPdf(String filename, String type) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); this.setTableFormat(dbTable); Cell dbCell = null; dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(vo.getDbName(), contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(ip, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(typename, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(runstr, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(grade, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); Table aTable = new Table(3); this.setTableFormat(aTable); // float[] widths = { 220f, 220f, 220f }; // aTable.setWidths(widths); // aTable.setWidthPercentage(100); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(pingnow + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingmin + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingconavg + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // img.setAbsolutePosition(0, 0); img.scalePercent(76); img.setAlignment(Image.MIDDLE);// document.add(dbTable); document.add(new Paragraph("\n")); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // Table dbInfoTable = new Table(6); this.setTableFormat(dbInfoTable); // float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; // dbInfoTable.setWidths(dbInfoWidths); // dbInfoTable.setWidthPercentage(100); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); cell.setColspan(6); dbInfoTable.addCell(cell); String buffercache = "0";// String dictionarycache = "0";// String librarycache = "0";// String pctmemorysorts = "0";// String pctbufgets = "0";// 10 String opencurstr = "0";// Hashtable memPerfValue = (Hashtable) reportHash.get("memPerfValue"); Hashtable memValue = (Hashtable) reportHash.get("memValue"); Hashtable cursors = (Hashtable) reportHash.get("cursors"); if (cursors == null) { cursors = new Hashtable(); } if (memPerfValue == null) memPerfValue = new Hashtable(); if (memPerfValue != null) { if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) { buffercache = (String) memPerfValue.get("buffercache") + "%"; } if (memPerfValue.containsKey("dictionarycache") && memPerfValue.get("dictionarycache") != null) { dictionarycache = (String) memPerfValue.get("dictionarycache") + "%"; } if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) { librarycache = (String) memPerfValue.get("librarycache") + "%"; } if (memPerfValue.containsKey("pctmemorysorts") && memPerfValue.get("pctmemorysorts") != null) { pctmemorysorts = (String) memPerfValue.get("pctmemorysorts") + "%"; } if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) { pctbufgets = (String) memPerfValue.get("pctbufgets") + "%"; } if (cursors.containsKey("opencur") && cursors.get("opencur") != null) { opencurstr = (String) cursors.get("opencur"); } } cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("10", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(buffercache, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(dictionarycache, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(librarycache, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(pctmemorysorts, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(pctbufgets, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(opencurstr, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); document.add(dbInfoTable); document.add(new Paragraph("\n")); // String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String[] sysItemch1 = { "", "", "", "Java" }; String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated" }; String[] sysItemch2 = { "PGA", "PGA", "PGA" }; Table ncTable = new Table(7); this.setTableFormat(ncTable); // float[] ncWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 // ncTable.setWidths(ncWidths); // ncTable.setWidthPercentage(100); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(7); this.setCellFormat(cell, true); ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[0], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[1], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[2], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[0], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[1], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[2], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[3], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[0]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[1]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[2]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[0]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[1]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[2]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[3]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); document.add(ncTable); document.add(new Paragraph("\n")); // HONGLI MODIFY START1 Table aTable1 = new Table(11); float[] arg0 = { 10f, 20f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f }; aTable1.setWidths(arg0); this.setTableFormat(aTable1); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(11); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // HONGLI ADD START1 cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // HONGLI ADD END1 cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // aTable1.endHeaders(); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase(rowStr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(_filename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(tablespace, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(size, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(free, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(percent, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START4 cell = new Cell(new Phrase(pyr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pyw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END4 cell = new Cell(new Phrase(status, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } document.add(aTable1); // document.add(new Paragraph("\n")); Table eventTable = new Table(2); this.setTableFormat(eventTable); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase((String) reportHash.get("downnum"), contextFont)); this.setCellFormat(cell, false); eventTable.addCell(cell); cell = new Cell(new Phrase(reportHash.get("count") + "", contextFont)); this.setCellFormat(cell, false); eventTable.addCell(cell); document.add(eventTable); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(new Paragraph("\n")); // addEventLisToPdf(document); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author HONGLI oracleexcel * @param filename * @throws DocumentException * @throws IOException */ public void createReportOracleCldExcel(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String[] sysItemch1 = { "", "", "", "Java" }; String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated" }; String[] sysItemch2 = { "PGA", "PGA", "PGA" }; String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String buffercache = "0";// String dictionarycache = "0";// String librarycache = "0";// String pctmemorysorts = "0";// String pctbufgets = "0";// 10 String opencurstr = "0";// Hashtable memPerfValue = (Hashtable) reportHash.get("memPerfValue"); Hashtable memValue = (Hashtable) reportHash.get("memValue"); Hashtable cursors = (Hashtable) reportHash.get("cursors"); if (cursors == null) { cursors = new Hashtable(); } if (memPerfValue == null) memPerfValue = new Hashtable(); if (memPerfValue != null) { if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) { buffercache = (String) memPerfValue.get("buffercache") + "%"; } if (memPerfValue.containsKey("dictionarycache") && memPerfValue.get("dictionarycache") != null) { dictionarycache = (String) memPerfValue.get("dictionarycache") + "%"; } if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) { librarycache = (String) memPerfValue.get("librarycache") + "%"; } if (memPerfValue.containsKey("pctmemorysorts") && memPerfValue.get("pctmemorysorts") != null) { pctmemorysorts = (String) memPerfValue.get("pctmemorysorts") + "%"; } if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) { pctbufgets = (String) memPerfValue.get("pctbufgets") + "%"; } if (cursors.containsKey("opencur") && cursors.get("opencur") != null) { opencurstr = (String) cursors.get("opencur"); } } Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 10, 0); sheet.mergeCells(0, 1, 10, 1); sheet.mergeCells(0, 2, 10, 2); // ip tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 4, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 4, 1, 4); sheet.mergeCells(2, 4, 3, 4); sheet.mergeCells(4, 4, 5, 4); sheet.mergeCells(6, 4, 7, 4); sheet.mergeCells(8, 4, 10, 4); tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, typename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5, runstr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 5, grade, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 5, 1, 5); sheet.mergeCells(2, 5, 3, 5); sheet.mergeCells(4, 5, 5, 5); sheet.mergeCells(6, 5, 7, 5); sheet.mergeCells(8, 5, 10, 5); // tmpLabel = new Label(0, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 7, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 7, 2, 7); sheet.mergeCells(3, 7, 5, 7); sheet.mergeCells(6, 7, 10, 7); tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 8, pingmin + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 8, pingconavg + "%", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 8, 2, 8); sheet.mergeCells(3, 8, 5, 8); sheet.mergeCells(6, 8, 10, 8); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(0, 9, 11, 8, file)); // allRow = allRow+7; int row = 17; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "10", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; tmpLabel = new Label(0, row, buffercache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, dictionarycache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, librarycache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, pctmemorysorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, pctbufgets, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, opencurstr, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); // row = row + 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, sysItemch2[0], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, sysItemch2[1], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, sysItemch2[2], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysItemch1[0], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, sysItemch1[1], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, sysItemch1[2], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, sysItemch1[3], b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; tmpLabel = new Label(0, row, memValue.get(sysItem2[0]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, memValue.get(sysItem2[1]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, memValue.get(sysItem2[2]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, memValue.get(sysItem1[0]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, memValue.get(sysItem1[1]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, memValue.get(sysItem1[2]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, memValue.get(sysItem1[3]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); // row = row + 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START1 tmpLabel = new Label(6, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "", b_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END1 // HONGLI MODIFY START1 tmpLabel = new Label(10, row, "", b_labelFormat); // HONGLI MODIFY END1 sheet.addCell(tmpLabel); // row = row++; Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 for (int i = 0; i < tableinfo_v.size(); i++) { p_labelFormat = super.colorChange(i); Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 tmpLabel = new Label(0, row, String.valueOf(i + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, _filename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tablespace, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, free, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, percent, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START4 tmpLabel = new Label(6, row, pyr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, pbr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, pyw, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, pbw, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END4 tmpLabel = new Label(10, row, status, p_labelFormat); sheet.addCell(tmpLabel); row++; } // row = row + 2; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 4, row); sheet.mergeCells(5, row, 10, row); row++; tmpLabel = new Label(0, row, (String) reportHash.get("downnum"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, reportHash.get("count") + "", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 4, row); sheet.mergeCells(5, row, 10, row); // addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("Error in ExcelReport.createReport()", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } // // --------------zhushouzhi // orapdf---------------------------------------- // public void createReport_oraPDF(String filename) throws // DocumentException, // IOException { // if (impReport.getTable() == null) { // fileName = null; // return; // } // try { // // // Document document = new Document(PageSize.A4); // // (Writer)document(Writer) // PdfWriter.getInstance(document, new FileOutputStream(filename)); // document.open(); // // // BaseFont bfChinese = BaseFont.createFont("STSong-Light", // "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // // // // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // // // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); // Font contextFont1 = new Font(bfChinese, 11, Font.NORMAL); // String hostname = (String) reportHash.get("dbname"); // String ip = (String) reportHash.get("ip"); // String newip = doip(ip); // Paragraph title = new Paragraph(hostname + "", titleFont); // // // title.setAlignment(Element.ALIGN_CENTER); // // title.setFont(titleFont); // document.add(title); // String Ping = (String) reportHash.get("Ping"); // String starttime = (String) reportHash.get("starttime"); // String totime = (String) reportHash.get("totime"); // // Hashtable maxping = (Hashtable) reportHash.get("ping"); // // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // // String contextString = ":" + impReport.getTimeStamp() + " \n"// // + ":" + starttime + " " + totime; // // Paragraph context = new Paragraph(contextString, contextFont1); // // // context.setAlignment(Element.ALIGN_LEFT); // // context.setFont(contextFont); // // // context.setSpacingBefore(5); // // // context.setFirstLineIndent(5); // document.add(context); // document.add(new Paragraph("\n")); // /* // * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); // * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + // * starttime + " " + totime); // */ // PdfPTable aTable = new PdfPTable(3); // float[] widths = { 220f, 220f, 220f }; // aTable.setWidths(widths); // aTable.setWidthPercentage(100); // PdfPCell cell = null; // cell = new PdfPCell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new PdfPCell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new PdfPCell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new PdfPCell(new Phrase("")); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // // // Image img = Image.getInstance(ResourceCenter.getInstance() // .getSysPath() // + "/resource/image/jfreechart/" // + newip // + "ConnectUtilization" + ".png"); // img.setAlignment(Image.MIDDLE);// // img.scalePercent(76); // document.add(aTable); // document.add(img); // document.add(new Paragraph("\n")); // PdfPTable aTable1 = new PdfPTable(8); // float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // aTable1.setWidths(width); // aTable1.setWidthPercentage(100); // aTable1.setHeaderRows(1); // cell = new PdfPCell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // cell = new PdfPCell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // cell = new PdfPCell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // cell = new PdfPCell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // cell = new PdfPCell(new Phrase("MB", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // cell = new PdfPCell(new Phrase("MB", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // cell = new PdfPCell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // cell = new PdfPCell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // // aTable1.endHeaders(); // // // // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // int row = 0; // for (int i = 0; i < tableinfo_v.size(); i++) { // Hashtable ht = (Hashtable) tableinfo_v.get(i); // String _filename = ht.get("file_name").toString(); // String tablespace = ht.get("tablespace").toString(); // String size = ht.get("size_mb").toString(); // String free = ht.get("free_mb").toString(); // String percent = ht.get("percent_free").toString(); // String status = ht.get("status").toString(); // // aTable1.addCell(new Phrase("")); // row = i + 1; // String rowStr = "" + row; // cell = new PdfPCell(new Phrase(rowStr)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // cell = new PdfPCell(new Phrase(_filename)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // cell = new PdfPCell(new Phrase(tablespace)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // cell = new PdfPCell(new Phrase(size)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // cell = new PdfPCell(new Phrase(free)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // cell = new PdfPCell(new Phrase(percent)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // cell = new PdfPCell(new Phrase(status)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable1.addCell(cell); // // } // // if (impReport.getChart() != null) { // ByteArrayOutputStream baos = new ByteArrayOutputStream(); // try { // ChartUtilities.writeChartAsPNG(baos, impReport.getChart() // .getChart(), impReport.getChart().getWidth(), // impReport.getChart().getHeight()); // } catch (IOException ioe) { // } // Image img1 = Image.getInstance(baos.toByteArray()); // img1.setAbsolutePosition(0, 0); // img1.setAlignment(Image.MIDDLE);// // // document.add(img1); // } // // document.add(aTable1); // document.close(); // } catch (Exception e) { // // SysLogger.error("Error in ExcelReport.createReport()",e); // SysLogger.error("", e); // } // // } // --------------zhushouzhi orapdf---------------------------------------- /** * MODIFY HONGLI 2010-10-27 */ public void createReport_oraPDF(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 11, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont1); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingnow"))); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); this.setCellFormat(cell, false); aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.MIDDLE);// img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // HONGLI MODIFY START1 PdfPTable aTable1 = new PdfPTable(12); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 aTable1.setWidths(width); aTable1.setWidthPercentage(100); aTable1.setHeaderRows(1); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // HONGLI ADD START1 cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // HONGLI ADD END1 cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // aTable1.endHeaders(); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 aTable1.addCell(new Phrase("")); row = i + 1; String rowStr = "" + row; cell = new PdfPCell(new Phrase(rowStr)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(_filename)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(tablespace)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(size)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(free)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(percent)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START4 cell = new PdfPCell(new Phrase(pyr)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(pbr)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(pyw)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(pbw)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END4 cell = new PdfPCell(new Phrase(status)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } // -------------------------------end---------------------------------- // zhushouzhi-----------------db ora public void createReport_oraNewDoc(String filename) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("dbnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String runstr = (String) reportHash.get("runstr"); // String[] sysItem1 = { "shared pool", "large pool", "buffer cache", // "java pool" }; String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String downnum = (String) reportHash.get("downnum"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(4); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("SGA(MB)", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); // SGA String valueall = "---"; String valuebig = "---"; String valuebuffer = "---"; String valuejava = "---"; if (oramem != null) { if (oramem.get(sysItem1[0]) != null) { valueall = (String) oramem.get(sysItem1[0]); } if (oramem.get(sysItem1[1]) != null) { valuebig = (String) oramem.get(sysItem1[1]); } if (oramem.get(sysItem1[2]) != null) { valuebuffer = (String) oramem.get(sysItem1[2]); } if (oramem.get(sysItem1[3]) != null) { valuejava = (String) oramem.get(sysItem1[3]); } } // SGA END cell = new Cell(new Phrase(valueall, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(valuebig, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(valuebuffer, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("Java", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(valuejava, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("PGA(MB)", titleFont)); cell.setRowspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated", "cache_hit_percentage", "bytes_processed", "extra_bytes_read/written", "recompute_count_(total)" }; String valuepgaall = "---"; String valuepganow = "---"; String valuepgabig = "---"; if (oramem != null) { if (oramem.get(sysItem2[0]) != null) { valuepgaall = (String) oramem.get(sysItem2[0]); } if (oramem.get(sysItem2[1]) != null) { valuepganow = (String) oramem.get(sysItem2[1]); } if (oramem.get(sysItem2[2]) != null) { valuepgabig = (String) oramem.get(sysItem2[2]); } } cell = new Cell(new Phrase("PGA", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); if (!"---".equals(valuepgaall)) { valuepgaall = CEIString.round(Double.valueOf(valuepgaall.replace("MB", "")), 2) + ""; } cell = new Cell(new Phrase(valuepgaall, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("PGA", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); if (!"---".equals(valuepganow)) { valuepganow = CEIString.round(Double.valueOf(valuepganow.replace("MB", "")), 2) + ""; } cell = new Cell(new Phrase(valuepganow, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("PGA", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); if (!"---".equals(valuepgabig)) { valuepgabig = CEIString.round(Double.valueOf(valuepgabig.replace("MB", "")), 2) + ""; } cell = new Cell(new Phrase(valuepgabig, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); OraspaceconfigDao oraspaceconfigDao = new OraspaceconfigDao(); List list = null; try { list = oraspaceconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { oraspaceconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(2 + list.size()); this.setCellFormat(cell, true); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); // ==== int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String tablespace = ht.get("tablespace").toString(); for (int j = 0; j < list.size(); j++) { Oraspaceconfig vo1 = (Oraspaceconfig) list.get(j); if (vo1.getSpacename().equals(tablespace)) { String size = ht.get("size_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); cell = new Cell(new Phrase(tablespace, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(size, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(percent, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(status, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); row = row + 1; } } } // ===============end String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); this.setCellFormat(cell, true); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); this.setCellFormat(cell, true); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String pinglog = ""; if ("0".equals(downnum)) { pinglog = " " + "2 "; } else { pinglog = " " + "2 " + downnum + ""; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } // zhushouzhi-----------------------db end public void createReport_oraNewPDF(String filename, String type) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("dbnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String runstr = (String) reportHash.get("runstr"); // String[] sysItem1 = { "shared pool", "large pool", "buffer cache", // "java pool" }; String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String downnum = (String) reportHash.get("downnum"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 10, Font.NORMAL); Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); this.setTableFormat(aTable); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(typename)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(4); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("SGA(MB)", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // SGA String valueall = "---"; String valuebig = "---"; String valuebuffer = "---"; String valuejava = "---"; if (oramem != null) { if (oramem.get(sysItem1[0]) != null) { valueall = (String) oramem.get(sysItem1[0]); } if (oramem.get(sysItem1[1]) != null) { valuebig = (String) oramem.get(sysItem1[1]); } if (oramem.get(sysItem1[2]) != null) { valuebuffer = (String) oramem.get(sysItem1[2]); } if (oramem.get(sysItem1[3]) != null) { valuejava = (String) oramem.get(sysItem1[3]); } } // SGA END cell = new Cell(new Phrase(valueall)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(valuebig)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(valuebuffer)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("Java", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(valuejava)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("PGA(MB)", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated", "cache_hit_percentage", "bytes_processed", "extra_bytes_read/written", "recompute_count_(total)" }; String valuepgaall = "---"; String valuepganow = "---"; String valuepgabig = "---"; if (oramem != null) { if (oramem.get(sysItem2[0]) != null) { valuepgaall = (String) oramem.get(sysItem2[0]); } if (oramem.get(sysItem2[1]) != null) { valuepganow = (String) oramem.get(sysItem2[1]); } if (oramem.get(sysItem2[2]) != null) { valuepgabig = (String) oramem.get(sysItem2[2]); } } cell = new Cell(new Phrase("PGA", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); if (!"---".equals(valuepgaall)) { valuepgaall = CEIString.round(Double.valueOf(valuepgaall.replace("MB", "")), 2) + ""; } cell = new Cell(new Phrase(valuepgaall)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("PGA", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); if (!"---".equals(valuepganow)) { valuepganow = CEIString.round(Double.valueOf(valuepganow.replace("MB", "")), 2) + ""; } cell = new Cell(new Phrase(valuepganow)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("PGA", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); if (!"---".equals(valuepgabig)) { valuepgabig = CEIString.round(Double.valueOf(valuepgabig.replace("MB", "")), 2) + ""; } cell = new Cell(new Phrase(valuepgabig)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); OraspaceconfigDao oraspaceconfigDao = new OraspaceconfigDao(); List list = null; try { list = oraspaceconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { oraspaceconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(2 + list.size()); this.setCellFormat(cell5, true); aTable.addCell(cell5); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ==== int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String tablespace = ht.get("tablespace").toString(); for (int j = 0; j < list.size(); j++) { Oraspaceconfig vo1 = (Oraspaceconfig) list.get(j); if (vo1.getSpacename().equals(tablespace)) { String size = ht.get("size_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); cell = new Cell(new Phrase(tablespace)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(size)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(percent)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(status)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); row = row + 1; } } } // ===============end String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); String pinglog = ""; if ("0".equals(downnum)) { pinglog = " " + "2 "; } else { pinglog = " " + "2 " + downnum + ""; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } // ---------------sql execl--------------------- public void createReport_sql(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, (String) maxping.get("pingnow"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "", _labelFormat); sheet.addCell(tmpLabel); int row = 14; // Hashtable dbValue = (Hashtable) reportHash.get("tableinfo_v"); Hashtable alldatabase = new Hashtable(); if (dbValue.get("database") != null) alldatabase = (Hashtable) dbValue.get("database"); Vector names = new Vector(); if (dbValue.get("names") != null) names = (Vector) dbValue.get("names"); if (alldatabase != null && alldatabase.size() > 0) { if (names == null) names = new Vector(); for (int i = 0; i < names.size(); i++) { String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); row = row + 1; tmpLabel = new Label(0, row, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, dbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, usedsize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, usedperc, p_labelFormat); sheet.addCell(tmpLabel); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // zhushouzhi--------------sql doc public void createReport_sqlDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // document.add(aTable); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// document.add(img); document.add(new Paragraph("\n")); Table aTable1 = new Table(6); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Hashtable dbValue = (Hashtable) reportHash.get("tableinfo_v"); Hashtable alldatabase = new Hashtable(); if (dbValue.get("database") != null) alldatabase = (Hashtable) dbValue.get("database"); Vector names = new Vector(); if (dbValue.get("names") != null) names = (Vector) dbValue.get("names"); if (alldatabase != null && alldatabase.size() > 0) { if (names == null) names = new Vector(); int row = 1; for (int i = 0; i < names.size(); i++) { String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); cell = new Cell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(row + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(dbname, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(size, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(usedsize, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(usedperc, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // TODO: handle exception } } // end-----------------------sql // zhushouzhi------------------------ sql pdf public void createReport_sqlPDF(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingnow"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// // document.add(aTable); img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); PdfPTable aTable1 = new PdfPTable(6); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Hashtable dbValue = (Hashtable) reportHash.get("tableinfo_v"); Hashtable alldatabase = new Hashtable(); if (dbValue.get("database") != null) alldatabase = (Hashtable) dbValue.get("database"); Vector names = new Vector(); if (dbValue.get("names") != null) names = (Vector) dbValue.get("names"); if (alldatabase != null && alldatabase.size() > 0) { if (names == null) names = new Vector(); int row = 1; for (int i = 0; i < names.size(); i++) { String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(row + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(dbname)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(size)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(usedsize)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(usedperc)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // TODO: handle exception } } // zhushouzhi--------------------------end sql pdf // zhushouzhi-----------------db sql /** * @param filename * @param type * @throws DocumentException * @throws IOException */ public void createReport_sqlNewDoc(String filename, String type) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("hostnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String runstr = (String) reportHash.get("runstr"); Hashtable sqlsys = (Hashtable) reportHash.get("sqlsys"); String[] sysItem1 = { "shared_pool", "large_pool", "buffer_cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); this.setTableFormat(aTable); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(5); this.setCellFormat(cell, true); aTable.addCell(cell); // mems Hashtable sqlValue = new Hashtable(); if ((Hashtable) reportHash.get("sqlValue") != null) sqlValue = (Hashtable) reportHash.get("sqlValue"); Hashtable memValue = new Hashtable(); if (sqlValue.get("mems") != null) memValue = (Hashtable) sqlValue.get("mems"); String totalMemory = "---"; String sqlMem = "---"; String optMemory = "---"; String lockMem = "---"; String conMemory = "---"; if (memValue != null && memValue.size() > 0) { if (memValue.get("totalMemory") != null) totalMemory = (String) memValue.get("totalMemory");// total if (memValue.get("sqlMem") != null) sqlMem = (String) memValue.get("sqlMem");// sql if (memValue.get("optMemory") != null) optMemory = (String) memValue.get("optMemory");// if (memValue.get("lockMem") != null) lockMem = (String) memValue.get("lockMem");// if (memValue.get("conMemory") != null) conMemory = (String) memValue.get("conMemory");// } cell = new Cell(new Phrase("(KB)", titleFont)); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalMemory.replace(".0", ""), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("SQL", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sqlMem.replace(".0", ""), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(optMemory.replace(".0", ""), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lockMem.replace(".0", ""), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(conMemory.replace(".0", ""), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String productlevel = ""; if (sqlsys.get("productlevel") != null) { productlevel = (String) sqlsys.get("productlevel"); } cell = new Cell(new Phrase(productlevel)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String IsSingleUser = ""; if (sqlsys.get("IsSingleUser") != null) { IsSingleUser = (String) sqlsys.get("IsSingleUser"); } cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(IsSingleUser, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String IsIntegratedSecurityOnly = ""; if (sqlsys.get("IsIntegratedSecurityOnly") != null) { IsIntegratedSecurityOnly = (String) sqlsys.get("IsIntegratedSecurityOnly"); } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(IsIntegratedSecurityOnly, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String IsClustered = ""; if (sqlsys.get("IsClustered") != null) { IsClustered = (String) sqlsys.get("IsClustered"); } cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(IsClustered, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Hashtable dbValue = (Hashtable) reportHash.get("dbValue"); Hashtable alldatabase = new Hashtable(); Hashtable alllogfile = new Hashtable(); alldatabase = (Hashtable) dbValue.get("database"); if (alldatabase == null) alldatabase = new Hashtable(); alllogfile = (Hashtable) dbValue.get("logfile"); if (alllogfile == null) alllogfile = new Hashtable(); Vector names = (Vector) dbValue.get("names"); /* * OraspaceconfigDao oraspaceconfigDao = new OraspaceconfigDao(); List * list = oraspaceconfigDao.getByIp(ip, 1); */ SqldbconfigDao sqldbconfigDao = new SqldbconfigDao(); List list = null; try { list = sqldbconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { sqldbconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(2 + list.size()); this.setCellFormat(cell5, true); aTable.addCell(cell5); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("%", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ==== // ==== int row = 0; for (int i = 0; i < names.size(); i++) { Hashtable ht = (Hashtable) dbValue.get(i); String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); for (int j = 0; j < list.size(); j++) { Sqldbconfig vo1 = (Sqldbconfig) list.get(j); if (vo1.getDbname().equals(dbname)) { String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); cell = new Cell(new Phrase(dbname, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(size, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(usedsize, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(usedperc, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); row = row + 1; } } } // ===============end String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); String pinglog = ""; if ("0".equals(downnum)) { pinglog = " " + "2 "; } else { pinglog = " " + "2 " + downnum + ""; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } // zhushouzhi-----------------------db docend // zhushouzhi-----------------db sql public void createReport_sqlNewPDF(String filename) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("hostnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); Hashtable sqlsys = (Hashtable) reportHash.get("sqlsys"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font contextFont = new Font(bfChinese, 11, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // mems Hashtable sqlValue = new Hashtable(); if ((Hashtable) reportHash.get("sqlValue") != null) sqlValue = (Hashtable) reportHash.get("sqlValue"); Hashtable memValue = new Hashtable(); if (sqlValue.get("mems") != null) memValue = (Hashtable) sqlValue.get("mems"); String totalMemory = "---"; String sqlMem = "---"; String optMemory = "---"; String lockMem = "---"; String conMemory = "---"; if (memValue != null && memValue.size() > 0) { if (memValue.get("totalMemory") != null) totalMemory = (String) memValue.get("totalMemory");// total if (memValue.get("sqlMem") != null) sqlMem = (String) memValue.get("sqlMem");// sql if (memValue.get("optMemory") != null) optMemory = (String) memValue.get("optMemory");// if (memValue.get("lockMem") != null) lockMem = (String) memValue.get("lockMem");// if (memValue.get("conMemory") != null) conMemory = (String) memValue.get("conMemory");// } cell = new Cell(new Phrase("(KB)", titleFont)); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalMemory.replace(".0", ""))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("SQL", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sqlMem.replace(".0", ""))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(optMemory.replace(".0", ""))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lockMem.replace(".0", ""))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(conMemory.replace(".0", ""))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String productlevel = ""; if (sqlsys.get("productlevel") != null) { productlevel = (String) sqlsys.get("productlevel"); } String IsSingleUser = ""; if (sqlsys.get("IsSingleUser") != null) { IsSingleUser = (String) sqlsys.get("IsSingleUser"); } String IsIntegratedSecurityOnly = ""; if (sqlsys.get("IsIntegratedSecurityOnly") != null) { IsIntegratedSecurityOnly = (String) sqlsys.get("IsIntegratedSecurityOnly"); } String IsClustered = ""; if (sqlsys.get("IsClustered") != null) { IsClustered = (String) sqlsys.get("IsClustered"); } cell = new Cell(new Phrase(productlevel)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(IsSingleUser, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(IsIntegratedSecurityOnly, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(IsClustered, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Hashtable dbValue = (Hashtable) reportHash.get("dbValue"); Hashtable alldatabase = new Hashtable(); Hashtable alllogfile = new Hashtable(); alldatabase = (Hashtable) dbValue.get("database"); if (alldatabase == null) alldatabase = new Hashtable(); alllogfile = (Hashtable) dbValue.get("logfile"); if (alllogfile == null) alllogfile = new Hashtable(); Vector names = (Vector) dbValue.get("names"); SqldbconfigDao sqldbconfigDao = new SqldbconfigDao(); List list = null; try { list = sqldbconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { sqldbconfigDao.close(); } // // List list = sqldbconfigDao.getByIp(ip, 1); // for (int i = 0; i < list.size(); i++) { // // } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(2 + list.size()); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); // cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell5); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("%", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ==== int row = 0; for (int i = 0; i < names.size(); i++) { Hashtable ht = (Hashtable) dbValue.get(i); String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); for (int j = 0; j < list.size(); j++) { Sqldbconfig vo1 = (Sqldbconfig) list.get(j); if (vo1.getDbname().equals(dbname)) { String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); cell = new Cell(new Phrase(dbname)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(size)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(usedsize)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(usedperc)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); row = row + 1; } } } // ===============end String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String pinglog = ""; if ("0".equals(downnum)) { pinglog = " " + "2 "; } else { pinglog = " " + "2 " + downnum + ""; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } // --------------------------------sybase------------------------------------ // sybase--------------------doc report zhushouzhi public void createReport_sybDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(""); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(aTable); document.add(img); document.add(new Paragraph("\n")); Table aTable1 = new Table(6); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); if (sysbaseVO == null) sysbaseVO = new SybaseVO(); List dbsizelist = (List) sysbaseVO.getDbInfo(); int row = 1; if (dbsizelist != null && dbsizelist.size() > 0) { for (int i = 0; i < dbsizelist.size(); i++) { TablesVO tablesVO = (TablesVO) dbsizelist.get(i); String dbname = tablesVO.getDb_name(); String dbsize = tablesVO.getDb_size(); String freesize = tablesVO.getDb_freesize(); String userdperc = tablesVO.getDb_usedperc(); cell = new Cell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(row + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(dbname, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(dbsize, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(freesize, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(userdperc, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); row = row + 1; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // TODO: handle exception } } // ---------------------end doc report // zhushouzhi----------------------end sql doc public void createReport_sybPDF(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); PdfPTable aTable1 = new PdfPTable(6); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); if (sysbaseVO == null) sysbaseVO = new SybaseVO(); List dbsizelist = (List) sysbaseVO.getDbInfo(); int row = 1; if (dbsizelist != null && dbsizelist.size() > 0) { for (int i = 0; i < dbsizelist.size(); i++) { TablesVO tablesVO = (TablesVO) dbsizelist.get(i); String dbname = tablesVO.getDb_name(); String dbsize = tablesVO.getDb_size(); String freesize = tablesVO.getDb_freesize(); String userdperc = tablesVO.getDb_usedperc(); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(row + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(dbname)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(dbsize)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(freesize)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(userdperc)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // TODO: handle exception } } // ---------------------end pdf report // zhushouzhi------------------------ sybase pdf public void createReport_sybaseNewDoc(String filename) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("hostnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_physicalMemory(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_dataCache(), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("Metadata(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getMetadata_cache(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getProcedure_cache(), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_logicalMemory(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getData_hitrate(), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getProcedure_hitrate(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getServerName(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getVersion(), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // SybspaceconfigDao sybspaceconfigDao = new SybspaceconfigDao(); List list = null; try { list = sybspaceconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { sybspaceconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(8 + list.size()); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); // cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell5); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getIdle(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("cpu()", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getCpu_busy(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("I/O()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getIo_busy(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IO(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getIo_busy_rate(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getSent_rate(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getReceived_rate(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getWrite_rate(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getRead_rate(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getDisk_count(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getLocks_count(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getXact_count(), contextFont1)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("%", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // get dbspace message================== if (sysbaseVO == null) sysbaseVO = new SybaseVO(); List dbsizelist = (List) sysbaseVO.getDbInfo(); int row = 1; if (dbsizelist != null && dbsizelist.size() > 0) { for (int i = 0; i < dbsizelist.size(); i++) { TablesVO tablesVO = (TablesVO) dbsizelist.get(i); String dbname = tablesVO.getDb_name(); for (int j = 0; j < list.size(); j++) { Sybspaceconfig vo = (Sybspaceconfig) list.get(j); if (vo.getSpacename().equals(dbname)) { String dbsize = tablesVO.getDb_size(); String freesize = tablesVO.getDb_freesize(); String userdperc = tablesVO.getDb_usedperc(); cell = new Cell(new Phrase(dbname, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(dbsize, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(freesize, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(userdperc, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } } String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String pinglog = ""; if (!"0".equals(downnum)) { pinglog = " " + "2 " + downnum + ""; } else { pinglog = " " + "2 "; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } // zhushouzhi-----------------------db end // -------------------------doc end // ----------------------- pdfreport // sybase===============pdf new ```zhushouzhi public void createReport_sybaseNewPDF(String filename) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("hostnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font contextFont = new Font(bfChinese, 11, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_physicalMemory(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_dataCache())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("Metadata(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getMetadata_cache())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getProcedure_cache())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_logicalMemory(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getData_hitrate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getProcedure_hitrate(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getServerName())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getVersion())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // SybspaceconfigDao sybspaceconfigDao = new SybspaceconfigDao(); List list = null; try { list = sybspaceconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { sybspaceconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(8 + list.size()); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); // cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell5); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getIdle())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("cpu()", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getCpu_busy())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("I/O()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getIo_busy())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IO(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getIo_busy_rate())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getSent_rate())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getReceived_rate())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getWrite_rate())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getRead_rate())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getDisk_count())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getLocks_count())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getXact_count())); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("%", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // get dbspace message================== if (sysbaseVO == null) sysbaseVO = new SybaseVO(); List dbsizelist = (List) sysbaseVO.getDbInfo(); int row = 1; if (dbsizelist != null && dbsizelist.size() > 0) { for (int i = 0; i < dbsizelist.size(); i++) { TablesVO tablesVO = (TablesVO) dbsizelist.get(i); String dbname = tablesVO.getDb_name(); for (int j = 0; j < list.size(); j++) { Sybspaceconfig vo = (Sybspaceconfig) list.get(j); if (vo.getSpacename().equals(dbname)) { String dbsize = tablesVO.getDb_size(); String freesize = tablesVO.getDb_freesize(); String userdperc = tablesVO.getDb_usedperc(); cell = new Cell(new Phrase(dbname)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(dbsize)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(freesize)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(userdperc)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } } String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String pinglog = ""; if (!"0".equals(downnum)) { pinglog = " " + "2 " + downnum + ""; } else { pinglog = " " + "2 "; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } /** * mysql doc * * @Author HONGLI * @param filename * @throws DocumentException * @throws IOException */ public void createReport_mysqlNewDoc(String filename, String type) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("hostnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); DBVo vo = (DBVo) reportHash.get("vo"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); this.setTableFormat(aTable); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); this.setCellFormat(cell, true); cell.setColspan(8); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Vector val = (Vector) reportHash.get("Val"); String Max_used_connections = ""; String Table_locks_immediate = ""; String Table_locks_waited = ""; String Key_read_requests = ""; String Key_reads = ""; String log_slow_queries = ""; String Threads_connected = ""; String Open_tables = ""; String Opened_tables = ""; if (val != null && val.size() > 0) { for (int i = 0; i < val.size(); i++) { Hashtable return_value = (Hashtable) val.get(i); if (return_value != null && return_value.size() > 0) { String name = return_value.get("variable_name").toString(); String value = return_value.get("value").toString(); if (name.equalsIgnoreCase("Max_used_connections")) { // name=""; Max_used_connections = value; } if (name.equalsIgnoreCase("Table_locks_immediate")) { // name=""; Table_locks_immediate = value; } if (name.equalsIgnoreCase("Table_locks_waited")) { // name=""; Table_locks_waited = value; } if (name.equalsIgnoreCase("Key_read_requests")) { // name=""; Key_read_requests = value; } if (name.equalsIgnoreCase("Key_reads")) { // name=""; Key_reads = value; } if (name.equalsIgnoreCase("log_slow_queries")) { // name=""; log_slow_queries = value; } if (name.equalsIgnoreCase("Threads_connected")) { // name=""; Threads_connected = value; } if (name.equalsIgnoreCase("Open_tables")) { // name=""; Open_tables = value; } if (name.equalsIgnoreCase("Opened_tables")) { // name=""; Opened_tables = value; } } } } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Max_used_connections, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Table_locks_immediate, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Table_locks_waited, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Key_read_requests, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Key_reads, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(log_slow_queries, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Threads_connected, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Open_tables, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Opened_tables, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); String Threads_cached = ""; String Innodb_buffer_pool_pages_total = ""; String Threads_created = ""; String Uptime = ""; if (tableinfo_v != null) { for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String size = ht.get("variable_name").toString(); String free = ht.get("value").toString(); if (size.equalsIgnoreCase("Threads_cached")) { // size=""; Threads_cached = free; } if (size.equalsIgnoreCase("Innodb_buffer_pool_pages_total")) { // size=""; Innodb_buffer_pool_pages_total = free; } if (size.equalsIgnoreCase("Threads_created")) { // size=""; Threads_created = free; } if (size.equalsIgnoreCase("Uptime")) { // size=":"; Uptime = free; } } } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Threads_cached, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Innodb_buffer_pool_pages_total, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Threads_created, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Uptime, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // SybspaceconfigDao sybspaceconfigDao = new SybspaceconfigDao(); List list = null; try { list = sybspaceconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { sybspaceconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); // cell5.setRowspan(8 + list.size()); this.setCellFormat(cell5, true); aTable.addCell(cell5); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(new Phrase("()", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getIdle(), contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("cpu()", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getCpu_busy(), contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("I/O()", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getIo_busy(), contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("IO(%)", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getIo_busy_rate(), // contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("(/)", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getSent_rate(), contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("(/)", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getReceived_rate(), // contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("(/)", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getWrite_rate(), contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("(/)", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getRead_rate(), contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getDisk_count(), contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getLocks_count(), // contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getXact_count(), contextFont1)); // cell.setColspan(6); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("MB", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("MB", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("%", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // get dbspace message================== // if (sysbaseVO == null) // sysbaseVO = new SybaseVO(); // List dbsizelist = (List) sysbaseVO.getDbInfo(); // int row = 1; // if (dbsizelist != null && dbsizelist.size() > 0) { // for (int i = 0; i < dbsizelist.size(); i++) { // // TablesVO tablesVO = (TablesVO) dbsizelist.get(i); // String dbname = tablesVO.getDb_name(); // for (int j = 0; j < list.size(); j++) { // Sybspaceconfig vo = (Sybspaceconfig) list.get(j); // if (vo.getSpacename().equals(dbname)) { // // String dbsize = tablesVO.getDb_size(); // String freesize = tablesVO.getDb_freesize(); // String userdperc = tablesVO.getDb_usedperc(); // // cell = new Cell(new Phrase(dbname, contextFont1)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(dbsize, contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(freesize, contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(userdperc, contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // } // } // } // } // String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); String pinglog = ""; if (!"0".equals(downnum)) { pinglog = " " + "2 " + downnum + ""; } else { pinglog = " " + "2 "; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } /** * mysql pdf * * @author HONGLI * @param filename * @throws DocumentException * @throws IOException */ public void createReport_mysqlNewPDF(String filename) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("hostnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); DBVo vo = (DBVo) reportHash.get("vo"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font contextFont = new Font(bfChinese, 11, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(5); Vector val = (Vector) reportHash.get("Val"); String Max_used_connections = ""; String Table_locks_immediate = ""; String Table_locks_waited = ""; String Key_read_requests = ""; String Key_reads = ""; String log_slow_queries = ""; String Threads_connected = ""; String Open_tables = ""; String Opened_tables = ""; if (val != null && val.size() > 0) { for (int i = 0; i < val.size(); i++) { Hashtable return_value = (Hashtable) val.get(i); if (return_value != null && return_value.size() > 0) { String name = return_value.get("variable_name").toString(); String value = return_value.get("value").toString(); if (name.equalsIgnoreCase("Max_used_connections")) { // name=""; Max_used_connections = value; } if (name.equalsIgnoreCase("Table_locks_immediate")) { // name=""; Table_locks_immediate = value; } if (name.equalsIgnoreCase("Table_locks_waited")) { // name=""; Table_locks_waited = value; } if (name.equalsIgnoreCase("Key_read_requests")) { // name=""; Key_read_requests = value; } if (name.equalsIgnoreCase("Key_reads")) { // name=""; Key_reads = value; } if (name.equalsIgnoreCase("log_slow_queries")) { // name=""; log_slow_queries = value; } if (name.equalsIgnoreCase("Threads_connected")) { // name=""; Threads_connected = value; } if (name.equalsIgnoreCase("Open_tables")) { // name=""; Open_tables = value; } if (name.equalsIgnoreCase("Opened_tables")) { // name=""; Opened_tables = value; } } } } cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Max_used_connections, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Table_locks_immediate, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Table_locks_waited, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Key_read_requests, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Key_reads, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(log_slow_queries, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Threads_connected, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Open_tables, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Opened_tables, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); String Threads_cached = ""; String Innodb_buffer_pool_pages_total = ""; String Threads_created = ""; String Uptime = ""; if (tableinfo_v != null) { for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String size = ht.get("variable_name").toString(); String free = ht.get("value").toString(); if (size.equalsIgnoreCase("Threads_cached")) { // size=""; Threads_cached = free; } if (size.equalsIgnoreCase("Innodb_buffer_pool_pages_total")) { // size=""; Innodb_buffer_pool_pages_total = free; } if (size.equalsIgnoreCase("Threads_created")) { // size=""; Threads_created = free; } if (size.equalsIgnoreCase("Uptime")) { // size=":"; Uptime = free; } } } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Threads_cached)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Threads_cached)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Threads_cached)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Uptime)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("")); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // // // // SybspaceconfigDao sybspaceconfigDao = new SybspaceconfigDao(); // // List list = null; // try { // list = sybspaceconfigDao.getByIp(ip, 1); // } catch (Exception e) { // SysLogger.error("", e); // } finally { // sybspaceconfigDao.close(); // } // Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(1); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); // cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell5); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(new Phrase("()", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getIdle())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("cpu()", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getCpu_busy())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("I/O()", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getIo_busy())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("IO(%)", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getIo_busy_rate())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("(/)", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getSent_rate())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("(/)", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getReceived_rate())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("(/)", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getWrite_rate())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("(/)", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getRead_rate())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getDisk_count())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getLocks_count())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getXact_count())); // cell.setColspan(6); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("MB", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("MB", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("%", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // get dbspace message================== // if (sysbaseVO == null) // sysbaseVO = new SybaseVO(); // List dbsizelist = (List) sysbaseVO.getDbInfo(); // int row = 1; // if (dbsizelist != null && dbsizelist.size() > 0) { // for (int i = 0; i < dbsizelist.size(); i++) { // // TablesVO tablesVO = (TablesVO) dbsizelist.get(i); // String dbname = tablesVO.getDb_name(); // for (int j = 0; j < list.size(); j++) { // Sybspaceconfig vo = (Sybspaceconfig) list.get(j); // if (vo.getSpacename().equals(dbname)) { // // String dbsize = tablesVO.getDb_size(); // String freesize = tablesVO.getDb_freesize(); // String userdperc = tablesVO.getDb_usedperc(); // // cell = new Cell(new Phrase(dbname)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(dbsize)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(freesize)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(userdperc)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // } // } // } // } // String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String pinglog = ""; if (!"0".equals(downnum)) { pinglog = " " + "2 " + downnum + ""; } else { pinglog = " " + "2 "; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } // create db2 report doc public void createReport_db2Doc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String servername = (String) reportHash.get("servername"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); Hashtable returnhash = (Hashtable) reportHash.get("returnhash"); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(""); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// // document.add(aTable); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); Enumeration dbs = returnhash.keys(); // List retList = new ArrayList(); List retList = new ArrayList(); Paragraph context1 = null; Table aTable1 = null; while (dbs.hasMoreElements()) { aTable1 = new Table(6); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// String obj = (String) dbs.nextElement(); retList = (List) returnhash.get(obj); String contextString1 = "DB2:" + obj + "(" + "IP:" + ip + ")"; context1 = new Paragraph(contextString1, contextFont); // context1.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context1.setSpacingBefore(5); // context1.setFirstLineIndent(5); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // /* * Hashtable tableinfo_v = (Hashtable) * reportHash.get("tableinfo_v"); * * String[] dbs1 = servername.split(","); for (int i = 0; i < * tableinfo_v.size(); i++) { List list = (List) * tableinfo_v.get(dbs1[i]); for (int k = 0; k < list.size(); * k++) { * * row = row + 1; Hashtable ht = (Hashtable) list.get(k); if (ht == * null) continue; String spacename = ""; if * (ht.get("tablespace_name") != null) spacename = * ht.get("tablespace_name").toString(); String size = ""; if * (ht.get("totalspac") != null) size = * ht.get("totalspac").toString(); String free = ""; if * (ht.get("usablespac") != null) free = * ht.get("usablespac").toString(); String percent = "---"; if * (ht.get("usableper") != null) percent = * ht.get("usableper").toString(); */ for (int i = 0; i < retList.size(); i++) { Hashtable ht = (Hashtable) retList.get(i); if (ht == null) continue; String spacename = ""; if (ht.get("tablespace_name") != null) spacename = ht.get("tablespace_name").toString(); String size = ""; if (ht.get("totalspac") != null) size = ht.get("totalspac").toString(); String free = ""; if (ht.get("usablespac") != null) free = ht.get("usablespac").toString(); String percent = ""; if (ht.get("usableper") != null) percent = ht.get("usableper").toString(); cell = new Cell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(i + 1 + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(spacename, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(size, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(free, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(percent, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } document.add(context1); document.add(aTable1); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.close(); } catch (Exception e) { // TODO: handle exception } }// end db2 report doc // db2 pdf report-------------------zhushouzhi public void createReport_db2PDF(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 11, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String servername = (String) reportHash.get("servername"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable returnhash = (Hashtable) reportHash.get("returnhash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont1); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); Enumeration dbs = returnhash.keys(); List retList = new ArrayList(); Paragraph context1 = null; PdfPTable aTable1 = null; while (dbs.hasMoreElements()) { aTable1 = new PdfPTable(6); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // String obj = (String) dbs.nextElement(); retList = (List) returnhash.get(obj); String contextString1 = "DB2:" + obj + "(" + "IP:" + ip + ")"; context1 = new Paragraph(contextString1, contextFont); // context1.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context1.setSpacingBefore(5); // context1.setFirstLineIndent(5); int row = 1; for (int i = 0; i < retList.size(); i++) { Hashtable ht = (Hashtable) retList.get(i); if (ht == null) continue; String spacename = ""; if (ht.get("tablespace_name") != null) spacename = ht.get("tablespace_name").toString(); String size = ""; if (ht.get("totalspac") != null) size = ht.get("totalspac").toString(); String free = ""; if (ht.get("usablespac") != null) free = ht.get("usablespac").toString(); String percent = ""; if (ht.get("usableper") != null) percent = ht.get("usableper").toString(); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(i + 1 + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(spacename)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(size)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(free)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(percent)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } document.add(context1); document.add(new Paragraph("\n")); document.add(aTable1); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.close(); } catch (Exception e) { // TODO: handle exception } } // zhushouzhi-----------------db2 new doc /** * @param filename * @param type * @throws DocumentException * @throws IOException */ public void createReport_db2NewDoc(String filename, String type) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("dbnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".endsWith(type)) { PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); // ==== Hashtable returnhash = null; returnhash = (Hashtable) reportHash.get("returnhash"); Hashtable db2sys = (Hashtable) reportHash.get("sqlsys"); List retList = new ArrayList(); Enumeration dbs = returnhash.keys(); Table aTable = new Table(8); this.setTableFormat(aTable); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont1)); cell.setColspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont1)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont1)); cell.setColspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); this.setCellFormat(cell, false); aTable.addCell(cell); while (dbs.hasMoreElements()) { String obj = (String) dbs.nextElement(); returnhash = (Hashtable) db2sys.get(obj); cell = new Cell(new Phrase("\n" + "DB2:" + obj + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(4); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // jingcheng message if (db2sys == null) db2sys = new Hashtable(); // Enumeration dbs = db2sys.keys(); // Hashtable<String,Object> returnhash = new Hashtable(); String rows_read = "---"; String rows_selected = "---"; String lock_waits = "---"; String lock_wait_time = "---"; String deadlocks = "---"; String lock_escals = "---"; String host_name = "---"; String prod_release = ""; if (returnhash != null) { rows_read = (String) returnhash.get("rows_read"); rows_selected = (String) returnhash.get("rows_selected"); lock_waits = (String) returnhash.get("lock_waits"); lock_wait_time = (String) returnhash.get("lock_wait_time"); deadlocks = (String) returnhash.get("deadlocks"); lock_escals = (String) returnhash.get("lock_escals"); host_name = (String) returnhash.get("host_name"); prod_release = (String) returnhash.get("prod_release"); } // end message cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(rows_read, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(rows_selected, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lock_waits, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lock_wait_time, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(deadlocks, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lock_escals, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(host_name, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("DB2", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(prod_release, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Db2spaceconfigDao db2spaceconfigDao = new Db2spaceconfigDao(); List list = null; try { list = db2spaceconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { db2spaceconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); this.setCellFormat(cell5, true); int row = 0; for (int j = 0; j < list.size(); j++) { Db2spaceconfig vo1 = (Db2spaceconfig) list.get(j); if (vo1.getDbname().equals(obj)) { row++; } } // cell5.setRowspan(2+list.size()); cell5.setRowspan(2 + row); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); // cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell5); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ==== returnhash = (Hashtable) reportHash.get("returnhash"); retList = (List) returnhash.get(obj); int tie = 0; for (int i = 0; i < retList.size(); i++) { Hashtable ht = (Hashtable) retList.get(i); String tablespace = ht.get("tablespace_name").toString(); for (int j = 0; j < list.size(); j++) { Db2spaceconfig vo1 = (Db2spaceconfig) list.get(j); if (vo1.getSpacename().equals(tablespace)) { if (vo1.getDbname().equals(obj)) { String size = ""; if (ht.get("totalspac") != null) size = ht.get("totalspac").toString(); String free = ""; if (ht.get("usablespac") != null) free = ht.get("usablespac").toString(); String percent = "---"; if (ht.get("usableper") != null) percent = ht.get("usableper").toString(); cell = new Cell(new Phrase(tablespace, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(size, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(free, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(percent, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); tie++; } } } } } // ===============end String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); String pinglog = ""; if ("0".equals(downnum)) { pinglog = " " + "2 "; } else { pinglog = " " + "2 " + downnum + ""; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } // zhushouzhi-----------------db2 new doc public void createReport_db2NewPDF(String filename) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("dbnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); Hashtable returnhash = null; returnhash = (Hashtable) reportHash.get("returnhash"); Hashtable db2sys = (Hashtable) reportHash.get("sqlsys"); List retList = new ArrayList(); Enumeration dbs = returnhash.keys(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font contextFont = new Font(bfChinese, 11, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); while (dbs.hasMoreElements()) { String obj = (String) dbs.nextElement(); returnhash = (Hashtable) db2sys.get(obj); cell = new Cell(new Phrase("\n" + "DB2:" + obj + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // jingcheng message if (db2sys == null) db2sys = new Hashtable(); // Enumeration dbs = db2sys.keys(); // Hashtable<String,Object> returnhash = new Hashtable(); String rows_read = "---"; String rows_selected = "---"; String lock_waits = "---"; String lock_wait_time = "---"; String deadlocks = "---"; String lock_escals = "---"; String host_name = "---"; String prod_release = ""; if (returnhash != null) { rows_read = (String) returnhash.get("rows_read"); rows_selected = (String) returnhash.get("rows_selected"); lock_waits = (String) returnhash.get("lock_waits"); lock_wait_time = (String) returnhash.get("lock_wait_time"); deadlocks = (String) returnhash.get("deadlocks"); lock_escals = (String) returnhash.get("lock_escals"); host_name = (String) returnhash.get("host_name"); prod_release = (String) returnhash.get("prod_release"); } // end message cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(rows_read)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(rows_selected)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lock_waits)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lock_wait_time)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(deadlocks)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lock_escals)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(host_name)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("DB2", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(prod_release)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Db2spaceconfigDao db2spaceconfigDao = new Db2spaceconfigDao(); List list = null; try { list = db2spaceconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { db2spaceconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); int row = 0; for (int j = 0; j < list.size(); j++) { Db2spaceconfig vo1 = (Db2spaceconfig) list.get(j); if (vo1.getDbname().equals(obj)) { row++; } } // cell5.setRowspan(2+list.size()); cell5.setRowspan(2 + row); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); // cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell5); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ==== returnhash = (Hashtable) reportHash.get("returnhash"); retList = (List) returnhash.get(obj); int tie = 0; for (int i = 0; i < retList.size(); i++) { Hashtable ht = (Hashtable) retList.get(i); String tablespace = ht.get("tablespace_name").toString(); for (int j = 0; j < list.size(); j++) { Db2spaceconfig vo1 = (Db2spaceconfig) list.get(j); if (vo1.getSpacename().equals(tablespace)) { if (vo1.getDbname().equals(obj)) { String size = ""; if (ht.get("totalspac") != null) size = ht.get("totalspac").toString(); String free = ""; if (ht.get("usablespac") != null) free = ht.get("usablespac").toString(); String percent = "---"; if (ht.get("usableper") != null) percent = ht.get("usableper").toString(); cell = new Cell(new Phrase(tablespace)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(size)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(free)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(percent)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); tie++; } } } } } // ===============end String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String pinglog = ""; if ("0".equals(downnum)) { pinglog = " " + "2 "; } else { pinglog = " " + "2 " + downnum + ""; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } // zhushouzhi-----------------db2 new pdf // zhushouzhi-----------------------db2 new pdfend // zhushouzhi--------------infor star @Override public void createReport_oawork(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("memlist"); Vector vector = (Vector) reportHash.get("sxoanetifreport"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 10, 0); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); sheet.mergeCells(0, 1, 10, 1); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); sheet.mergeCells(0, 2, 10, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { p_labelFormat = this.colorChange(i); List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) vector.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) vector.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5 + i, "", p_labelFormat); sheet.addCell(tmpLabel); } } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_serviceworkchoce(String starttime, String totime, String file, String username, String positionname) throws DocumentException, IOException { Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; /* * String starttime = (String) reportHash.get("starttime"); String * totime = (String) reportHash.get("totime"); */ Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont1 = new Font(bfChinese, 14, Font.BOLD); Font titleFont = new Font(bfChinese, 14, Font.BOLD); // Font contextFont = new Font(bfChinese, 14, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); try { fileName = ResourceCenter.getInstance().getSysPath() + file; Table aTable = new Table(13); float[] widths = { 40f, 100f, 40f, 40f, 40f, 40f, 40f, 40f, 40f, 40f, 40f, 40f, 40f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont1)); cell.setColspan(13); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(""); cell = new Cell(new Phrase("" + starttime + "" + totime, contextFont)); cell.setColspan(12); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(username, contextFont)); cell.setColspan(4); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(positionname, contextFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setColspan(11); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setColspan(11); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(13); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); int netsize = 0; Hashtable netreporthash = (Hashtable) allreporthash.get("netreporthash"); if (netreporthash != null) { netsize = netreporthash.size(); } cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(3 + netsize); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("CPU(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("KB/S", titleFont)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); java.text.NumberFormat formatenet = java.text.NumberFormat.getNumberInstance(); formatenet.setMaximumFractionDigits(0);// if (netreporthash != null && netreporthash.size() > 0) { Iterator keys = netreporthash.keySet().iterator(); HostNode node = null; while (keys.hasNext()) { node = (HostNode) keys.next(); Hashtable report_has = (Hashtable) netreporthash.get(node); String hostname = (String) report_has.get("equipname"); // WritableSheet sheet = wb.createSheet(hostname+"", // sheetNum); Hashtable CPU = (Hashtable) report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); String ip = (String) report_has.get("ip"); Calendar colTime = Calendar.getInstance(); Date cc = colTime.getTime(); Vector netifVector = (Vector) report_has.get("netifVector"); Hashtable portconfigHash = (Hashtable) report_has.get("portconfigHash"); List reportports = (List) report_has.get("reportports"); Vector iprouterVector = (Vector) report_has.get("iprouterVector"); Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] netIfItemch = { "", "", "", "(M)", "", "", "" }; String[] ipRouterItemch = { "", "", "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization", "INodeUsedSize", "INodeUtilization" }; String[] diskItemch = { "", "", "", "i-node", "i-node" }; String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" }; String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)", "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)", "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" }; String avginput = (String) report_has.get("avginput"); String avgoutput = (String) report_has.get("avgoutput"); String maxinput = (String) report_has.get("maxinput"); String maxoutput = (String) report_has.get("maxoutput"); String level4 = (String) report_has.get("level4"); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String string1 = ((String) maxping.get("pingmax")).replace("%", ""); String string2 = ((String) maxping.get("avgpingcon")).replace("%", ""); cell = new Cell(new Phrase(formatenet.format(Double.valueOf(string2)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formatenet.format(Double.valueOf(string1)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = ""; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); String string3 = avgcpu.replace("%", ""); String string4 = cpumax.replace("%", ""); cell = new Cell(new Phrase(formatenet.format(Double.valueOf(string3)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formatenet.format(Double.valueOf(string4)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(""); aTable.addCell(cell); cell = new Cell(""); aTable.addCell(cell); cell = new Cell(new Phrase(avgoutput.replace(".0", ""), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(maxoutput.replace(".0", ""), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(avginput.replace(".0", ""), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(maxinput.replace(".0", ""), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(level4, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } // ===================================================================== Hashtable hostreporthash = (Hashtable) allreporthash.get("hostreporthash"); int hostsize = 0; if (hostreporthash != null) { hostsize = hostreporthash.size(); } cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2 + hostsize); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("CPU(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("KB/S", titleFont)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); java.text.NumberFormat formatehost = java.text.NumberFormat.getNumberInstance(); formatehost.setMaximumFractionDigits(0);// if (hostreporthash != null && hostreporthash.size() > 0) { Iterator keys = hostreporthash.keySet().iterator(); HostNode node = null; while (keys.hasNext()) { node = (HostNode) keys.next(); // String newip = doip(ip); Hashtable report_has = (Hashtable) hostreporthash.get(node); String hostname = (String) report_has.get("equipname"); Hashtable CPU = (Hashtable) report_has.get("CPU"); String Ping = (String) report_has.get("Ping"); Calendar colTime = (Calendar) report_has.get("time"); Date cc = colTime.getTime(); Hashtable Memory = (Hashtable) report_has.get("Memory"); Hashtable Disk = (Hashtable) report_has.get("Disk"); Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) report_has.get("memavghash"); Hashtable maxping = (Hashtable) report_has.get("ping"); String ip = (String) report_has.get("ip"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "c" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization", "Utilizationvalue" }; String[] diskItemch = { "", "", "" }; String level4 = (String) report_has.get("level4"); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ======= String string7 = ((String) maxping.get("pingmax")).replace("%", ""); String string8 = ((String) maxping.get("avgpingcon")).replace("%", ""); // formate.format(Double.valueOf(string1)); // System.out.println(formate.format(Double.valueOf(string))+"@@@@@@@0000000000"); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string8)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string7)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String cpu = ""; if (CPU.get("cpu") != null) cpu = (String) CPU.get("cpu"); String cpumax = ""; if (CPU.get("cpumax") != null) cpumax = (String) CPU.get("cpumax"); String avgcpu = ""; if (CPU.get("avgcpu") != null) avgcpu = (String) CPU.get("avgcpu"); String string3 = avgcpu.replace("%", ""); String string4 = cpumax.replace("%", ""); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string3)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string4)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String avgvalue = "0.0%"; if (memAvgHash.get("PhysicalMemory") != null) { avgvalue = (String) memAvgHash.get("PhysicalMemory"); String string5 = avgvalue.replace("%", ""); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string5)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } else { String string5 = avgvalue.replace("%", ""); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string5)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } String value = "0.0%"; if (memMaxHash.get("PhysicalMemory") != null) { value = (String) memMaxHash.get("PhysicalMemory"); String string6 = value.replace("%", ""); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string6)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } else { String string6 = value.replace("%", ""); cell = new Cell(new Phrase(formatehost.format(Double.valueOf(string6)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } String value1 = "0"; String value2 = "100"; String name = ""; String name1 = ""; String Utilization = ""; String Utilization1 = ""; if (Disk != null && Disk.size() > 0) { for (int i = 0; i < Disk.size(); i++) { Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i))); if (diskhash.get(diskItem[3]) != null) { if (value1.compareTo((String) diskhash.get(diskItem[3])) < 0) { value1 = (String) diskhash.get(diskItem[3]); name = (String) diskhash.get("name"); Utilization = (String) diskhash.get(diskItem[2]); } } if (diskhash.get(diskItem[3]) != null) { if (value2.compareTo((String) diskhash.get(diskItem[3])) >= 0) { value2 = (String) diskhash.get(diskItem[3]); name1 = (String) diskhash.get("name"); Utilization1 = (String) diskhash.get(diskItem[2]); } } } cell = new Cell(name + " " + Utilization); cell.setColspan(2); aTable.addCell(cell); cell = new Cell(name1 + " " + Utilization1); cell.setColspan(2); aTable.addCell(cell); } else { cell = new Cell("---"); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell("---"); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase(level4, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } // =========================================================================== Hashtable dbreporthash = (Hashtable) allreporthash.get("dbreporthash"); int dbsize = 0; if (dbreporthash != null) { dbsize = dbreporthash.size(); } cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2 + dbsize); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } java.text.NumberFormat formatedb = java.text.NumberFormat.getNumberInstance(); formatedb.setMaximumFractionDigits(0);// if (dbreporthash != null && dbreporthash.size() > 0) { Iterator keys = dbreporthash.keySet().iterator(); DBVo node = null; while (keys.hasNext()) { // String newip = doip(ip); node = (DBVo) keys.next(); Hashtable report_has = (Hashtable) dbreporthash.get(node); Hashtable maxping = (Hashtable) report_has.get("maxping"); String string1 = ((String) maxping.get("pingmax")).replace("%", ""); String string2 = ((String) maxping.get("avgpingcon")).replace("%", ""); String ip = (String) report_has.get("ip"); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String dbtype = (String) report_has.get("dbtype"); cell = new Cell(new Phrase(dbtype, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ======= cell = new Cell(new Phrase(formatedb.format(Double.valueOf(string2)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formatedb.format(Double.valueOf(string1)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String maxspace = ""; String minspace = ""; if ((Integer) report_has.get("maxspace") != 0) { maxspace = (Integer) report_has.get("maxspace") + ""; } if ((Integer) report_has.get("mixspace") != 0) { minspace = (Integer) report_has.get("mixspace") + ""; } if (dbtype.equals("SQLServer") || dbtype.equals("Sybase") || dbtype.equals("Informix")) { maxspace = "---"; minspace = "---"; } cell = new Cell(new Phrase(maxspace, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(minspace, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } // =================================================================== Hashtable tomcatreporthash = (Hashtable) allreporthash.get("tomcatreporthash"); Hashtable iisreporthash = (Hashtable) allreporthash.get("iisreporthash"); Hashtable weblogicreporthash = (Hashtable) allreporthash.get("weblogicreporthash"); int tomcatsize = 0; if (tomcatreporthash != null) { tomcatsize = tomcatreporthash.size(); } int iissize = 0; if (iisreporthash != null) { iissize = iisreporthash.size(); } int weblogicsize = 0; if (weblogicreporthash != null) { weblogicsize = weblogicreporthash.size(); } cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2 + tomcatsize + iissize + weblogicsize); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 8; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 8; i++) { cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } // tomcat============================================================ java.text.NumberFormat formatetomcat = java.text.NumberFormat.getNumberInstance(); formatetomcat.setMaximumFractionDigits(0);// if (tomcatreporthash != null && tomcatreporthash.size() > 0) { Iterator keys = tomcatreporthash.keySet().iterator(); Node node = null; while (keys.hasNext()) { node = (Node) keys.next(); Hashtable report_has = (Hashtable) tomcatreporthash.get(node); Hashtable maxping = (Hashtable) report_has.get("maxping"); String string1 = ((String) maxping.get("pingmax")).replace("%", ""); String string2 = ((String) maxping.get("avgpingcon")).replace("%", ""); String ip = (String) report_has.get("ip"); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String tomcattype = (String) report_has.get("TOMCAT"); cell = new Cell(new Phrase(tomcattype, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ======= cell = new Cell(new Phrase(formatetomcat.format(Double.valueOf(string2)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formatetomcat.format(Double.valueOf(string1)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 8; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } // IIS============================================================================ java.text.NumberFormat formateiis = java.text.NumberFormat.getNumberInstance(); formateiis.setMaximumFractionDigits(0);// if (iisreporthash != null && iisreporthash.size() > 0) { Iterator keys = iisreporthash.keySet().iterator(); Node node = null; while (keys.hasNext()) { node = (Node) keys.next(); Hashtable report_has = (Hashtable) iisreporthash.get(node); Hashtable maxping = (Hashtable) report_has.get("maxping"); String string1 = ((String) maxping.get("pingmax")).replace("%", ""); String string2 = ((String) maxping.get("avgpingcon")).replace("%", ""); String ip = (String) report_has.get("ip"); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String tomcattype = (String) report_has.get("IIS"); cell = new Cell(new Phrase(tomcattype, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ======= cell = new Cell(new Phrase(formateiis.format(Double.valueOf(string2)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formateiis.format(Double.valueOf(string1)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 8; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } // weblogic================================================================ java.text.NumberFormat formateweblogic = java.text.NumberFormat.getNumberInstance(); formateweblogic.setMaximumFractionDigits(0);// if (weblogicreporthash != null && weblogicreporthash.size() > 0) { Iterator keys = weblogicreporthash.keySet().iterator(); Node node = null; while (keys.hasNext()) { node = (Node) keys.next(); Hashtable report_has = (Hashtable) weblogicreporthash.get(node); Hashtable maxping = (Hashtable) report_has.get("maxping"); String string1 = ((String) maxping.get("pingmax")).replace("%", ""); String string2 = ((String) maxping.get("avgpingcon")).replace("%", ""); String ip = (String) report_has.get("ip"); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String tomcattype = (String) report_has.get("WEBLOGIC"); cell = new Cell(new Phrase(tomcattype, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ======= cell = new Cell(new Phrase(formateweblogic.format(Double.valueOf(string2)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(formateweblogic.format(Double.valueOf(string1)), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 8; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } // ============================================================= cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ======= cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("0", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("0", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("0", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("SSO", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); for (int i = 0; i < 6; i++) { cell = new Cell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } cell = new Cell(new Phrase("0", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); document.add(aTable); document.close(); } catch (Exception e) { // TODO: handle exception } } // ##############################start by // guangfei############################/ /** * IISLog IP excel */ public void createReport_iislogip(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); int sheetNum = 0; WritableSheet sheet = wb.createSheet("IISLogIP", sheetNum); // File file = new File( ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/IISLogIP.png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(0, 6, 8, 10, file)); Label tmpLabel = null; tmpLabel = new Label(0, 2, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); // allRow = allRow+7; wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * IISLog excel * * @param filename */ public void createReport_iislogstate(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); int sheetNum = 0; WritableSheet sheet = wb.createSheet("IISLog", sheetNum); // File file = new File( ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/IISLogState.png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(0, 6, 8, 10, file)); // allRow = allRow+7; Label tmpLabel = null; tmpLabel = new Label(0, 2, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * IISLog IP word * * @param filename * @throws DocumentException * @throws IOException */ public void createReport_iislogipword(String filename) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); // Image img = Image .getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/IISLogIP.png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(img); document.close(); } /** * IISLog word * * @param filename * @throws DocumentException * @throws IOException */ public void createReport_iislogstateword(String filename) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); // // Image img = Image.getInstance( ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/IISLogState.png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(img); document.close(); } // #########################end by // gaoguangfei######################################### public void createReport_petrol(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("petrol", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); List petrollist = (List) reportHash.get("list"); WritableFont font = new WritableFont(WritableFont.TIMES, 11, WritableFont.BOLD);// WritableCellFormat format = null; try { // font.setColour(Colour.BLUE);// format = new WritableCellFormat(font); format.setAlignment(jxl.format.Alignment.CENTRE);// format.setVerticalAlignment(VerticalAlignment.CENTRE);// /* * format.setBorder(Border.ALL, BorderLineStyle.THIN, * Colour.BLACK);// format.setBackground(Colour.GRAY_25);// * */ } catch (WriteException e1) { e1.printStackTrace(); } Label tmpLabel = null; sheet.mergeCells(0, 0, 13, 0); tmpLabel = new Label(0, 0, "", format); sheet.addCell(tmpLabel); sheet.mergeCells(0, 1, 0, 2); tmpLabel = new Label(0, 1, "", format); sheet.addCell(tmpLabel); sheet.mergeCells(1, 1, 1, 2); tmpLabel = new Label(1, 1, "", format); sheet.addCell(tmpLabel); sheet.mergeCells(2, 1, 2, 2); tmpLabel = new Label(2, 1, "", format); sheet.addCell(tmpLabel); sheet.mergeCells(3, 1, 3, 2); tmpLabel = new Label(3, 1, "", format); sheet.addCell(tmpLabel); sheet.mergeCells(4, 1, 6, 1); tmpLabel = new Label(4, 1, "", format); sheet.addCell(tmpLabel); // sheet.mergeCells(4,1,6, 1); tmpLabel = new Label(4, 2, "", format); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 2, "", format); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 2, "", format); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 2, "IP", format); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 2, "LANIP", format); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 2, "IP", format); sheet.addCell(tmpLabel); sheet.mergeCells(7, 1, 9, 1); tmpLabel = new Label(7, 1, "IP", format); sheet.addCell(tmpLabel); sheet.mergeCells(10, 1, 10, 2); tmpLabel = new Label(10, 1, "", format); sheet.addCell(tmpLabel); sheet.mergeCells(11, 1, 11, 2); tmpLabel = new Label(11, 1, "", format); sheet.addCell(tmpLabel); sheet.mergeCells(12, 1, 12, 2); tmpLabel = new Label(12, 1, "", format); sheet.addCell(tmpLabel); sheet.mergeCells(13, 1, 13, 2); tmpLabel = new Label(13, 1, "", format); sheet.addCell(tmpLabel); // // Petrolconfig vo=null; // for(int i=0;i<petrollist.size();i++) // { // vo=(Petrolconfig)petrollist.get(i); // String id = vo.getId()+""; // // //row = row + (i); // tmpLabel = new Label(0, 3+i, i+1+"", p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 3+i, vo.getAddress(), p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 3+i, vo.getName(), p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(3, 3+i, vo.getEquipname(), p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(4, 3+i, vo.getModelname(), p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(5, 3+i, vo.getSerialname(), p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(6, 3+i, vo.getProductime(), p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(7, 3+i,vo.getNetip() , p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(8, 3+i,vo.getLanip() , p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(9, 3+i, vo.getIp(), p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(10, 3+i, vo.getBw(), p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(11, 3+i, vo.getSettime(), p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(12, 3+i, vo.getRepairtime(), p_labelFormat); // sheet.addCell(tmpLabel); // tmpLabel = new Label(13, 3+i,vo.getComment(), p_labelFormat); // sheet.addCell(tmpLabel); // // } // wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_statistic(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("Syslog", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); List sysloglist = (List) reportHash.get("list"); Integer index = (Integer) reportHash.get("startRow"); int startRow = 1; if (null != index) { startRow = index.intValue(); } Label tmpLabel = null; // tmpLabel = new Label(2, 0, "Syslog", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 1, "", _labelFormat); sheet.addCell(tmpLabel); String status = ""; NetSyslogViewer syslog = null; for (int i = 0; i < sysloglist.size(); i++) { status = ""; syslog = (NetSyslogViewer) sysloglist.get(i); if (Integer.parseInt(syslog.getStatus()) == 1) { status = ""; } // row = row + (i); tmpLabel = new Label(0, 2 + i, startRow + i + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, syslog.getHostName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, syslog.getIpaddress(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, status, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2 + i, syslog.getErrors() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 2 + i, syslog.getWarnings() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 2 + i, syslog.getFailures() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 2 + i, syslog.getOthers() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 2 + i, syslog.getAll() + "", p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_impevt(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("Syslog", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); List sysloglist = (List) reportHash.get("list"); Integer index = (Integer) reportHash.get("startRow"); int startRow = 1; if (null != index) { startRow = index.intValue(); } Label tmpLabel = null; // tmpLabel = new Label(2, 0, "Syslog", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "", _labelFormat); sheet.addCell(tmpLabel); NetSyslogEvent syslog = null; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); for (int i = 0; i < sysloglist.size(); i++) { syslog = (NetSyslogEvent) sysloglist.get(i); Date cc = syslog.getRecordtime().getTime(); String message = syslog.getMessage(); int priority = syslog.getPriority(); String priorityname = syslog.getPriorityName(); String rtime1 = _sdf.format(cc); // row = row + (i); tmpLabel = new Label(0, 2 + i, startRow + i + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, priorityname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, syslog.getHostname() + syslog.getIpaddress(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, message, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2 + i, rtime1, p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_syslog(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("Syslog", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); List sysloglist = (List) reportHash.get("list"); int startRow = ((Integer) reportHash.get("startRow")).intValue(); Label tmpLabel = null; // tmpLabel = new Label(2, 0, "Syslog", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "", _labelFormat); sheet.addCell(tmpLabel); NetSyslog syslog = null; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); for (int i = 0; i < sysloglist.size(); i++) { syslog = (NetSyslog) sysloglist.get(i); Date cc = syslog.getRecordtime().getTime(); String message = syslog.getMessage(); int priority = syslog.getPriority(); String priorityname = syslog.getPriorityName(); String rtime1 = _sdf.format(cc); // row = row + (i); tmpLabel = new Label(0, 2 + i, startRow + i + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, priorityname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, syslog.getHostname() + syslog.getIpaddress(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, message, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2 + i, rtime1, p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_syslogall(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("Syslog", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); List sysloglist = (List) reportHash.get("list"); Label tmpLabel = null; // tmpLabel = new Label(2, 0, "Syslog", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "", _labelFormat); sheet.addCell(tmpLabel); NetSyslog syslog = null; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); for (int i = 0; i < sysloglist.size(); i++) { syslog = (NetSyslog) sysloglist.get(i); Date cc = syslog.getRecordtime().getTime(); String message = syslog.getMessage(); int priority = syslog.getPriority(); String priorityname = syslog.getPriorityName(); String rtime1 = _sdf.format(cc); // row = row + (i); tmpLabel = new Label(0, 2 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, priorityname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, syslog.getHostname() + syslog.getIpaddress(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, message, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2 + i, rtime1, p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // zhushouzhi----------------------------------------------linklist public void createReport_linklist(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); LinkDao linkDao = new LinkDao(); List linklist = linkDao.loadAll(); Label tmpLabel = null; linkDao.close(); // tmpLabel = new Label(2, 0, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 1, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 1, "(KB/S)", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 1, "(%)", _labelFormat); sheet.addCell(tmpLabel); Link vo = null; // int startRow = jp.getStartRow(); // java.text.SimpleDateFormat _sdf = new // java.text.SimpleDateFormat("MM-dd HH:mm"); for (int i = 0; i < linklist.size(); i++) { vo = (Link) linklist.get(i); HostNode node = new HostNode(); HostNodeDao dao = new HostNodeDao(); node = dao.loadHost(vo.getStartId()); HostNode endnode = new HostNode(); dao = new HostNodeDao(); endnode = dao.loadHost(vo.getEndId()); // row = row + (i); tmpLabel = new Label(0, 2 + i, vo.getId() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, vo.getStartAlias(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, vo.getStartIp(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, vo.getStartIndex(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2 + i, vo.getEndAlias(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 2 + i, vo.getEndIp(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 2 + i, vo.getEndIndex(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 2 + i, vo.getMaxSpeed(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 2 + i, vo.getMaxPer(), p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void backup_linklist(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); LinkDao linkDao = new LinkDao(); List linklist = linkDao.loadAll(); Label tmpLabel = null; linkDao.close(); // tmpLabel = new Label(2, 0, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "ID", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 1, "MAC", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 1, "ID", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 1, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(12, 1, "MAC", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(13, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(14, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(15, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(16, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(17, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(18, 1, "(KB/S)", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(19, 1, "(%)", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(20, 1, "", _labelFormat); sheet.addCell(tmpLabel); Link vo = null; // int startRow = jp.getStartRow(); // java.text.SimpleDateFormat _sdf = new // java.text.SimpleDateFormat("MM-dd HH:mm"); for (int i = 0; i < linklist.size(); i++) { vo = (Link) linklist.get(i); // row = row + (i); tmpLabel = new Label(0, 2 + i, vo.getId() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, vo.getStartId() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, vo.getStartIp(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, vo.getStartDescr(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2 + i, vo.getStartIndex(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 2 + i, vo.getStartPort(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 2 + i, vo.getStartMac(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 2 + i, vo.getEndId() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 2 + i, vo.getEndIp(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 2 + i, vo.getEndDescr(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 2 + i, vo.getEndIndex(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, 2 + i, vo.getEndPort(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(12, 2 + i, vo.getEndMac(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(13, 2 + i, vo.getLinkName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(14, 2 + i, vo.getAssistant() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(15, 2 + i, vo.getType() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(16, 2 + i, vo.getFindtype() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(17, 2 + i, vo.getLinktype() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(18, 2 + i, vo.getMaxSpeed(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(19, 2 + i, vo.getMaxPer(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(20, 2 + i, vo.getShowinterf() + "", p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // quzhi public void createReport_ipmacall(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("IPMAC", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); List ipmaclist = (List) reportHash.get("list"); Label tmpLabel = null; tmpLabel = new Label(2, 0, "IPMAC", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "MAC", _labelFormat); sheet.addCell(tmpLabel); IpMac ipmac = null; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); for (int i = 0; i < ipmaclist.size(); i++) { ipmac = (IpMac) ipmaclist.get(i); // row = row + (i); tmpLabel = new Label(0, 2 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, ipmac.getRelateipaddr(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, ipmac.getIfindex(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, ipmac.getIpaddress(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2 + i, ipmac.getMac(), p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_ipmac(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("IPMAC", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); List ipmaclist = (List) reportHash.get("list"); int startRow = ((Integer) reportHash.get("startRow")).intValue(); Label tmpLabel = null; // tmpLabel = new Label(2, 0, "IPMAC", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "MAC", _labelFormat); sheet.addCell(tmpLabel); IpMac ipmac = null; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); for (int i = 0; i < ipmaclist.size(); i++) { ipmac = (IpMac) ipmaclist.get(i); // row = row + (i); tmpLabel = new Label(0, 2 + i, startRow + i + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, ipmac.getRelateipaddr(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, ipmac.getIfindex(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, ipmac.getIpaddress(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2 + i, ipmac.getMac(), p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_fdb(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("FDB", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); List fdbList = (List) reportHash.get("list"); int startRow = ((Integer) reportHash.get("startRow")).intValue(); Label tmpLabel = null; // tmpLabel = new Label(2, 0, "FDB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "type", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "subtype", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "ifindex", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 1, "ipaddress", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 1, "mac", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 1, "ifband", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 1, "ifsms", _labelFormat); sheet.addCell(tmpLabel); FdbNodeTemp fdb = null; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); for (int i = 0; i < fdbList.size(); i++) { fdb = (FdbNodeTemp) fdbList.get(i); // row = row + (i); tmpLabel = new Label(0, 2 + i, startRow + i + "", p_labelFormat); sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 2 + i, fdb.getNodeid(), // p_labelFormat); // sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, fdb.getIp(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, fdb.getType(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, fdb.getSubtype(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2 + i, fdb.getIfindex(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 2 + i, fdb.getIpaddress(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 2 + i, fdb.getMac(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 2 + i, fdb.getIfband(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 2 + i, fdb.getIfsms(), p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); e.printStackTrace(); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_networklist(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); HostNodeDao hostNodeDao = new HostNodeDao(); List networkhostlist = new ArrayList(); BusinessDao bussdao = new BusinessDao(); List allbuss = bussdao.loadAll(); try { networkhostlist = hostNodeDao.loadall(); } catch (Exception e) { } finally { hostNodeDao.close(); } Label tmpLabel = null; // tmpLabel = new Label(4, 0, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "(ip)", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "MAC", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 1, "OID", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 1, "SNMP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(12, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(13, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(14, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(15, 1, "", _labelFormat); sheet.addCell(tmpLabel); HostNode vo = null; for (int i = 0; i < networkhostlist.size(); i++) { vo = (HostNode) networkhostlist.get(i); // row = row + (i); tmpLabel = new Label(0, 2 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, vo.getAlias(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, vo.getIpAddress(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, vo.getBridgeAddress(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2 + i, vo.getNetMask(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 2 + i, vo.getType(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 2 + i, vo.getSysOid(), p_labelFormat); sheet.addCell(tmpLabel); if (vo.isManaged() == true) { tmpLabel = new Label(7, 2 + i, "", p_labelFormat); } else { tmpLabel = new Label(7, 2 + i, "", p_labelFormat); } sheet.addCell(tmpLabel); if (vo.getEndpoint() == 1) { tmpLabel = new Label(8, 2 + i, "", p_labelFormat); } else { tmpLabel = new Label(8, 2 + i, "", p_labelFormat); } sheet.addCell(tmpLabel); tmpLabel = new Label(9, 2 + i, vo.getCollecttype() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 2 + i, vo.getSnmpversion() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, 2 + i, vo.getCommunity(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(12, 2 + i, vo.getWriteCommunity(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(13, 2 + i, vo.getCategory() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(14, 2 + i, vo.getOstype() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(15, 2 + i, vo.getBid(), p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * oa * * @param filename * */ public void createReport_oawork(String filename, String startdate, String todate) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); // String starttime = (String) reportHash.get("starttime"); // String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("memlist"); Vector vector = (Vector) reportHash.get("sxoanetifreport"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "", labelFormat); sheet.mergeCells(0, 0, 10, 0); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); sheet.mergeCells(0, 1, 10, 1); tmpLabel = new Label(0, 2, ": " + startdate + " 00:00:00 " + " " + todate + " 23:59:59 "); sheet.addCell(tmpLabel); sheet.mergeCells(0, 2, 10, 2); tmpLabel = new Label(0, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "CPU", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 4, "", _labelFormat); sheet.addCell(tmpLabel); // if (null != vector && vector.size() > 0) { Hashtable hash = new Hashtable(); for (int i = 0; i < vector.size(); i++) { hash = (Hashtable) vector.get(i); this.colorChange(i); // tmpLabel = new Label(0, 5 + i, i + 1 + "", // p_labelFormat); // sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5 + i, "" + hash.get("ipaddress"), // vector"" p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, "" + hash.get("ifname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, "" + hash.get("linkuse"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, "" + hash.get("avgcpu") + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, "" + hash.get("avgmemory") + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5 + i, "" + hash.get("avgping") + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5 + i, "" + hash.get("avgresponse") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5 + i, "" + hash.get("maxout") + "kb/s", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 5 + i, "" + hash.get("maxin") + "kb/s", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 5 + i, "" + hash.get("agvout") + "kb/s", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 5 + i, "" + hash.get("agvin") + "kb/s", p_labelFormat); sheet.addCell(tmpLabel); } } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // -----------zhushouzhi public void createReport_tomcatDoc(String file, String type) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); Hashtable maxjvm = (Hashtable) reportHash.get("maxjvm"); String jvmnow = (String) reportHash.get("jvmnow"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(file)); } else { RtfWriter2.getInstance(document, new FileOutputStream(file)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, titleFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(4); this.setTableFormat(aTable); // float[] widths = { 220f, 300f, 220f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// // aTable.endHeaders(); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), false)); aTable.addCell(this.setCellFormat(new Phrase(Ping + "%", contextFont), false)); aTable.addCell(this.setCellFormat(new Phrase((String) maxping.get("pingmax"), contextFont), false)); aTable.addCell(this.setCellFormat(new Phrase((String) maxping.get("avgpingcon"), contextFont), false)); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "TomcatPing" + ".png"); // img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(aTable); document.add(img); Table aTable1 = new Table(4); this.setTableFormat(aTable1); // float[] widths1 = { 220f, 300f, 220f, 220f }; // aTable.setWidths(widths1); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// // aTable.endHeaders(); aTable1.addCell(this.setCellFormat(new Phrase("JVM", contextFont), true)); aTable1.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable1.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable1.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable1.addCell(this.setCellFormat(new Phrase("", contextFont), false)); aTable1.addCell(this.setCellFormat(new Phrase(jvmnow + "%", contextFont), false)); aTable1.addCell(this.setCellFormat(new Phrase((String) maxjvm.get("max_tomcat_jvm"), contextFont), false)); aTable1.addCell(this.setCellFormat(new Phrase((String) maxjvm.get("avg_tomcat_jvm"), contextFont), false)); Image img1 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "tomcat_jvm" + ".png"); // img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.LEFT);// document.add(aTable1); document.add(img1); document.close(); } // tomcat pdf================= public void createReport_tomcatPDF(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Hashtable CPU = (Hashtable) reportHash.get("CPU"); if (CPU == null) CPU = new Hashtable(); String Ping = (String) reportHash.get("Ping"); Calendar colTime = (Calendar) reportHash.get("time"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String jvmnow = (String) reportHash.get("jvmnow"); Hashtable maxjvm = (Hashtable) reportHash.get("maxjvm"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", contextFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); PdfPTable aTable = new PdfPTable(4); float[] widths = { 220f, 300f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); // aTable.addCell("3.2",Ping+"%"); aTable.addCell(""); aTable.addCell(Ping + "%"); aTable.addCell((String) maxping.get("pingmax")); aTable.addCell((String) maxping.get("avgpingcon")); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "TomcatPing" + ".png"); img.setAlignment(Image.LEFT);// img.scalePercent(75); document.add(aTable); document.add(img); PdfPTable aTable1 = new PdfPTable(4); float[] widths1 = { 220f, 300f, 220f, 220f }; aTable1.setWidths(widths1); aTable1.setWidthPercentage(100); aTable1.addCell(new Phrase("JVM", contextFont)); aTable1.addCell(new Phrase("", contextFont)); aTable1.addCell(new Phrase("", contextFont)); aTable1.addCell(new Phrase("", contextFont)); // aTable.addCell("3.2",Ping+"%"); aTable1.addCell(""); aTable1.addCell(jvmnow + "%"); aTable1.addCell((String) maxjvm.get("max_tomcat_jvm")); aTable1.addCell((String) maxjvm.get("avg_tomcat_jvm")); Image img1 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "tomcat_jvm" + ".png"); img1.setAlignment(Image.LEFT);// img1.scalePercent(75); document.add(aTable1); document.add(img1); document.close(); } // tomcat yunxingfenxi zhushouzhi /** * @param file * @param type * @throws DocumentException * @throws IOException */ public void createReport_tomcatNewDoc(String file, String type) throws DocumentException, IOException { Hashtable Memory = (Hashtable) reportHash.get("Memory"); // EventListDao eventListDao = new EventListDao(); Hashtable maxping = (Hashtable) reportHash.get("ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String hostnameDoc = (String) reportHash.get("equipnameDoc"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String startdate = (String) reportHash.get("startdate"); Tomcat tomcat = (Tomcat) reportHash.get("tomcat"); Hashtable maxjvm = (Hashtable) reportHash.get("maxjvm"); String downnum = (String) reportHash.get("downnum"); /* String type = (String)request.getAttribute("type"); */ Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(file)); } else { RtfWriter2.getInstance(document, new FileOutputStream(file)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); this.setTableFormat(aTable); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// // // aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); this.setCellFormat(cell, true); cell.setColspan(8); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + starttime + " " + totime + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(hostnameDoc, contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont)); cell.setColspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase("\n" + grade + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(4); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setColspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "JVM" + "\n", titleFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase((String) maxjvm.get("max_tomcat_jvm"), contextFont)); cell.setColspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase((String) maxjvm.get("avg_tomcat_jvm"), contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setRowspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "TOMCAT" + "\n", titleFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(tomcat.getVersion(), contextFont)); cell.setColspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("JVM", titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(tomcat.getJvmversion(), contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "JVM" + "\n", titleFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(tomcat.getJvmvender(), contextFont)); cell.setColspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(tomcat.getOs(), contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); cell.setColspan(8); aTable.addCell(cell); String strping = ""; if ("0".equals(downnum)) { strping = " 2 " + downnum + "" + "\n" + "\n"; } else { strping = " 2 " + "\n" + "\n"; } cell = new Cell(new Phrase(" 1 " + " \n" + "\n" + strping + "\n" + "\n" + "\n", contextFont) ); cell.setColspan(8); aTable.addCell(cell); // end // end } document.add(aTable); document.close(); } // zhushouzhi pdf tomcat run public void createReport_tomcatNewPDF(String file) throws DocumentException, IOException { Hashtable Memory = (Hashtable) reportHash.get("Memory"); // EventListDao eventListDao = new EventListDao(); Hashtable maxping = (Hashtable) reportHash.get("ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String hostnameDoc = (String) reportHash.get("equipnameDoc"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String startdate = (String) reportHash.get("startdate"); String downnum = (String) reportHash.get("downnum"); Tomcat tomcat = (Tomcat) reportHash.get("tomcat"); /* String type = (String)request.getAttribute("type"); */ Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 10, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); aTable.addCell(cell); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell = new Cell(new Phrase("\n" + starttime + " " + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnameDoc, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase("\n" + grade + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "JVM" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "TOMCAT" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(tomcat.getVersion())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("JVM", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(tomcat.getJvmversion())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "JVM" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(tomcat.getJvmvender())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(tomcat.getOs())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setColspan(8); aTable.addCell(cell); String strping = ""; if ("0".equals(downnum)) { strping = " 2 " + downnum + "" + "\n" + "\n"; } else { strping = " 2 " + "\n" + "\n"; } cell = new Cell(new Phrase(" 1 " + " \n" + "\n" + strping + "\n" + "\n" + "\n", contextFont) ); cell.setColspan(8); aTable.addCell(cell); // end // end } document.add(aTable); document.close(); } // iis```` public void createReport_iis(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String iisnow = (String) reportHash.get("iisnow"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); Calendar colTime = (Calendar) reportHash.get("time"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 7, 0); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); sheet.mergeCells(0, 1, 7, 1); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); sheet.mergeCells(0, 2, 7, 2); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 4, 0, 12); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 4, 2, 4); sheet.mergeCells(3, 4, 4, 4); sheet.mergeCells(5, 4, 7, 4); tmpLabel = new Label(1, 5, iisnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 5, 2, 5); sheet.mergeCells(3, 5, 4, 5); sheet.mergeCells(5, 5, 7, 5); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "iisPing" + ".png"); sheet.addImage(new WritableImage(1, 6, 7, 7, file)); wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_iisAll(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreport_has = new Hashtable(); allreport_has = reportHash; if (allreport_has != null && allreport_has.size() > 0) { Iterator keys = allreport_has.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreport_has.get(ip); reportHash = report_has; // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String iisnow = (String) reportHash.get("iisnow"); WritableSheet sheet = wb.createSheet(hostname + "", 0); Calendar colTime = (Calendar) reportHash.get("time"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; Label tmpLabel = null; tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 7, 0); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); sheet.mergeCells(0, 1, 7, 1); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); sheet.mergeCells(0, 2, 7, 2); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 4, 0, 12); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 4, 2, 4); sheet.mergeCells(3, 4, 4, 4); sheet.mergeCells(5, 4, 7, 4); tmpLabel = new Label(1, 5, iisnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 5, 2, 5); sheet.mergeCells(3, 5, 4, 5); sheet.mergeCells(5, 5, 7, 5); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "iisPing" + ".png"); sheet.addImage(new WritableImage(1, 6, 7, 7, file)); wb.write(); } } } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } // iis-------------word public void createReport_iisDoc(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Calendar colTime = (Calendar) reportHash.get("time"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String iisnow = (String) reportHash.get("iisnow"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(4); this.setTableFormat(aTable); // float[] widths = { 220f, 300f, 220f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// // aTable.endHeaders(); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); // aTable.addCell("3.2",Ping+"%"); aTable.addCell(""); aTable.addCell(iisnow + "%"); aTable.addCell((String) maxping.get("pingmax")); aTable.addCell((String) maxping.get("avgpingcon")); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "iisPing" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(aTable); document.add(img); document.close(); } // iis------------pdf public void createReport_iisPDF(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Calendar colTime = (Calendar) reportHash.get("time"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String iisnow = (String) reportHash.get("iisnow"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(4); this.setTableFormat(aTable); // float[] widths = { 220f, 300f, 220f, 220f }; // aTable.setWidths(widths); // aTable.setWidthPercentage(100); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); // aTable.addCell("3.2",Ping+"%"); aTable.addCell(""); aTable.addCell(iisnow + "%"); aTable.addCell((String) maxping.get("pingmax")); aTable.addCell((String) maxping.get("avgpingcon")); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "iisPing" + ".png"); img.setAlignment(Image.LEFT);// img.scalePercent(75); document.add(aTable); document.add(img); PdfPTable aTable1 = new PdfPTable(4); float[] widths1 = { 220f, 300f, 220f, 220f }; aTable1.setWidths(widths1); aTable1.setWidthPercentage(100); document.close(); } /** * @param file * @param type * @throws DocumentException * @throws IOException */ public void createReport_iisNewDoc(String file, String type) throws DocumentException, IOException { Hashtable Memory = (Hashtable) reportHash.get("Memory"); // EventListDao eventListDao = new EventListDao(); Hashtable maxping = (Hashtable) reportHash.get("ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String hostnameDoc = (String) reportHash.get("equipnameDoc"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String startdate = (String) reportHash.get("startdate"); Tomcat tomcat = (Tomcat) reportHash.get("tomcat"); Hashtable maxjvm = (Hashtable) reportHash.get("maxjvm"); String downnum = (String) reportHash.get("downnum"); IIS iis = (IIS) reportHash.get("iis"); // time Hashtable pollingtime_ht = new Hashtable(); IISManager tm = new IISManager(); String lasttime; String nexttime; try { pollingtime_ht = tm.getCollecttime(iis.getIpAddress()); } catch (Exception e) { SysLogger.error("", e); } if (pollingtime_ht != null) { lasttime = (String) pollingtime_ht.get("lasttime"); nexttime = (String) pollingtime_ht.get("nexttime"); } else { lasttime = null; nexttime = null; } // List data_list = new ArrayList(); Hashtable iisvalues = ShareData.getIisdata(); if (iisvalues != null && iisvalues.size() > 0) { data_list = (List) iisvalues.get(ip); } System.out.println(data_list + "----------------------------===================="); String totalBytesSentHighWord = ""; String totalBytesSentLowWord = ""; String totalBytesReceivedHighWord = ""; String totalBytesReceivedLowWord = ""; String totalFilesSent = ""; String totalFilesReceived = ""; String currentAnonymousUsers = ""; String totalAnonymousUsers = ""; String maxAnonymousUsers = ""; String currentConnections = ""; String maxConnections = ""; String connectionAttempts = ""; String logonAttempts = ""; String totalGets = ""; String totalPosts = ""; String totalNotFoundErrors = ""; if (data_list != null && data_list.size() > 0) { IISVo iisvo = (IISVo) data_list.get(0); totalBytesSentHighWord = iisvo.getTotalBytesSentHighWord(); totalBytesSentLowWord = iisvo.getTotalBytesSentLowWord(); totalBytesReceivedHighWord = iisvo.getTotalBytesReceivedHighWord(); totalBytesReceivedLowWord = iisvo.getTotalBytesReceivedLowWord(); totalFilesSent = iisvo.getTotalFilesSent(); totalFilesReceived = iisvo.getTotalFilesReceived(); currentAnonymousUsers = iisvo.getCurrentAnonymousUsers(); totalAnonymousUsers = iisvo.getTotalAnonymousUsers(); maxAnonymousUsers = iisvo.getMaxAnonymousUsers(); currentConnections = iisvo.getCurrentConnections(); maxConnections = iisvo.getMaxConnections(); connectionAttempts = iisvo.getConnectionAttempts(); logonAttempts = iisvo.getLogonAttempts(); totalGets = iisvo.getTotalGets(); totalPosts = iisvo.getTotalPosts(); totalNotFoundErrors = iisvo.getTotalNotFoundErrors(); } // end /* String type = (String)request.getAttribute("type"); */ Document document = null; // (Writer)document(Writer) if ("pdf".equals(type)) { document = new Document(PageSize.B4); PdfWriter.getInstance(document, new FileOutputStream(file)); } else { document = new Document(PageSize.A4); RtfWriter2.getInstance(document, new FileOutputStream(file)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); this.setTableFormat(aTable); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// // aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); aTable.addCell(cell); this.setCellFormat(cell, true); cell = new Cell(new Phrase("\n" + starttime + " " + totime + "\n", contextFont)); cell.setColspan(7); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(hostnameDoc, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase("\n" + grade + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(10); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lasttime, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nexttime, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setRowspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "32 :" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalBytesSentHighWord, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("32 :", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalBytesSentLowWord, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "32 :" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalBytesReceivedHighWord, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("32 :", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalBytesReceivedLowWord, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalFilesSent, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalFilesReceived, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(currentAnonymousUsers, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalAnonymousUsers, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(maxAnonymousUsers, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(currentConnections, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(maxConnections, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("::", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(connectionAttempts, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(logonAttempts, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("GET:", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalGets, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "POST:" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalPosts, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalNotFoundErrors, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); cell.setColspan(8); aTable.addCell(cell); String strping = ""; if ("0".equals(downnum)) { strping = " 2 " + downnum + "" + "\n" + "\n"; } else { strping = " 2 " + "\n" + "\n"; } cell = new Cell(new Phrase(" 1 " + " \n" + "\n" + strping + "\n" + "\n" + "\n", contextFont)); cell.setColspan(8); aTable.addCell(cell); // end // end } document.add(aTable); document.close(); } // iis----------------new pdf public void createReport_iisNewPDF(String file) throws DocumentException, IOException { Hashtable maxping = (Hashtable) reportHash.get("ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String hostnameDoc = (String) reportHash.get("equipnameDoc"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String startdate = (String) reportHash.get("startdate"); Tomcat tomcat = (Tomcat) reportHash.get("tomcat"); Hashtable maxjvm = (Hashtable) reportHash.get("maxjvm"); String downnum = (String) reportHash.get("downnum"); IIS iis = (IIS) reportHash.get("iis"); // time Hashtable pollingtime_ht = new Hashtable(); IISManager tm = new IISManager(); String lasttime; String nexttime; try { pollingtime_ht = tm.getCollecttime(iis.getIpAddress()); } catch (Exception e) { SysLogger.error("", e); } if (pollingtime_ht != null) { lasttime = (String) pollingtime_ht.get("lasttime"); nexttime = (String) pollingtime_ht.get("nexttime"); } else { lasttime = null; nexttime = null; } // List data_list = new ArrayList(); Hashtable iisvalues = ShareData.getIisdata(); if (iisvalues != null && iisvalues.size() > 0) { data_list = (List) iisvalues.get(ip); } System.out.println(data_list + "----------------------------===================="); String totalBytesSentHighWord = ""; String totalBytesSentLowWord = ""; String totalBytesReceivedHighWord = ""; String totalBytesReceivedLowWord = ""; String totalFilesSent = ""; String totalFilesReceived = ""; String currentAnonymousUsers = ""; String totalAnonymousUsers = ""; String maxAnonymousUsers = ""; String currentConnections = ""; String maxConnections = ""; String connectionAttempts = ""; String logonAttempts = ""; String totalGets = ""; String totalPosts = ""; String totalNotFoundErrors = ""; if (data_list != null && data_list.size() > 0) { IISVo iisvo = (IISVo) data_list.get(0); totalBytesSentHighWord = iisvo.getTotalBytesSentHighWord(); totalBytesSentLowWord = iisvo.getTotalBytesSentLowWord(); totalBytesReceivedHighWord = iisvo.getTotalBytesReceivedHighWord(); totalBytesReceivedLowWord = iisvo.getTotalBytesReceivedLowWord(); totalFilesSent = iisvo.getTotalFilesSent(); totalFilesReceived = iisvo.getTotalFilesReceived(); currentAnonymousUsers = iisvo.getCurrentAnonymousUsers(); totalAnonymousUsers = iisvo.getTotalAnonymousUsers(); maxAnonymousUsers = iisvo.getMaxAnonymousUsers(); currentConnections = iisvo.getCurrentConnections(); maxConnections = iisvo.getMaxConnections(); connectionAttempts = iisvo.getConnectionAttempts(); logonAttempts = iisvo.getLogonAttempts(); totalGets = iisvo.getTotalGets(); totalPosts = iisvo.getTotalPosts(); totalNotFoundErrors = iisvo.getTotalNotFoundErrors(); } // end /* String type = (String)request.getAttribute("type"); */ Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 10, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); aTable.addCell(cell); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell = new Cell(new Phrase("\n" + starttime + " " + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnameDoc, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase("\n" + grade + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lasttime)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nexttime)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setRowspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "32 :" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalBytesSentHighWord)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("32 :", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalBytesSentLowWord)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "32 :" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalBytesReceivedHighWord)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("32 :", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalBytesReceivedLowWord)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalFilesSent)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalFilesReceived)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(currentAnonymousUsers)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalAnonymousUsers)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(maxAnonymousUsers)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(currentConnections)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(maxConnections)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("::", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(connectionAttempts)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(logonAttempts)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("GET:", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalGets)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "POST:" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalPosts)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(totalNotFoundErrors)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setColspan(8); aTable.addCell(cell); String strping = ""; if ("0".equals(downnum)) { strping = " 2 " + downnum + "" + "\n" + "\n"; } else { strping = " 2 " + "\n" + "\n"; } cell = new Cell(new Phrase(" 1 " + " \n" + "\n" + strping + "\n" + "\n" + "\n", contextFont) ); cell.setColspan(8); aTable.addCell(cell); // end // end } document.add(aTable); document.close(); } // zhushouzhi----------------weblogic // weblogic excel report public void createReport_weblogic(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); Weblogic weblogic = (Weblogic) reportHash.get("weblogic"); String weblogicnow = (String) reportHash.get("weblogicnow"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); Calendar colTime = (Calendar) reportHash.get("time"); Hashtable hash = (Hashtable) reportHash.get("weblogicnmphash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 7, 0); sheet.mergeCells(0, 1, 7, 1); sheet.mergeCells(0, 2, 7, 2); sheet.mergeCells(0, 4, 0, 12); sheet.mergeCells(1, 4, 2, 4); sheet.mergeCells(3, 4, 4, 4); sheet.mergeCells(5, 4, 7, 4); tmpLabel = new Label(1, 5, weblogicnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 5, 2, 5); sheet.mergeCells(3, 5, 4, 5); sheet.mergeCells(5, 5, 7, 5); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "WeblogicPing" + ".png"); sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // // Hashtable hash = null; // WeblogicSnmp weblogicsnmp = null; // WeblogicConfigDao weblogicconfigdao = new WeblogicConfigDao(); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic.getPortnum()); // hash = weblogicsnmp.collectData(); List queuedatalist = new ArrayList(); tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 14, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(6, 14, 7, 14); if (hash != null) { queuedatalist = (List) hash.get("queueValue"); } sheet.mergeCells(0, 14, 0, 14 + queuedatalist.size()); int row = 0; for (int i = 0; i < queuedatalist.size(); i++) { p_labelFormat = this.colorChange(i); WeblogicQueue vo = (WeblogicQueue) queuedatalist.get(i); tmpLabel = new Label(1, 15 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15 + i, vo.getExecuteQueueRuntimeName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15 + i, vo.getThreadPoolRuntimeExecuteThreadIdleCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 15 + i, vo.getExecuteQueueRuntimePendingRequestOldestTime(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 15 + i, vo.getExecuteQueueRuntimePendingRequestCurrentCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 15 + i, vo.getExecuteQueueRuntimePendingRequestTotalCount(), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(6, 15 + i, 7, 15 + i); row++; } // jdbc int row1 = 15 + row + 1; tmpLabel = new Label(0, row1, "JDBC", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row1, "", _labelFormat); sheet.addCell(tmpLabel); List jdbcdatalist = new ArrayList(); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic.getPortnum()); // hash = weblogicsnmp.collectData(); jdbcdatalist = (List) hash.get("jdbcValue"); sheet.mergeCells(0, row1, 0, row1 + jdbcdatalist.size()); int row2 = 0; for (int i = 0; i < jdbcdatalist.size(); i++) { p_labelFormat = this.colorChange(i); WeblogicJdbc vo = (WeblogicJdbc) jdbcdatalist.get(i); tmpLabel = new Label(1, row1 + 1 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row1 + 1 + i, vo.getJdbcConnectionPoolName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeActiveConnectionsCurrentCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeVersionJDBCDriver(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeMaxCapacity(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeActiveConnectionsAverageCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeHighestNumAvailable(), p_labelFormat); sheet.addCell(tmpLabel); row2++; } // jvm int row3 = row1 + 1 + row2 + 1; // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic.getPortnum()); // hash = weblogicsnmp.collectData(); List heapdatalist = new ArrayList(); heapdatalist = (List) hash.get("heapValue"); tmpLabel = new Label(0, row3, "JVM", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row3, 0, row3 + heapdatalist.size()); tmpLabel = new Label(1, row3, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row3, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row3, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row3, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(2, row3, 3, row3); sheet.mergeCells(4, row3, 5, row3); sheet.mergeCells(6, row3, 7, row3); int row4 = 0; for (int i = 0; i < heapdatalist.size(); i++) { p_labelFormat = this.colorChange(i); WeblogicHeap vo = (WeblogicHeap) heapdatalist.get(i); tmpLabel = new Label(1, row3 + 1 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row3 + 1 + i, vo.getJvmRuntimeName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row3 + 1 + i, vo.getJvmRuntimeHeapSizeCurrent(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row3 + 1 + i, vo.getJvmRuntimeHeapFreeCurrent(), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(2, row3 + 1 + i, 3, row3 + 1 + i); sheet.mergeCells(4, row3 + 1 + i, 5, row3 + 1 + i); sheet.mergeCells(6, row3 + 1 + i, 7, row3 + 1 + i); row4++; } int row5 = row3 + 1 + row4 + 1; tmpLabel = new Label(0, row5, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row5, "Socket", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row5, "IP", _labelFormat); sheet.addCell(tmpLabel); List serverdatalist = new ArrayList(); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic.getPortnum()); // hash = weblogicsnmp.collectData(); serverdatalist = (List) hash.get("serverValue"); sheet.mergeCells(0, row5, 0, row5 + serverdatalist.size()); for (int i = 0; i < serverdatalist.size(); i++) { p_labelFormat = this.colorChange(i); WeblogicServer vo = (WeblogicServer) serverdatalist.get(i); tmpLabel = new Label(1, row5 + 1 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row5 + 1 + i, vo.getServerRuntimeName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row5 + 1 + i, vo.getServerRuntimeListenAddress(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row5 + 1 + i, vo.getServerRuntimeListenPort(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row5 + 1 + i, vo.getServerRuntimeOpenSocketsCurrentCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row5 + 1 + i, vo.getServerRuntimeState(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row5 + 1 + i, weblogic.getIpAddress(), p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } /** * @param filename */ public void createReport_weblogicAll(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; Hashtable allreport_has = new Hashtable(); allreport_has = reportHash; wb = Workbook.createWorkbook(new File(fileName)); if (allreport_has != null && allreport_has.size() > 0) { Iterator keys = allreport_has.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreport_has.get(ip); reportHash = report_has; fileName = ResourceCenter.getInstance().getSysPath() + filename; String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); Weblogic weblogic = (Weblogic) reportHash.get("weblogic"); String weblogicnow = (String) reportHash.get("weblogicnow"); WritableSheet sheet = wb.createSheet(hostname + "", sheetNum); sheetNum++; Calendar colTime = (Calendar) reportHash.get("time"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new // WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new // WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new // WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 7, 0); sheet.mergeCells(0, 1, 7, 1); sheet.mergeCells(0, 2, 7, 2); sheet.mergeCells(0, 4, 0, 12); sheet.mergeCells(1, 4, 2, 4); sheet.mergeCells(3, 4, 4, 4); sheet.mergeCells(5, 4, 7, 4); tmpLabel = new Label(1, 5, weblogicnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 5, 2, 5); sheet.mergeCells(3, 5, 4, 5); sheet.mergeCells(5, 5, 7, 5); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "WeblogicPing" + ".png"); sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // Hashtable hash = (Hashtable) report_has.get("weblogicnmphash"); // Hashtable hash = null; // WeblogicSnmp weblogicsnmp = null; // WeblogicConfigDao weblogicconfigdao = new // WeblogicConfigDao(); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic // .getPortnum()); // hash = weblogicsnmp.collectData(); List queuedatalist = new ArrayList(); tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 14, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(6, 14, 7, 14); if (hash != null) { queuedatalist = (List) hash.get("queueValue"); } sheet.mergeCells(0, 14, 0, 14 + queuedatalist.size()); int row = 0; for (int i = 0; i < queuedatalist.size(); i++) { p_labelFormat = this.colorChange(i); WeblogicQueue vo = (WeblogicQueue) queuedatalist.get(i); tmpLabel = new Label(1, 15 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15 + i, vo.getExecuteQueueRuntimeName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15 + i, vo.getThreadPoolRuntimeExecuteThreadIdleCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 15 + i, vo.getExecuteQueueRuntimePendingRequestOldestTime(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 15 + i, vo.getExecuteQueueRuntimePendingRequestCurrentCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 15 + i, vo.getExecuteQueueRuntimePendingRequestTotalCount(), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(6, 15 + i, 7, 15 + i); row++; } // jdbc int row1 = 15 + row + 1; tmpLabel = new Label(0, row1, "JDBC", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row1, "", _labelFormat); sheet.addCell(tmpLabel); List jdbcdatalist = new ArrayList(); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic // .getPortnum()); // hash = weblogicsnmp.collectData(); jdbcdatalist = (List) hash.get("jdbcValue"); sheet.mergeCells(0, row1, 0, row1 + jdbcdatalist.size()); int row2 = 0; for (int i = 0; i < jdbcdatalist.size(); i++) { p_labelFormat = this.colorChange(i); WeblogicJdbc vo = (WeblogicJdbc) jdbcdatalist.get(i); tmpLabel = new Label(1, row1 + 1 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row1 + 1 + i, vo.getJdbcConnectionPoolName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeActiveConnectionsCurrentCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeVersionJDBCDriver(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeMaxCapacity(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeActiveConnectionsAverageCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row1 + 1 + i, vo.getJdbcConnectionPoolRuntimeHighestNumAvailable(), p_labelFormat); sheet.addCell(tmpLabel); row2++; } // jvm int row3 = row1 + 1 + row2 + 1; // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic // .getPortnum()); // hash = weblogicsnmp.collectData(); List heapdatalist = new ArrayList(); heapdatalist = (List) hash.get("heapValue"); tmpLabel = new Label(0, row3, "JVM", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row3, 0, row3 + heapdatalist.size()); tmpLabel = new Label(1, row3, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row3, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row3, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row3, "", _labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(2, row3, 3, row3); sheet.mergeCells(4, row3, 5, row3); sheet.mergeCells(6, row3, 7, row3); int row4 = 0; for (int i = 0; i < heapdatalist.size(); i++) { p_labelFormat = this.colorChange(i); WeblogicHeap vo = (WeblogicHeap) heapdatalist.get(i); tmpLabel = new Label(1, row3 + 1 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row3 + 1 + i, vo.getJvmRuntimeName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row3 + 1 + i, vo.getJvmRuntimeHeapSizeCurrent(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row3 + 1 + i, vo.getJvmRuntimeHeapFreeCurrent(), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(2, row3 + 1 + i, 3, row3 + 1 + i); sheet.mergeCells(4, row3 + 1 + i, 5, row3 + 1 + i); sheet.mergeCells(6, row3 + 1 + i, 7, row3 + 1 + i); row4++; } int row5 = row3 + 1 + row4 + 1; tmpLabel = new Label(0, row5, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row5, "Socket", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row5, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row5, "IP", _labelFormat); sheet.addCell(tmpLabel); List serverdatalist = new ArrayList(); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic // .getPortnum()); // hash = weblogicsnmp.collectData(); serverdatalist = (List) hash.get("serverValue"); sheet.mergeCells(0, row5, 0, row5 + serverdatalist.size()); for (int i = 0; i < serverdatalist.size(); i++) { p_labelFormat = this.colorChange(i); WeblogicServer vo = (WeblogicServer) serverdatalist.get(i); tmpLabel = new Label(1, row5 + 1 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row5 + 1 + i, vo.getServerRuntimeName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row5 + 1 + i, vo.getServerRuntimeListenAddress(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row5 + 1 + i, vo.getServerRuntimeListenPort(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row5 + 1 + i, vo.getServerRuntimeOpenSocketsCurrentCount(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row5 + 1 + i, vo.getServerRuntimeState(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row5 + 1 + i, weblogic.getIpAddress(), p_labelFormat); sheet.addCell(tmpLabel); } } } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } } /** * @param file * @param type * @throws DocumentException * @throws IOException */ public void createReport_weblogicDoc(String file, String type) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Calendar colTime = (Calendar) reportHash.get("time"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String weblogicnow = (String) reportHash.get("weblogicnow"); Weblogic weblogic = (Weblogic) reportHash.get("weblogic"); Hashtable hash = (Hashtable) reportHash.get("weblogicnmphash"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { document = new Document(PageSize.B4); PdfWriter.getInstance(document, new FileOutputStream(file)); } else { RtfWriter2.getInstance(document, new FileOutputStream(file)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(4); this.setTableFormat(aTable); // float[] widths = { 220f, 300f, 220f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// // aTable.endHeaders(); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); aTable.addCell(this.setCellFormat(new Phrase("", contextFont), true)); // aTable.addCell("3.2",Ping+"%"); aTable.addCell(""); aTable.addCell(weblogicnow + "%"); aTable.addCell((String) maxping.get("pingmax")); aTable.addCell((String) maxping.get("avgpingcon")); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "WeblogicPing" + ".png"); // img.setAbsolutePosition(0, 0); if ("pdf".equals(type)) { img.scalePercent(75); } img.setAlignment(Image.LEFT);// document.add(aTable); document.add(img); document.add(new Paragraph("\n")); Table aTable1 = new Table(7); // float[] widths1 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // aTable1.setWidths(widths1); // aTable1.setWidth(100); // 90% // aTable1.setAlignment(Element.ALIGN_CENTER);// // aTable1.setAutoFillEmptyCells(true); // // aTable1.setBorderWidth(1); // // aTable1.setBorderColor(new Color(0, 125, 255)); // // aTable1.setPadding(2);// // aTable1.setSpacing(0);// // aTable1.setBorder(2);// // aTable1.endHeaders(); this.setTableFormat(aTable1); Cell cell = null; cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); List queuedatalist = new ArrayList(); // Hashtable hash = null; // WeblogicSnmp weblogicsnmp = null; // WeblogicConfigDao weblogicconfigdao = new WeblogicConfigDao(); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic.getPortnum()); // hash = weblogicsnmp.collectData(); if (hash != null) { queuedatalist = (List) hash.get("queueValue"); } for (int i = 0; i < queuedatalist.size(); i++) { WeblogicQueue vo = (WeblogicQueue) queuedatalist.get(i); cell = new Cell(new Phrase("")); aTable1.addCell(cell); cell = new Cell(new Phrase(i + 1 + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(vo.getExecuteQueueRuntimeName(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(vo.getThreadPoolRuntimeExecuteThreadIdleCount(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(vo.getExecuteQueueRuntimePendingRequestOldestTime(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(vo.getExecuteQueueRuntimePendingRequestCurrentCount(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(vo.getExecuteQueueRuntimePendingRequestTotalCount(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } document.add(aTable1); Table aTable2 = new Table(8); this.setTableFormat(aTable2); // float[] widths2 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // aTable2.setWidths(widths2); // aTable2.setWidth(100); // 90% // aTable2.setAlignment(Element.ALIGN_CENTER);// // aTable2.setAutoFillEmptyCells(true); // // aTable2.setBorderWidth(1); // // aTable2.setBorderColor(new Color(0, 125, 255)); // // aTable2.setPadding(2);// // aTable2.setSpacing(0);// // aTable2.setBorder(2);// // aTable2.endHeaders(); cell = new Cell(new Phrase("JDBC", contextFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); List jdbcdatalist = new ArrayList(); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic.getPortnum()); // hash = weblogicsnmp.collectData(); jdbcdatalist = (List) hash.get("jdbcValue"); for (int i = 0; i < jdbcdatalist.size(); i++) { WeblogicJdbc vo = (WeblogicJdbc) jdbcdatalist.get(i); cell = new Cell(new Phrase("")); aTable2.addCell(cell); cell = new Cell(new Phrase(i + 1 + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase(vo.getJdbcConnectionPoolName(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell( new Phrase(vo.getJdbcConnectionPoolRuntimeActiveConnectionsCurrentCount(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase(vo.getJdbcConnectionPoolRuntimeVersionJDBCDriver(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase(vo.getJdbcConnectionPoolRuntimeMaxCapacity(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell( new Phrase(vo.getJdbcConnectionPoolRuntimeActiveConnectionsAverageCount(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase(vo.getJdbcConnectionPoolRuntimeHighestNumAvailable(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); } document.add(aTable2); Table aTable3 = new Table(5); this.setTableFormat(aTable3); // float[] widths3 = { 220f, 220f, 220f, 220f, 220f }; // aTable3.setWidths(widths3); // aTable3.setWidth(100); // 90% // aTable3.setAlignment(Element.ALIGN_CENTER);// // aTable3.setAutoFillEmptyCells(true); // // aTable3.setBorderWidth(1); // // aTable3.setBorderColor(new Color(0, 125, 255)); // // aTable3.setPadding(2);// // aTable3.setSpacing(0);// // aTable3.setBorder(2);// // aTable3.endHeaders(); cell = new Cell(new Phrase("JVM", contextFont)); this.setCellFormat(cell, true); aTable3.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable3.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable3.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable3.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable3.addCell(cell); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic.getPortnum()); // hash = weblogicsnmp.collectData(); List heapdatalist = new ArrayList(); heapdatalist = (List) hash.get("heapValue"); for (int i = 0; i < heapdatalist.size(); i++) { WeblogicHeap vo = (WeblogicHeap) heapdatalist.get(i); cell = new Cell(new Phrase("")); aTable3.addCell(cell); cell = new Cell(new Phrase(i + 1 + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase(vo.getJvmRuntimeName(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase(vo.getJvmRuntimeHeapSizeCurrent(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase(vo.getJvmRuntimeHeapFreeCurrent(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); } document.add(aTable3); Table aTable4 = new Table(8); // float[] widths4 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // aTable4.setWidths(widths4); // aTable4.setWidth(100); // 90% // aTable4.setAlignment(Element.ALIGN_CENTER);// // aTable4.setAutoFillEmptyCells(true); // // aTable4.setBorderWidth(1); // // aTable4.setBorderColor(new Color(0, 125, 255)); // // aTable4.setPadding(2);// // aTable4.setSpacing(0);// // aTable4.setBorder(2);// // aTable4.endHeaders(); this.setTableFormat(aTable4); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase("Socket", contextFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase("", contextFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase("IP", contextFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic.getPortnum()); // hash = weblogicsnmp.collectData(); List serverdatalist = new ArrayList(); serverdatalist = (List) hash.get("serverValue"); for (int i = 0; i < serverdatalist.size(); i++) { WeblogicServer vo = (WeblogicServer) serverdatalist.get(i); cell = new Cell(""); aTable4.addCell(cell); cell = new Cell(new Phrase(i + 1 + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase(vo.getServerRuntimeName(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase(vo.getServerRuntimeListenAddress(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase(vo.getServerRuntimeListenPort(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase(vo.getServerRuntimeOpenSocketsCurrentCount(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase(vo.getServerRuntimeState(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase(weblogic.getIpAddress(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); } document.add(aTable4); document.close(); } public void createReport_weblogicPDF(String file) throws DocumentException, IOException { String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // WritableSheet sheet = wb.createSheet(hostname + "", 0); Calendar colTime = (Calendar) reportHash.get("time"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String weblogicnow = (String) reportHash.get("weblogicnow"); Weblogic weblogic = (Weblogic) reportHash.get("weblogic"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); PdfPTable aTable = new PdfPTable(4); float[] widths = { 220f, 300f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); // aTable.addCell("3.2",Ping+"%"); aTable.addCell(""); aTable.addCell(weblogicnow + "%"); aTable.addCell((String) maxping.get("pingmax")); aTable.addCell((String) maxping.get("avgpingcon")); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "WeblogicPing" + ".png"); img.setAlignment(Image.LEFT);// img.scalePercent(75); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); PdfPTable aTable1 = new PdfPTable(7); float[] widths1 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(widths1); aTable1.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); List queuedatalist = new ArrayList(); Hashtable hash = null; WeblogicSnmp weblogicsnmp = null; WeblogicConfigDao weblogicconfigdao = new WeblogicConfigDao(); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic.getPortnum()); // hash = weblogicsnmp.collectData(); if (hash != null) { queuedatalist = (List) hash.get("queueValue"); } for (int i = 0; i < queuedatalist.size(); i++) { WeblogicQueue vo = (WeblogicQueue) queuedatalist.get(i); cell = new PdfPCell(new Phrase("")); aTable1.addCell(cell); cell = new PdfPCell(new Phrase(i + 1 + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(vo.getExecuteQueueRuntimeName())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(vo.getThreadPoolRuntimeExecuteThreadIdleCount())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(vo.getExecuteQueueRuntimePendingRequestOldestTime())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(vo.getExecuteQueueRuntimePendingRequestCurrentCount())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(vo.getExecuteQueueRuntimePendingRequestTotalCount())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } document.add(aTable1); document.add(new Paragraph("\n")); PdfPTable aTable2 = new PdfPTable(8); float[] widths2 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable2.setWidths(widths2); aTable2.setWidthPercentage(100); cell = new PdfPCell(new Phrase("JDBC", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); List jdbcdatalist = new ArrayList(); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic.getPortnum()); // hash = weblogicsnmp.collectData(); jdbcdatalist = (List) hash.get("jdbcValue"); for (int i = 0; i < jdbcdatalist.size(); i++) { WeblogicJdbc vo = (WeblogicJdbc) jdbcdatalist.get(i); cell = new PdfPCell(new Phrase("")); aTable2.addCell(cell); cell = new PdfPCell(new Phrase(i + 1 + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase(vo.getJdbcConnectionPoolName())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase(vo.getJdbcConnectionPoolRuntimeActiveConnectionsCurrentCount())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase(vo.getJdbcConnectionPoolRuntimeVersionJDBCDriver())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase(vo.getJdbcConnectionPoolRuntimeMaxCapacity())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase(vo.getJdbcConnectionPoolRuntimeActiveConnectionsAverageCount())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase(vo.getJdbcConnectionPoolRuntimeHighestNumAvailable())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); } document.add(aTable2); document.add(new Paragraph("\n")); PdfPTable aTable3 = new PdfPTable(5); float[] widths3 = { 220f, 220f, 220f, 220f, 220f }; aTable3.setWidths(widths3); aTable3.setWidthPercentage(100); cell = new PdfPCell(new Phrase("JVM", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic.getPortnum()); // hash = weblogicsnmp.collectData(); List heapdatalist = new ArrayList(); heapdatalist = (List) hash.get("heapValue"); for (int i = 0; i < heapdatalist.size(); i++) { WeblogicHeap vo = (WeblogicHeap) heapdatalist.get(i); cell = new PdfPCell(new Phrase("")); aTable3.addCell(cell); cell = new PdfPCell(new Phrase(i + 1 + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase(vo.getJvmRuntimeName())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase(vo.getJvmRuntimeHeapSizeCurrent())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase(vo.getJvmRuntimeHeapFreeCurrent())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); } document.add(aTable3); document.add(new Paragraph("\n")); PdfPTable aTable4 = new PdfPTable(8); float[] widths4 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable4.setWidths(widths4); aTable4.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase("Socket", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase("", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase("IP", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); // weblogicsnmp = new WeblogicSnmp(weblogic.getIpAddress(), // weblogic.getCommunity(), weblogic.getPortnum()); // hash = weblogicsnmp.collectData(); List serverdatalist = new ArrayList(); serverdatalist = (List) hash.get("serverValue"); for (int i = 0; i < serverdatalist.size(); i++) { WeblogicServer vo = (WeblogicServer) serverdatalist.get(i); cell = new PdfPCell(new Phrase("")); aTable3.addCell(cell); aTable4.addCell(cell); cell = new PdfPCell(new Phrase(i + 1 + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase(vo.getServerRuntimeName())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase(vo.getServerRuntimeListenAddress())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase(vo.getServerRuntimeListenPort())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase(vo.getServerRuntimeOpenSocketsCurrentCount())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase(vo.getServerRuntimeState())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase(weblogic.getIpAddress())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); } document.add(aTable4); document.close(); } /** * @param file * @param type * @throws DocumentException * @throws IOException */ public void createReport_weblogicNewDoc(String file, String type) throws DocumentException, IOException { Hashtable Memory = (Hashtable) reportHash.get("Memory"); // EventListDao eventListDao = new EventListDao(); Hashtable maxping = (Hashtable) reportHash.get("ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String hostnameDoc = (String) reportHash.get("equipnameDoc"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String startdate = (String) reportHash.get("startdate"); Hashtable maxjvm = (Hashtable) reportHash.get("maxjvm"); String downnum = (String) reportHash.get("downnum"); Hashtable hash = (Hashtable) reportHash.get("weblogicnmphash"); WeblogicConfig weblogicconf = (WeblogicConfig) reportHash.get("weblogicconf"); WeblogicNormal normalvalue = (WeblogicNormal) reportHash.get("normalvalue"); // time Hashtable pollingtime_ht = new Hashtable(); WeblogicManager tm = new WeblogicManager(); String lasttime; String nexttime; try { pollingtime_ht = tm.getCollecttime(weblogicconf.getIpAddress()); } catch (Exception e) { SysLogger.error("", e); } if (pollingtime_ht != null) { lasttime = (String) pollingtime_ht.get("lasttime"); nexttime = (String) pollingtime_ht.get("nexttime"); } else { lasttime = null; nexttime = null; } // end /* String type = (String)request.getAttribute("type"); */ Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(file)); } else { RtfWriter2.getInstance(document, new FileOutputStream(file)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// this.setTableFormat(aTable); aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); aTable.addCell(cell); this.setCellFormat(cell, true); cell = new Cell(new Phrase("\n" + starttime + " " + totime + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(hostnameDoc, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase("\n" + grade + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(4); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(normalvalue.getDomainName(), contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(normalvalue.getDomainAdministrationPort(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(weblogicconf.getPortnum() + "", contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(normalvalue.getDomainConfigurationVersion(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lasttime, contextFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nexttime, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); cell.setColspan(8); aTable.addCell(cell); String strping = ""; if ("0".equals(downnum)) { strping = " 2 " + downnum + "" + "\n" + "\n"; } else { strping = " 2 " + "\n" + "\n"; } cell = new Cell(new Phrase(" 1 " + " \n" + "\n" + strping + "\n" + "\n" + "\n", contextFont) ); cell.setColspan(8); aTable.addCell(cell); // end // end } document.add(aTable); document.close(); } public void createReport_weblogicNewPDF(String file) throws DocumentException, IOException { Hashtable Memory = (Hashtable) reportHash.get("Memory"); // EventListDao eventListDao = new EventListDao(); Hashtable maxping = (Hashtable) reportHash.get("ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String hostname = (String) reportHash.get("equipname"); String hostnameDoc = (String) reportHash.get("equipnameDoc"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String startdate = (String) reportHash.get("startdate"); Hashtable maxjvm = (Hashtable) reportHash.get("maxjvm"); String downnum = (String) reportHash.get("downnum"); WeblogicConfig weblogicconf = (WeblogicConfig) reportHash.get("weblogicconf"); WeblogicNormal normalvalue = (WeblogicNormal) reportHash.get("normalvalue"); // time Hashtable pollingtime_ht = new Hashtable(); WeblogicManager tm = new WeblogicManager(); String lasttime; String nexttime; try { pollingtime_ht = tm.getCollecttime(weblogicconf.getIpAddress()); } catch (Exception e) { SysLogger.error("", e); } if (pollingtime_ht != null) { lasttime = (String) pollingtime_ht.get("lasttime"); nexttime = (String) pollingtime_ht.get("nexttime"); } else { lasttime = null; nexttime = null; } // end /* String type = (String)request.getAttribute("type"); */ Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 10, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); aTable.addCell(cell); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell = new Cell(new Phrase("\n" + starttime + " " + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnameDoc, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase("\n" + grade + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setRowspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(normalvalue.getDomainName())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(normalvalue.getDomainAdministrationPort(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(weblogicconf.getPortnum() + "")); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(normalvalue.getDomainConfigurationVersion(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + ":" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lasttime)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nexttime)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setColspan(8); aTable.addCell(cell); String strping = ""; if ("0".equals(downnum)) { strping = " 2 " + "\n" + "\n"; } else { strping = " 2 " + downnum + "" + "\n" + "\n"; } cell = new Cell(new Phrase(" 1 " + " \n" + "\n" + strping + "\n" + "\n" + "\n", contextFont) ); cell.setColspan(8); aTable.addCell(cell); // end // end } document.add(aTable); document.close(); } public void createReport_midping(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List pinglist = (List) reportHash.get("pinglist"); List pinglistiis = (List) reportHash.get("pinglistiis"); List pinglistweblogic = (List) reportHash.get("pinglistweblogic"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 4, 0); sheet.mergeCells(0, 1, 4, 1); sheet.mergeCells(0, 2, 4, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (pinglist != null && pinglist.size() > 0) { for (int i = 0; i < pinglist.size(); i++) { p_labelFormat = super.colorChange(i); List pinglist1 = (List) pinglist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) pinglist1.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) pinglist1.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) pinglist1.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5 + i, (String) pinglist1.get(4), p_labelFormat); sheet.addCell(tmpLabel); } row += pinglist.size(); } if (pinglistiis != null && pinglistiis.size() > 0) { for (int i = 0; i < pinglistiis.size(); i++) { p_labelFormat = super.colorChange(i); List pinglist1 = (List) pinglistiis.get(i); row = row + (i); tmpLabel = new Label(0, pinglist.size() + 5 + i, pinglist.size() + i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, pinglist.size() + 5 + i, (String) pinglist1.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, pinglist.size() + 5 + i, (String) pinglist1.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, pinglist.size() + 5 + i, (String) pinglist1.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, pinglist.size() + 5 + i, (String) pinglist1.get(4), p_labelFormat); sheet.addCell(tmpLabel); } row += pinglistiis.size(); } if (pinglistweblogic != null && pinglistweblogic.size() > 0) { for (int i = 0; i < pinglistweblogic.size(); i++) { p_labelFormat = super.colorChange(i); List pinglist1 = (List) pinglistweblogic.get(i); row = row + (i); tmpLabel = new Label(0, pinglistiis.size() + pinglist.size() + 5 + i, pinglistiis.size() + pinglist.size() + i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, pinglistiis.size() + pinglist.size() + 5 + i, (String) pinglist1.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, pinglistiis.size() + pinglist.size() + 5 + i, (String) pinglist1.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, pinglistiis.size() + pinglist.size() + 5 + i, (String) pinglist1.get(3), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, pinglistiis.size() + pinglist.size() + 5 + i, (String) pinglist1.get(4), p_labelFormat); sheet.addCell(tmpLabel); } row += pinglistweblogic.size(); } row += 2; // String pingpath = (String) reportHash.get("pingpath"); File file = new File(pingpath); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, row, 7, 7, file)); /* * if(impReport.getChart()!=null){ ByteArrayOutputStream baos = new * ByteArrayOutputStream(); try { * ChartUtilities.writeChartAsPNG(baos, * impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); } * catch (IOException ioe){} WritableImage wi = new * WritableImage(2,10000 + 5, 8, 12, baos.toByteArray()); * sheet.addImage(wi); } */ wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // quzhi public void createReport_softwarelist(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); Vector softwareV = (Vector) reportHash.get("softwareV"); Label tmpLabel = null; tmpLabel = new Label(2, 0, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", _labelFormat); sheet.addCell(tmpLabel); IpMac ipmac = null; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); for (int i = 0; i < softwareV.size(); i++) { Softwarecollectdata swdata = (Softwarecollectdata) softwareV.get(i); // row = row + (i); tmpLabel = new Label(0, 2 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, swdata.getName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, swdata.getType(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, swdata.getInsdate(), p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // quzhi public void createReport_devicelist(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); Vector deviceV = (Vector) reportHash.get("deviceV"); Label tmpLabel = null; tmpLabel = new Label(2, 0, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", _labelFormat); sheet.addCell(tmpLabel); IpMac ipmac = null; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); for (int i = 0; i < deviceV.size(); i++) { Devicecollectdata devicedata = (Devicecollectdata) deviceV.get(i); // row = row + (i); tmpLabel = new Label(0, 2 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, devicedata.getName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, devicedata.getType(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, devicedata.getStatus(), p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // hukelei public void createReport_storagelist(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); Vector storageV = (Vector) reportHash.get("storageV"); Label tmpLabel = null; tmpLabel = new Label(2, 0, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", _labelFormat); sheet.addCell(tmpLabel); IpMac ipmac = null; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); for (int i = 0; i < storageV.size(); i++) { Storagecollectdata storagedata = (Storagecollectdata) storageV.get(i); // row = row + (i); tmpLabel = new Label(0, 2 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, storagedata.getName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, storagedata.getType(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, storagedata.getCap(), p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_netDistrictIplist(String filename, String title, List list) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("ip", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); Label tmpLabel = null; // sheet.mergeCells(0, 0, 3, 0); tmpLabel = new Label(0, 0, title, b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "(ip)", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", b_labelFormat); sheet.addCell(tmpLabel); NetDistrictIpDetail vo = null; if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { vo = (NetDistrictIpDetail) list.get(i); // row = row + (i); tmpLabel = new Label(0, 2 + i, i + 1 + "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, vo.getIpaddress(), b_labelFormat); sheet.addCell(tmpLabel); String isUsed = ""; if ("1".equals(vo.getIsUsed())) { isUsed = ""; } tmpLabel = new Label(2, 2 + i, isUsed, b_labelFormat); sheet.addCell(tmpLabel); String isOnline = ""; if ("1".equals(vo.getIsOnline())) { isOnline = ""; } tmpLabel = new Label(3, 2 + i, isOnline, b_labelFormat); sheet.addCell(tmpLabel); } } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_macconfiglist(String filename, String title, List list) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("Mac ", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); Label tmpLabel = null; // sheet.mergeCells(0, 0, 3, 0); tmpLabel = new Label(0, 0, title, b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "MAC", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", b_labelFormat); sheet.addCell(tmpLabel); Macconfig vo = null; if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { vo = (Macconfig) list.get(i); // row = row + (i); tmpLabel = new Label(0, 2 + i, i + 1 + "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, vo.getMac(), b_labelFormat); sheet.addCell(tmpLabel); int discrictid = vo.getDiscrictid(); DistrictConfig districtConfig = null; DistrictDao districtDao = new DistrictDao(); try { districtConfig = (DistrictConfig) districtDao.findByID(String.valueOf(discrictid)); } catch (RuntimeException e) { SysLogger.error("", e); } finally { districtDao.close(); } tmpLabel = new Label(2, 2 + i, districtConfig.getName(), b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, vo.getMacdesc(), b_labelFormat); sheet.addCell(tmpLabel); } } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_portscanlist(String filename, String title, List list) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); Label tmpLabel = null; // sheet.mergeCells(0, 0, 5, 0); tmpLabel = new Label(0, 0, title, b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "IP ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 1, "", b_labelFormat); sheet.addCell(tmpLabel); PortConfig vo = null; if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { vo = (PortConfig) list.get(i); // row = row + (i); tmpLabel = new Label(0, 2 + i, i + 1 + "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, vo.getIpaddress(), b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, vo.getPort(), b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, vo.getPortName(), b_labelFormat); sheet.addCell(tmpLabel); String status = ""; if ("1".equals(vo.getStatus())) { status = ""; } tmpLabel = new Label(4, 2 + i, status, b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 2 + i, vo.getScantime(), b_labelFormat); sheet.addCell(tmpLabel); } } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // nielin add public void createReport_falseLoglist(String filename, String title, List list) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); Label tmpLabel = null; // sheet.mergeCells(0, 0, 2, 0); tmpLabel = new Label(0, 0, title, b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", b_labelFormat); sheet.addCell(tmpLabel); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { List valuelist = (List) list.get(i); // row = row + (i); tmpLabel = new Label(0, 2 + i, i + 1 + "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, (String) valuelist.get(0), b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, (String) valuelist.get(1), b_labelFormat); sheet.addCell(tmpLabel); } } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // zhushouzhi--------------infor star public void createReport_infor(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); ArrayList dbspaces = new ArrayList(); dbspaces = (ArrayList) dbinfo.get("informixspaces");// Hashtable maxping = (Hashtable) reportHash.get("ping"); ArrayList dbsession = new ArrayList(); dbsession = (ArrayList) dbinfo.get("sessionList");// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 14, "(%)", _labelFormat); sheet.addCell(tmpLabel); int row = 14; int row1 = 0; // if (dbspaces != null && dbspaces.size() > 0) { for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); double all = 100.00; double show = all - Double.parseDouble(tablesVO.get("percent_free").toString()); String str = show + ""; if (str.length() > 5) { str = str.substring(0, 5); } row = row + (i); tmpLabel = new Label(1, 15 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15 + i, (String) tablesVO.get("dbspace"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15 + i, (String) tablesVO.get("owner"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 15 + i, (String) tablesVO.get("fname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 15 + i, (String) tablesVO.get("pages_size"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 15 + i, (String) tablesVO.get("pages_used"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 15 + i, (String) tablesVO.get("pages_free"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 15 + i, str, p_labelFormat); sheet.addCell(tmpLabel); row1++; } } row1 = 15 + row1; // tmpLabel = new Label(0, row1 + 1, "INFORMIX", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row1 + 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row1 + 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row1 + 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row1 + 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row1 + 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row1 + 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row1 + 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row1 + 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row1 + 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, row1 + 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, row1 + 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(12, row1 + 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(13, row1 + 1, "", _labelFormat); sheet.addCell(tmpLabel); int row2 = row1 + 2; int row3 = 0; if (dbsession != null && dbsession.size() > 0) { for (int i = 0; i < dbsession.size(); i++) { Hashtable tablesVO = (Hashtable) dbsession.get(i); tmpLabel = new Label(1, row2 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row2 + i, (String) tablesVO.get("username"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row2 + i, (String) tablesVO.get("hostname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row2 + i, (String) tablesVO.get("access"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row2 + i, ((Integer) tablesVO.get("lockreqs")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row2 + i, ((Integer) tablesVO.get("locksheld")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row2 + i, ((Integer) tablesVO.get("lockwts")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row2 + i, ((Integer) tablesVO.get("deadlks")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row2 + i, ((Integer) tablesVO.get("lktouts")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, row2 + i, ((Integer) tablesVO.get("bufreads")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, row2 + i, ((Integer) tablesVO.get("bufwrites")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(12, row2 + i, ((Integer) tablesVO.get("pagreads")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(13, row2 + i, ((Integer) tablesVO.get("pagwrites")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); row3++; } } int row4 = row3 + row2; int row5 = 0; tmpLabel = new Label(0, row4 + 1, "INFORMIX", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row4 + 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row4 + 1, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row4 + 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row4 + 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row4 + 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row4 + 1, "", _labelFormat); sheet.addCell(tmpLabel); // ArrayList dblock = new ArrayList(); dblock = (ArrayList) dbinfo.get("lockList");// if (dblock != null && dblock.size() > 0) { for (int i = 0; i < dblock.size(); i++) { Hashtable tablesVO = (Hashtable) dblock.get(i); String type = (String) tablesVO.get("type"); String desc = ""; if ("B".equals(type)) { desc = ""; } else if ("IS".equals(type)) { desc = ""; } else if ("S".equals(type)) { desc = ""; } else if ("XS".equals(type)) { desc = ""; } else if ("U".equals(type)) { desc = ""; } else if ("IX".equals(type)) { desc = ""; } else if ("SIX".equals(type)) { desc = ""; } else if ("X".equals(type)) { desc = ""; } else if ("XR".equals(type)) { desc = ""; } tmpLabel = new Label(1, row4 + 2 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row4 + 2 + i, (String) tablesVO.get("username"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row4 + 2 + i, (String) tablesVO.get("hostname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row4 + 2 + i, (String) tablesVO.get("dbsname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row4 + 2 + i, (String) tablesVO.get("tabname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row4 + 2 + i, (String) tablesVO.get("desc"), p_labelFormat); sheet.addCell(tmpLabel); row5++; } } // end // informix int row6 = row5 + row4 + 3; int row7 = 0; tmpLabel = new Label(0, row6, "INFORMIX", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row6, "ID", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row6, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row6, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row6, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row6, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row6, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row6, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row6, "", _labelFormat); sheet.addCell(tmpLabel); ArrayList dblog = new ArrayList(); dblog = (ArrayList) dbinfo.get("informixlog");// if (dblog != null && dblog.size() > 0) { for (int i = 0; i < dblog.size(); i++) { Hashtable tablesVO = (Hashtable) dblog.get(i); tmpLabel = new Label(1, row6 + 1 + i, ((Integer) tablesVO.get("uniqid")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row6 + 1 + i, ((Integer) tablesVO.get("size")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row6 + 1 + i, ((Integer) tablesVO.get("used")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row6 + 1 + i, (String) tablesVO.get("is_used"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row6 + 1 + i, (String) tablesVO.get("is_current"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row6 + 1 + i, (String) tablesVO.get("is_backed_up"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row6 + 1 + i, (String) tablesVO.get("is_archived"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row6 + 1 + i, (String) tablesVO.get("is_temp"), p_labelFormat); sheet.addCell(tmpLabel); row7++; } } // end // informix i/o int row8 = row7 + row6 + 2; tmpLabel = new Label(0, row8, "INFORMIXI/O", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row8, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row8, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row8, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row8, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row8, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row8, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row8, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row8, " ", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row8, "", _labelFormat); sheet.addCell(tmpLabel); ArrayList dbio = new ArrayList(); dbio = (ArrayList) dbinfo.get("iolist");// IO if (dbio != null && dbio.size() > 0) { for (int i = 0; i < dbio.size(); i++) { Hashtable tablesVO = (Hashtable) dbio.get(i); tmpLabel = new Label(1, row8 + 1 + i, (String) tablesVO.get("chunknum"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row8 + 1 + i, ((Integer) tablesVO.get("reads")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row8 + 1 + i, ((Integer) tablesVO.get("pagesread")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row8 + 1 + i, ((Integer) tablesVO.get("writes")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row8 + 1 + i, ((Integer) tablesVO.get("pageswritten")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row8 + 1 + i, ((Integer) tablesVO.get("mreads")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row8 + 1 + i, ((Integer) tablesVO.get("mpagesread")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row8 + 1 + i, ((Integer) tablesVO.get("mwrites")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row8 + 1 + i, ((Integer) tablesVO.get("mpageswritten")).intValue() + "", p_labelFormat); sheet.addCell(tmpLabel); } } // end if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // zhushouzhi-----------------infor end // zhushozhi--------------------infor doc start public void createReport_inforDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); ArrayList dbspaces = new ArrayList(); dbspaces = (ArrayList) dbinfo.get("informixspaces");// Hashtable maxping = (Hashtable) reportHash.get("ping"); ArrayList dbsession = new ArrayList(); dbsession = (ArrayList) dbinfo.get("sessionList");// Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(""); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // informix Table aTable1 = new Table(9); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // int row = 0; if (dbspaces != null && dbspaces.size() > 0) { for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); double all = 100.00; double show = all - Double.parseDouble(tablesVO.get("percent_free").toString()); String str = show + ""; if (str.length() > 5) { str = str.substring(0, 5); } aTable1.addCell(""); row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase(rowStr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("dbspace"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("owner"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("fname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("pages_size"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("pages_used"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("pages_free"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(str, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } } // informix Table aTable2 = new Table(9); float[] widthss = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable2.setWidths(widthss); aTable2.setWidth(100); // 90% aTable2.setAlignment(Element.ALIGN_CENTER);// aTable2.setAutoFillEmptyCells(true); // aTable2.setBorderWidth(1); // aTable2.setBorderColor(new Color(0, 125, 255)); // aTable2.setPadding(2);// aTable2.setSpacing(0);// aTable2.setBorder(2);// cell = new Cell(new Phrase("INFORMIX", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase("ID", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); ArrayList dblog = new ArrayList(); dblog = (ArrayList) dbinfo.get("informixlog");// if (dblog != null && dblog.size() > 0) { for (int i = 0; i < dblog.size(); i++) { Hashtable tablesVO = (Hashtable) dblog.get(i); aTable2.addCell(""); row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase(((Integer) tablesVO.get("uniqid")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("size")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("used")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("is_used"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("is_current"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("is_backed_up"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("is_archived"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("is_temp"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); } } // end // -- Table aTable3 = new Table(14); float[] widths1 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable3.setWidths(widths1); aTable3.setWidth(100); // 90% aTable3.setAlignment(Element.ALIGN_CENTER);// aTable3.setAutoFillEmptyCells(true); // aTable3.setBorderWidth(1); // aTable3.setBorderColor(new Color(0, 125, 255)); // aTable3.setPadding(2);// aTable3.setSpacing(0);// aTable3.setBorder(2);// cell = new Cell(new Phrase("INFORMIX", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); int row3 = 0; if (dbsession != null && dbsession.size() > 0) { for (int i = 0; i < dbsession.size(); i++) { Hashtable tablesVO = (Hashtable) dbsession.get(i); aTable3.addCell(""); row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase(i + 1 + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("access"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("lockreqs")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("locksheld")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("lockwts")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("deadlks")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("lktouts")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("bufreads")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("bufwrites")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("pagreads")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("pagwrites")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); } } // int row4 = row3 + row2; int row5 = 0; Table aTable4 = new Table(7); float[] widths2 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable4.setWidths(widths2); aTable4.setWidth(100); // 90% aTable4.setAlignment(Element.ALIGN_CENTER);// aTable4.setAutoFillEmptyCells(true); // aTable4.setBorderWidth(1); // aTable4.setBorderColor(new Color(0, 125, 255)); // aTable4.setPadding(2);// aTable4.setSpacing(0);// aTable4.setBorder(2);// // cell = new Cell(new Phrase("INFORMIX", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); ArrayList dblock = new ArrayList(); dblock = (ArrayList) dbinfo.get("lockList");// if (dblock != null && dblock.size() > 0) { for (int i = 0; i < dblock.size(); i++) { Hashtable tablesVO = (Hashtable) dblock.get(i); String type = (String) tablesVO.get("type"); String desc = ""; if ("B".equals(type)) { desc = ""; } else if ("IS".equals(type)) { desc = ""; } else if ("S".equals(type)) { desc = ""; } else if ("XS".equals(type)) { desc = ""; } else if ("U".equals(type)) { desc = ""; } else if ("IX".equals(type)) { desc = ""; } else if ("SIX".equals(type)) { desc = ""; } else if ("X".equals(type)) { desc = ""; } else if ("XR".equals(type)) { desc = ""; } aTable4.addCell(""); row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase(i + 1 + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("dbsname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("tabname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("desc"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); } } // informix i/o Table aTable5 = new Table(10); float[] widths3 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable5.setWidths(widths3); aTable5.setWidth(100); // 90% aTable5.setAlignment(Element.ALIGN_CENTER);// aTable5.setAutoFillEmptyCells(true); // aTable5.setBorderWidth(1); // aTable5.setBorderColor(new Color(0, 125, 255)); // aTable5.setPadding(2);// aTable5.setSpacing(0);// aTable5.setBorder(2);// cell = new Cell(new Phrase("INFORMIXI/O", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); ArrayList dbio = new ArrayList(); dbio = (ArrayList) dbinfo.get("iolist");// IO if (dbio != null && dbio.size() > 0) { for (int i = 0; i < dbio.size(); i++) { Hashtable tablesVO = (Hashtable) dbio.get(i); aTable5.addCell(""); row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase((String) tablesVO.get("chunknum"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("reads")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("pagesread")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("writes")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell( new Phrase(((Integer) tablesVO.get("pageswritten")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("mreads")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell( new Phrase(((Integer) tablesVO.get("mpagesread")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell(new Phrase(((Integer) tablesVO.get("mwrites")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new Cell( new Phrase(((Integer) tablesVO.get("mpageswritten")).intValue() + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.add(aTable2); document.add(aTable3); document.add(aTable4); document.add(aTable5); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } // zhushouzhi==-----------------------end // zhushouzhi--------------------------infor pdf start public void createReport_inforPDF(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 11, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); ArrayList dbspaces = new ArrayList(); dbspaces = (ArrayList) dbinfo.get("informixspaces");// Hashtable maxping = (Hashtable) reportHash.get("ping"); ArrayList dbsession = new ArrayList(); dbsession = (ArrayList) dbinfo.get("sessionList");// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont1); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.MIDDLE);// img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // informix PdfPTable aTable1 = new PdfPTable(9); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // informix int row = 0; if (dbspaces != null && dbspaces.size() > 0) { for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); double all = 100.00; double show = all - Double.parseDouble(tablesVO.get("percent_free").toString()); String str = show + ""; if (str.length() > 5) { str = str.substring(0, 5); } aTable1.addCell(""); row = i + 1; String rowStr = "" + row; cell = new PdfPCell(new Phrase(rowStr)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("dbspace"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("owner"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("fname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("pages_size"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("pages_used"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("pages_free"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(str)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } } // informix PdfPTable aTable2 = new PdfPTable(9); float[] widthss = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable2.setWidths(widthss); aTable2.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("ID", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); ArrayList dblog = new ArrayList(); dblog = (ArrayList) dbinfo.get("informixlog");// if (dblog != null && dblog.size() > 0) { for (int i = 0; i < dblog.size(); i++) { Hashtable tablesVO = (Hashtable) dblog.get(i); aTable2.addCell(""); row = i + 1; String rowStr = "" + row; cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("uniqid")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("size")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("used")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("is_used"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("is_current"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("is_backed_up"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("is_archived"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("is_temp"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable2.addCell(cell); } } // end // -- PdfPTable aTable3 = new PdfPTable(14); float[] widths1 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable3.setWidths(widths1); aTable3.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); int row3 = 0; if (dbsession != null && dbsession.size() > 0) { for (int i = 0; i < dbsession.size(); i++) { Hashtable tablesVO = (Hashtable) dbsession.get(i); aTable3.addCell(""); row = i + 1; String rowStr = "" + row; cell = new PdfPCell(new Phrase(i + 1 + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("username"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("access"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("lockreqs")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("locksheld")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("lockwts")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("deadlks")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("lktouts")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("bufreads")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("bufwrites")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("pagreads")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("pagwrites")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable3.addCell(cell); } } // int row4 = row3 + row2; int row5 = 0; PdfPTable aTable4 = new PdfPTable(7); float[] widths2 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable4.setWidths(widths2); aTable4.setWidthPercentage(100); // cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); ArrayList dblock = new ArrayList(); dblock = (ArrayList) dbinfo.get("lockList");// if (dblock != null && dblock.size() > 0) { for (int i = 0; i < dblock.size(); i++) { Hashtable tablesVO = (Hashtable) dblock.get(i); String type = (String) tablesVO.get("type"); String desc = ""; if ("B".equals(type)) { desc = ""; } else if ("IS".equals(type)) { desc = ""; } else if ("S".equals(type)) { desc = ""; } else if ("XS".equals(type)) { desc = ""; } else if ("U".equals(type)) { desc = ""; } else if ("IX".equals(type)) { desc = ""; } else if ("SIX".equals(type)) { desc = ""; } else if ("X".equals(type)) { desc = ""; } else if ("XR".equals(type)) { desc = ""; } aTable4.addCell(""); row = i + 1; String rowStr = "" + row; cell = new PdfPCell(new Phrase(i + 1 + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("username"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("dbsname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("tabname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("desc"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable4.addCell(cell); } } // informix i/o PdfPTable aTable5 = new PdfPTable(10); float[] widths3 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable5.setWidths(widths3); aTable5.setWidthPercentage(100); cell = new PdfPCell(new Phrase("I/O", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); ArrayList dbio = new ArrayList(); dbio = (ArrayList) dbinfo.get("iolist");// IO if (dbio != null && dbio.size() > 0) { for (int i = 0; i < dbio.size(); i++) { Hashtable tablesVO = (Hashtable) dbio.get(i); aTable5.addCell(""); row = i + 1; String rowStr = "" + row; cell = new PdfPCell(new Phrase((String) tablesVO.get("chunknum"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("reads")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("pagesread")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("writes")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("pageswritten")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("mreads")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("mpagesread")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("mwrites")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); cell = new PdfPCell(new Phrase(((Integer) tablesVO.get("mpageswritten")).intValue() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable5.addCell(cell); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.add(new Paragraph("\n")); document.add(aTable2); document.add(new Paragraph("\n")); document.add(aTable3); document.add(new Paragraph("\n")); document.add(aTable4); document.add(new Paragraph("\n")); document.add(aTable5); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } // end // informix--------------new doc // zhushouzhi------------------------ sybase pdf /** * @param filename * @param type * @throws DocumentException * @throws IOException */ public void createReport_inforNewDoc(String filename, String type) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("dbnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); ArrayList dbspaces = new ArrayList(); dbspaces = (ArrayList) dbinfo.get("informixspaces");// DBTypeDao typedao = new DBTypeDao(); DBTypeVo typevo = typedao.findByDbtype("informix"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = null; // (Writer)document(Writer) if ("pdf".equals(type)) { document = new Document(PageSize.B3); PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { document = new Document(PageSize.A4); RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// this.setTableFormat(aTable); Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont1)); cell.setColspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont1)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont1)); cell.setColspan(2); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(5); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("Metadata(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // InformixspaceconfigDao informixspaceconfigDao = new InformixspaceconfigDao(); List list = null; try { list = informixspaceconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { informixspaceconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); this.setCellFormat(cell5, true); cell5.setRowspan(15 + list.size()); aTable.addCell(cell5); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // io ArrayList dbabout = new ArrayList(); dbabout = (ArrayList) dbinfo.get("aboutlist");// Hashtable hashtable = new Hashtable(); if (dbabout != null && dbabout.size() > 0) { for (int i = 0; i < dbabout.size(); i++) { Hashtable tablesVO = (Hashtable) dbabout.get(i); String name = ((String) tablesVO.get("name")).trim(); String desc = ""; if ("dskreads".equals(name)) { desc = ""; hashtable.put("dskreads", tablesVO.get("value")); } else if ("bufreads".equals(name)) { desc = ""; hashtable.put("bufreads", tablesVO.get("value")); } else if ("dskwrites".equals(name)) { desc = ""; hashtable.put("dskwrites", tablesVO.get("value")); } else if ("bufwrites".equals(name)) { desc = ""; hashtable.put("bufwrites", tablesVO.get("value")); } else if ("isamtot".equals(name)) { desc = ""; hashtable.put("isamtot", tablesVO.get("value")); } else if ("isopens".equals(name)) { desc = "isopen"; hashtable.put("isopens", tablesVO.get("value")); } else if ("isstarts".equals(name)) { desc = "isstart"; hashtable.put("isstarts", tablesVO.get("value")); } else if ("isreads".equals(name)) { desc = "isread"; hashtable.put("isreads", tablesVO.get("value")); } else if ("iswrites".equals(name)) { desc = "iswirte"; hashtable.put("iswrites", tablesVO.get("value")); } else if ("isrewrites".equals(name)) { desc = "isrewrite"; hashtable.put("isrewrites", tablesVO.get("value")); } else if ("isdeletes".equals(name)) { desc = "isdelete"; hashtable.put("isdeletes", tablesVO.get("value")); } else if ("iscommits".equals(name)) { desc = "iscommit"; hashtable.put("iscommits", tablesVO.get("value")); } else if ("isrollbacks".equals(name)) { desc = "isrollback"; hashtable.put("isrollbacks", tablesVO.get("value")); } else if ("ovlock".equals(name)) { desc = ""; hashtable.put("ovlock", tablesVO.get("value")); } else if ("ovuser".equals(name)) { desc = ""; hashtable.put("ovuser", tablesVO.get("value")); } else if ("ovtrans".equals(name)) { desc = ""; hashtable.put("ovtrans", tablesVO.get("value")); } else if ("latchwts".equals(name)) { desc = ""; hashtable.put("latchwts", tablesVO.get("value")); } else if ("buffwts".equals(name)) { desc = ""; hashtable.put("buffwts", tablesVO.get("value")); } else if ("lockreqs".equals(name)) { desc = ""; hashtable.put("lockreqs", tablesVO.get("value")); } else if ("lockwts".equals(name)) { desc = ""; hashtable.put("lockwts", tablesVO.get("value")); } else if ("ckptwts".equals(name)) { desc = ""; hashtable.put("ckptwts", tablesVO.get("value")); } else if ("deadlks".equals(name)) { desc = ""; hashtable.put("deadlks", tablesVO.get("value")); } else if ("lktouts".equals(name)) { desc = ""; hashtable.put("lktouts", tablesVO.get("value")); } else if ("numckpts".equals(name)) { desc = ""; hashtable.put("numckpts", tablesVO.get("value")); } else if ("plgpagewrites".equals(name)) { desc = ""; hashtable.put("plgpagewrites", tablesVO.get("value")); } else if ("plgwrites".equals(name)) { desc = ""; hashtable.put("plgwrites", tablesVO.get("value")); } else if ("llgrecs".equals(name)) { desc = ""; hashtable.put("llgrecs", tablesVO.get("value")); } else if ("llgpagewrites".equals(name)) { desc = ""; hashtable.put("llgpagewrites", tablesVO.get("value")); } else if ("llgwrites".equals(name)) { desc = ""; hashtable.put("llgwrites", tablesVO.get("value")); } else if ("pagreads".equals(name)) { desc = ""; hashtable.put("pagreads", tablesVO.get("value")); } else if ("pagwrites".equals(name)) { desc = ""; hashtable.put("pagwrites", tablesVO.get("value")); } else if ("flushes".equals(name)) { desc = ""; hashtable.put("flushes", tablesVO.get("value")); } else if ("compress".equals(name)) { desc = ""; hashtable.put("compress", tablesVO.get("value")); } else if ("fgwrites".equals(name)) { desc = ""; hashtable.put("fgwrites", tablesVO.get("value")); } else if ("lruwrites".equals(name)) { desc = "LRU"; hashtable.put("lruwrites", tablesVO.get("value")); } else if ("chunkwrites".equals(name)) { desc = ""; hashtable.put("chunkwrites", tablesVO.get("value")); } else if ("btradata".equals(name)) { desc = ""; hashtable.put("btradata", tablesVO.get("value")); } else if ("btraidx".equals(name)) { desc = ""; hashtable.put("btraidx", tablesVO.get("value")); } else if ("dpra".equals(name)) { desc = ""; hashtable.put("dpra", tablesVO.get("value")); } else if ("rapgs_used".equals(name)) { desc = ""; hashtable.put("rapgs_used", tablesVO.get("value")); } else if ("seqscans".equals(name)) { desc = ""; hashtable.put("seqscans", tablesVO.get("value")); } else if ("totalsorts".equals(name)) { desc = ""; hashtable.put("totalsorts", tablesVO.get("value")); } else if ("memsorts".equals(name)) { desc = ""; hashtable.put("memsorts", tablesVO.get("value")); } else if ("disksorts".equals(name)) { desc = ""; hashtable.put("disksorts", tablesVO.get("value")); } else if ("maxsortspace".equals(name)) { desc = ""; hashtable.put("maxsortspace", tablesVO.get("value")); } } } cell = new Cell(new Phrase("IO", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("dskreads"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("bufreads"), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("dskwrites"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("bufwrites"), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isamtot"), contextFont1)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isopen", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isopens"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isstart", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isstarts"), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isread", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isreads"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("iswirte", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("iswrites"), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isrewrite", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isrewrites"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isdelete", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isdeletes"), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("iscommit", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("iscommits"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isrollback", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isrollbacks"), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("latchwts"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("buffwts"), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("lockreqs"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("lockwts"), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("ckptwts"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("deadlks"), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("lktouts"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("numckpts"), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(list.size() + 1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("%", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // get dbspace message================== int row = 0; DecimalFormat df = new DecimalFormat("#.###"); if (dbspaces != null && dbspaces.size() > 0) { for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); double all = 100.00; double show = all - Double.parseDouble(tablesVO.get("percent_free").toString()); String str = df.format(show) + ""; String spacenameString = (String) tablesVO.get("dbspace"); for (int j = 0; j < list.size(); j++) { Informixspaceconfig vo = (Informixspaceconfig) list.get(j); DBDao dbdao = new DBDao(); // dbdao = new DBDao(); List shareList = null; try { shareList = dbdao.getDbByTypeAndIpaddress(typevo.getId(), vo.getIpaddress()); } catch (Exception e) { } finally { dbdao.close(); } if (shareList == null || shareList.size() == 0) continue; DBVo dbvo = (DBVo) shareList.get(0); if (spacenameString.equals(vo.getSpacename())) { cell = new Cell(new Phrase(spacenameString, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("pages_size"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_used") + "")), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(str, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } } String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); String pinglog = ""; if ("0".equals(downnum)) { pinglog = " " + "2 "; } else { pinglog = " " + "2 " + downnum + ""; } String spacelog = ""; if ("0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } public void createReport_inforNewPDF(String filename) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("dbnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); ArrayList dbspaces = new ArrayList(); dbspaces = (ArrayList) dbinfo.get("informixspaces");// DBTypeDao typedao = new DBTypeDao(); DBTypeVo typevo = typedao.findByDbtype("informix"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font contextFont2 = new Font(bfChinese, 11, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont2)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("Metadata(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // InformixspaceconfigDao informixspaceconfigDao = new InformixspaceconfigDao(); List list = null; try { list = informixspaceconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { informixspaceconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(15 + list.size()); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); // cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell5); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // io ArrayList dbabout = new ArrayList(); dbabout = (ArrayList) dbinfo.get("aboutlist");// Hashtable hashtable = new Hashtable(); if (dbabout != null && dbabout.size() > 0) { for (int i = 0; i < dbabout.size(); i++) { Hashtable tablesVO = (Hashtable) dbabout.get(i); String name = ((String) tablesVO.get("name")).trim(); String desc = ""; if ("dskreads".equals(name)) { desc = ""; hashtable.put("dskreads", tablesVO.get("value")); } else if ("bufreads".equals(name)) { desc = ""; hashtable.put("bufreads", tablesVO.get("value")); } else if ("dskwrites".equals(name)) { desc = ""; hashtable.put("dskwrites", tablesVO.get("value")); } else if ("bufwrites".equals(name)) { desc = ""; hashtable.put("bufwrites", tablesVO.get("value")); } else if ("isamtot".equals(name)) { desc = ""; hashtable.put("isamtot", tablesVO.get("value")); } else if ("isopens".equals(name)) { desc = "isopen"; hashtable.put("isopens", tablesVO.get("value")); } else if ("isstarts".equals(name)) { desc = "isstart"; hashtable.put("isstarts", tablesVO.get("value")); } else if ("isreads".equals(name)) { desc = "isread"; hashtable.put("isreads", tablesVO.get("value")); } else if ("iswrites".equals(name)) { desc = "iswirte"; hashtable.put("iswrites", tablesVO.get("value")); } else if ("isrewrites".equals(name)) { desc = "isrewrite"; hashtable.put("isrewrites", tablesVO.get("value")); } else if ("isdeletes".equals(name)) { desc = "isdelete"; hashtable.put("isdeletes", tablesVO.get("value")); } else if ("iscommits".equals(name)) { desc = "iscommit"; hashtable.put("iscommits", tablesVO.get("value")); } else if ("isrollbacks".equals(name)) { desc = "isrollback"; hashtable.put("isrollbacks", tablesVO.get("value")); } else if ("ovlock".equals(name)) { desc = ""; hashtable.put("ovlock", tablesVO.get("value")); } else if ("ovuser".equals(name)) { desc = ""; hashtable.put("ovuser", tablesVO.get("value")); } else if ("ovtrans".equals(name)) { desc = ""; hashtable.put("ovtrans", tablesVO.get("value")); } else if ("latchwts".equals(name)) { desc = ""; hashtable.put("latchwts", tablesVO.get("value")); } else if ("buffwts".equals(name)) { desc = ""; hashtable.put("buffwts", tablesVO.get("value")); } else if ("lockreqs".equals(name)) { desc = ""; hashtable.put("lockreqs", tablesVO.get("value")); } else if ("lockwts".equals(name)) { desc = ""; hashtable.put("lockwts", tablesVO.get("value")); } else if ("ckptwts".equals(name)) { desc = ""; hashtable.put("ckptwts", tablesVO.get("value")); } else if ("deadlks".equals(name)) { desc = ""; hashtable.put("deadlks", tablesVO.get("value")); } else if ("lktouts".equals(name)) { desc = ""; hashtable.put("lktouts", tablesVO.get("value")); } else if ("numckpts".equals(name)) { desc = ""; hashtable.put("numckpts", tablesVO.get("value")); } else if ("plgpagewrites".equals(name)) { desc = ""; hashtable.put("plgpagewrites", tablesVO.get("value")); } else if ("plgwrites".equals(name)) { desc = ""; hashtable.put("plgwrites", tablesVO.get("value")); } else if ("llgrecs".equals(name)) { desc = ""; hashtable.put("llgrecs", tablesVO.get("value")); } else if ("llgpagewrites".equals(name)) { desc = ""; hashtable.put("llgpagewrites", tablesVO.get("value")); } else if ("llgwrites".equals(name)) { desc = ""; hashtable.put("llgwrites", tablesVO.get("value")); } else if ("pagreads".equals(name)) { desc = ""; hashtable.put("pagreads", tablesVO.get("value")); } else if ("pagwrites".equals(name)) { desc = ""; hashtable.put("pagwrites", tablesVO.get("value")); } else if ("flushes".equals(name)) { desc = ""; hashtable.put("flushes", tablesVO.get("value")); } else if ("compress".equals(name)) { desc = ""; hashtable.put("compress", tablesVO.get("value")); } else if ("fgwrites".equals(name)) { desc = ""; hashtable.put("fgwrites", tablesVO.get("value")); } else if ("lruwrites".equals(name)) { desc = "LRU"; hashtable.put("lruwrites", tablesVO.get("value")); } else if ("chunkwrites".equals(name)) { desc = ""; hashtable.put("chunkwrites", tablesVO.get("value")); } else if ("btradata".equals(name)) { desc = ""; hashtable.put("btradata", tablesVO.get("value")); } else if ("btraidx".equals(name)) { desc = ""; hashtable.put("btraidx", tablesVO.get("value")); } else if ("dpra".equals(name)) { desc = ""; hashtable.put("dpra", tablesVO.get("value")); } else if ("rapgs_used".equals(name)) { desc = ""; hashtable.put("rapgs_used", tablesVO.get("value")); } else if ("seqscans".equals(name)) { desc = ""; hashtable.put("seqscans", tablesVO.get("value")); } else if ("totalsorts".equals(name)) { desc = ""; hashtable.put("totalsorts", tablesVO.get("value")); } else if ("memsorts".equals(name)) { desc = ""; hashtable.put("memsorts", tablesVO.get("value")); } else if ("disksorts".equals(name)) { desc = ""; hashtable.put("disksorts", tablesVO.get("value")); } else if ("maxsortspace".equals(name)) { desc = ""; hashtable.put("maxsortspace", tablesVO.get("value")); } } } cell = new Cell(new Phrase("IO", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("dskreads"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("bufreads"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("dskwrites"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("bufwrites"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isamtot"), contextFont1)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isopen")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isopens"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isstart")); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isstarts"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isread")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isreads"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("iswirte")); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("iswrites"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isrewrite")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isrewrites"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isdelete")); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isdeletes"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("iscommit")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("iscommits"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isrollback")); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isrollbacks"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("latchwts"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("buffwts"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("lockreqs"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("lockwts"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("ckptwts"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("deadlks"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("lktouts"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("numckpts"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(list.size() + 1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("%", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // get dbspace message================== int row = 0; DecimalFormat df = new DecimalFormat("#.###"); if (dbspaces != null && dbspaces.size() > 0) { for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); double all = 100.00; double show = all - Double.parseDouble(tablesVO.get("percent_free").toString()); String str = df.format(show) + ""; String spacenameString = (String) tablesVO.get("dbspace"); for (int j = 0; j < list.size(); j++) { Informixspaceconfig vo = (Informixspaceconfig) list.get(j); DBDao dbdao = new DBDao(); // dbdao = new DBDao(); List shareList = null; try { shareList = dbdao.getDbByTypeAndIpaddress(typevo.getId(), vo.getIpaddress()); } catch (Exception e) { } finally { dbdao.close(); } if (shareList == null || shareList.size() == 0) continue; DBVo dbvo = (DBVo) shareList.get(0); if (spacenameString.equals(vo.getSpacename())) { cell = new Cell(new Phrase(spacenameString)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("pages_size"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_used") + "")))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(str)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } } String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String pinglog = ""; if ("0".equals(downnum)) { pinglog = " " + "2 "; } else { pinglog = " " + "2 " + downnum + ""; } String spacelog = ""; if ("0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); } // zhushouzhi------------------------------------- public void createReport_faworklist(String filename, User user) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); Label tmpLabel = null; // List moidlist = (List)reportHash.get("list"); // User current_user = // (User)session.getAttribute(SessionConstant.CURRENT_USER); StringBuffer s = new StringBuffer(); int _flag = 0; String businessid = user.getBusinessids(); if (businessid != null) { if (businessid != "-1") { String[] bids = businessid.split(","); if (bids.length > 0) { for (int i = 0; i < bids.length; i++) { if (bids[i].trim().length() > 0) { if (_flag == 0) { s.append(" and ( bid like '%," + bids[i].trim() + ",%' "); _flag = 1; } else { // flag = 1; s.append(" or bid like '%," + bids[i].trim() + ",%' "); } } } s.append(") "); } } } NodeMonitorDao nmdao = new NodeMonitorDao(); List moidlist = new ArrayList(); try { moidlist = nmdao.loadByBID(user.getBusinessids()); } catch (Exception e) { } finally { nmdao.close(); } tmpLabel = new Label(4, 0, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "()", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 1, "()", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 1, "()", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(12, 1, "", _labelFormat); sheet.addCell(tmpLabel); if (moidlist != null) { for (int i = 0; i < moidlist.size(); i++) { NodeMonitor nm = (NodeMonitor) moidlist.get(i); HostNode vo = new HostNode(); HostNodeDao dao = new HostNodeDao(); try { vo = dao.loadHost(nm.getNodeID()); } catch (Exception e) { } finally { dao.close(); } String enable = ""; if (!nm.isEnabled()) enable = ""; if (vo == null) continue; String sms0 = ""; if (nm.getSms0() == 0) sms0 = ""; String sms1 = ""; if (nm.getSms1() == 0) sms1 = ""; String sms2 = ""; if (nm.getSms2() == 0) sms2 = ""; tmpLabel = new Label(0, 2 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, vo.getAlias() + "(" + nm.getIp() + ")", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, nm.getDescr(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, enable, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2 + i, nm.getLimenvalue0() + nm.getUnit(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 2 + i, nm.getTime0() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 2 + i, sms0, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 2 + i, nm.getLimenvalue1() + nm.getUnit(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 2 + i, nm.getTime1() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 2 + i, sms1, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 2 + i, nm.getLimenvalue2() + nm.getUnit(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, 2 + i, nm.getTime1() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(12, 2 + i, sms2, p_labelFormat); sheet.addCell(tmpLabel); } } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_faworklistdoc(String filename, User user) throws DocumentException, IOException { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Paragraph title = new Paragraph("", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); // document.add(new Paragraph("\n")); Table aTable = new Table(13); float[] widths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; NodeMonitorDao nmdao = new NodeMonitorDao(); List moidlist = new ArrayList(); try { moidlist = nmdao.loadByBID(user.getBusinessids()); } catch (Exception e) { } finally { nmdao.close(); } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); if (moidlist != null) { for (int i = 0; i < moidlist.size(); i++) { NodeMonitor nm = (NodeMonitor) moidlist.get(i); HostNode vo = new HostNode(); HostNodeDao dao = new HostNodeDao(); try { vo = dao.loadHost(nm.getNodeID()); } catch (Exception e) { } finally { dao.close(); } String enable = ""; if (!nm.isEnabled()) enable = ""; if (vo == null) continue; String sms0 = ""; if (nm.getSms0() == 0) sms0 = ""; String sms1 = ""; if (nm.getSms1() == 0) sms1 = ""; String sms2 = ""; if (nm.getSms2() == 0) sms2 = ""; cell = new Cell(new Phrase(i + 1 + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(vo.getAlias() + "(" + nm.getIp() + ")", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getDescr(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(enable, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getLimenvalue0() + nm.getUnit(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getTime0() + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sms0, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getLimenvalue1() + nm.getUnit(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getTime1() + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sms1, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getLimenvalue2() + nm.getUnit(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getTime1() + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sms2, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); }// end db2 report doc public void createReport_faworklistpdf(String filename, User user) throws DocumentException, IOException { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Paragraph title = new Paragraph("", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); document.add(new Paragraph("\n")); // document.add(new Paragraph("\n")); PdfPTable aTable = new PdfPTable(13); float[] widths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; NodeMonitorDao nmdao = new NodeMonitorDao(); List moidlist = new ArrayList(); try { moidlist = nmdao.loadByBID(user.getBusinessids()); } catch (Exception e) { } finally { nmdao.close(); } cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); if (moidlist != null) { for (int i = 0; i < moidlist.size(); i++) { NodeMonitor nm = (NodeMonitor) moidlist.get(i); HostNode vo = new HostNode(); HostNodeDao dao = new HostNodeDao(); try { vo = dao.loadHost(nm.getNodeID()); } catch (Exception e) { } finally { dao.close(); } String enable = ""; if (!nm.isEnabled()) enable = ""; if (vo == null) continue; String sms0 = ""; if (nm.getSms0() == 0) sms0 = ""; String sms1 = ""; if (nm.getSms1() == 0) sms1 = ""; String sms2 = ""; if (nm.getSms2() == 0) sms2 = ""; cell = new PdfPCell(new Phrase(i + 1 + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(vo.getAlias() + "(" + nm.getIp() + ")")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getDescr(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(enable, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getLimenvalue0() + nm.getUnit())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getTime0() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(sms0, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getLimenvalue1() + nm.getUnit())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getTime1() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(sms1, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getLimenvalue2() + nm.getUnit())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getTime1() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(sms2, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); }// end db2 report doc public void createReport_faworklistsearchpdf(String filename) throws DocumentException, IOException { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Paragraph title = new Paragraph("", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); document.add(new Paragraph("\n")); List moidlist = (List) reportHash.get("list"); // document.add(new Paragraph("\n")); PdfPTable aTable = new PdfPTable(13); float[] widths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); if (moidlist != null) { for (int i = 0; i < moidlist.size(); i++) { NodeMonitor nm = (NodeMonitor) moidlist.get(i); HostNode vo = new HostNode(); HostNodeDao dao = new HostNodeDao(); vo = dao.loadHost(nm.getNodeID()); String enable = ""; if (!nm.isEnabled()) enable = ""; if (vo == null) continue; dao.close(); String sms0 = ""; if (nm.getSms0() == 0) sms0 = ""; String sms1 = ""; if (nm.getSms1() == 0) sms1 = ""; String sms2 = ""; if (nm.getSms2() == 0) sms2 = ""; cell = new PdfPCell(new Phrase(i + 1 + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(vo.getAlias() + "(" + nm.getIp() + ")")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getDescr(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(enable, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getLimenvalue0() + nm.getUnit())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getTime0() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(sms0, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getLimenvalue1() + nm.getUnit())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getTime1() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(sms1, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getLimenvalue2() + nm.getUnit())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(nm.getTime1() + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(sms2, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); }// end db2 report doc public void createReport_faworklistsearchdoc(String filename) throws DocumentException, IOException { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Paragraph title = new Paragraph("", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); // document.add(new Paragraph("\n")); Table aTable = new Table(13); float[] widths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; List moidlist = (List) reportHash.get("list"); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); if (moidlist != null) { for (int i = 0; i < moidlist.size(); i++) { NodeMonitor nm = (NodeMonitor) moidlist.get(i); HostNode vo = new HostNode(); HostNodeDao dao = new HostNodeDao(); vo = dao.loadHost(nm.getNodeID()); String enable = ""; if (!nm.isEnabled()) enable = ""; if (vo == null) continue; dao.close(); String sms0 = ""; if (nm.getSms0() == 0) sms0 = ""; String sms1 = ""; if (nm.getSms1() == 0) sms1 = ""; String sms2 = ""; if (nm.getSms2() == 0) sms2 = ""; cell = new Cell(new Phrase(i + 1 + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(vo.getAlias() + "(" + nm.getIp() + ")", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getDescr(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(enable, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getLimenvalue0() + nm.getUnit(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getTime0() + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sms0, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getLimenvalue1() + nm.getUnit(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getTime1() + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sms1, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getLimenvalue2() + nm.getUnit(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getTime1() + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sms2, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); }// end db2 report doc // zhushouzhi------------------------------------- public void createReport_faworklistsearch(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); Label tmpLabel = null; // List moidlist = (List)reportHash.get("list"); /* * DaoInterface nmdao = new NodeMonitorDao(); List moidlist = * nmdao.loadAll(); nmdao.close(); */ List moidlist = (List) reportHash.get("list"); tmpLabel = new Label(4, 0, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "()", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 1, "()", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 1, "()", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(12, 1, "", _labelFormat); sheet.addCell(tmpLabel); if (moidlist != null) { for (int i = 0; i < moidlist.size(); i++) { NodeMonitor nm = (NodeMonitor) moidlist.get(i); HostNode vo = new HostNode(); HostNodeDao dao = new HostNodeDao(); vo = dao.loadHost(nm.getNodeID()); String enable = ""; if (!nm.isEnabled()) enable = ""; if (vo == null) continue; dao.close(); String sms0 = ""; if (nm.getSms0() == 0) sms0 = ""; String sms1 = ""; if (nm.getSms1() == 0) sms1 = ""; String sms2 = ""; if (nm.getSms2() == 0) sms2 = ""; tmpLabel = new Label(0, 2 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, vo.getAlias() + "(" + nm.getIp() + ")", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, nm.getDescr(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, enable, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2 + i, nm.getLimenvalue0() + nm.getUnit(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 2 + i, nm.getTime0() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 2 + i, sms0, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 2 + i, nm.getLimenvalue1() + nm.getUnit(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 2 + i, nm.getTime1() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 2 + i, sms1, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 2 + i, nm.getLimenvalue2() + nm.getUnit(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(11, 2 + i, nm.getTime1() + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(12, 2 + i, sms2, p_labelFormat); sheet.addCell(tmpLabel); } } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * @author HONGLI sqlserverword * @param filename * @throws DocumentException * @throws IOException */ public void createReport_SqlServerCldDoc(String filename, String type) throws IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); this.setTableFormat(dbTable); // float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; // dbTable.setWidths(cellWidths); // dbTable.setWidth(100); // 90% // dbTable.setAlignment(Element.ALIGN_CENTER);// // dbTable.setAutoFillEmptyCells(true); // // dbTable.setBorderWidth(1); // // dbTable.setBorderColor(new Color(0, 125, 255)); // // dbTable.setPadding(2);// // dbTable.setSpacing(0);// // dbTable.setBorder(2);// // dbTable.endHeaders(); Cell dbCell = null; dbCell = new Cell(new Phrase("", titleFont)); dbCell.setColspan(5); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(vo.getDbName(), contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(ip, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(typename, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(runstr, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(grade, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); Table aTable = new Table(3); this.setTableFormat(aTable); // float[] widths = { 220f, 220f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// // aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(pingnow + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingmin + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingconavg + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // img.setAbsolutePosition(0, 0); img.scalePercent(75); img.setAlignment(Image.LEFT);// document.add(dbTable); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // Table dbInfoTable = new Table(5); this.setTableFormat(dbInfoTable); // float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f }; // dbInfoTable.setWidths(dbInfoWidths); // dbInfoTable.setWidth(100); // 90% // dbInfoTable.setAlignment(Element.ALIGN_CENTER);// // dbInfoTable.setAutoFillEmptyCells(true); // // dbInfoTable.setBorderWidth(1); // // dbInfoTable.setBorderColor(new Color(0, 125, 255)); // // dbInfoTable.setPadding(2);// // dbInfoTable.setSpacing(0);// // dbInfoTable.setBorder(2);// Hashtable mems = (Hashtable) reportHash.get("mems");// cell = new Cell(new Phrase("(KB)", titleFont)); cell.setColspan(5); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("SQL", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase((String) mems.get("totalMemory"), contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase((String) mems.get("optMemory"), contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase((String) mems.get("conMemory"), contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase((String) mems.get("sqlMem"), contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase((String) mems.get("lockMem"), contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); document.add(dbInfoTable); // Table sysInfoTable = new Table(4); this.setTableFormat(sysInfoTable); // float[] sysInfoWidths = { 220f, 220f, 220f, 220f }; // dbInfoTable.setWidths(dbInfoWidths); // sysInfoTable.setWidth(100); // 90% // sysInfoTable.setAlignment(Element.ALIGN_CENTER);// // sysInfoTable.setAutoFillEmptyCells(true); // // sysInfoTable.setBorderWidth(1); // // sysInfoTable.setBorderColor(new Color(0, 125, 255)); // // sysInfoTable.setPadding(2);// // sysInfoTable.setSpacing(0);// // sysInfoTable.setBorder(2);// Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// cell = new Cell(new Phrase("(KB)", titleFont)); cell.setColspan(4); this.setCellFormat(cell, true); sysInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); sysInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); sysInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); sysInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); sysInfoTable.addCell(cell); cell = new Cell(new Phrase((String) sysValue.get("productlevel"), contextFont)); this.setCellFormat(cell, false); sysInfoTable.addCell(cell); cell = new Cell(new Phrase((String) sysValue.get("IsIntegratedSecurityOnly"), contextFont)); this.setCellFormat(cell, false); sysInfoTable.addCell(cell); cell = new Cell(new Phrase((String) sysValue.get("IsSingleUser"), contextFont)); this.setCellFormat(cell, false); sysInfoTable.addCell(cell); cell = new Cell(new Phrase((String) sysValue.get("IsClustered"), contextFont)); this.setCellFormat(cell, false); sysInfoTable.addCell(cell); document.add(sysInfoTable); Table aTable1 = new Table(6); this.setTableFormat(aTable1); float[] width = { 220f, 220f, 330f, 220f, 220f, 220f }; aTable1.setWidths(width); // aTable1.setWidth(100); // 90% // aTable1.setAlignment(Element.ALIGN_CENTER);// // aTable1.setAutoFillEmptyCells(true); // // aTable1.setBorderWidth(1); // // aTable1.setBorderColor(new Color(0, 125, 255)); // // aTable1.setPadding(2);// // aTable1.setSpacing(0);// // aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(6); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // aTable1.endHeaders(); // Hashtable dbValue = (Hashtable) reportHash.get("tableinfo_v"); Hashtable alldatabase = new Hashtable(); if (dbValue.get("database") != null) alldatabase = (Hashtable) dbValue.get("database"); Vector names = new Vector(); if (dbValue.get("names") != null) names = (Vector) dbValue.get("names"); if (alldatabase != null && alldatabase.size() > 0) { if (names == null) names = new Vector(); int row = 1; for (int i = 0; i < names.size(); i++) { String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); cell = new Cell(new Phrase("")); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(row + "", titleFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(dbname, titleFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(size, titleFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(usedsize, titleFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(usedperc, titleFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); // Table evenInfoTable = new Table(2); this.setTableFormat(evenInfoTable); // float[] evenInfoWidths = { 220f, 220f }; // evenInfoTable.setWidths(evenInfoWidths); // evenInfoTable.setWidth(100); // 90% // evenInfoTable.setAlignment(Element.ALIGN_CENTER);// // evenInfoTable.setAutoFillEmptyCells(true); // // evenInfoTable.setBorderWidth(1); // // evenInfoTable.setBorderColor(new Color(0, 125, 255)); // // evenInfoTable.setPadding(2);// // evenInfoTable.setSpacing(0);// // evenInfoTable.setBorder(2);// String downnum = (String) reportHash.get("downnum"); String count = (Integer) reportHash.get("count") + ""; cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); evenInfoTable.addCell(cell); cell = new Cell(new Phrase(downnum, contextFont)); this.setCellFormat(cell, false); evenInfoTable.addCell(cell); cell = new Cell(new Phrase(count, contextFont)); this.setCellFormat(cell, false); evenInfoTable.addCell(cell); document.add(evenInfoTable); // addEventListToDoc(document, titleFont, contextFont); document.close(); } catch (Exception e) { SysLogger.error("", e); } } /** * @author HONGLI sqlserverpdf * @param filename * @throws DocumentException * @throws IOException */ public void createReport_SqlServerCldPdf(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // PdfPTable dbTable = new PdfPTable(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidthPercentage(100); PdfPCell dbCell = null; dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setColspan(5); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("IP", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(vo.getDbName(), contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(ip, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(typename, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(runstr, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(grade, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(pingnow + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(pingmin + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(pingconavg + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // img.setAbsolutePosition(0, 0); img.scalePercent(76); img.setAlignment(Image.MIDDLE);// document.add(dbTable); document.add(new Paragraph("\n")); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // (KB) PdfPTable dbInfoTable = new PdfPTable(5); float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f }; dbInfoTable.setWidths(dbInfoWidths); dbInfoTable.setWidthPercentage(100); Hashtable mems = (Hashtable) reportHash.get("mems");// cell = new PdfPCell(new Phrase("(KB)", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new PdfPCell(new Phrase("SQL", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new PdfPCell(new Phrase((String) mems.get("totalMemory"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new PdfPCell(new Phrase((String) mems.get("optMemory"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new PdfPCell(new Phrase((String) mems.get("conMemory"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new PdfPCell(new Phrase((String) mems.get("sqlMem"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new PdfPCell(new Phrase((String) mems.get("lockMem"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); document.add(dbInfoTable); document.add(new Paragraph("\n")); // (KB) PdfPTable ncTable = new PdfPTable(4); float[] ncWidths = { 220f, 220f, 220f, 220f }; ncTable.setWidths(ncWidths); ncTable.setWidthPercentage(100); Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new PdfPCell(new Phrase((String) sysValue.get("productlevel"), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new PdfPCell(new Phrase((String) sysValue.get("IsIntegratedSecurityOnly"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new PdfPCell(new Phrase((String) sysValue.get("IsSingleUser"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new PdfPCell(new Phrase((String) sysValue.get("IsClustered"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); document.add(ncTable); document.add(new Paragraph("\n")); PdfPTable aTable1 = new PdfPTable(6); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Hashtable dbValue = (Hashtable) reportHash.get("tableinfo_v"); Hashtable alldatabase = new Hashtable(); if (dbValue.get("database") != null) alldatabase = (Hashtable) dbValue.get("database"); Vector names = new Vector(); if (dbValue.get("names") != null) names = (Vector) dbValue.get("names"); if (alldatabase != null && alldatabase.size() > 0) { if (names == null) names = new Vector(); int row = 1; for (int i = 0; i < names.size(); i++) { String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(row + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(dbname)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(size)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(usedsize)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(usedperc)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.add(new Paragraph("\n")); // PdfPTable eventTable = new PdfPTable(2); float[] eventWidths = { 220f, 220f }; eventTable.setWidths(eventWidths); eventTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase((String) reportHash.get("downnum"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(reportHash.get("count") + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); document.add(eventTable); document.add(new Paragraph("\n")); // addEventLisToPdf(document); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author HONGLI sqlserverexcel * @param filename * @throws DocumentException * @throws IOException */ public void createReport_SqlServerCldXls(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { wb = Workbook.createWorkbook(new File(filename)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable mems = (Hashtable) reportHash.get("mems");// Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); // ip tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, typename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, runstr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, grade, p_labelFormat); sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 8, pingmin + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 8, pingconavg + "%", p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 9, 7, 7, file)); // allRow = allRow+7; // tmpLabel = new Label(0, 16, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 16, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 16, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 16, "SQL", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 16, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 17, (String) mems.get("totalMemory"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 17, (String) mems.get("optMemory"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 17, (String) mems.get("conMemory"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 17, (String) mems.get("sqlMem"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 17, (String) mems.get("lockMem"), p_labelFormat); sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 19, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 19, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 19, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 19, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 20, (String) sysValue.get("productlevel"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 20, (String) sysValue.get("IsIntegratedSecurityOnly"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 20, (String) sysValue.get("IsSingleUser"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 20, (String) sysValue.get("IsClustered"), p_labelFormat); sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 22, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 22, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 22, "(MB)", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 22, "(MB)", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 22, "(%)", b_labelFormat); sheet.addCell(tmpLabel); int row = 22; // Hashtable dbValue = (Hashtable) reportHash.get("tableinfo_v"); Hashtable alldatabase = new Hashtable(); if (dbValue.get("database") != null) alldatabase = (Hashtable) dbValue.get("database"); Vector names = new Vector(); if (dbValue.get("names") != null) names = (Vector) dbValue.get("names"); if (alldatabase != null && alldatabase.size() > 0) { if (names == null) names = new Vector(); for (int i = 0; i < names.size(); i++) { String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); row = row + 1; tmpLabel = new Label(0, row, i + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, dbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, usedsize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, usedperc, p_labelFormat); sheet.addCell(tmpLabel); } } // row = row + 2; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, (String) reportHash.get("downnum"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, reportHash.get("count") + "", p_labelFormat); sheet.addCell(tmpLabel); // addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * @author HONGLI DB2 doc * @param filename * @throws DocumentException * @throws IOException */ public void createReportDB2SelfDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // document.add(aTable); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// document.add(img); document.add(new Paragraph("\n")); Table aTable1 = new Table(5); float[] width = { 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo"); if (spaceInfo.get("toolsdb") != null) { List toolsdb = (ArrayList) spaceInfo.get("toolsdb");// if (toolsdb != null && toolsdb.size() > 0) { for (int i = 0; i < toolsdb.size(); i++) { Hashtable tempSpace = (Hashtable) toolsdb.get(i); String SYSCATSPACE = tempSpace.get("tablespace_name") + ""; String totalspac = tempSpace.get("totalspac") + ""; String usablespac = tempSpace.get("usablespac") + ""; String usableper = (String) tempSpace.get("usableper"); if (usableper == null || usableper.trim().equals("")) { usableper = "0"; } cell = new Cell(new Phrase((i + 1) + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(SYSCATSPACE, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(totalspac, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(usablespac, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(usableper, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } } document.add(aTable1); document.close(); } catch (Exception e) { SysLogger.error("", e); } } /** * @author HONGLI DB2 xls * @param filename * @throws DocumentException * @throws IOException */ public void createReportDB2SelfExcel(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, (String) maxping.get("pingnow"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "(MB)", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "(MB)", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "(%)", _labelFormat); sheet.addCell(tmpLabel); int row = 14; // Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo"); Iterator iterator = spaceInfo.keySet().iterator(); while (iterator.hasNext()) { String dbName = (String) iterator.next(); List toolsdb = (ArrayList) spaceInfo.get(dbName); if (toolsdb != null && toolsdb.size() > 0) { for (int i = 0; i < toolsdb.size(); i++) { Hashtable tempSpace = (Hashtable) toolsdb.get(i); String SYSCATSPACE = tempSpace.get("tablespace_name") + ""; String totalspac = tempSpace.get("totalspac") + ""; String usablespac = tempSpace.get("usablespac") + ""; String usableper = (String) tempSpace.get("usableper"); if (usableper == null || usableper.trim().equals("")) { usableper = "0"; } row = row + 1; tmpLabel = new Label(0, row, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, SYSCATSPACE, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, totalspac, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, usablespac, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, usableper, p_labelFormat); sheet.addCell(tmpLabel); } } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * @author HONGLI DB2 pdf * @param filename * @throws DocumentException * @throws IOException */ public void createReportDB2SelfPdf(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingnow"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// // document.add(aTable); img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); PdfPTable aTable1 = new PdfPTable(5); float[] width = { 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo"); Iterator iterator = spaceInfo.keySet().iterator(); while (iterator.hasNext()) { String dbName = (String) iterator.next(); List toolsdb = (ArrayList) spaceInfo.get(dbName); if (toolsdb != null && toolsdb.size() > 0) { for (int i = 0; i < toolsdb.size(); i++) { Hashtable tempSpace = (Hashtable) toolsdb.get(i); String SYSCATSPACE = tempSpace.get("tablespace_name") + ""; String totalspac = tempSpace.get("totalspac") + ""; String usablespac = tempSpace.get("usablespac") + ""; String usableper = (String) tempSpace.get("usableper"); if (usableper == null || usableper.trim().equals("")) { usableper = "0"; } cell = new PdfPCell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(SYSCATSPACE)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(totalspac)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(usablespac)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(usableper)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // TODO: handle exception } } /** * @author HONGLI db2word * @param filename * @param type * @throws IOException */ public void createReport_DB2CldDoc(String filename, String type) throws IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); Hashtable conn = (Hashtable) reportHash.get("conn");// if (conn == null) conn = new Hashtable(); Hashtable poolInfo = (Hashtable) reportHash.get("poolInfo");// if (poolInfo == null) poolInfo = new Hashtable(); Hashtable log = (Hashtable) reportHash.get("log");// if (log == null) log = new Hashtable(); Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo");// if (spaceInfo == null) spaceInfo = new Hashtable(); String[] sysDbStatus = { "", "", "", "" }; String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); this.setTableFormat(dbTable); // float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; // dbTable.setWidths(cellWidths); // dbTable.setWidth(100); // 90% // dbTable.setAlignment(Element.ALIGN_CENTER);// // dbTable.setAutoFillEmptyCells(true); // // dbTable.setBorderWidth(1); // // dbTable.setBorderColor(new Color(0, 125, 255)); // // dbTable.setPadding(2);// // dbTable.setSpacing(0);// // dbTable.setBorder(2);// // dbTable.endHeaders(); Cell dbCell = null; dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbCell.setColspan(5); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(vo.getDbName(), contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(ip, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(typename, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(runstr, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(grade, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); Table aTable = new Table(3); this.setTableFormat(aTable); // float[] widths = { 220f, 220f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// // aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(pingnow + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingmin + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingconavg + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // img.setAbsolutePosition(0, 0); if ("pdf".equals(type)) { img.scalePercent(75); } img.setAlignment(Image.LEFT);// document.add(dbTable); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // Table spaceTable = new Table(5); this.setTableFormat(spaceTable); // float[] width3 = { 220f, 220f, 220f, 220f, 220f }; // spaceTable.setWidths(width3); // spaceTable.setWidth(100); // 90% // spaceTable.setAlignment(Element.ALIGN_CENTER);// // spaceTable.setAutoFillEmptyCells(true); // // spaceTable.setBorderWidth(1); // // spaceTable.setBorderColor(new Color(0, 125, 255)); // // spaceTable.setPadding(2);// // spaceTable.setSpacing(0);// // spaceTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); cell.setColspan(5); spaceTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); spaceTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); spaceTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); spaceTable.addCell(cell); cell = new Cell(new Phrase(" % ", titleFont)); this.setCellFormat(cell, true); spaceTable.addCell(cell); Iterator iterator = spaceInfo.keySet().iterator(); while (iterator.hasNext()) { String dbName = (String) iterator.next(); List toolsdb = (ArrayList) spaceInfo.get(dbName); if (toolsdb != null && toolsdb.size() > 0) { for (int i = 0; i < toolsdb.size(); i++) { Hashtable tempSpace = new Hashtable(); tempSpace = (Hashtable) toolsdb.get(i); String tablespace_name = (String) tempSpace.get("tablespace_name"); String totalspac = (String) tempSpace.get("totalspac"); String usablespac = (String) tempSpace.get("usablespac"); String usableper = (String) tempSpace.get("usableper"); if (usableper == null || "0".equals(totalspac.trim())) { usableper = "100"; } cell = new Cell(new Phrase((i + 1) + "", titleFont)); this.setCellFormat(cell, false); spaceTable.addCell(cell); cell = new Cell(new Phrase(tablespace_name, titleFont)); this.setCellFormat(cell, false); spaceTable.addCell(cell); cell = new Cell(new Phrase(totalspac, titleFont)); this.setCellFormat(cell, false); spaceTable.addCell(cell); cell = new Cell(new Phrase(usablespac, titleFont)); this.setCellFormat(cell, false); spaceTable.addCell(cell); cell = new Cell(new Phrase(usableper, titleFont)); this.setCellFormat(cell, false); spaceTable.addCell(cell); } } } document.add(spaceTable); // Table dbInfoTable = new Table(10); this.setTableFormat(dbInfoTable); // float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f, // 220f, 220f, 220f, 220f }; // dbInfoTable.setWidths(dbInfoWidths); // dbInfoTable.setWidth(100); // 90% // dbInfoTable.setAlignment(Element.ALIGN_CENTER);// // dbInfoTable.setAutoFillEmptyCells(true); // // dbInfoTable.setBorderWidth(1); // // dbInfoTable.setBorderColor(new Color(0, 125, 255)); // // dbInfoTable.setPadding(2);// // dbInfoTable.setSpacing(0);// // dbInfoTable.setBorder(2);// Hashtable mems = (Hashtable) reportHash.get("mems");// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(10); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("SQL ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("SQL ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); Enumeration dbs = conn.keys(); Hashtable<String, Object> allhash = new Hashtable(); List poolList = new ArrayList(); while (dbs.hasMoreElements()) { String obj = (String) dbs.nextElement(); List connList = (List) conn.get(obj); for (int i = 0; i < connList.size(); i++) { Hashtable ht = (Hashtable) connList.get(i); String db_name = ht.get("db_name").toString(); String db_path = ht.get("db_path").toString(); String db_status = ht.get("db_status").toString(); String sqlm_elm_last_backup = ht.get("sqlm_elm_last_backup").toString(); String total_cons = ht.get("total_cons").toString(); String connections_top = ht.get("connections_top").toString(); String appls_cur_cons = ht.get("appls_cur_cons").toString(); String failedsql = ht.get("failedsql").toString(); String commitsql = ht.get("commitsql").toString(); cell = new Cell(new Phrase((i + 1) + "", contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(db_name, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(db_path, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(sysDbStatus[Integer.parseInt(db_status)], contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(sqlm_elm_last_backup, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(total_cons, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(connections_top, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(appls_cur_cons, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(failedsql, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(commitsql, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); } } document.add(dbInfoTable); // Table sysInfoTable = new Table(7); this.setTableFormat(sysInfoTable); // sysInfoTable.setWidth(100); // 90% // sysInfoTable.setAlignment(Element.ALIGN_CENTER);// // sysInfoTable.setAutoFillEmptyCells(true); // // sysInfoTable.setBorderWidth(1); // // sysInfoTable.setBorderColor(new Color(0, 125, 255)); // // sysInfoTable.setPadding(2);// // sysInfoTable.setSpacing(0);// // sysInfoTable.setBorder(2);// Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); cell.setColspan(7); sysInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); sysInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); sysInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); sysInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); sysInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); sysInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); sysInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); sysInfoTable.addCell(cell); Enumeration dbs2 = poolInfo.keys(); Hashtable<String, Object> allhash2 = new Hashtable(); List poolList2 = new ArrayList(); while (dbs2.hasMoreElements()) { String obj = (String) dbs2.nextElement(); allhash = (Hashtable) poolInfo.get(obj); poolList = (List) allhash.get("poolValue"); List lockList = (List) allhash.get("lockValue"); List readList = (List) allhash.get("readValue"); List writeList = (List) allhash.get("writeValue"); for (int i = 0; i < poolList.size(); i++) { Hashtable ht = (Hashtable) poolList.get(i); String bp_name = ht.get("bp_name").toString(); String data_hit_ratio = ht.get("data_hit_ratio").toString(); String index_hit_ratio = ht.get("index_hit_ratio").toString(); String BP_hit_ratio = ht.get("BP_hit_ratio").toString(); String Async_read_pct = ht.get("Async_read_pct").toString(); String Direct_RW_Ratio = ht.get("Direct_RW_Ratio").toString(); cell = new Cell(new Phrase((i + 1) + "", contextFont)); this.setCellFormat(cell, false); sysInfoTable.addCell(cell); cell = new Cell(new Phrase(bp_name, contextFont)); this.setCellFormat(cell, false); sysInfoTable.addCell(cell); cell = new Cell(new Phrase(data_hit_ratio, contextFont)); this.setCellFormat(cell, false); sysInfoTable.addCell(cell); cell = new Cell(new Phrase(index_hit_ratio, contextFont)); this.setCellFormat(cell, false); sysInfoTable.addCell(cell); cell = new Cell(new Phrase(BP_hit_ratio, contextFont)); this.setCellFormat(cell, false); sysInfoTable.addCell(cell); cell = new Cell(new Phrase(Async_read_pct, contextFont)); this.setCellFormat(cell, false); sysInfoTable.addCell(cell); cell = new Cell(new Phrase(Direct_RW_Ratio, contextFont)); this.setCellFormat(cell, false); sysInfoTable.addCell(cell); } } document.newPage(); document.add(sysInfoTable); // Table aTable1 = new Table(10); this.setTableFormat(aTable1); // float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, // 220f, 220f }; // aTable1.setWidths(width); // aTable1.setWidth(100); // 90% // aTable1.setAlignment(Element.ALIGN_CENTER);// // aTable1.setAutoFillEmptyCells(true); // // aTable1.setBorderWidth(1); // // aTable1.setBorderColor(new Color(0, 125, 255)); // // aTable1.setPadding(2);// // aTable1.setSpacing(0);// // aTable1.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(10); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // aTable1.endHeaders(); Enumeration dbs3 = poolInfo.keys(); Hashtable<String, Object> allhash3 = new Hashtable(); List poolList3 = new ArrayList(); while (dbs3.hasMoreElements()) { String obj = (String) dbs3.nextElement(); allhash3 = (Hashtable) poolInfo.get(obj); poolList3 = (List) allhash3.get("poolValue"); // System.out.println("poolList size === "+poolList.size()); List lockList = (List) allhash3.get("lockValue"); List readList = (List) allhash3.get("readValue"); List writeList = (List) allhash3.get("writeValue"); for (int i = 0; i < lockList.size(); i++) { Hashtable ht = (Hashtable) lockList.get(i); String db_name = ht.get("db_name").toString(); String rows_read = ht.get("rows_read").toString(); String rows_selected = ht.get("rows_selected").toString(); String lock_waits = ht.get("lock_waits").toString(); String lock_wait_time = ht.get("lock_wait_time").toString(); String deadlocks = ht.get("deadlocks").toString(); String lock_escals = ht.get("lock_escals").toString(); String total_sorts = ht.get("total_sorts").toString(); String total_sort_time = ht.get("total_sort_time").toString(); cell = new Cell(new Phrase((i + 1) + "")); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(db_name, contextFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(rows_read, contextFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(rows_selected, contextFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(lock_waits, contextFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(lock_wait_time, contextFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(deadlocks, contextFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(lock_escals, contextFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(total_sorts, contextFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); cell = new Cell(new Phrase(total_sort_time, contextFont)); this.setCellFormat(cell, false); aTable1.addCell(cell); } } // Table aTable2 = new Table(7); this.setTableFormat(aTable2); // float[] width2 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // aTable2.setWidths(width2); // aTable2.setWidth(100); // 90% // aTable2.setAlignment(Element.ALIGN_CENTER);// // aTable2.setAutoFillEmptyCells(true); // // aTable2.setBorderWidth(1); // // aTable2.setBorderColor(new Color(0, 125, 255)); // // aTable2.setPadding(2);// // aTable2.setSpacing(0);// // aTable2.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(7); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase("(Mb) ", titleFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase("(Mb) ", titleFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase("(%) ", titleFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase("(Mb) ", titleFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); cell = new Cell(new Phrase("/", titleFont)); this.setCellFormat(cell, true); aTable2.addCell(cell); Enumeration dbs4 = log.keys(); Hashtable<String, Object> allhash4 = new Hashtable(); List poolList4 = new ArrayList(); while (dbs4.hasMoreElements()) { String obj = (String) dbs4.nextElement(); List logList = (List) log.get(obj); for (int i = 0; i < logList.size(); i++) { Hashtable ht = (Hashtable) logList.get(i); String logused = ht.get("logused").toString(); String logspacefree = ht.get("logspacefree").toString(); String pctused = ht.get("pctused").toString(); String maxlogused = ht.get("maxlogused").toString(); String maxsecused = ht.get("maxsecused").toString(); cell = new Cell(new Phrase((i + 1) + "")); this.setCellFormat(cell, false); aTable2.addCell(cell); cell = new Cell(new Phrase(obj, contextFont)); this.setCellFormat(cell, false); aTable2.addCell(cell); cell = new Cell(new Phrase(logused, contextFont)); this.setCellFormat(cell, false); aTable2.addCell(cell); cell = new Cell(new Phrase(logspacefree, contextFont)); this.setCellFormat(cell, false); aTable2.addCell(cell); cell = new Cell(new Phrase(pctused, contextFont)); this.setCellFormat(cell, false); aTable2.addCell(cell); cell = new Cell(new Phrase(maxlogused, contextFont)); this.setCellFormat(cell, false); aTable2.addCell(cell); cell = new Cell(new Phrase(maxsecused, contextFont)); this.setCellFormat(cell, false); aTable2.addCell(cell); } } // Table aTable3 = new Table(7); this.setTableFormat(aTable3); // float[] awidth3 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // aTable3.setWidths(awidth3); // aTable3.setWidth(100); // 90% // aTable3.setAlignment(Element.ALIGN_CENTER);// // aTable3.setAutoFillEmptyCells(true); // // aTable3.setBorderWidth(1); // // aTable3.setBorderColor(new Color(0, 125, 255)); // // aTable3.setPadding(2);// // aTable3.setSpacing(0);// // aTable3.setBorder(2);// cell = new Cell(new Phrase("10", titleFont)); cell.setColspan(7); this.setCellFormat(cell, true); aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable3.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable3.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable3.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable3.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable3.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable3.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable3.addCell(cell); Enumeration dbs5 = poolInfo.keys(); Hashtable<String, Object> allhash5 = new Hashtable(); List poolList5 = new ArrayList(); String obj = null; Hashtable allhash6 = null; List lockList = null; List readList = null; List writeList = null; while (dbs5.hasMoreElements()) { obj = (String) dbs5.nextElement(); allhash6 = (Hashtable) poolInfo.get(obj); poolList = (List) allhash6.get("poolValue"); // System.out.println("poolList size === "+poolList.size()); lockList = (List) allhash6.get("lockValue"); readList = (List) allhash6.get("readValue"); writeList = (List) allhash6.get("writeValue"); } if (readList != null && readList.size() > 0) { for (int i = 0; i < readList.size(); i++) { Hashtable ht = (Hashtable) readList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); cell = new Cell(new Phrase((i + 1) + "", contextFont)); this.setCellFormat(cell, false); aTable3.addCell(cell); cell = new Cell(new Phrase(tbschema, contextFont)); this.setCellFormat(cell, false); aTable3.addCell(cell); cell = new Cell(new Phrase(tbname, contextFont)); this.setCellFormat(cell, false); aTable3.addCell(cell); cell = new Cell(new Phrase(rows_read, contextFont)); this.setCellFormat(cell, false); aTable3.addCell(cell); cell = new Cell(new Phrase(rows_written, contextFont)); this.setCellFormat(cell, false); aTable3.addCell(cell); cell = new Cell(new Phrase(overflow_accesses, contextFont)); this.setCellFormat(cell, false); aTable3.addCell(cell); cell = new Cell(new Phrase(page_reorgs, contextFont)); this.setCellFormat(cell, false); aTable3.addCell(cell); } } Table aTable4 = new Table(7); this.setTableFormat(aTable4); // float[] width4 = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // aTable4.setWidths(width4); // aTable4.setWidth(100); // 90% // aTable4.setAlignment(Element.ALIGN_CENTER);// // aTable4.setAutoFillEmptyCells(true); // // aTable4.setBorderWidth(1); // // aTable4.setBorderColor(new Color(0, 125, 255)); // // aTable4.setPadding(2);// // aTable4.setSpacing(0);// // aTable4.setBorder(2);// cell = new Cell(new Phrase("10", titleFont)); cell.setColspan(7); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); aTable4.addCell(cell); if (writeList != null && writeList.size() > 0) { for (int i = 0; i < writeList.size(); i++) { Hashtable ht = (Hashtable) writeList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); cell = new Cell(new Phrase((i + 1) + "", contextFont)); this.setCellFormat(cell, false); aTable4.addCell(cell); cell = new Cell(new Phrase(tbschema, contextFont)); this.setCellFormat(cell, false); aTable4.addCell(cell); cell = new Cell(new Phrase(tbname, contextFont)); this.setCellFormat(cell, false); aTable4.addCell(cell); cell = new Cell(new Phrase(rows_read, contextFont)); this.setCellFormat(cell, false); aTable4.addCell(cell); cell = new Cell(new Phrase(rows_written, contextFont)); this.setCellFormat(cell, false); aTable4.addCell(cell); cell = new Cell(new Phrase(overflow_accesses, contextFont)); this.setCellFormat(cell, false); aTable4.addCell(cell); cell = new Cell(new Phrase(page_reorgs, contextFont)); this.setCellFormat(cell, false); aTable4.addCell(cell); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); // img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.add(aTable2); document.add(aTable3); document.add(aTable4); // Table evenInfoTable = new Table(2); this.setTableFormat(evenInfoTable); // float[] evenInfoWidths = { 220f, 220f }; // evenInfoTable.setWidths(evenInfoWidths); // evenInfoTable.setWidth(100); // 90% // evenInfoTable.setAlignment(Element.ALIGN_CENTER);// // evenInfoTable.setAutoFillEmptyCells(true); // // evenInfoTable.setBorderWidth(1); // // evenInfoTable.setBorderColor(new Color(0, 125, 255)); // // evenInfoTable.setPadding(2);// // evenInfoTable.setSpacing(0);// // evenInfoTable.setBorder(2);// String downnum = (String) reportHash.get("downnum"); String count = (Integer) reportHash.get("count") + ""; cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); evenInfoTable.addCell(cell); cell = new Cell(new Phrase(downnum, contextFont)); this.setCellFormat(cell, false); evenInfoTable.addCell(cell); cell = new Cell(new Phrase(count, contextFont)); this.setCellFormat(cell, false); evenInfoTable.addCell(cell); document.newPage(); document.add(evenInfoTable); // addEventListToDoc(document, titleFont, contextFont); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author HONGLI DB2pdf * @param filename * @throws DocumentException * @throws IOException */ public void createReport_DB2CldPdf(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); Hashtable conn = (Hashtable) reportHash.get("conn");// if (conn == null) conn = new Hashtable(); Hashtable poolInfo = (Hashtable) reportHash.get("poolInfo");// if (poolInfo == null) poolInfo = new Hashtable(); Hashtable log = (Hashtable) reportHash.get("log");// if (log == null) log = new Hashtable(); Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo");// if (spaceInfo == null) spaceInfo = new Hashtable(); String[] sysDbStatus = { "", "", "", "" }; String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // PdfPTable dbTable = new PdfPTable(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidthPercentage(100); PdfPCell dbCell = null; dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setColspan(5); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("IP", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(vo.getDbName(), contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(ip, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(typename, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(runstr, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(grade, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(pingnow + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(pingmin + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(pingconavg + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // img.setAbsolutePosition(0, 0); img.scalePercent(76); img.setAlignment(Image.MIDDLE);// document.add(dbTable); document.add(new Paragraph("\n")); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // PdfPTable spaceInfoTable = new PdfPTable(5); float[] spaceInfoWidths = { 220f, 220f, 220f, 220f, 220f }; spaceInfoTable.setWidths(spaceInfoWidths); spaceInfoTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceInfoTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceInfoTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceInfoTable.addCell(cell); cell = new PdfPCell(new Phrase("MB ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceInfoTable.addCell(cell); cell = new PdfPCell(new Phrase("MB ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceInfoTable.addCell(cell); cell = new PdfPCell(new Phrase(" % ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceInfoTable.addCell(cell); if (spaceInfo == null) spaceInfo = new Hashtable(); Iterator iterator = spaceInfo.keySet().iterator(); while (iterator.hasNext()) { String dbName = (String) iterator.next(); List toolsdb = (ArrayList) spaceInfo.get(dbName); if (toolsdb != null && toolsdb.size() > 0) { for (int i = 0; i < toolsdb.size(); i++) { Hashtable tempSpace = new Hashtable(); tempSpace = (Hashtable) toolsdb.get(i); String tablespace_name = (String) tempSpace.get("tablespace_name"); String totalspac = (String) tempSpace.get("totalspac"); String usablespac = (String) tempSpace.get("usablespac"); String usableper = (String) tempSpace.get("usableper"); if (usableper == null || "0".equals(totalspac.trim())) { usableper = "100"; } cell = new PdfPCell(new Phrase((i + 1) + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceInfoTable.addCell(cell); cell = new PdfPCell(new Phrase(tablespace_name, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceInfoTable.addCell(cell); cell = new PdfPCell(new Phrase(totalspac, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceInfoTable.addCell(cell); cell = new PdfPCell(new Phrase(usablespac, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceInfoTable.addCell(cell); cell = new PdfPCell(new Phrase(usableper, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceInfoTable.addCell(cell); } } } document.add(spaceInfoTable); document.add(new Paragraph("\n")); // PdfPTable connTable = new PdfPTable(10); float[] connWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; connTable.setWidths(connWidths); connTable.setWidthPercentage(100); Hashtable mems = (Hashtable) reportHash.get("mems");// cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase("SQL ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase("SQL ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); Enumeration dbs = conn.keys(); Hashtable<String, Object> allhash = new Hashtable(); List poolList = new ArrayList(); while (dbs.hasMoreElements()) { String obj = (String) dbs.nextElement(); List connList = (List) conn.get(obj); for (int i = 0; i < connList.size(); i++) { Hashtable ht = (Hashtable) connList.get(i); String db_name = ht.get("db_name").toString(); String db_path = ht.get("db_path").toString(); String db_status = ht.get("db_status").toString(); String sqlm_elm_last_backup = ht.get("sqlm_elm_last_backup").toString(); String total_cons = ht.get("total_cons").toString(); String connections_top = ht.get("connections_top").toString(); String appls_cur_cons = ht.get("appls_cur_cons").toString(); String failedsql = ht.get("failedsql").toString(); String commitsql = ht.get("commitsql").toString(); cell = new PdfPCell(new Phrase((i + 1) + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(db_name, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(db_path, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(sysDbStatus[Integer.parseInt(db_status)], contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(sqlm_elm_last_backup, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(total_cons, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(connections_top, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(appls_cur_cons, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(failedsql, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(commitsql, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); } } document.add(connTable); document.add(new Paragraph("\n")); // PdfPTable hcTable = new PdfPTable(7); float[] hcWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; hcTable.setWidths(hcWidths); hcTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); Enumeration dbs2 = poolInfo.keys(); Hashtable<String, Object> allhash2 = new Hashtable(); List poolList2 = new ArrayList(); while (dbs2.hasMoreElements()) { String obj = (String) dbs2.nextElement(); allhash = (Hashtable) poolInfo.get(obj); poolList = (List) allhash.get("poolValue"); List lockList = (List) allhash.get("lockValue"); List readList = (List) allhash.get("readValue"); List writeList = (List) allhash.get("writeValue"); for (int i = 0; i < poolList.size(); i++) { Hashtable ht = (Hashtable) poolList.get(i); String bp_name = ht.get("bp_name").toString(); String data_hit_ratio = ht.get("data_hit_ratio").toString(); String index_hit_ratio = ht.get("index_hit_ratio").toString(); String BP_hit_ratio = ht.get("BP_hit_ratio").toString(); String Async_read_pct = ht.get("Async_read_pct").toString(); String Direct_RW_Ratio = ht.get("Direct_RW_Ratio").toString(); cell = new PdfPCell(new Phrase((i + 1) + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); cell = new PdfPCell(new Phrase(bp_name, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); cell = new PdfPCell(new Phrase(data_hit_ratio, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); cell = new PdfPCell(new Phrase(index_hit_ratio, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); cell = new PdfPCell(new Phrase(BP_hit_ratio, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); cell = new PdfPCell(new Phrase(Async_read_pct, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); cell = new PdfPCell(new Phrase(Direct_RW_Ratio, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcTable.addCell(cell); } } document.add(hcTable); document.add(new Paragraph("\n")); // PdfPTable lockTable = new PdfPTable(10); float[] lockWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; lockTable.setWidths(lockWidths); lockTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); Enumeration dbs3 = poolInfo.keys(); Hashtable<String, Object> allhash3 = new Hashtable(); List poolList3 = new ArrayList(); while (dbs3.hasMoreElements()) { String obj = (String) dbs3.nextElement(); allhash3 = (Hashtable) poolInfo.get(obj); poolList3 = (List) allhash3.get("poolValue"); // System.out.println("poolList size === "+poolList.size()); List lockList = (List) allhash3.get("lockValue"); List readList = (List) allhash3.get("readValue"); List writeList = (List) allhash3.get("writeValue"); for (int i = 0; i < lockList.size(); i++) { Hashtable ht = (Hashtable) lockList.get(i); String db_name = ht.get("db_name").toString(); String rows_read = ht.get("rows_read").toString(); String rows_selected = ht.get("rows_selected").toString(); String lock_waits = ht.get("lock_waits").toString(); String lock_wait_time = ht.get("lock_wait_time").toString(); String deadlocks = ht.get("deadlocks").toString(); String lock_escals = ht.get("lock_escals").toString(); String total_sorts = ht.get("total_sorts").toString(); String total_sort_time = ht.get("total_sort_time").toString(); cell = new PdfPCell(new Phrase((i + 1) + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(db_name, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(rows_read, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(rows_selected, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(lock_waits, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(lock_wait_time, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(deadlocks, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(lock_escals, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(total_sorts, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(total_sort_time, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); } } document.add(lockTable); document.add(new Paragraph("\n")); // PdfPTable logTable = new PdfPTable(7); float[] logWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; logTable.setWidths(logWidths); logTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase("(Mb) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase("(Mb) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase("(%) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase("(Mb)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase("/ ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); Enumeration dbs4 = log.keys(); Hashtable<String, Object> allhash4 = new Hashtable(); List poolList4 = new ArrayList(); while (dbs4.hasMoreElements()) { String obj = (String) dbs4.nextElement(); List logList = (List) log.get(obj); for (int i = 0; i < logList.size(); i++) { Hashtable ht = (Hashtable) logList.get(i); String logused = ht.get("logused").toString(); String logspacefree = ht.get("logspacefree").toString(); String pctused = ht.get("pctused").toString(); String maxlogused = ht.get("maxlogused").toString(); String maxsecused = ht.get("maxsecused").toString(); cell = new PdfPCell(new Phrase((i + 1) + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(obj, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(logused, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(logspacefree, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(pctused, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(maxlogused, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(maxsecused, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); } } document.add(logTable); document.add(new Paragraph("\n")); // 10 PdfPTable readTopTenTable = new PdfPTable(7); float[] readTopTenWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; readTopTenTable.setWidths(readTopTenWidths); readTopTenTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("10", titleFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); Enumeration dbs5 = poolInfo.keys(); Hashtable<String, Object> allhash5 = new Hashtable(); List poolList5 = new ArrayList(); String obj = null; Hashtable allhash6 = null; List lockList = null; List readList = null; List writeList = null; while (dbs5.hasMoreElements()) { obj = (String) dbs5.nextElement(); allhash6 = (Hashtable) poolInfo.get(obj); poolList = (List) allhash6.get("poolValue"); // System.out.println("poolList size === "+poolList.size()); lockList = (List) allhash6.get("lockValue"); readList = (List) allhash6.get("readValue"); writeList = (List) allhash6.get("writeValue"); } if (readList != null && readList.size() > 0) { for (int i = 0; i < readList.size(); i++) { Hashtable ht = (Hashtable) readList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); cell = new PdfPCell(new Phrase((i + 1) + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(tbschema, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(tbname, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(rows_read, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(rows_written, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(overflow_accesses, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(page_reorgs, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // readTopTenTable.addCell(cell); } } document.add(readTopTenTable); document.add(new Paragraph("\n")); // 10 PdfPTable writeTopTenTable = new PdfPTable(7); float[] writeTopTenWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; writeTopTenTable.setWidths(writeTopTenWidths); writeTopTenTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("10", titleFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); if (writeList != null && writeList.size() > 0) { for (int i = 0; i < writeList.size(); i++) { Hashtable ht = (Hashtable) writeList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); cell = new PdfPCell(new Phrase((i + 1) + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(tbschema, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(tbname, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(rows_read, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(rows_written, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(overflow_accesses, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); cell = new PdfPCell(new Phrase(page_reorgs, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // writeTopTenTable.addCell(cell); } } document.add(writeTopTenTable); document.add(new Paragraph("\n")); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(new Paragraph("\n")); // PdfPTable eventTable = new PdfPTable(2); float[] eventWidths = { 220f, 220f }; eventTable.setWidths(eventWidths); eventTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase((String) reportHash.get("downnum"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(reportHash.get("count") + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); document.add(eventTable); document.add(new Paragraph("\n")); // addEventLisToPdf(document); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author HONGLI DB2excel * @param filename * @throws DocumentException * @throws IOException */ public void createReport_DB2CldXls(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { wb = Workbook.createWorkbook(new File(filename)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable mems = (Hashtable) reportHash.get("mems");// Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); Hashtable conn = (Hashtable) reportHash.get("conn");// if (conn == null) conn = new Hashtable(); Hashtable poolInfo = (Hashtable) reportHash.get("poolInfo");// if (poolInfo == null) poolInfo = new Hashtable(); Hashtable log = (Hashtable) reportHash.get("log");// if (log == null) log = new Hashtable(); Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo");// if (spaceInfo == null) spaceInfo = new Hashtable(); String[] sysDbStatus = { "", "", "", "" }; Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); WritableCellFormat red_labelFormat = new WritableCellFormat(); red_labelFormat.setBackground(jxl.format.Colour.RED); WritableCellFormat orange_labelFormat = new WritableCellFormat(); orange_labelFormat.setBackground(jxl.format.Colour.ORANGE); WritableCellFormat yellow_labelFormat = new WritableCellFormat(); yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); // ip tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, typename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, runstr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, grade, p_labelFormat); sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 8, pingmin + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 8, pingconavg + "%", p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 9, 7, 7, file)); // allRow = allRow+7; // tmpLabel = new Label(0, 16, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 17, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 17, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 17, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 17, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 17, " %", b_labelFormat); sheet.addCell(tmpLabel); int row = 18; Iterator iterator = spaceInfo.keySet().iterator(); while (iterator.hasNext()) { String dbName = (String) iterator.next(); List toolsdb = (ArrayList) spaceInfo.get(dbName); if (toolsdb != null && toolsdb.size() > 0) { for (int i = 0; i < toolsdb.size(); i++) { Hashtable tempSpace = new Hashtable(); tempSpace = (Hashtable) toolsdb.get(i); String tablespace_name = (String) tempSpace.get("tablespace_name"); String totalspac = (String) tempSpace.get("totalspac"); String usablespac = (String) tempSpace.get("usablespac"); String usableper = (String) tempSpace.get("usableper"); if (usableper == null || "0".equals(totalspac.trim())) { usableper = "100"; } tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tablespace_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, totalspac, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, usablespac, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, usableper, p_labelFormat); sheet.addCell(tmpLabel); row++; } } } row = row + 2; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "SQL ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "SQL", b_labelFormat); sheet.addCell(tmpLabel); row++; Enumeration dbs = conn.keys(); Hashtable<String, Object> allhash = new Hashtable(); List poolList = new ArrayList(); while (dbs.hasMoreElements()) { String obj = (String) dbs.nextElement(); List connList = (List) conn.get(obj); for (int i = 0; i < connList.size(); i++) { Hashtable ht = (Hashtable) connList.get(i); String db_name = ht.get("db_name").toString(); String db_path = ht.get("db_path").toString(); String db_status = ht.get("db_status").toString(); String sqlm_elm_last_backup = ht.get("sqlm_elm_last_backup").toString(); String total_cons = ht.get("total_cons").toString(); String connections_top = ht.get("connections_top").toString(); String appls_cur_cons = ht.get("appls_cur_cons").toString(); String failedsql = ht.get("failedsql").toString(); String commitsql = ht.get("commitsql").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, db_path, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysDbStatus[Integer.parseInt(db_status)], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, sqlm_elm_last_backup, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, total_cons, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, connections_top, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, appls_cur_cons, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, failedsql, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, commitsql, p_labelFormat); sheet.addCell(tmpLabel); row++; } } // row = row + 2; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; Enumeration dbs2 = poolInfo.keys(); Hashtable<String, Object> allhash2 = new Hashtable(); List poolList2 = new ArrayList(); while (dbs2.hasMoreElements()) { String obj = (String) dbs2.nextElement(); allhash = (Hashtable) poolInfo.get(obj); poolList = (List) allhash.get("poolValue"); List lockList = (List) allhash.get("lockValue"); List readList = (List) allhash.get("readValue"); List writeList = (List) allhash.get("writeValue"); for (int i = 0; i < poolList.size(); i++) { Hashtable ht = (Hashtable) poolList.get(i); String bp_name = ht.get("bp_name").toString(); String data_hit_ratio = ht.get("data_hit_ratio").toString(); String index_hit_ratio = ht.get("index_hit_ratio").toString(); String BP_hit_ratio = ht.get("BP_hit_ratio").toString(); String Async_read_pct = ht.get("Async_read_pct").toString(); String Direct_RW_Ratio = ht.get("Direct_RW_Ratio").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, bp_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, data_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, index_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, BP_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, Async_read_pct, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, Direct_RW_Ratio, p_labelFormat); sheet.addCell(tmpLabel); row++; } } // row = row + 2; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; Enumeration dbs3 = poolInfo.keys(); Hashtable<String, Object> allhash3 = new Hashtable(); List poolList3 = new ArrayList(); while (dbs3.hasMoreElements()) { String obj = (String) dbs3.nextElement(); allhash3 = (Hashtable) poolInfo.get(obj); poolList3 = (List) allhash3.get("poolValue"); // System.out.println("poolList size === "+poolList.size()); List lockList = (List) allhash3.get("lockValue"); List readList = (List) allhash3.get("readValue"); List writeList = (List) allhash3.get("writeValue"); for (int i = 0; i < lockList.size(); i++) { Hashtable ht = (Hashtable) lockList.get(i); String db_name = ht.get("db_name").toString(); String rows_read = ht.get("rows_read").toString(); String rows_selected = ht.get("rows_selected").toString(); String lock_waits = ht.get("lock_waits").toString(); String lock_wait_time = ht.get("lock_wait_time").toString(); String deadlocks = ht.get("deadlocks").toString(); String lock_escals = ht.get("lock_escals").toString(); String total_sorts = ht.get("total_sorts").toString(); String total_sort_time = ht.get("total_sort_time").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_selected, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, lock_waits, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, lock_wait_time, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, deadlocks, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, lock_escals, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, total_sorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, total_sort_time, p_labelFormat); sheet.addCell(tmpLabel); row++; } } // row = row + 2; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(%) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, "/ ", b_labelFormat); sheet.addCell(tmpLabel); row++; Enumeration dbs4 = log.keys(); Hashtable<String, Object> allhash4 = new Hashtable(); List poolList4 = new ArrayList(); while (dbs4.hasMoreElements()) { String obj = (String) dbs4.nextElement(); List logList = (List) log.get(obj); for (int i = 0; i < logList.size(); i++) { Hashtable ht = (Hashtable) logList.get(i); String logused = ht.get("logused").toString(); String logspacefree = ht.get("logspacefree").toString(); String pctused = ht.get("pctused").toString(); String maxlogused = ht.get("maxlogused").toString(); String maxsecused = ht.get("maxsecused").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, obj, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, logused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, logspacefree, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, pctused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, maxlogused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, maxsecused, p_labelFormat); sheet.addCell(tmpLabel); row++; } } // 10 row = row + 2; tmpLabel = new Label(0, row, "10 ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; Enumeration dbs5 = poolInfo.keys(); Hashtable<String, Object> allhash5 = new Hashtable(); List poolList5 = new ArrayList(); String obj = null; Hashtable allhash6 = null; List lockList = null; List readList = null; List writeList = null; while (dbs5.hasMoreElements()) { obj = (String) dbs5.nextElement(); allhash6 = (Hashtable) poolInfo.get(obj); poolList = (List) allhash6.get("poolValue"); // System.out.println("poolList size === "+poolList.size()); lockList = (List) allhash6.get("lockValue"); readList = (List) allhash6.get("readValue"); writeList = (List) allhash6.get("writeValue"); } if (readList != null && readList.size() > 0) { for (int i = 0; i < readList.size(); i++) { Hashtable ht = (Hashtable) readList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tbschema, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, rows_written, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, overflow_accesses, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, page_reorgs, p_labelFormat); sheet.addCell(tmpLabel); row++; } } // 10 row = row + 2; tmpLabel = new Label(0, row, "10 ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; if (writeList != null && writeList.size() > 0) { for (int i = 0; i < writeList.size(); i++) { Hashtable ht = (Hashtable) writeList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tbschema, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, rows_written, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, overflow_accesses, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, page_reorgs, p_labelFormat); sheet.addCell(tmpLabel); row++; } } // row = row + 2; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, (String) reportHash.get("downnum"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, reportHash.get("count") + "", p_labelFormat); sheet.addCell(tmpLabel); // addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * @author HONGLI Sybase doc * @param filename * @throws DocumentException * @throws IOException */ public void createReportSybaseSelfDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // document.add(aTable); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// document.add(img); document.add(new Paragraph("\n")); // Table spaceTable = new Table(5); float[] width = { 220f, 220f, 220f, 220f, 220f }; spaceTable.setWidths(width); spaceTable.setWidth(100); // 90% spaceTable.setAlignment(Element.ALIGN_CENTER);// spaceTable.setAutoFillEmptyCells(true); // spaceTable.setBorderWidth(1); // spaceTable.setBorderColor(new Color(0, 125, 255)); // spaceTable.setPadding(2);// spaceTable.setSpacing(0);// spaceTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("MB ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); // spaceTable.endHeaders(); // List dbInfo = (ArrayList) sysbaseVO.getDbInfo(); if (dbInfo != null && dbInfo.size() > 0) { for (int i = 0; i < dbInfo.size(); i++) { TablesVO tempSpace = (TablesVO) dbInfo.get(i); String db_name = (String) tempSpace.getDb_name(); String db_size = (String) tempSpace.getDb_size(); String db_freesize = (String) tempSpace.getDb_freesize(); String db_usedperc = (String) tempSpace.getDb_usedperc(); cell = new Cell(new Phrase((i + 1) + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_name, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_size, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_freesize, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_usedperc, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(spaceTable); document.close(); } catch (Exception e) { SysLogger.error("ExcelReport1.createReportDB2SelfDoc()"); } } /** * @author HONGLI Sybase xls * @param filename * @throws DocumentException * @throws IOException */ public void createReportSybaseSelfExcel(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, (String) maxping.get("pingnow"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; int row = 15; tmpLabel = new Label(1, row, "", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(%)", b_labelFormat); sheet.addCell(tmpLabel); row++; List dbInfo = (ArrayList) sysbaseVO.getDbInfo(); if (dbInfo != null && dbInfo.size() > 0) { for (int i = 0; i < dbInfo.size(); i++) { TablesVO tempSpace = (TablesVO) dbInfo.get(i); String db_name = (String) tempSpace.getDb_name(); String db_size = (String) tempSpace.getDb_size(); String db_freesize = (String) tempSpace.getDb_freesize(); String db_usedperc = (String) tempSpace.getDb_usedperc(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, db_size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, db_freesize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, db_usedperc, p_labelFormat); sheet.addCell(tmpLabel); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * @author HONGLI Sybase pdf * @param filename * @throws DocumentException * @throws IOException */ public void createReportSybaseSelfPdf(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingnow"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// // document.add(aTable); img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); PdfPTable aTable1 = new PdfPTable(5); float[] width = { 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); List dbInfo = (ArrayList) sysbaseVO.getDbInfo(); if (dbInfo != null && dbInfo.size() > 0) { for (int i = 0; i < dbInfo.size(); i++) { TablesVO tempSpace = (TablesVO) dbInfo.get(i); String db_name = (String) tempSpace.getDb_name(); String db_size = (String) tempSpace.getDb_size(); String db_freesize = (String) tempSpace.getDb_freesize(); String db_usedperc = (String) tempSpace.getDb_usedperc(); cell = new PdfPCell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(db_name)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(db_size)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(db_freesize)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(db_usedperc)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // TODO: handle exception } } /** * @author HONGLI Sybaseword * @param filename * @throws DocumentException * @throws IOException */ public void createReport_SybaseCldDoc(String filename) throws IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidth(100); // 90% dbTable.setAlignment(Element.ALIGN_CENTER);// dbTable.setAutoFillEmptyCells(true); // dbTable.setBorderWidth(1); // dbTable.setBorderColor(new Color(0, 125, 255)); // dbTable.setPadding(2);// dbTable.setSpacing(0);// dbTable.setBorder(2);// dbTable.endHeaders(); Cell dbCell = null; dbCell = new Cell(new Phrase("", titleFont)); dbCell.setColspan(5); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("IP", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(vo.getDbName(), contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(ip, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(typename, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(runstr, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(grade, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingnow + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingmin + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingconavg + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(dbTable); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // Table spaceTable = new Table(5); float[] width = { 220f, 220f, 220f, 220f, 220f }; spaceTable.setWidths(width); spaceTable.setWidth(100); // 90% spaceTable.setAlignment(Element.ALIGN_CENTER);// spaceTable.setAutoFillEmptyCells(true); // spaceTable.setBorderWidth(1); // spaceTable.setBorderColor(new Color(0, 125, 255)); // spaceTable.setPadding(2);// spaceTable.setSpacing(0);// spaceTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("MB ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); // spaceTable.endHeaders(); List dbInfo = (ArrayList) sysbaseVO.getDbInfo(); if (dbInfo != null && dbInfo.size() > 0) { for (int i = 0; i < dbInfo.size(); i++) { TablesVO tempSpace = (TablesVO) dbInfo.get(i); String db_name = (String) tempSpace.getDb_name(); String db_size = (String) tempSpace.getDb_size(); String db_freesize = (String) tempSpace.getDb_freesize(); String db_usedperc = (String) tempSpace.getDb_usedperc(); cell = new Cell(new Phrase((i + 1) + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_name, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_size, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_freesize, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_usedperc, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); } } document.add(spaceTable); // Table memTable = new Table(6); float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; memTable.setWidths(dbInfoWidths); memTable.setWidth(100); // 90% memTable.setAlignment(Element.ALIGN_CENTER);// memTable.setAutoFillEmptyCells(true); // memTable.setBorderWidth(1); // memTable.setBorderColor(new Color(0, 125, 255)); // memTable.setPadding(2);// memTable.setSpacing(0);// memTable.setBorder(2);// Hashtable mems = (Hashtable) reportHash.get("mems");// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("Metadata(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(MB) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(MB) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(%) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_dataCache(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_physicalMemory(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getMetadata_cache(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getProcedure_cache(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_logicalMemory(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getData_hitrate(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); document.add(memTable); // Sysbase Table remoteServerTable = new Table(5); float[] remoteServerWidths = { 220f, 220f, 220f, 220f, 220f }; remoteServerTable.setWidths(remoteServerWidths); remoteServerTable.setWidth(100); // 90% remoteServerTable.setAlignment(Element.ALIGN_CENTER);// remoteServerTable.setAutoFillEmptyCells(true); // remoteServerTable.setBorderWidth(1); // remoteServerTable.setBorderColor(new Color(0, 125, 255)); // remoteServerTable.setPadding(2);// remoteServerTable.setSpacing(0);// remoteServerTable.setBorder(2);// Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// cell = new Cell(new Phrase("Sysbase ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); List serverlist = (List) sysbaseVO.getServersInfo(); if (serverlist != null && serverlist.size() > 0) { for (int k = 0; k < serverlist.size(); k++) { TablesVO tVO = (TablesVO) serverlist.get(k); cell = new Cell(new Phrase((k + 1) + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(tVO.getServer_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(tVO.getServer_network_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(tVO.getServer_class(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(tVO.getServer_status(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); } } document.add(remoteServerTable); Table userTable = new Table(5); float[] uWidth = { 220f, 220f, 220f, 220f, 220f }; userTable.setWidths(uWidth); userTable.setWidth(100); // 90% userTable.setAlignment(Element.ALIGN_CENTER);// userTable.setAutoFillEmptyCells(true); // userTable.setBorderWidth(1); // userTable.setBorderColor(new Color(0, 125, 255)); // userTable.setPadding(2);// userTable.setSpacing(0);// userTable.setBorder(2);// cell = new Cell(new Phrase(" Sysbase ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase("id ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); // userTable.endHeaders(); List userlist = (List) sysbaseVO.getUserInfo(); if (userlist != null && userlist.size() > 0) { for (int k = 0; k < userlist.size(); k++) { TablesVO tVO = (TablesVO) userlist.get(k); cell = new Cell(new Phrase((k + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(tVO.getUsers_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(tVO.getID_in_db(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(tVO.getGroup_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(tVO.getLogin_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); } } document.add(userTable); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } // Table evenInfoTable = new Table(2); float[] evenInfoWidths = { 220f, 220f }; evenInfoTable.setWidths(evenInfoWidths); evenInfoTable.setWidth(100); // 90% evenInfoTable.setAlignment(Element.ALIGN_CENTER);// evenInfoTable.setAutoFillEmptyCells(true); // evenInfoTable.setBorderWidth(1); // evenInfoTable.setBorderColor(new Color(0, 125, 255)); // evenInfoTable.setPadding(2);// evenInfoTable.setSpacing(0);// evenInfoTable.setBorder(2);// String downnum = (String) reportHash.get("downnum"); String count = (Integer) reportHash.get("count") + ""; cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase(downnum, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase(count, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); document.add(evenInfoTable); // addEventListToDoc(document, titleFont, contextFont); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author HONGLI Sybasepdf * @param filename * @throws DocumentException * @throws IOException */ public void createReport_SybaseCldPdf(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); DBVo vo = (DBVo) reportHash.get("vo"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // PdfPTable dbTable = new PdfPTable(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidthPercentage(100); PdfPCell dbCell = null; dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setColspan(5); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("IP", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(vo.getDbName(), contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(ip, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(typename, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(runstr, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(grade, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(pingnow + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(pingmin + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(pingconavg + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // img.setAbsolutePosition(0, 0); img.scalePercent(76); img.setAlignment(Image.MIDDLE);// document.add(dbTable); document.add(new Paragraph("\n")); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); PdfPTable aTable1 = new PdfPTable(5); float[] width = { 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); List dbInfo = (ArrayList) sysbaseVO.getDbInfo(); if (dbInfo != null && dbInfo.size() > 0) { for (int i = 0; i < dbInfo.size(); i++) { TablesVO tempSpace = (TablesVO) dbInfo.get(i); String db_name = (String) tempSpace.getDb_name(); String db_size = (String) tempSpace.getDb_size(); String db_freesize = (String) tempSpace.getDb_freesize(); String db_usedperc = (String) tempSpace.getDb_usedperc(); cell = new PdfPCell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(db_name)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(db_size)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(db_freesize)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(db_usedperc)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } } // PdfPTable memTable = new PdfPTable(6); float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; memTable.setWidths(dbInfoWidths); memTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new PdfPCell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new PdfPCell(new Phrase("(MB) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new PdfPCell(new Phrase("Metadata(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new PdfPCell(new Phrase("(MB) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new PdfPCell(new Phrase("(MB) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new PdfPCell(new Phrase("(%) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new PdfPCell(new Phrase(sysbaseVO.getTotal_dataCache(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new PdfPCell(new Phrase(sysbaseVO.getTotal_physicalMemory(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new PdfPCell(new Phrase(sysbaseVO.getMetadata_cache(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new PdfPCell(new Phrase(sysbaseVO.getProcedure_cache(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new PdfPCell(new Phrase(sysbaseVO.getTotal_logicalMemory(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new PdfPCell(new Phrase(sysbaseVO.getData_hitrate(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); document.add(memTable); document.add(new Paragraph("\n")); // Sysbase PdfPTable remoteServerTable = new PdfPTable(5); float[] ncWidths = { 220f, 220f, 220f, 220f, 220f }; remoteServerTable.setWidths(ncWidths); remoteServerTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("Sysbase ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); List serverlist = (List) sysbaseVO.getServersInfo(); if (serverlist != null && serverlist.size() > 0) { for (int k = 0; k < serverlist.size(); k++) { TablesVO tVO = (TablesVO) serverlist.get(k); cell = new PdfPCell(new Phrase((k + 1) + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new PdfPCell(new Phrase(tVO.getServer_name(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new PdfPCell(new Phrase(tVO.getServer_network_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new PdfPCell(new Phrase(tVO.getServer_class(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new PdfPCell(new Phrase(tVO.getServer_status(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); } } document.add(remoteServerTable); document.add(new Paragraph("\n")); // Sysbase PdfPTable userTable = new PdfPTable(5); float[] uWidths = { 220f, 220f, 220f, 220f, 220f }; userTable.setWidths(uWidths); userTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase(" Sysbase ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new PdfPCell(new Phrase("id ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); List userlist = (List) sysbaseVO.getUserInfo(); if (userlist != null && userlist.size() > 0) { for (int k = 0; k < userlist.size(); k++) { TablesVO tVO = (TablesVO) userlist.get(k); cell = new PdfPCell(new Phrase((k + 1) + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new PdfPCell(new Phrase(tVO.getUsers_name(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new PdfPCell(new Phrase(tVO.getID_in_db(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new PdfPCell(new Phrase(tVO.getGroup_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new PdfPCell(new Phrase(tVO.getLogin_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); } } document.add(userTable); document.add(new Paragraph("\n")); // Sysbase PdfPTable deviceTable = new PdfPTable(4); float[] dWidths = { 220f, 220f, 220f, 220f }; deviceTable.setWidths(dWidths); deviceTable.setWidthPercentage(100); Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// cell = new PdfPCell(new Phrase("Sysbase ", titleFont)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // deviceTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // deviceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // deviceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // deviceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // deviceTable.addCell(cell); List devicelist = (List) sysbaseVO.getDeviceInfo(); if (devicelist != null && devicelist.size() > 0) { for (int k = 0; k < devicelist.size(); k++) { TablesVO tVO = (TablesVO) devicelist.get(k); cell = new PdfPCell(new Phrase((k + 1) + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // deviceTable.addCell(cell); cell = new PdfPCell(new Phrase(tVO.getDevice_name(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // deviceTable.addCell(cell); cell = new PdfPCell(new Phrase(tVO.getDevice_physical_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // deviceTable.addCell(cell); cell = new PdfPCell(new Phrase(tVO.getDevice_description(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // deviceTable.addCell(cell); } } document.add(deviceTable); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(new Paragraph("\n")); // PdfPTable eventTable = new PdfPTable(2); float[] eventWidths = { 220f, 220f }; eventTable.setWidths(eventWidths); eventTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase((String) reportHash.get("downnum"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(reportHash.get("count") + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); document.add(eventTable); document.add(new Paragraph("\n")); // addEventLisToPdf(document); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author HONGLI Sybaseexcel * @param filename * @throws DocumentException * @throws IOException */ public void createReport_SybaseCldXls(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { wb = Workbook.createWorkbook(new File(filename)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable mems = (Hashtable) reportHash.get("mems");// Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); // ip tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, typename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, runstr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, grade, p_labelFormat); sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 8, pingmin + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 8, pingconavg + "%", p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 9, 7, 7, file)); // allRow = allRow+7; int row = 15; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(%)", b_labelFormat); sheet.addCell(tmpLabel); row++; List dbInfo = (ArrayList) sysbaseVO.getDbInfo(); if (dbInfo != null && dbInfo.size() > 0) { for (int i = 0; i < dbInfo.size(); i++) { TablesVO tempSpace = (TablesVO) dbInfo.get(i); String db_name = (String) tempSpace.getDb_name(); String db_size = (String) tempSpace.getDb_size(); String db_freesize = (String) tempSpace.getDb_freesize(); String db_usedperc = (String) tempSpace.getDb_usedperc(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, db_size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, db_freesize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, db_usedperc, p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "(MB)", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "(MB) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "Metadata(MB)", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "(MB) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(MB) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "(%)", b_labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, sysbaseVO.getTotal_dataCache(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, sysbaseVO.getTotal_physicalMemory(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, sysbaseVO.getMetadata_cache(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysbaseVO.getProcedure_cache(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, sysbaseVO.getTotal_logicalMemory(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, sysbaseVO.getData_hitrate(), p_labelFormat); sheet.addCell(tmpLabel); row++; // Sysbase tmpLabel = new Label(0, row, "Sysbase ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List serverlist = (List) sysbaseVO.getServersInfo(); if (serverlist != null && serverlist.size() > 0) { for (int k = 0; k < serverlist.size(); k++) { TablesVO tVO = (TablesVO) serverlist.get(k); tmpLabel = new Label(0, row, (k + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tVO.getServer_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tVO.getServer_network_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tVO.getServer_class(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tVO.getServer_status(), p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // Sysbase tmpLabel = new Label(0, row, "Sysbase ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "id ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List userlist = (List) sysbaseVO.getUserInfo(); if (userlist != null && userlist.size() > 0) { for (int k = 0; k < userlist.size(); k++) { TablesVO tVO = (TablesVO) userlist.get(k); tmpLabel = new Label(0, row, (k + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tVO.getUsers_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tVO.getID_in_db(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tVO.getGroup_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tVO.getLogin_name(), p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // Sysbase tmpLabel = new Label(0, row, "Sysbase ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List devicelist = (List) sysbaseVO.getDeviceInfo(); if (devicelist != null && devicelist.size() > 0) { for (int k = 0; k < devicelist.size(); k++) { TablesVO tVO = (TablesVO) devicelist.get(k); tmpLabel = new Label(0, row, (k + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tVO.getDevice_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tVO.getDevice_physical_name(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tVO.getDevice_description(), p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, (String) reportHash.get("downnum"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, reportHash.get("count") + "", p_labelFormat); sheet.addCell(tmpLabel); // addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * @author HONGLI Informix doc * @param filename * @throws DocumentException * @throws IOException */ public void createReportInformixSelfDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // document.add(aTable); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// document.add(img); document.add(new Paragraph("\n")); // Informix Table spaceTable = new Table(8); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; spaceTable.setWidths(width); spaceTable.setWidth(100); // 90% spaceTable.setAlignment(Element.ALIGN_CENTER);// spaceTable.setAutoFillEmptyCells(true); // spaceTable.setBorderWidth(1); // spaceTable.setBorderColor(new Color(0, 125, 255)); // spaceTable.setPadding(2);// spaceTable.setSpacing(0);// spaceTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(8); spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); // spaceTable.endHeaders(); ArrayList dbspaces = new ArrayList(); if (dbinfo != null) { dbspaces = (ArrayList) dbinfo.get("informixspaces");// } if (dbspaces != null) { if (dbspaces.size() > 0) { DecimalFormat df = new DecimalFormat("#.###"); for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); cell = new Cell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("dbspace"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("owner"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("fname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); } } } document.add(spaceTable); // Informix Table hhTable = new Table(8); float[] hhWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; hhTable.setWidths(hhWidth); hhTable.setWidth(100); // 90% hhTable.setAlignment(Element.ALIGN_CENTER);// hhTable.setAutoFillEmptyCells(true); // hhTable.setBorderWidth(1); // hhTable.setBorderColor(new Color(0, 125, 255)); // hhTable.setPadding(2);// hhTable.setSpacing(0);// hhTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(8); hhTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); // hhTable.endHeaders(); List dbsession = (ArrayList) dbinfo.get("sessionList");// if (dbsession != null && dbsession.size() > 0) { for (int i = 0; i < dbsession.size(); i++) { Hashtable tablesVO = (Hashtable) dbsession.get(i); String seqscans = String.valueOf(tablesVO.get("seqscans")); if ("null".equals(seqscans)) { seqscans = ""; } String total_sorts = String.valueOf(tablesVO.get("total_sorts")); if ("null".equals(total_sorts)) { total_sorts = ""; } String dsksorts = String.valueOf(tablesVO.get("dsksorts")); if ("null".equals(dsksorts)) { dsksorts = ""; } cell = new Cell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(tablesVO.get("access") + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(tablesVO.get("locksheld") + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(seqscans, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(total_sorts, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(dsksorts, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); } } document.add(hhTable); // Informix Table lockTable = new Table(6); float[] lockWidth = { 220f, 220f, 220f, 220f, 220f, 220f }; lockTable.setWidths(lockWidth); lockTable.setWidth(100); // 90% lockTable.setAlignment(Element.ALIGN_CENTER);// lockTable.setAutoFillEmptyCells(true); // lockTable.setBorderWidth(1); // lockTable.setBorderColor(new Color(0, 125, 255)); // lockTable.setPadding(2);// lockTable.setSpacing(0);// lockTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(6); lockTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); // lockTable.endHeaders(); List dblock = (ArrayList) dbinfo.get("lockList");// if (dblock != null && dblock.size() > 0) { for (int i = 0; i < dblock.size(); i++) { Hashtable tablesVO = (Hashtable) dblock.get(i); String type = (String) tablesVO.get("type"); String desc = ""; if ("B".equals(type)) { desc = ""; } else if ("IS".equals(type)) { desc = ""; } else if ("S".equals(type)) { desc = ""; } else if ("XS".equals(type)) { desc = ""; } else if ("U".equals(type)) { desc = ""; } else if ("IX".equals(type)) { desc = ""; } else if ("SIX".equals(type)) { desc = ""; } else if ("X".equals(type)) { desc = ""; } else if ("XR".equals(type)) { desc = ""; } cell = new Cell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("dbsname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("tabname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(desc, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); } } document.add(lockTable); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.close(); } catch (Exception e) { SysLogger.error("", e); } } /** * @author HONGLI Informix xls * @param filename * @throws DocumentException * @throws IOException */ public void createReportInformixSelfExcel(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, (String) maxping.get("pingnow"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; int row = 14; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; // ArrayList dbspaces = new ArrayList(); if (dbinfo != null) { dbspaces = (ArrayList) dbinfo.get("informixspaces");// } if (dbspaces != null) { if (dbspaces.size() > 0) { DecimalFormat df = new DecimalFormat("#.###"); for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, (String) tablesVO.get("dbspace"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) tablesVO.get("owner"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, (String) tablesVO.get("fname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%", p_labelFormat); sheet.addCell(tmpLabel); row++; } } } row = row + 2; // Informix tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List dbsession = (ArrayList) dbinfo.get("sessionList");// if (dbsession != null && dbsession.size() > 0) { for (int i = 0; i < dbsession.size(); i++) { Hashtable tablesVO = (Hashtable) dbsession.get(i); String seqscans = String.valueOf(tablesVO.get("seqscans")); if ("null".equals(seqscans)) { seqscans = ""; } String total_sorts = String.valueOf(tablesVO.get("total_sorts")); if ("null".equals(total_sorts)) { total_sorts = ""; } String dsksorts = String.valueOf(tablesVO.get("dsksorts")); if ("null".equals(dsksorts)) { dsksorts = ""; } tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, (String) tablesVO.get("username"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) tablesVO.get("hostname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tablesVO.get("access") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tablesVO.get("locksheld") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, seqscans, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, total_sorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, dsksorts, p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // Informix tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List dblock = (ArrayList) dbinfo.get("lockList");// if (dblock != null && dblock.size() > 0) { for (int i = 0; i < dblock.size(); i++) { Hashtable tablesVO = (Hashtable) dblock.get(i); String type = (String) tablesVO.get("type"); String desc = ""; if ("B".equals(type)) { desc = ""; } else if ("IS".equals(type)) { desc = ""; } else if ("S".equals(type)) { desc = ""; } else if ("XS".equals(type)) { desc = ""; } else if ("U".equals(type)) { desc = ""; } else if ("IX".equals(type)) { desc = ""; } else if ("SIX".equals(type)) { desc = ""; } else if ("X".equals(type)) { desc = ""; } else if ("XR".equals(type)) { desc = ""; } tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, (String) tablesVO.get("username"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) tablesVO.get("hostname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tablesVO.get("dbsname") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tablesVO.get("tabname") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, desc, p_labelFormat); sheet.addCell(tmpLabel); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * @author HONGLI Informix pdf * @param filename * @throws DocumentException * @throws IOException */ public void createReportInformixSelfPdf(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingnow"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// // document.add(aTable); img.scalePercent(76); document.add(aTable); document.add(img); // Informix document.add(new Paragraph("\n")); PdfPTable spaceTable = new PdfPTable(8); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; spaceTable.setWidths(width); spaceTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); // spaceTable.endHeaders(); ArrayList dbspaces = new ArrayList(); if (dbinfo != null) { dbspaces = (ArrayList) dbinfo.get("informixspaces");// } if (dbspaces != null) { if (dbspaces.size() > 0) { DecimalFormat df = new DecimalFormat("#.###"); for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); cell = new PdfPCell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("dbspace"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("owner"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("fname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell( new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell( new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell( new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase( df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); } } } document.add(spaceTable); // Informix document.add(new Paragraph("\n")); PdfPTable hhTable = new PdfPTable(8); float[] hhWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; hhTable.setWidths(hhWidth); hhTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); // hhTable.endHeaders(); List dbsession = (ArrayList) dbinfo.get("sessionList");// if (dbsession != null && dbsession.size() > 0) { for (int i = 0; i < dbsession.size(); i++) { Hashtable tablesVO = (Hashtable) dbsession.get(i); String seqscans = String.valueOf(tablesVO.get("seqscans")); if ("null".equals(seqscans)) { seqscans = ""; } String total_sorts = String.valueOf(tablesVO.get("total_sorts")); if ("null".equals(total_sorts)) { total_sorts = ""; } String dsksorts = String.valueOf(tablesVO.get("dsksorts")); if ("null".equals(dsksorts)) { dsksorts = ""; } cell = new PdfPCell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("username"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(tablesVO.get("access") + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(tablesVO.get("locksheld") + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(seqscans)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(total_sorts)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(dsksorts)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); } } document.add(hhTable); // Informix document.add(new Paragraph("\n")); PdfPTable lockTable = new PdfPTable(6); float[] lockWidth = { 220f, 220f, 220f, 220f, 220f, 220f }; lockTable.setWidths(lockWidth); lockTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); // lockTable.endHeaders(); List dblock = (ArrayList) dbinfo.get("lockList");// if (dblock != null && dblock.size() > 0) { for (int i = 0; i < dblock.size(); i++) { Hashtable tablesVO = (Hashtable) dblock.get(i); String type = (String) tablesVO.get("type"); String desc = ""; if ("B".equals(type)) { desc = ""; } else if ("IS".equals(type)) { desc = ""; } else if ("S".equals(type)) { desc = ""; } else if ("XS".equals(type)) { desc = ""; } else if ("U".equals(type)) { desc = ""; } else if ("IX".equals(type)) { desc = ""; } else if ("SIX".equals(type)) { desc = ""; } else if ("X".equals(type)) { desc = ""; } else if ("XR".equals(type)) { desc = ""; } cell = new PdfPCell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("username"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("dbsname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("tabname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(desc)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); } } document.add(lockTable); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.close(); } catch (Exception e) { SysLogger.error("", e); } } /** * @author HONGLI Informixword * @param filename * @param types * @throws IOException */ public void createReport_InformixCldDoc(String filename, String types) throws IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(types)) { PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); this.setTableFormat(dbTable); // float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; // dbTable.setWidths(cellWidths); // dbTable.setWidth(100); // 90% // dbTable.setAlignment(Element.ALIGN_CENTER);// // dbTable.setAutoFillEmptyCells(true); // // dbTable.setBorderWidth(1); // // dbTable.setBorderColor(new Color(0, 125, 255)); // // dbTable.setPadding(2);// // dbTable.setSpacing(0);// // dbTable.setBorder(2);// // dbTable.endHeaders(); Cell dbCell = null; dbCell = new Cell(new Phrase("", titleFont)); dbCell.setColspan(5); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(vo.getDbName(), contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(ip, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(typename, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(runstr, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(grade, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); Table aTable = new Table(3); // float[] widths = { 220f, 220f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// // aTable.endHeaders(); this.setTableFormat(aTable); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(pingnow + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingmin + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingconavg + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // img.setAbsolutePosition(0, 0); img.scalePercent(75); img.setAlignment(Image.LEFT);// document.add(dbTable); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // Informix Table spaceTable = new Table(8); this.setTableFormat(spaceTable); // float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f // }; // spaceTable.setWidths(width); // spaceTable.setWidth(100); // 90% // spaceTable.setAlignment(Element.ALIGN_CENTER);// // spaceTable.setAutoFillEmptyCells(true); // // spaceTable.setBorderWidth(1); // // spaceTable.setBorderColor(new Color(0, 125, 255)); // // spaceTable.setPadding(2);// // spaceTable.setSpacing(0);// // spaceTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); spaceTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); spaceTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); spaceTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); spaceTable.addCell(cell); // spaceTable.endHeaders(); ArrayList dbspaces = new ArrayList(); if (dbinfo != null) { dbspaces = (ArrayList) dbinfo.get("informixspaces");// } if (dbspaces != null) { if (dbspaces.size() > 0) { DecimalFormat df = new DecimalFormat("#.###"); for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); cell = new Cell(new Phrase((i + 1) + "")); this.setCellFormat(cell, false); spaceTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("dbspace"), contextFont)); this.setCellFormat(cell, false); spaceTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("owner"), contextFont)); this.setCellFormat(cell, false); spaceTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("fname"), contextFont)); this.setCellFormat(cell, false); spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M", contextFont)); this.setCellFormat(cell, false); spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M", contextFont)); this.setCellFormat(cell, false); spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M", contextFont)); this.setCellFormat(cell, false); spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%", contextFont)); this.setCellFormat(cell, false); spaceTable.addCell(cell); } } } document.add(spaceTable); document.newPage(); // Informix Table hhTable = new Table(8); this.setTableFormat(hhTable); float[] hhWidth = { 220f, 220f, 220f, 220f, 220f, 440f, 220f, 220f }; hhTable.setWidths(hhWidth); // hhTable.setWidth(100); // 90% // hhTable.setAlignment(Element.ALIGN_CENTER);// // hhTable.setAutoFillEmptyCells(true); // // hhTable.setBorderWidth(1); // // hhTable.setBorderColor(new Color(0, 125, 255)); // // hhTable.setPadding(2);// // hhTable.setSpacing(0);// // hhTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); hhTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); hhTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); hhTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); hhTable.addCell(cell); // hhTable.endHeaders(); List dbsession = (ArrayList) dbinfo.get("sessionList");// if (dbsession != null && dbsession.size() > 0) { for (int i = 0; i < dbsession.size(); i++) { Hashtable tablesVO = (Hashtable) dbsession.get(i); String seqscans = String.valueOf(tablesVO.get("seqscans")); if ("null".equals(seqscans)) { seqscans = ""; } String total_sorts = String.valueOf(tablesVO.get("total_sorts")); if ("null".equals(total_sorts)) { total_sorts = ""; } String dsksorts = String.valueOf(tablesVO.get("dsksorts")); if ("null".equals(dsksorts)) { dsksorts = ""; } cell = new Cell(new Phrase((i + 1) + "")); this.setCellFormat(cell, false); hhTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont)); this.setCellFormat(cell, false); hhTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont)); this.setCellFormat(cell, false); hhTable.addCell(cell); cell = new Cell(new Phrase(tablesVO.get("access") + "", contextFont)); this.setCellFormat(cell, false); hhTable.addCell(cell); cell = new Cell(new Phrase(tablesVO.get("locksheld") + "", contextFont)); this.setCellFormat(cell, false); hhTable.addCell(cell); cell = new Cell(new Phrase(seqscans, contextFont)); this.setCellFormat(cell, false); hhTable.addCell(cell); cell = new Cell(new Phrase(total_sorts, contextFont)); this.setCellFormat(cell, false); hhTable.addCell(cell); cell = new Cell(new Phrase(dsksorts, contextFont)); this.setCellFormat(cell, false); hhTable.addCell(cell); } } document.add(hhTable); // Informix Table lockTable = new Table(6); // float[] lockWidth = { 220f, 220f, 220f, 220f, 220f, 220f }; // lockTable.setWidths(lockWidth); // lockTable.setWidth(100); // 90% // lockTable.setAlignment(Element.ALIGN_CENTER);// // lockTable.setAutoFillEmptyCells(true); // // lockTable.setBorderWidth(1); // // lockTable.setBorderColor(new Color(0, 125, 255)); // // lockTable.setPadding(2);// // lockTable.setSpacing(0);// // lockTable.setBorder(2);// this.setTableFormat(lockTable); cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(6); this.setCellFormat(cell, true); lockTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); lockTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); lockTable.addCell(cell); // lockTable.endHeaders(); List dblock = (ArrayList) dbinfo.get("lockList");// if (dblock != null && dblock.size() > 0) { for (int i = 0; i < dblock.size(); i++) { Hashtable tablesVO = (Hashtable) dblock.get(i); String type = (String) tablesVO.get("type"); String desc = ""; if ("B".equals(type)) { desc = ""; } else if ("IS".equals(type)) { desc = ""; } else if ("S".equals(type)) { desc = ""; } else if ("XS".equals(type)) { desc = ""; } else if ("U".equals(type)) { desc = ""; } else if ("IX".equals(type)) { desc = ""; } else if ("SIX".equals(type)) { desc = ""; } else if ("X".equals(type)) { desc = ""; } else if ("XR".equals(type)) { desc = ""; } cell = new Cell(new Phrase((i + 1) + "")); this.setCellFormat(cell, false); lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont)); this.setCellFormat(cell, false); lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont)); this.setCellFormat(cell, false); lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("dbsname"), contextFont)); this.setCellFormat(cell, false); lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("tabname"), contextFont)); this.setCellFormat(cell, false); lockTable.addCell(cell); cell = new Cell(new Phrase(desc, contextFont)); this.setCellFormat(cell, false); lockTable.addCell(cell); } } document.add(lockTable); // Informix Table logTable = new Table(9); this.setTableFormat(logTable); // float[] logWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, // 220f, 220f }; // logTable.setWidths(logWidth); // logTable.setWidth(100); // 90% // logTable.setAlignment(Element.ALIGN_CENTER);// // logTable.setAutoFillEmptyCells(true); // // logTable.setBorderWidth(1); // // logTable.setBorderColor(new Color(0, 125, 255)); // // logTable.setPadding(2);// // logTable.setSpacing(0);// // logTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(9); this.setCellFormat(cell, true); logTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); logTable.addCell(cell); cell = new Cell(new Phrase("ID ", titleFont)); this.setCellFormat(cell, true); logTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); logTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); logTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); logTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); logTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); logTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); logTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); logTable.addCell(cell); // logTable.endHeaders(); List dblog = (ArrayList) dbinfo.get("informixlog");// if (dblog != null && dblog.size() > 0) { for (int i = 0; i < dblog.size(); i++) { Hashtable tablesVO = (Hashtable) dblog.get(i); cell = new Cell(new Phrase((i + 1) + "")); this.setCellFormat(cell, false); logTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("uniqid")), contextFont)); this.setCellFormat(cell, false); logTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("size")), contextFont)); this.setCellFormat(cell, false); logTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("used")), contextFont)); this.setCellFormat(cell, false); logTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("is_used")), contextFont)); this.setCellFormat(cell, false); logTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("is_current")), contextFont)); this.setCellFormat(cell, false); logTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("is_backed_up")), contextFont)); this.setCellFormat(cell, false); logTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("is_archived")), contextFont)); this.setCellFormat(cell, false); logTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("is_temp")), contextFont)); this.setCellFormat(cell, false); logTable.addCell(cell); } } document.add(logTable); // InformixIO Table ioTable = new Table(10); this.setTableFormat(ioTable); // float[] ioWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, // 220f, 220f, 220f }; // ioTable.setWidths(ioWidth); // ioTable.setWidth(100); // 90% // ioTable.setAlignment(Element.ALIGN_CENTER);// // ioTable.setAutoFillEmptyCells(true); // // ioTable.setBorderWidth(1); // // ioTable.setBorderColor(new Color(0, 125, 255)); // // ioTable.setPadding(2);// // ioTable.setSpacing(0);// // ioTable.setBorder(2);// cell = new Cell(new Phrase("IO ", titleFont)); cell.setColspan(10); this.setCellFormat(cell, true); ioTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); ioTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); ioTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); ioTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); ioTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); ioTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); ioTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); ioTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); ioTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); ioTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); ioTable.addCell(cell); // ioTable.endHeaders(); List dbio = (ArrayList) dbinfo.get("iolist");// IO if (dbio != null && dbio.size() > 0) { for (int i = 0; i < dbio.size(); i++) { Hashtable tablesVO = (Hashtable) dbio.get(i); cell = new Cell(new Phrase((i + 1) + "")); this.setCellFormat(cell, false); ioTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("chunknum")), contextFont)); this.setCellFormat(cell, false); ioTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("reads")), contextFont)); this.setCellFormat(cell, false); ioTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("pagesread")), contextFont)); this.setCellFormat(cell, false); ioTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("writes")), contextFont)); this.setCellFormat(cell, false); ioTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("pageswritten")), contextFont)); this.setCellFormat(cell, false); ioTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("mreads")), contextFont)); this.setCellFormat(cell, false); ioTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("mpagesread")), contextFont)); this.setCellFormat(cell, false); ioTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("mwrites")), contextFont)); this.setCellFormat(cell, false); ioTable.addCell(cell); cell = new Cell(new Phrase(String.valueOf(tablesVO.get("mpageswritten")), contextFont)); this.setCellFormat(cell, false); ioTable.addCell(cell); } } document.add(ioTable); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); // img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } // Table evenInfoTable = new Table(2); // float[] evenInfoWidths = { 220f, 220f }; // evenInfoTable.setWidths(evenInfoWidths); // evenInfoTable.setWidth(100); // 90% // evenInfoTable.setAlignment(Element.ALIGN_CENTER);// // evenInfoTable.setAutoFillEmptyCells(true); // // evenInfoTable.setBorderWidth(1); // // evenInfoTable.setBorderColor(new Color(0, 125, 255)); // // evenInfoTable.setPadding(2);// // evenInfoTable.setSpacing(0);// // evenInfoTable.setBorder(2);// this.setTableFormat(evenInfoTable); String downnum = (String) reportHash.get("downnum"); String count = (Integer) reportHash.get("count") + ""; cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); evenInfoTable.addCell(cell); cell = new Cell(new Phrase(downnum, contextFont)); this.setCellFormat(cell, false); evenInfoTable.addCell(cell); cell = new Cell(new Phrase(count, contextFont)); this.setCellFormat(cell, false); evenInfoTable.addCell(cell); document.add(evenInfoTable); // addEventListToDoc(document, titleFont, contextFont); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author HONGLI Informixpdf * @param filename * @throws DocumentException * @throws IOException */ public void createReport_InformixCldPdf(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingnow"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// // document.add(aTable); img.scalePercent(76); document.add(aTable); document.add(img); // Informix document.add(new Paragraph("\n")); PdfPTable spaceTable = new PdfPTable(8); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; spaceTable.setWidths(width); spaceTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); // spaceTable.endHeaders(); ArrayList dbspaces = new ArrayList(); if (dbinfo != null) { dbspaces = (ArrayList) dbinfo.get("informixspaces");// } if (dbspaces != null) { if (dbspaces.size() > 0) { DecimalFormat df = new DecimalFormat("#.###"); for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); cell = new PdfPCell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("dbspace"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("owner"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("fname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell( new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell( new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell( new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new PdfPCell(new Phrase( df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); } } } document.add(spaceTable); // Informix document.add(new Paragraph("\n")); PdfPTable hhTable = new PdfPTable(8); float[] hhWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; hhTable.setWidths(hhWidth); hhTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); // hhTable.endHeaders(); List dbsession = (ArrayList) dbinfo.get("sessionList");// if (dbsession != null && dbsession.size() > 0) { for (int i = 0; i < dbsession.size(); i++) { Hashtable tablesVO = (Hashtable) dbsession.get(i); String seqscans = String.valueOf(tablesVO.get("seqscans")); if ("null".equals(seqscans)) { seqscans = ""; } String total_sorts = String.valueOf(tablesVO.get("total_sorts")); if ("null".equals(total_sorts)) { total_sorts = ""; } String dsksorts = String.valueOf(tablesVO.get("dsksorts")); if ("null".equals(dsksorts)) { dsksorts = ""; } cell = new PdfPCell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("username"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(tablesVO.get("access") + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(tablesVO.get("locksheld") + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(seqscans)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(total_sorts)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new PdfPCell(new Phrase(dsksorts)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); } } document.add(hhTable); // Informix document.add(new Paragraph("\n")); PdfPTable lockTable = new PdfPTable(6); float[] lockWidth = { 220f, 220f, 220f, 220f, 220f, 220f }; lockTable.setWidths(lockWidth); lockTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); // lockTable.endHeaders(); List dblock = (ArrayList) dbinfo.get("lockList");// if (dblock != null && dblock.size() > 0) { for (int i = 0; i < dblock.size(); i++) { Hashtable tablesVO = (Hashtable) dblock.get(i); String type = (String) tablesVO.get("type"); String desc = ""; if ("B".equals(type)) { desc = ""; } else if ("IS".equals(type)) { desc = ""; } else if ("S".equals(type)) { desc = ""; } else if ("XS".equals(type)) { desc = ""; } else if ("U".equals(type)) { desc = ""; } else if ("IX".equals(type)) { desc = ""; } else if ("SIX".equals(type)) { desc = ""; } else if ("X".equals(type)) { desc = ""; } else if ("XR".equals(type)) { desc = ""; } cell = new PdfPCell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("username"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("dbsname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase((String) tablesVO.get("tabname"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new PdfPCell(new Phrase(desc)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); } } document.add(lockTable); // Informix document.add(new Paragraph("\n")); PdfPTable logTable = new PdfPTable(9); float[] logWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; logTable.setWidths(logWidth); logTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setColspan(9); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase("ID ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); // logTable.endHeaders(); List dblog = (ArrayList) dbinfo.get("informixlog");// if (dblog != null && dblog.size() > 0) { for (int i = 0; i < dblog.size(); i++) { Hashtable tablesVO = (Hashtable) dblog.get(i); cell = new PdfPCell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("uniqid")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("size")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("used")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_used")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_current")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_backed_up")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_archived")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_temp")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // logTable.addCell(cell); } } document.add(logTable); // InformixIO document.add(new Paragraph("\n")); PdfPTable ioTable = new PdfPTable(10); float[] ioWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; ioTable.setWidths(ioWidth); ioTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("IO ", titleFont)); cell.setColspan(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); // ioTable.endHeaders(); List dbio = (ArrayList) dbinfo.get("iolist");// IO if (dbio != null && dbio.size() > 0) { for (int i = 0; i < dbio.size(); i++) { Hashtable tablesVO = (Hashtable) dbio.get(i); cell = new PdfPCell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("chunknum")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("reads")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("pagesread")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("writes")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("pageswritten")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("mreads")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("mpagesread")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("mwrites")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("mpageswritten")))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ioTable.addCell(cell); } } document.add(ioTable); // document.add(new Paragraph("\n")); PdfPTable eventTable = new PdfPTable(2); float[] eventWidths = { 220f, 220f }; eventTable.setWidths(eventWidths); eventTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase((String) reportHash.get("downnum"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(reportHash.get("count") + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); document.add(eventTable); document.add(new Paragraph("\n")); // addEventLisToPdf(document); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.close(); } catch (Exception e) { SysLogger.error("", e); } } /** * @author HONGLI Informixexcel * @param filename * @throws DocumentException * @throws IOException */ public void createReport_InformixCldXls(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; wb = Workbook.createWorkbook(new File(filename)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, (String) maxping.get("pingnow"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; int row = 14; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; // ArrayList dbspaces = new ArrayList(); if (dbinfo != null) { dbspaces = (ArrayList) dbinfo.get("informixspaces");// } if (dbspaces != null) { if (dbspaces.size() > 0) { DecimalFormat df = new DecimalFormat("#.###"); for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, (String) tablesVO.get("dbspace"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) tablesVO.get("owner"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, (String) tablesVO.get("fname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%", p_labelFormat); sheet.addCell(tmpLabel); row++; } } } row = row + 2; // Informix tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List dbsession = (ArrayList) dbinfo.get("sessionList");// if (dbsession != null && dbsession.size() > 0) { for (int i = 0; i < dbsession.size(); i++) { Hashtable tablesVO = (Hashtable) dbsession.get(i); String seqscans = String.valueOf(tablesVO.get("seqscans")); if ("null".equals(seqscans)) { seqscans = ""; } String total_sorts = String.valueOf(tablesVO.get("total_sorts")); if ("null".equals(total_sorts)) { total_sorts = ""; } String dsksorts = String.valueOf(tablesVO.get("dsksorts")); if ("null".equals(dsksorts)) { dsksorts = ""; } tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, (String) tablesVO.get("username"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) tablesVO.get("hostname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tablesVO.get("access") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tablesVO.get("locksheld") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, seqscans, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, total_sorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, dsksorts, p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // Informix tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List dblock = (ArrayList) dbinfo.get("lockList");// if (dblock != null && dblock.size() > 0) { for (int i = 0; i < dblock.size(); i++) { Hashtable tablesVO = (Hashtable) dblock.get(i); String type = (String) tablesVO.get("type"); String desc = ""; if ("B".equals(type)) { desc = ""; } else if ("IS".equals(type)) { desc = ""; } else if ("S".equals(type)) { desc = ""; } else if ("XS".equals(type)) { desc = ""; } else if ("U".equals(type)) { desc = ""; } else if ("IX".equals(type)) { desc = ""; } else if ("SIX".equals(type)) { desc = ""; } else if ("X".equals(type)) { desc = ""; } else if ("XR".equals(type)) { desc = ""; } tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, (String) tablesVO.get("username"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) tablesVO.get("hostname"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tablesVO.get("dbsname") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tablesVO.get("tabname") + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, desc, p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // Informix tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "ID ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List dblog = (ArrayList) dbinfo.get("informixlog");// if (dblog != null && dblog.size() > 0) { for (int i = 0; i < dblog.size(); i++) { Hashtable tablesVO = (Hashtable) dblog.get(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, String.valueOf(tablesVO.get("uniqid")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, String.valueOf(tablesVO.get("size")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, String.valueOf(tablesVO.get("used")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, String.valueOf(tablesVO.get("is_used")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, String.valueOf(tablesVO.get("is_current")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, String.valueOf(tablesVO.get("is_backed_up")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, String.valueOf(tablesVO.get("is_archived")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, String.valueOf(tablesVO.get("is_temp")), p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // InformixIO tmpLabel = new Label(0, row, "IO ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; List dbio = (ArrayList) dbinfo.get("iolist");// IO if (dbio != null && dbio.size() > 0) { for (int i = 0; i < dbio.size(); i++) { Hashtable tablesVO = (Hashtable) dbio.get(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, String.valueOf(tablesVO.get("chunknum")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, String.valueOf(tablesVO.get("reads")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, String.valueOf(tablesVO.get("pagesread")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, String.valueOf(tablesVO.get("writes")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, String.valueOf(tablesVO.get("pageswritten")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, String.valueOf(tablesVO.get("mreads")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, String.valueOf(tablesVO.get("mpagesread")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, String.valueOf(tablesVO.get("mwrites")), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, String.valueOf(tablesVO.get("mpageswritten")), p_labelFormat); sheet.addCell(tmpLabel); row++; } } row = row + 2; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, (String) reportHash.get("downnum"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, reportHash.get("count") + "", p_labelFormat); sheet.addCell(tmpLabel); // addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } // #####HONGLI /** * @author HONGLI date 2010-11-11 doc */ public void createReportPingDoc(String filename) { try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String dbtype = (String) reportHash.get("dbtype"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // System.out.println("newi ========================"+newip); Paragraph title = new Paragraph(dbtype + "(" + ip + ")" + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n" + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Table aTable = new Table(4); float[] widths = { 220f, 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(""); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(new Phrase((String) // maxping.get("pingmax"),contextFont)); cell = new Cell(new Phrase(reportHash.get("pingnow") + "%", contextFont));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(new Phrase((String) // maxping.get("ping"),contextFont)); cell = new Cell(new Phrase(reportHash.get("pingmin") + "%", contextFont));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(reportHash.get("avgpingcon") + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); document.add(aTable); document.add(img); document.close(); } catch (Exception e) { SysLogger.error("", e); } } /** * @author HONGLI date 2010-11-11 pdf * @param filename */ public void createReportPingPdf(String filename) { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 11, Font.NORMAL); String dbtype = (String) reportHash.get("dbtype"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(dbtype + "(" + ip + ")" + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); document.add(title); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont1); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); PdfPTable aTable = new PdfPTable(4); float[] widths = { 220f, 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell = new PdfPCell(new Phrase(reportHash.get("pingnow") + "%"));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new PdfPCell(new Phrase((String) maxping.get("ping"))); cell = new PdfPCell(new Phrase(reportHash.get("pingmin") + "%"));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(reportHash.get("avgpingcon") + "%")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.MIDDLE);// img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.close(); } catch (Exception e) { SysLogger.error("", e); } } /** * @author HONGLI xls * @param filename */ public void createReportPingExcel(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { wb = Workbook.createWorkbook(new File(filename)); String dbtype = (String) reportHash.get("dbtype"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(dbtype + "(" + ip + ")" + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, dbtype + "(" + ip + ")" + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); // tmpLabel = new Label(1, 5, (String) // maxping.get("pingmax"),p_labelFormat); tmpLabel = new Label(1, 5, reportHash.get("pingnow") + "%", p_labelFormat);// HONGLI // MODIFY sheet.addCell(tmpLabel); // tmpLabel = new Label(2, 5, (String) // maxping.get("ping"),p_labelFormat); tmpLabel = new Label(2, 5, reportHash.get("pingmin") + "%", p_labelFormat);// HONGLI // MODIFY sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, reportHash.get("avgpingcon") + "%", p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, 6, 7, 7, file)); wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * @author HONGLI word * @param filename * @throws DocumentException * @throws IOException */ public void createReport_EventDoc(String filename) throws IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); DBVo vo = (DBVo) reportHash.get("vo"); String downnum = (String) reportHash.get("downnum"); String count = (Integer) reportHash.get("count") + ""; String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidth(100); // 90% dbTable.setAlignment(Element.ALIGN_CENTER);// dbTable.setAutoFillEmptyCells(true); // dbTable.setBorderWidth(1); // dbTable.setBorderColor(new Color(0, 125, 255)); // dbTable.setPadding(2);// dbTable.setSpacing(0);// dbTable.setBorder(2);// dbTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(vo.getDbName(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(downnum, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(count, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); document.add(dbTable); addEventListToDoc(document, titleFont, contextFont); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author HONGLI excel * @param filename * @throws DocumentException * @throws IOException */ public void createReport_EventXls(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { wb = Workbook.createWorkbook(new File(filename)); String hostname = (String) reportHash.get("dbname"); WritableSheet sheet = wb.createSheet(hostname + "", 0); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); DBVo vo = (DBVo) reportHash.get("vo"); String downnum = (String) reportHash.get("downnum"); String count = (Integer) reportHash.get("count") + ""; String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String newip = doip(ip); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); WritableCellFormat red_labelFormat = new WritableCellFormat(); red_labelFormat.setBackground(jxl.format.Colour.RED); WritableCellFormat orange_labelFormat = new WritableCellFormat(); orange_labelFormat.setBackground(jxl.format.Colour.ORANGE); WritableCellFormat yellow_labelFormat = new WritableCellFormat(); yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); // ip tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, typename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, downnum, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, count, p_labelFormat); sheet.addCell(tmpLabel); // int row = 7; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); row++; int index = 0; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); List list = (ArrayList) reportHash.get("list"); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { index++; EventList eventlist = (EventList) list.get(i); Date cc = eventlist.getRecordtime().getTime(); Integer eventid = eventlist.getId(); String eventlocation = eventlist.getEventlocation(); String content = eventlist.getContent(); String level = String.valueOf(eventlist.getLevel1()); String status = String.valueOf(eventlist.getManagesign()); String s = status; String showlevel = null; String act = ""; if ("1".equals(level)) { showlevel = ""; } else if ("2".equals(level)) { showlevel = ""; } else { showlevel = ""; } if ("0".equals(status)) { status = ""; } if ("1".equals(status)) { status = ""; } if ("2".equals(status)) { status = ""; } String rptman = eventlist.getReportman(); String rtime1 = _sdf.format(cc); tmpLabel = new Label(0, row, String.valueOf(index), p_labelFormat); sheet.addCell(tmpLabel); if ("3".equals(level)) { tmpLabel = new Label(1, row, showlevel, red_labelFormat); sheet.addCell(tmpLabel); } else if ("2".equals(level)) { tmpLabel = new Label(1, row, showlevel, orange_labelFormat); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(1, row, showlevel, yellow_labelFormat); sheet.addCell(tmpLabel); } tmpLabel = new Label(2, row, content, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rtime1, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, rptman, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, status, p_labelFormat); sheet.addCell(tmpLabel); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * @author HONGLI pdf * @param filename * @throws DocumentException * @throws IOException */ public void createReport_EventPdf(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); DBVo vo = (DBVo) reportHash.get("vo"); String downnum = (String) reportHash.get("downnum"); String count = (Integer) reportHash.get("count") + ""; String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String hostname = (String) reportHash.get("dbname"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // PdfPTable dbTable = new PdfPTable(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new PdfPCell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new PdfPCell(new Phrase(vo.getDbName(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new PdfPCell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new PdfPCell(new Phrase(typename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new PdfPCell(new Phrase(downnum, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new PdfPCell(new Phrase(count, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); document.add(dbTable); document.add(new Paragraph("\n")); // PdfPTable eventTable = new PdfPTable(6); float[] eventWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; eventTable.setWidths(eventWidths); eventTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); int index = 0; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); List list = (ArrayList) reportHash.get("list"); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { index++; EventList eventlist = (EventList) list.get(i); Date cc = eventlist.getRecordtime().getTime(); Integer eventid = eventlist.getId(); String eventlocation = eventlist.getEventlocation(); String content = eventlist.getContent(); String level = String.valueOf(eventlist.getLevel1()); String status = String.valueOf(eventlist.getManagesign()); String s = status; String showlevel = null; String act = ""; if ("1".equals(level)) { showlevel = ""; } else if ("2".equals(level)) { showlevel = ""; } else { showlevel = ""; } if ("0".equals(status)) { status = ""; } if ("1".equals(status)) { status = ""; } if ("2".equals(status)) { status = ""; } String rptman = eventlist.getReportman(); String rtime1 = _sdf.format(cc); cell = new PdfPCell(new Phrase(String.valueOf(index), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); if ("3".equals(level)) { cell = new PdfPCell(new Phrase(showlevel, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setBackgroundColor(Color.red); eventTable.addCell(cell); } else if ("2".equals(level)) { cell = new PdfPCell(new Phrase(showlevel, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setBackgroundColor(Color.orange); eventTable.addCell(cell); } else { cell = new PdfPCell(new Phrase(showlevel, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setBackgroundColor(Color.yellow); eventTable.addCell(cell); } cell = new PdfPCell(new Phrase(content, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(rtime1, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(rptman, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(status, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); } } document.add(eventTable); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author HONGLI MySQL doc * @param filename * @throws DocumentException * @throws IOException */ public void createReportMySQLSelfDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Vector val = (Vector) reportHash.get("Val"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // document.add(aTable); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// document.add(img); document.add(new Paragraph("\n")); Table aTable1 = new Table(2); float[] width = { 220f, 220f }; aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // if (val != null && val.size() > 0) { for (int i = 0; i < val.size(); i++) { Hashtable return_value = (Hashtable) val.get(i); if (return_value != null && return_value.size() > 0) { String name = return_value.get("variable_name").toString(); String value = return_value.get("value").toString(); if (name.equalsIgnoreCase("Max_used_connections")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_first")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_key")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_next")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_prev")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_rnd")) { name = "H"; } if (name.equalsIgnoreCase("Handler_read_rnd_next")) { name = ""; } if (name.equalsIgnoreCase("Open_tables")) { name = ""; } if (name.equalsIgnoreCase("Opened_tables")) { name = ""; } if (name.equalsIgnoreCase("Threads_cached")) { name = ""; } if (name.equalsIgnoreCase("Threads_connected")) { name = ""; } if (name.equalsIgnoreCase("Threads_created")) { name = ""; } if (name.equalsIgnoreCase("Threads_running")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_immediate")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_waited")) { name = ""; } if (name.equalsIgnoreCase("Key_read_requests")) { name = ""; } if (name.equalsIgnoreCase("Key_reads")) { name = ""; } if (name.equalsIgnoreCase("log_slow_queries")) { name = ""; } if (name.equalsIgnoreCase("slow_launch_time")) { name = "Slow_launch_threads"; } cell = new Cell(new Phrase(name, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(value, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { SysLogger.error("", e); } } /** * @author HONGLI MySQL xls * @param filename * @throws DocumentException * @throws IOException */ public void createReportMySQLSelfExcel(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Vector val = (Vector) reportHash.get("Val"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, (String) maxping.get("pingnow"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, " ", b_labelFormat); sheet.addCell(tmpLabel); int row = 15; if (val != null && val.size() > 0) { for (int i = 0; i < val.size(); i++) { Hashtable return_value = (Hashtable) val.get(i); if (return_value != null && return_value.size() > 0) { String name = return_value.get("variable_name").toString(); String value = return_value.get("value").toString(); if (name.equalsIgnoreCase("Max_used_connections")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_first")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_key")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_next")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_prev")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_rnd")) { name = "H"; } if (name.equalsIgnoreCase("Handler_read_rnd_next")) { name = ""; } if (name.equalsIgnoreCase("Open_tables")) { name = ""; } if (name.equalsIgnoreCase("Opened_tables")) { name = ""; } if (name.equalsIgnoreCase("Threads_cached")) { name = ""; } if (name.equalsIgnoreCase("Threads_connected")) { name = ""; } if (name.equalsIgnoreCase("Threads_created")) { name = ""; } if (name.equalsIgnoreCase("Threads_running")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_immediate")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_waited")) { name = ""; } if (name.equalsIgnoreCase("Key_read_requests")) { name = ""; } if (name.equalsIgnoreCase("Key_reads")) { name = ""; } if (name.equalsIgnoreCase("log_slow_queries")) { name = ""; } if (name.equalsIgnoreCase("slow_launch_time")) { name = "Slow_launch_threads"; } tmpLabel = new Label(0, row, name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, value, p_labelFormat); sheet.addCell(tmpLabel); row++; } } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * @author HONGLI MySQL pdf * @param filename * @throws DocumentException * @throws IOException */ public void createReportMySQLSelfPdf(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Vector val = (Vector) reportHash.get("Val"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingnow"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// // document.add(aTable); img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); PdfPTable aTable1 = new PdfPTable(2); float[] width = { 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); if (val != null && val.size() > 0) { for (int i = 0; i < val.size(); i++) { Hashtable return_value = (Hashtable) val.get(i); if (return_value != null && return_value.size() > 0) { String name = return_value.get("variable_name").toString(); String value = return_value.get("value").toString(); if (name.equalsIgnoreCase("Max_used_connections")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_first")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_key")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_next")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_prev")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_rnd")) { name = "H"; } if (name.equalsIgnoreCase("Handler_read_rnd_next")) { name = ""; } if (name.equalsIgnoreCase("Open_tables")) { name = ""; } if (name.equalsIgnoreCase("Opened_tables")) { name = ""; } if (name.equalsIgnoreCase("Threads_cached")) { name = ""; } if (name.equalsIgnoreCase("Threads_connected")) { name = ""; } if (name.equalsIgnoreCase("Threads_created")) { name = ""; } if (name.equalsIgnoreCase("Threads_running")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_immediate")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_waited")) { name = ""; } if (name.equalsIgnoreCase("Key_read_requests")) { name = ""; } if (name.equalsIgnoreCase("Key_reads")) { name = ""; } if (name.equalsIgnoreCase("log_slow_queries")) { name = ""; } if (name.equalsIgnoreCase("slow_launch_time")) { name = "Slow_launch_threads"; } cell = new PdfPCell(new Phrase(name, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(value)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); } } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // TODO: handle exception } } /** * @author HONGLI MySQLword,pdf * @param filename * @param type * @throws IOException */ public void createReport_MySQLCldDoc(String filename, String type) throws IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); Vector val = (Vector) reportHash.get("Val"); if (val == null) { val = new Vector(); } List sessionlist = (ArrayList) reportHash.get("sessionlist"); if (sessionlist == null) { sessionlist = new ArrayList(); } Hashtable tablesHash = (Hashtable) reportHash.get("tablesHash"); if (tablesHash == null) { tablesHash = new Hashtable(); } Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); if (tableinfo_v == null) { tableinfo_v = new Vector(); } String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); this.setTableFormat(dbTable); // float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; // dbTable.setWidths(cellWidths); // dbTable.setWidth(100); // 90% // dbTable.setAlignment(Element.ALIGN_CENTER);// // dbTable.setAutoFillEmptyCells(true); // // dbTable.setBorderWidth(1); // // dbTable.setBorderColor(new Color(0, 125, 255)); // // dbTable.setPadding(2);// // dbTable.setSpacing(0);// // dbTable.setBorder(2);// // dbTable.endHeaders(); Cell dbCell = null; dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbCell.setColspan(5); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(vo.getDbName(), contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(ip, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(typename, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(runstr, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(grade, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); Table aTable = new Table(3); this.setTableFormat(aTable); // float[] widths = { 220f, 220f, 220f }; // aTable.setWidths(widths); // aTable.setWidth(100); // 90% // aTable.setAlignment(Element.ALIGN_CENTER);// // aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(0);// // aTable.setBorder(2);// // aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(pingnow + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingmin + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingconavg + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // img.setAbsolutePosition(0, 0); img.scalePercent(76); img.setAlignment(Image.LEFT);// document.add(dbTable); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); Table xnTable = new Table(2); this.setTableFormat(xnTable); // float[] width = { 220f, 220f }; // xnTable.setWidths(width); // xnTable.setWidth(100); // 90% // xnTable.setAlignment(Element.ALIGN_CENTER);// // xnTable.setAutoFillEmptyCells(true); // // xnTable.setBorderWidth(1); // // xnTable.setBorderColor(new Color(0, 125, 255)); // // xnTable.setPadding(2);// // xnTable.setSpacing(0);// // xnTable.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); cell.setColspan(2); xnTable.addCell(cell); // if (val != null && val.size() > 0) { for (int i = 0; i < val.size(); i++) { Hashtable return_value = (Hashtable) val.get(i); if (return_value != null && return_value.size() > 0) { String name = return_value.get("variable_name").toString(); String value = return_value.get("value").toString(); if (name.equalsIgnoreCase("Max_used_connections")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_first")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_key")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_next")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_prev")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_rnd")) { name = "H"; } if (name.equalsIgnoreCase("Handler_read_rnd_next")) { name = ""; } if (name.equalsIgnoreCase("Open_tables")) { name = ""; } if (name.equalsIgnoreCase("Opened_tables")) { name = ""; } if (name.equalsIgnoreCase("Threads_cached")) { name = ""; } if (name.equalsIgnoreCase("Threads_connected")) { name = ""; } if (name.equalsIgnoreCase("Threads_created")) { name = ""; } if (name.equalsIgnoreCase("Threads_running")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_immediate")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_waited")) { name = ""; } if (name.equalsIgnoreCase("Key_read_requests")) { name = ""; } if (name.equalsIgnoreCase("Key_reads")) { name = ""; } if (name.equalsIgnoreCase("log_slow_queries")) { name = ""; } if (name.equalsIgnoreCase("slow_launch_time")) { name = "Slow_launch_threads"; } cell = new Cell(new Phrase(name, contextFont)); this.setCellFormat(cell, true); xnTable.addCell(cell); cell = new Cell(new Phrase(value, contextFont)); this.setCellFormat(cell, false); xnTable.addCell(cell); } } } document.add(xnTable); // Table dbInfoTable = new Table(6); this.setTableFormat(dbInfoTable); // float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; // dbInfoTable.setWidths(dbInfoWidths); // dbInfoTable.setWidth(100); // 90% // dbInfoTable.setAlignment(Element.ALIGN_CENTER);// // dbInfoTable.setAutoFillEmptyCells(true); // // dbInfoTable.setBorderWidth(1); // // dbInfoTable.setBorderColor(new Color(0, 125, 255)); // // dbInfoTable.setPadding(2);// // dbInfoTable.setSpacing(0);// // dbInfoTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); cell.setColspan(6); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); if (sessionlist != null && sessionlist.size() > 0) { for (int i = 0; i < sessionlist.size(); i++) { List ipsessionlist = (List) sessionlist.get(i); if (ipsessionlist != null && ipsessionlist.size() > 0) { for (int k = 0; k < ipsessionlist.size(); k++) { String[] sessions = (String[]) ipsessionlist.get(k); if (sessions != null && sessions.length == 5) { cell = new Cell(new Phrase((k + 1) + "", contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(sessions[4], contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(sessions[0], contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(sessions[1], contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(sessions[2], contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(sessions[3], contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); } } } } } document.add(dbInfoTable); // Table tabTable = new Table(5); this.setTableFormat(tabTable); // float[] sysInfoWidths = { 220f, 220f, 220f, 220f, 220f }; // dbInfoTable.setWidths(dbInfoWidths); // tabTable.setWidth(100); // 90% // tabTable.setAlignment(Element.ALIGN_CENTER);// // tabTable.setAutoFillEmptyCells(true); // // tabTable.setBorderWidth(1); // // tabTable.setBorderColor(new Color(0, 125, 255)); // // tabTable.setPadding(2);// // tabTable.setSpacing(0);// // tabTable.setBorder(2);// Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); cell.setColspan(5); tabTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); tabTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); tabTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); tabTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); tabTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); tabTable.addCell(cell); String[] dbs = vo.getDbName().split(","); if (dbs != null && dbs.length > 0) { for (int i = 0; i < dbs.length; i++) { String dbStr = dbs[i]; // System.out.println(dbStr+"====="+tablesHash.size()); if (tablesHash.containsKey(dbStr)) { List tableslist = (List) tablesHash.get(dbStr); if (tableslist != null && tableslist.size() > 0) { for (int k = 0; k < tableslist.size(); k++) { String[] tables = (String[]) tableslist.get(k); if (tables != null && tables.length == 4) { cell = new Cell(new Phrase((k + 1) + "", contextFont)); this.setCellFormat(cell, false); tabTable.addCell(cell); cell = new Cell(new Phrase(tables[0], contextFont)); this.setCellFormat(cell, false); tabTable.addCell(cell); cell = new Cell(new Phrase(tables[1], contextFont)); this.setCellFormat(cell, false); tabTable.addCell(cell); cell = new Cell(new Phrase(tables[2], contextFont)); this.setCellFormat(cell, false); tabTable.addCell(cell); cell = new Cell(new Phrase(tables[3], contextFont)); this.setCellFormat(cell, false); tabTable.addCell(cell); } } } } } } document.add(tabTable); // Table stateTable = new Table(3); this.setTableFormat(stateTable); // float[] statewidth = { 220f, 220f, 220f }; // stateTable.setWidths(statewidth); // stateTable.setWidth(100); // 90% // stateTable.setAlignment(Element.ALIGN_CENTER);// // stateTable.setAutoFillEmptyCells(true); // // stateTable.setBorderWidth(1); // // stateTable.setBorderColor(new Color(0, 125, 255)); // // stateTable.setPadding(2);// // stateTable.setSpacing(0);// // stateTable.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); cell.setColspan(3);// HONGLILI stateTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); stateTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); stateTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); stateTable.addCell(cell); if (tableinfo_v != null) { for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String size = ht.get("variable_name").toString(); String free = ht.get("value").toString(); if (size.equalsIgnoreCase("auto_increment_increment")) { size = ""; } if (size.equalsIgnoreCase("auto_increment_offset")) { size = "AUTO_INCREMENT"; } if (size.equalsIgnoreCase("automatic_sp_privileges")) { size = "automatic_sp_privileges"; } if (size.equalsIgnoreCase("back_log")) { size = ""; } if (size.equalsIgnoreCase("basedir")) { size = "MySQL"; } if (size.equalsIgnoreCase("binlog_cache_size")) { size = "SQL"; } if (size.equalsIgnoreCase("bulk_insert_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("character_set_client")) { size = ""; } if (size.equalsIgnoreCase("character_set_connection")) { size = ""; } if (size.equalsIgnoreCase("character_set_database")) { size = ""; } if (size.equalsIgnoreCase("character_set_filesystem")) { size = "character_set_filesystem"; } if (size.equalsIgnoreCase("character_set_results")) { size = ""; } if (size.equalsIgnoreCase("character_set_server")) { size = ""; } if (size.equalsIgnoreCase("character_set_system")) { size = ""; } if (size.equalsIgnoreCase("character_sets_dir")) { size = ""; } if (size.equalsIgnoreCase("collation_connection")) { size = ""; } if (size.equalsIgnoreCase("collation_database")) { size = ""; } if (size.equalsIgnoreCase("collation_server")) { size = ""; } if (size.equalsIgnoreCase("completion_type")) { size = ""; } if (size.equalsIgnoreCase("concurrent_insert")) { size = ""; } if (size.equalsIgnoreCase("connect_timeout")) { size = "Bad handshake"; } if (size.equalsIgnoreCase("datadir")) { size = "MySQL"; } if (size.equalsIgnoreCase("date_format")) { size = "date_format()"; } if (size.equalsIgnoreCase("datetime_format")) { size = "datetime_format()"; } if (size.equalsIgnoreCase("default_week_format")) { size = "WEEK() "; } if (size.equalsIgnoreCase("delay_key_write")) { size = "DELAY_KEY_WRITE"; } if (size.equalsIgnoreCase("delayed_insert_limit")) { size = "INSERT DELAYEDSELECT"; } if (size.equalsIgnoreCase("delayed_insert_timeout")) { size = "INSERT DELAYEDINSERT"; } if (size.equalsIgnoreCase("delayed_queue_size")) { size = "INSERT DELAYED"; } if (size.equalsIgnoreCase("div_precision_increment")) { size = "/"; } if (size.equalsIgnoreCase("engine_condition_pushdown")) { size = "NDB"; } if (size.equalsIgnoreCase("expire_logs_days")) { size = ""; } if (size.equalsIgnoreCase("flush")) { size = "flushmysqld"; } if (size.equalsIgnoreCase("flush_time")) { size = ""; } if (size.equalsIgnoreCase("ft_boolean_syntax")) { size = "IN BOOLEAN MODE"; } if (size.equalsIgnoreCase("ft_max_word_len")) { size = "FULLTEXT"; } if (size.equalsIgnoreCase("ft_min_word_len")) { size = "FULLTEXT"; } if (size.equalsIgnoreCase("ft_query_expansion_limit")) { size = "WITH QUERY EXPANSION"; } if (size.equalsIgnoreCase("ft_stopword_file")) { size = ""; } if (size.equalsIgnoreCase("group_concat_max_len")) { size = "GROUP_CONCAT()"; } if (size.equalsIgnoreCase("have_archive")) { size = "mysqldARCHIVE"; } if (size.equalsIgnoreCase("have_bdb")) { size = "mysqldBDB"; } if (size.equalsIgnoreCase("have_blackhole_engine")) { size = "mysqldBLACKHOLE"; } if (size.equalsIgnoreCase("have_compress")) { size = "zlib"; } if (size.equalsIgnoreCase("have_crypt")) { size = "crypt()"; } if (size.equalsIgnoreCase("have_csv")) { size = "mysqldARCHIVE"; } if (size.equalsIgnoreCase("have_example_engine")) { size = "mysqldEXAMPLE"; } if (size.equalsIgnoreCase("have_federated_engine")) { size = "mysqldFEDERATED"; } if (size.equalsIgnoreCase("have_geometry")) { size = ""; } if (size.equalsIgnoreCase("have_innodb")) { size = "mysqldInnoDB"; } if (size.equalsIgnoreCase("have_isam")) { size = ""; } if (size.equalsIgnoreCase("have_ndbcluster")) { size = "mysqldNDB CLUSTER"; } if (size.equalsIgnoreCase("have_openssl")) { size = "mysqld/SSL()"; } if (size.equalsIgnoreCase("have_query_cache")) { size = "mysqld"; } if (size.equalsIgnoreCase("have_raid")) { size = "mysqldRAID"; } if (size.equalsIgnoreCase("have_rtree_keys")) { size = "RTREE"; } if (size.equalsIgnoreCase("have_symlink")) { size = ""; } if (size.equalsIgnoreCase("init_connect")) { size = ""; } if (size.equalsIgnoreCase("init_file")) { size = "--init-file"; } if (size.equalsIgnoreCase("init_slave")) { size = "SQL"; } if (size.equalsIgnoreCase("innodb_additional_mem_pool_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_autoextend_increment")) { size = ""; } if (size.equalsIgnoreCase("innodb_buffer_pool_awe_mem_mb")) { size = "32WindowsAWE"; } if (size.equalsIgnoreCase("innodb_buffer_pool_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_checksums")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_commit_concurrency")) { size = "innodb_commit_concurrency"; } if (size.equalsIgnoreCase("innodb_concurrency_tickets")) { size = "innodb_concurrency_tickets"; } if (size.equalsIgnoreCase("innodb_data_file_path")) { size = ""; } if (size.equalsIgnoreCase("innodb_data_home_dir")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_doublewrite")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_fast_shutdown")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_file_io_threads")) { size = "InnoDBI/O"; } if (size.equalsIgnoreCase("innodb_file_per_table")) { size = "InnoDB.ibd"; } if (size.equalsIgnoreCase("innodb_flush_log_at_trx_commit")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_flush_method")) { size = "InnoDBfsync()"; } if (size.equalsIgnoreCase("innodb_force_recovery")) { size = ""; } if (size.equalsIgnoreCase("innodb_lock_wait_timeout")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_locks_unsafe_for_binlog")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_log_arch_dir")) { size = " "; } if (size.equalsIgnoreCase("innodb_log_archive")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_buffer_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_log_file_size")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_files_in_group")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_group_home_dir")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_max_dirty_pages_pct")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_max_purge_lag")) { size = "INSERT,UPDATEDELETE"; } if (size.equalsIgnoreCase("innodb_mirrored_log_groups")) { size = ""; } if (size.equalsIgnoreCase("innodb_open_files")) { size = "InnoDB.ibd"; } if (size.equalsIgnoreCase("innodb_support_xa")) { size = "InnoDBXA"; } if (size.equalsIgnoreCase("innodb_sync_spin_loops")) { size = "innodb_sync_spin_loops"; } if (size.equalsIgnoreCase("innodb_table_locks")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_thread_concurrency")) { size = "InnoDBInnoDB"; } if (size.equalsIgnoreCase("innodb_thread_sleep_delay")) { size = "InnoDBSHOW INNODB STATUS<datadir>/innodb_status"; } if (size.equalsIgnoreCase("interactive_timeout")) { size = ""; } if (size.equalsIgnoreCase("join_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("key_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("key_cache_age_threshold")) { size = "(sub-chain)(sub-chain)"; } if (size.equalsIgnoreCase("key_cache_block_size")) { size = ""; } if (size.equalsIgnoreCase("key_cache_division_limit")) { size = ""; } if (size.equalsIgnoreCase("language")) { size = ""; } if (size.equalsIgnoreCase("large_files_support")) { size = "mysqld"; } if (size.equalsIgnoreCase("large_page_size")) { size = "large_page_size"; } if (size.equalsIgnoreCase("large_pages")) { size = ""; } if (size.equalsIgnoreCase("license")) { size = ""; } if (size.equalsIgnoreCase("local_infile")) { size = "LOCALLOAD DATA INFILE"; } if (size.equalsIgnoreCase("log")) { size = ""; } if (size.equalsIgnoreCase("log_bin")) { size = ""; } if (size.equalsIgnoreCase("log_bin_trust_function_creators")) { size = ""; } if (size.equalsIgnoreCase("log_error")) { size = ""; } if (size.equalsIgnoreCase("log_slave_updates")) { size = ""; } if (size.equalsIgnoreCase("log_slow_queries")) { size = ""; } if (size.equalsIgnoreCase("log_warnings")) { size = ""; } if (size.equalsIgnoreCase("long_query_time")) { size = "Slow_queries"; } if (size.equalsIgnoreCase("low_priority_updates")) { size = "sqlSELECTLOCK TABLE READ"; } if (size.equalsIgnoreCase("lower_case_file_system")) { size = ""; } if (size.equalsIgnoreCase("lower_case_table_names")) { size = "1"; } if (size.equalsIgnoreCase("max_allowed_packet")) { size = "/"; } if (size.equalsIgnoreCase("max_binlog_cache_size")) { size = ""; } if (size.equalsIgnoreCase("max_binlog_size")) { size = ""; } if (size.equalsIgnoreCase("max_connect_errors")) { size = ""; } if (size.equalsIgnoreCase("max_connections")) { size = ""; } if (size.equalsIgnoreCase("max_delayed_threads")) { size = "INSERT DELAYED"; } if (size.equalsIgnoreCase("max_error_count")) { size = "SHOW ERRORSSHOW WARNINGS"; } if (size.equalsIgnoreCase("max_heap_table_size")) { size = "MEMORY (HEAP)"; } if (size.equalsIgnoreCase("max_insert_delayed_threads")) { size = "INSERT DELAYED(max_delayed_threads)"; } if (size.equalsIgnoreCase("max_join_size")) { size = "max_join_size"; } if (size.equalsIgnoreCase("max_length_for_sort_data")) { size = "filesort"; } if (size.equalsIgnoreCase("max_prepared_stmt_count")) { size = "max_prepared_stmt_count"; } if (size.equalsIgnoreCase("max_relay_log_size")) { size = ""; } if (size.equalsIgnoreCase("max_seeks_for_key")) { size = ""; } if (size.equalsIgnoreCase("max_sort_length")) { size = "BLOBTEXT"; } if (size.equalsIgnoreCase("max_sp_recursion_depth")) { size = "max_sp_recursion_depth"; } if (size.equalsIgnoreCase("max_tmp_tables")) { size = ""; } if (size.equalsIgnoreCase("max_user_connections")) { size = "MySQL"; } if (size.equalsIgnoreCase("max_write_lock_count")) { size = ""; } if (size.equalsIgnoreCase("multi_range_count")) { size = "multi_range_count"; } if (size.equalsIgnoreCase("myisam_data_pointer_size")) { size = ""; } if (size.equalsIgnoreCase("myisam_max_sort_file_size")) { size = "MyISAMMySQL"; } if (size.equalsIgnoreCase("myisam_recover_options")) { size = "myisam-recover"; } if (size.equalsIgnoreCase("myisam_repair_threads")) { size = "1Repair by sortingMyISAM"; } if (size.equalsIgnoreCase("myisam_sort_buffer_size")) { size = "REPAIR TABLECREATE INDEXALTER TABLEMyISAM"; } if (size.equalsIgnoreCase("myisam_stats_method")) { size = "MyISAMNULL"; } if (size.equalsIgnoreCase("named_pipe")) { size = ""; } if (size.equalsIgnoreCase("net_buffer_length")) { size = ""; } if (size.equalsIgnoreCase("net_read_timeout")) { size = ""; } if (size.equalsIgnoreCase("net_retry_count")) { size = ""; } if (size.equalsIgnoreCase("net_write_timeout")) { size = ""; } if (size.equalsIgnoreCase("new")) { size = "MySQL 4.04.1"; } if (size.equalsIgnoreCase("old_passwords")) { size = "MySQLpre-4.1-style"; } if (size.equalsIgnoreCase("open_files_limit")) { size = "mysqld"; } if (size.equalsIgnoreCase("optimizer_prune_level")) { size = " 0"; } if (size.equalsIgnoreCase("optimizer_search_depth")) { size = ""; } if (size.equalsIgnoreCase("pid_file")) { size = "ID (PID)"; } if (size.equalsIgnoreCase("prepared_stmt_count")) { size = "prepared_stmt_count"; } if (size.equalsIgnoreCase("port")) { size = "TCP/IP"; } if (size.equalsIgnoreCase("preload_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("protocol_version")) { size = "MySQL/"; } if (size.equalsIgnoreCase("query_alloc_block_size")) { size = ""; } if (size.equalsIgnoreCase("query_cache_limit")) { size = ""; } if (size.equalsIgnoreCase("query_cache_min_res_unit")) { size = "()"; } if (size.equalsIgnoreCase("query_cache_size")) { size = ""; } if (size.equalsIgnoreCase("query_cache_type")) { size = ""; } if (size.equalsIgnoreCase("query_cache_wlock_invalidate")) { size = "WRITE"; } if (size.equalsIgnoreCase("query_prealloc_size")) { size = ""; } if (size.equalsIgnoreCase("range_alloc_block_size")) { size = ""; } if (size.equalsIgnoreCase("read_buffer_size")) { size = "()"; } if (size.equalsIgnoreCase("read_only")) { size = "ON"; } if (size.equalsIgnoreCase("read_only")) { size = "ON"; } if (size.equalsIgnoreCase("relay_log_purge")) { size = ""; } if (size.equalsIgnoreCase("read_rnd_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("secure_auth")) { size = "--secure-authMySQL(4.1)"; } if (size.equalsIgnoreCase("shared_memory")) { size = "(Windows)"; } if (size.equalsIgnoreCase("shared_memory_base_name")) { size = "(Windows)"; } if (size.equalsIgnoreCase("server_id")) { size = ""; } if (size.equalsIgnoreCase("skip_external_locking")) { size = "mysqld"; } if (size.equalsIgnoreCase("skip_networking")) { size = "(TCP/IP)"; } if (size.equalsIgnoreCase("skip_show_database")) { size = "SHOW DATABASESSHOW DATABASES"; } if (size.equalsIgnoreCase("slave_compressed_protocol")) { size = "/"; } if (size.equalsIgnoreCase("slave_load_tmpdir")) { size = "LOAD DATA INFILE"; } if (size.equalsIgnoreCase("slave_net_timeout")) { size = "/"; } if (size.equalsIgnoreCase("slave_skip_errors")) { size = "()"; } if (size.equalsIgnoreCase("slave_transaction_retries")) { size = "SQLslave_transaction_retries"; } if (size.equalsIgnoreCase("slow_launch_time")) { size = "Slow_launch_threads"; } if (size.equalsIgnoreCase("sort_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("sql_mode")) { size = "SQL"; } if (size.equalsIgnoreCase("storage_engine")) { size = "table_typeisMySQL 5.1,storage_engine"; } if (size.equalsIgnoreCase("sync_binlog")) { size = "sync_binlog'thMySQL"; } if (size.equalsIgnoreCase("sync_frm")) { size = "1,.frm"; } if (size.equalsIgnoreCase("system_time_zone")) { size = ""; } if (size.equalsIgnoreCase("table_cache")) { size = ""; } if (size.equalsIgnoreCase("table_type")) { size = "()"; } if (size.equalsIgnoreCase("thread_cache_size")) { size = ""; } if (size.equalsIgnoreCase("thread_stack")) { size = ""; } if (size.equalsIgnoreCase("time_format")) { size = ""; } if (size.equalsIgnoreCase("time_zone")) { size = ""; } if (size.equalsIgnoreCase("tmp_table_size")) { size = "MySQLMyISAM"; } if (size.equalsIgnoreCase("tmpdir")) { size = ""; } if (size.equalsIgnoreCase("transaction_alloc_block_size")) { size = "()"; } if (size.equalsIgnoreCase("transaction_prealloc_size")) { size = "transaction_alloc_blocks"; } if (size.equalsIgnoreCase("tx_isolation")) { size = ""; } if (size.equalsIgnoreCase("updatable_views_with_limit")) { size = "LIMIT"; } if (size.equalsIgnoreCase("version")) { size = ""; } if (size.equalsIgnoreCase("version_bdb")) { size = "BDB"; } if (size.equalsIgnoreCase("version_comment")) { size = "configure--with-commentMySQL"; } if (size.equalsIgnoreCase("version_compile_machine")) { size = "MySQL"; } if (size.equalsIgnoreCase("version_compile_os")) { size = "MySQL"; } if (size.equalsIgnoreCase("wait_timeout")) { size = ""; } cell = new Cell(new Phrase(String.valueOf(i + 1), contextFont)); this.setCellFormat(cell, false); stateTable.addCell(cell); cell = new Cell(new Phrase(size, contextFont)); this.setCellFormat(cell, false); stateTable.addCell(cell); cell = new Cell(new Phrase(free, contextFont)); this.setCellFormat(cell, false); stateTable.addCell(cell); // stateTable.endHeaders(); } } // HONGLILI document.add(stateTable); // Table evenInfoTable = new Table(2); this.setTableFormat(evenInfoTable); // float[] evenInfoWidths = { 220f, 220f }; // evenInfoTable.setWidths(evenInfoWidths); // evenInfoTable.setWidth(100); // 90% // evenInfoTable.setAlignment(Element.ALIGN_CENTER);// // evenInfoTable.setAutoFillEmptyCells(true); // // evenInfoTable.setBorderWidth(1); // // evenInfoTable.setBorderColor(new Color(0, 125, 255)); // // evenInfoTable.setPadding(2);// // evenInfoTable.setSpacing(0);// // evenInfoTable.setBorder(2);// String downnum = (String) reportHash.get("downnum"); String count = (Integer) reportHash.get("count") + ""; cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); evenInfoTable.addCell(cell); cell = new Cell(new Phrase(downnum, contextFont)); this.setCellFormat(cell, false); evenInfoTable.addCell(cell); cell = new Cell(new Phrase(count, contextFont)); this.setCellFormat(cell, false); evenInfoTable.addCell(cell); document.add(evenInfoTable); // addEventListToDoc(document, titleFont, contextFont); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author HONGLI MySQLpdf * @param filename * @throws DocumentException * @throws IOException */ public void createReport_MySQLCldPdf(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); Vector val = (Vector) reportHash.get("Val"); if (val == null) { val = new Vector(); } List sessionlist = (ArrayList) reportHash.get("sessionlist"); if (sessionlist == null) { sessionlist = new ArrayList(); } Hashtable tablesHash = (Hashtable) reportHash.get("tablesHash"); if (tablesHash == null) { tablesHash = new Hashtable(); } Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); if (tableinfo_v == null) { tableinfo_v = new Vector(); } String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // PdfPTable dbTable = new PdfPTable(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidthPercentage(100); PdfPCell dbCell = null; dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setColspan(5); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("IP", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(vo.getDbName(), contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(ip, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(typename, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(runstr, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new PdfPCell(new Phrase(grade, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(pingnow + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(pingmin + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(pingconavg + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // img.setAbsolutePosition(0, 0); img.scalePercent(76); img.setAlignment(Image.MIDDLE);// document.add(dbTable); document.add(new Paragraph("\n")); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // PdfPTable xnTable = new PdfPTable(2); float[] width = { 220f, 220f }; xnTable.setWidths(width); xnTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // xnTable.addCell(cell); if (val != null && val.size() > 0) { for (int i = 0; i < val.size(); i++) { Hashtable return_value = (Hashtable) val.get(i); if (return_value != null && return_value.size() > 0) { String name = return_value.get("variable_name").toString(); String value = return_value.get("value").toString(); if (name.equalsIgnoreCase("Max_used_connections")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_first")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_key")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_next")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_prev")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_rnd")) { name = "H"; } if (name.equalsIgnoreCase("Handler_read_rnd_next")) { name = ""; } if (name.equalsIgnoreCase("Open_tables")) { name = ""; } if (name.equalsIgnoreCase("Opened_tables")) { name = ""; } if (name.equalsIgnoreCase("Threads_cached")) { name = ""; } if (name.equalsIgnoreCase("Threads_connected")) { name = ""; } if (name.equalsIgnoreCase("Threads_created")) { name = ""; } if (name.equalsIgnoreCase("Threads_running")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_immediate")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_waited")) { name = ""; } if (name.equalsIgnoreCase("Key_read_requests")) { name = ""; } if (name.equalsIgnoreCase("Key_reads")) { name = ""; } if (name.equalsIgnoreCase("log_slow_queries")) { name = ""; } if (name.equalsIgnoreCase("slow_launch_time")) { name = "Slow_launch_threads"; } cell = new PdfPCell(new Phrase(name, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // xnTable.addCell(cell); cell = new PdfPCell(new Phrase(value, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // xnTable.addCell(cell); // xnTable.endHeaders(); } } } document.add(xnTable); document.add(new Paragraph("\n")); // PdfPTable connTable = new PdfPTable(6); float[] cwidth = { 220f, 220f, 220f, 220f, 220f, 220f }; connTable.setWidths(cwidth); connTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); if (sessionlist != null && sessionlist.size() > 0) { int rowI = 1; for (int i = 0; i < sessionlist.size(); i++) { List ipsessionlist = (List) sessionlist.get(i); if (ipsessionlist != null && ipsessionlist.size() > 0) { for (int k = 0; k < ipsessionlist.size(); k++) { String[] sessions = (String[]) ipsessionlist.get(k); if (sessions != null && sessions.length == 5) { cell = new PdfPCell(new Phrase(String.valueOf(rowI), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(sessions[4], contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(sessions[0], contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(sessions[1], contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(sessions[2], contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); cell = new PdfPCell(new Phrase(sessions[3], contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // connTable.addCell(cell); // connTable.endHeaders(); rowI++; } } } } } document.add(connTable); document.add(new Paragraph("\n")); // PdfPTable tabTable = new PdfPTable(5); float[] tabwidth = { 220f, 220f, 220f, 220f, 220f }; tabTable.setWidths(tabwidth); tabTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // tabTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // tabTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // tabTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // tabTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // tabTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // tabTable.addCell(cell); String[] dbs = vo.getDbName().split(","); if (dbs != null && dbs.length > 0) { int rowI = 1; for (int i = 0; i < dbs.length; i++) { String dbStr = dbs[i]; // System.out.println(dbStr+"====="+tablesHash.size()); if (tablesHash.containsKey(dbStr)) { List tableslist = (List) tablesHash.get(dbStr); if (tableslist != null && tableslist.size() > 0) { for (int k = 0; k < tableslist.size(); k++) { String[] tables = (String[]) tableslist.get(k); if (tables != null && tables.length == 4) { cell = new PdfPCell(new Phrase(String.valueOf(rowI), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // tabTable.addCell(cell); cell = new PdfPCell(new Phrase(tables[0], contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // tabTable.addCell(cell); cell = new PdfPCell(new Phrase(tables[1], contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // tabTable.addCell(cell); cell = new PdfPCell(new Phrase(tables[2], contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // tabTable.addCell(cell); cell = new PdfPCell(new Phrase(tables[3], contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // tabTable.addCell(cell); // tabTable.endHeaders(); rowI++; } } } } } } document.add(tabTable); document.add(new Paragraph("\n")); // PdfPTable stateTable = new PdfPTable(3); float[] swidth = { 220f, 220f, 220f }; stateTable.setWidths(swidth); stateTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // stateTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // stateTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // stateTable.addCell(cell); cell = new PdfPCell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // stateTable.addCell(cell); if (tableinfo_v != null) { int rowI = 1; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String size = ht.get("variable_name").toString(); String free = ht.get("value").toString(); if (size.equalsIgnoreCase("auto_increment_increment")) { size = ""; } if (size.equalsIgnoreCase("auto_increment_offset")) { size = "AUTO_INCREMENT"; } if (size.equalsIgnoreCase("automatic_sp_privileges")) { size = "automatic_sp_privileges"; } if (size.equalsIgnoreCase("back_log")) { size = ""; } if (size.equalsIgnoreCase("basedir")) { size = "MySQL"; } if (size.equalsIgnoreCase("binlog_cache_size")) { size = "SQL"; } if (size.equalsIgnoreCase("bulk_insert_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("character_set_client")) { size = ""; } if (size.equalsIgnoreCase("character_set_connection")) { size = ""; } if (size.equalsIgnoreCase("character_set_database")) { size = ""; } if (size.equalsIgnoreCase("character_set_filesystem")) { size = "character_set_filesystem"; } if (size.equalsIgnoreCase("character_set_results")) { size = ""; } if (size.equalsIgnoreCase("character_set_server")) { size = ""; } if (size.equalsIgnoreCase("character_set_system")) { size = ""; } if (size.equalsIgnoreCase("character_sets_dir")) { size = ""; } if (size.equalsIgnoreCase("collation_connection")) { size = ""; } if (size.equalsIgnoreCase("collation_database")) { size = ""; } if (size.equalsIgnoreCase("collation_server")) { size = ""; } if (size.equalsIgnoreCase("completion_type")) { size = ""; } if (size.equalsIgnoreCase("concurrent_insert")) { size = ""; } if (size.equalsIgnoreCase("connect_timeout")) { size = "Bad handshake"; } if (size.equalsIgnoreCase("datadir")) { size = "MySQL"; } if (size.equalsIgnoreCase("date_format")) { size = "date_format()"; } if (size.equalsIgnoreCase("datetime_format")) { size = "datetime_format()"; } if (size.equalsIgnoreCase("default_week_format")) { size = "WEEK() "; } if (size.equalsIgnoreCase("delay_key_write")) { size = "DELAY_KEY_WRITE"; } if (size.equalsIgnoreCase("delayed_insert_limit")) { size = "INSERT DELAYEDSELECT"; } if (size.equalsIgnoreCase("delayed_insert_timeout")) { size = "INSERT DELAYEDINSERT"; } if (size.equalsIgnoreCase("delayed_queue_size")) { size = "INSERT DELAYED"; } if (size.equalsIgnoreCase("div_precision_increment")) { size = "/"; } if (size.equalsIgnoreCase("engine_condition_pushdown")) { size = "NDB"; } if (size.equalsIgnoreCase("expire_logs_days")) { size = ""; } if (size.equalsIgnoreCase("flush")) { size = "flushmysqld"; } if (size.equalsIgnoreCase("flush_time")) { size = ""; } if (size.equalsIgnoreCase("ft_boolean_syntax")) { size = "IN BOOLEAN MODE"; } if (size.equalsIgnoreCase("ft_max_word_len")) { size = "FULLTEXT"; } if (size.equalsIgnoreCase("ft_min_word_len")) { size = "FULLTEXT"; } if (size.equalsIgnoreCase("ft_query_expansion_limit")) { size = "WITH QUERY EXPANSION"; } if (size.equalsIgnoreCase("ft_stopword_file")) { size = ""; } if (size.equalsIgnoreCase("group_concat_max_len")) { size = "GROUP_CONCAT()"; } if (size.equalsIgnoreCase("have_archive")) { size = "mysqldARCHIVE"; } if (size.equalsIgnoreCase("have_bdb")) { size = "mysqldBDB"; } if (size.equalsIgnoreCase("have_blackhole_engine")) { size = "mysqldBLACKHOLE"; } if (size.equalsIgnoreCase("have_compress")) { size = "zlib"; } if (size.equalsIgnoreCase("have_crypt")) { size = "crypt()"; } if (size.equalsIgnoreCase("have_csv")) { size = "mysqldARCHIVE"; } if (size.equalsIgnoreCase("have_example_engine")) { size = "mysqldEXAMPLE"; } if (size.equalsIgnoreCase("have_federated_engine")) { size = "mysqldFEDERATED"; } if (size.equalsIgnoreCase("have_geometry")) { size = ""; } if (size.equalsIgnoreCase("have_innodb")) { size = "mysqldInnoDB"; } if (size.equalsIgnoreCase("have_isam")) { size = ""; } if (size.equalsIgnoreCase("have_ndbcluster")) { size = "mysqldNDB CLUSTER"; } if (size.equalsIgnoreCase("have_openssl")) { size = "mysqld/SSL()"; } if (size.equalsIgnoreCase("have_query_cache")) { size = "mysqld"; } if (size.equalsIgnoreCase("have_raid")) { size = "mysqldRAID"; } if (size.equalsIgnoreCase("have_rtree_keys")) { size = "RTREE"; } if (size.equalsIgnoreCase("have_symlink")) { size = ""; } if (size.equalsIgnoreCase("init_connect")) { size = ""; } if (size.equalsIgnoreCase("init_file")) { size = "--init-file"; } if (size.equalsIgnoreCase("init_slave")) { size = "SQL"; } if (size.equalsIgnoreCase("innodb_additional_mem_pool_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_autoextend_increment")) { size = ""; } if (size.equalsIgnoreCase("innodb_buffer_pool_awe_mem_mb")) { size = "32WindowsAWE"; } if (size.equalsIgnoreCase("innodb_buffer_pool_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_checksums")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_commit_concurrency")) { size = "innodb_commit_concurrency"; } if (size.equalsIgnoreCase("innodb_concurrency_tickets")) { size = "innodb_concurrency_tickets"; } if (size.equalsIgnoreCase("innodb_data_file_path")) { size = ""; } if (size.equalsIgnoreCase("innodb_data_home_dir")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_doublewrite")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_fast_shutdown")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_file_io_threads")) { size = "InnoDBI/O"; } if (size.equalsIgnoreCase("innodb_file_per_table")) { size = "InnoDB.ibd"; } if (size.equalsIgnoreCase("innodb_flush_log_at_trx_commit")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_flush_method")) { size = "InnoDBfsync()"; } if (size.equalsIgnoreCase("innodb_force_recovery")) { size = ""; } if (size.equalsIgnoreCase("innodb_lock_wait_timeout")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_locks_unsafe_for_binlog")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_log_arch_dir")) { size = " "; } if (size.equalsIgnoreCase("innodb_log_archive")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_buffer_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_log_file_size")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_files_in_group")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_group_home_dir")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_max_dirty_pages_pct")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_max_purge_lag")) { size = "INSERT,UPDATEDELETE"; } if (size.equalsIgnoreCase("innodb_mirrored_log_groups")) { size = ""; } if (size.equalsIgnoreCase("innodb_open_files")) { size = "InnoDB.ibd"; } if (size.equalsIgnoreCase("innodb_support_xa")) { size = "InnoDBXA"; } if (size.equalsIgnoreCase("innodb_sync_spin_loops")) { size = "innodb_sync_spin_loops"; } if (size.equalsIgnoreCase("innodb_table_locks")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_thread_concurrency")) { size = "InnoDBInnoDB"; } if (size.equalsIgnoreCase("innodb_thread_sleep_delay")) { size = "InnoDBSHOW INNODB STATUS<datadir>/innodb_status"; } if (size.equalsIgnoreCase("interactive_timeout")) { size = ""; } if (size.equalsIgnoreCase("join_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("key_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("key_cache_age_threshold")) { size = "(sub-chain)(sub-chain)"; } if (size.equalsIgnoreCase("key_cache_block_size")) { size = ""; } if (size.equalsIgnoreCase("key_cache_division_limit")) { size = ""; } if (size.equalsIgnoreCase("language")) { size = ""; } if (size.equalsIgnoreCase("large_files_support")) { size = "mysqld"; } if (size.equalsIgnoreCase("large_page_size")) { size = "large_page_size"; } if (size.equalsIgnoreCase("large_pages")) { size = ""; } if (size.equalsIgnoreCase("license")) { size = ""; } if (size.equalsIgnoreCase("local_infile")) { size = "LOCALLOAD DATA INFILE"; } if (size.equalsIgnoreCase("log")) { size = ""; } if (size.equalsIgnoreCase("log_bin")) { size = ""; } if (size.equalsIgnoreCase("log_bin_trust_function_creators")) { size = ""; } if (size.equalsIgnoreCase("log_error")) { size = ""; } if (size.equalsIgnoreCase("log_slave_updates")) { size = ""; } if (size.equalsIgnoreCase("log_slow_queries")) { size = ""; } if (size.equalsIgnoreCase("log_warnings")) { size = ""; } if (size.equalsIgnoreCase("long_query_time")) { size = "Slow_queries"; } if (size.equalsIgnoreCase("low_priority_updates")) { size = "sqlSELECTLOCK TABLE READ"; } if (size.equalsIgnoreCase("lower_case_file_system")) { size = ""; } if (size.equalsIgnoreCase("lower_case_table_names")) { size = "1"; } if (size.equalsIgnoreCase("max_allowed_packet")) { size = "/"; } if (size.equalsIgnoreCase("max_binlog_cache_size")) { size = ""; } if (size.equalsIgnoreCase("max_binlog_size")) { size = ""; } if (size.equalsIgnoreCase("max_connect_errors")) { size = ""; } if (size.equalsIgnoreCase("max_connections")) { size = ""; } if (size.equalsIgnoreCase("max_delayed_threads")) { size = "INSERT DELAYED"; } if (size.equalsIgnoreCase("max_error_count")) { size = "SHOW ERRORSSHOW WARNINGS"; } if (size.equalsIgnoreCase("max_heap_table_size")) { size = "MEMORY (HEAP)"; } if (size.equalsIgnoreCase("max_insert_delayed_threads")) { size = "INSERT DELAYED(max_delayed_threads)"; } if (size.equalsIgnoreCase("max_join_size")) { size = "max_join_size"; } if (size.equalsIgnoreCase("max_length_for_sort_data")) { size = "filesort"; } if (size.equalsIgnoreCase("max_prepared_stmt_count")) { size = "max_prepared_stmt_count"; } if (size.equalsIgnoreCase("max_relay_log_size")) { size = ""; } if (size.equalsIgnoreCase("max_seeks_for_key")) { size = ""; } if (size.equalsIgnoreCase("max_sort_length")) { size = "BLOBTEXT"; } if (size.equalsIgnoreCase("max_sp_recursion_depth")) { size = "max_sp_recursion_depth"; } if (size.equalsIgnoreCase("max_tmp_tables")) { size = ""; } if (size.equalsIgnoreCase("max_user_connections")) { size = "MySQL"; } if (size.equalsIgnoreCase("max_write_lock_count")) { size = ""; } if (size.equalsIgnoreCase("multi_range_count")) { size = "multi_range_count"; } if (size.equalsIgnoreCase("myisam_data_pointer_size")) { size = ""; } if (size.equalsIgnoreCase("myisam_max_sort_file_size")) { size = "MyISAMMySQL"; } if (size.equalsIgnoreCase("myisam_recover_options")) { size = "myisam-recover"; } if (size.equalsIgnoreCase("myisam_repair_threads")) { size = "1Repair by sortingMyISAM"; } if (size.equalsIgnoreCase("myisam_sort_buffer_size")) { size = "REPAIR TABLECREATE INDEXALTER TABLEMyISAM"; } if (size.equalsIgnoreCase("myisam_stats_method")) { size = "MyISAMNULL"; } if (size.equalsIgnoreCase("named_pipe")) { size = ""; } if (size.equalsIgnoreCase("net_buffer_length")) { size = ""; } if (size.equalsIgnoreCase("net_read_timeout")) { size = ""; } if (size.equalsIgnoreCase("net_retry_count")) { size = ""; } if (size.equalsIgnoreCase("net_write_timeout")) { size = ""; } if (size.equalsIgnoreCase("new")) { size = "MySQL 4.04.1"; } if (size.equalsIgnoreCase("old_passwords")) { size = "MySQLpre-4.1-style"; } if (size.equalsIgnoreCase("open_files_limit")) { size = "mysqld"; } if (size.equalsIgnoreCase("optimizer_prune_level")) { size = " 0"; } if (size.equalsIgnoreCase("optimizer_search_depth")) { size = ""; } if (size.equalsIgnoreCase("pid_file")) { size = "ID (PID)"; } if (size.equalsIgnoreCase("prepared_stmt_count")) { size = "prepared_stmt_count"; } if (size.equalsIgnoreCase("port")) { size = "TCP/IP"; } if (size.equalsIgnoreCase("preload_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("protocol_version")) { size = "MySQL/"; } if (size.equalsIgnoreCase("query_alloc_block_size")) { size = ""; } if (size.equalsIgnoreCase("query_cache_limit")) { size = ""; } if (size.equalsIgnoreCase("query_cache_min_res_unit")) { size = "()"; } if (size.equalsIgnoreCase("query_cache_size")) { size = ""; } if (size.equalsIgnoreCase("query_cache_type")) { size = ""; } if (size.equalsIgnoreCase("query_cache_wlock_invalidate")) { size = "WRITE"; } if (size.equalsIgnoreCase("query_prealloc_size")) { size = ""; } if (size.equalsIgnoreCase("range_alloc_block_size")) { size = ""; } if (size.equalsIgnoreCase("read_buffer_size")) { size = "()"; } if (size.equalsIgnoreCase("read_only")) { size = "ON"; } if (size.equalsIgnoreCase("read_only")) { size = "ON"; } if (size.equalsIgnoreCase("relay_log_purge")) { size = ""; } if (size.equalsIgnoreCase("read_rnd_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("secure_auth")) { size = "--secure-authMySQL(4.1)"; } if (size.equalsIgnoreCase("shared_memory")) { size = "(Windows)"; } if (size.equalsIgnoreCase("shared_memory_base_name")) { size = "(Windows)"; } if (size.equalsIgnoreCase("server_id")) { size = ""; } if (size.equalsIgnoreCase("skip_external_locking")) { size = "mysqld"; } if (size.equalsIgnoreCase("skip_networking")) { size = "(TCP/IP)"; } if (size.equalsIgnoreCase("skip_show_database")) { size = "SHOW DATABASESSHOW DATABASES"; } if (size.equalsIgnoreCase("slave_compressed_protocol")) { size = "/"; } if (size.equalsIgnoreCase("slave_load_tmpdir")) { size = "LOAD DATA INFILE"; } if (size.equalsIgnoreCase("slave_net_timeout")) { size = "/"; } if (size.equalsIgnoreCase("slave_skip_errors")) { size = "()"; } if (size.equalsIgnoreCase("slave_transaction_retries")) { size = "SQLslave_transaction_retries"; } if (size.equalsIgnoreCase("slow_launch_time")) { size = "Slow_launch_threads"; } if (size.equalsIgnoreCase("sort_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("sql_mode")) { size = "SQL"; } if (size.equalsIgnoreCase("storage_engine")) { size = "table_typeisMySQL 5.1,storage_engine"; } if (size.equalsIgnoreCase("sync_binlog")) { size = "sync_binlog'thMySQL"; } if (size.equalsIgnoreCase("sync_frm")) { size = "1,.frm"; } if (size.equalsIgnoreCase("system_time_zone")) { size = ""; } if (size.equalsIgnoreCase("table_cache")) { size = ""; } if (size.equalsIgnoreCase("table_type")) { size = "()"; } if (size.equalsIgnoreCase("thread_cache_size")) { size = ""; } if (size.equalsIgnoreCase("thread_stack")) { size = ""; } if (size.equalsIgnoreCase("time_format")) { size = ""; } if (size.equalsIgnoreCase("time_zone")) { size = ""; } if (size.equalsIgnoreCase("tmp_table_size")) { size = "MySQLMyISAM"; } if (size.equalsIgnoreCase("tmpdir")) { size = ""; } if (size.equalsIgnoreCase("transaction_alloc_block_size")) { size = "()"; } if (size.equalsIgnoreCase("transaction_prealloc_size")) { size = "transaction_alloc_blocks"; } if (size.equalsIgnoreCase("tx_isolation")) { size = ""; } if (size.equalsIgnoreCase("updatable_views_with_limit")) { size = "LIMIT"; } if (size.equalsIgnoreCase("version")) { size = ""; } if (size.equalsIgnoreCase("version_bdb")) { size = "BDB"; } if (size.equalsIgnoreCase("version_comment")) { size = "configure--with-commentMySQL"; } if (size.equalsIgnoreCase("version_compile_machine")) { size = "MySQL"; } if (size.equalsIgnoreCase("version_compile_os")) { size = "MySQL"; } if (size.equalsIgnoreCase("wait_timeout")) { size = ""; } cell = new PdfPCell(new Phrase(String.valueOf(rowI), contextFont));// mark cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // stateTable.addCell(cell); cell = new PdfPCell(new Phrase(size, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // stateTable.addCell(cell); cell = new PdfPCell(new Phrase(free, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // stateTable.addCell(cell); rowI++; } } document.add(stateTable); document.add(new Paragraph("\n")); // PdfPTable eventTable = new PdfPTable(2); float[] eventWidths = { 220f, 220f }; eventTable.setWidths(eventWidths); eventTable.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase((String) reportHash.get("downnum"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); cell = new PdfPCell(new Phrase(reportHash.get("count") + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventTable.addCell(cell); document.add(eventTable); document.add(new Paragraph("\n")); // addEventLisToPdf(document); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } } /** * @author HONGLI MySQLexcel * @param filename * @throws DocumentException * @throws IOException */ public void createReport_MySQLCldXls(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { wb = Workbook.createWorkbook(new File(filename)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); Vector val = (Vector) reportHash.get("Val"); if (val == null) { val = new Vector(); } List sessionlist = (ArrayList) reportHash.get("sessionlist"); if (sessionlist == null) { sessionlist = new ArrayList(); } Hashtable tablesHash = (Hashtable) reportHash.get("tablesHash"); if (tablesHash == null) { tablesHash = new Hashtable(); } Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); if (tableinfo_v == null) { tableinfo_v = new Vector(); } Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); // ip tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, typename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, runstr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, grade, p_labelFormat); sheet.addCell(tmpLabel); // tmpLabel = new Label(0, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 8, pingmin + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 8, pingconavg + "%", p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 9, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, " ", b_labelFormat); sheet.addCell(tmpLabel); int row = 15; if (val != null && val.size() > 0) { for (int i = 0; i < val.size(); i++) { Hashtable return_value = (Hashtable) val.get(i); if (return_value != null && return_value.size() > 0) { String name = return_value.get("variable_name").toString(); String value = return_value.get("value").toString(); if (name.equalsIgnoreCase("Max_used_connections")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_first")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_key")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_next")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_prev")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_rnd")) { name = "H"; } if (name.equalsIgnoreCase("Handler_read_rnd_next")) { name = ""; } if (name.equalsIgnoreCase("Open_tables")) { name = ""; } if (name.equalsIgnoreCase("Opened_tables")) { name = ""; } if (name.equalsIgnoreCase("Threads_cached")) { name = ""; } if (name.equalsIgnoreCase("Threads_connected")) { name = ""; } if (name.equalsIgnoreCase("Threads_created")) { name = ""; } if (name.equalsIgnoreCase("Threads_running")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_immediate")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_waited")) { name = ""; } if (name.equalsIgnoreCase("Key_read_requests")) { name = ""; } if (name.equalsIgnoreCase("Key_reads")) { name = ""; } if (name.equalsIgnoreCase("log_slow_queries")) { name = ""; } if (name.equalsIgnoreCase("slow_launch_time")) { name = "Slow_launch_threads"; } tmpLabel = new Label(0, row, name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, value, p_labelFormat); sheet.addCell(tmpLabel); row++; } } } // row = row + 2; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; if (sessionlist != null && sessionlist.size() > 0) { for (int i = 0; i < sessionlist.size(); i++) { List ipsessionlist = (List) sessionlist.get(i); if (ipsessionlist != null && ipsessionlist.size() > 0) { for (int k = 0; k < ipsessionlist.size(); k++) { String[] sessions = (String[]) ipsessionlist.get(k); if (sessions != null && sessions.length == 5) { tmpLabel = new Label(0, row, String.valueOf(k + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, sessions[4], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, sessions[0], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sessions[1], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, sessions[2], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, sessions[3], p_labelFormat); sheet.addCell(tmpLabel); row++; } } } } } // row = row + 2; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; String[] dbs = vo.getDbName().split(","); if (dbs != null && dbs.length > 0) { for (int i = 0; i < dbs.length; i++) { String dbStr = dbs[i]; // System.out.println(dbStr+"====="+tablesHash.size()); if (tablesHash.containsKey(dbStr)) { List tableslist = (List) tablesHash.get(dbStr); if (tableslist != null && tableslist.size() > 0) { for (int k = 0; k < tableslist.size(); k++) { String[] tables = (String[]) tableslist.get(k); if (tables != null && tables.length == 4) { tmpLabel = new Label(0, row, String.valueOf(k + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tables[0], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tables[1], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, tables[2], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, tables[3], p_labelFormat); sheet.addCell(tmpLabel); row++; } } } } } } // row = row + 2; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); row++; if (tableinfo_v != null) {// HONGLILI for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String size = ht.get("variable_name").toString(); String free = ht.get("value").toString(); if (size.equalsIgnoreCase("auto_increment_increment")) { size = ""; } if (size.equalsIgnoreCase("auto_increment_offset")) { size = "AUTO_INCREMENT"; } if (size.equalsIgnoreCase("automatic_sp_privileges")) { size = "automatic_sp_privileges"; } if (size.equalsIgnoreCase("back_log")) { size = ""; } if (size.equalsIgnoreCase("basedir")) { size = "MySQL"; } if (size.equalsIgnoreCase("binlog_cache_size")) { size = "SQL"; } if (size.equalsIgnoreCase("bulk_insert_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("character_set_client")) { size = ""; } if (size.equalsIgnoreCase("character_set_connection")) { size = ""; } if (size.equalsIgnoreCase("character_set_database")) { size = ""; } if (size.equalsIgnoreCase("character_set_filesystem")) { size = "character_set_filesystem"; } if (size.equalsIgnoreCase("character_set_results")) { size = ""; } if (size.equalsIgnoreCase("character_set_server")) { size = ""; } if (size.equalsIgnoreCase("character_set_system")) { size = ""; } if (size.equalsIgnoreCase("character_sets_dir")) { size = ""; } if (size.equalsIgnoreCase("collation_connection")) { size = ""; } if (size.equalsIgnoreCase("collation_database")) { size = ""; } if (size.equalsIgnoreCase("collation_server")) { size = ""; } if (size.equalsIgnoreCase("completion_type")) { size = ""; } if (size.equalsIgnoreCase("concurrent_insert")) { size = ""; } if (size.equalsIgnoreCase("connect_timeout")) { size = "Bad handshake"; } if (size.equalsIgnoreCase("datadir")) { size = "MySQL"; } if (size.equalsIgnoreCase("date_format")) { size = "date_format()"; } if (size.equalsIgnoreCase("datetime_format")) { size = "datetime_format()"; } if (size.equalsIgnoreCase("default_week_format")) { size = "WEEK() "; } if (size.equalsIgnoreCase("delay_key_write")) { size = "DELAY_KEY_WRITE"; } if (size.equalsIgnoreCase("delayed_insert_limit")) { size = "INSERT DELAYEDSELECT"; } if (size.equalsIgnoreCase("delayed_insert_timeout")) { size = "INSERT DELAYEDINSERT"; } if (size.equalsIgnoreCase("delayed_queue_size")) { size = "INSERT DELAYED"; } if (size.equalsIgnoreCase("div_precision_increment")) { size = "/"; } if (size.equalsIgnoreCase("engine_condition_pushdown")) { size = "NDB"; } if (size.equalsIgnoreCase("expire_logs_days")) { size = ""; } if (size.equalsIgnoreCase("flush")) { size = "flushmysqld"; } if (size.equalsIgnoreCase("flush_time")) { size = ""; } if (size.equalsIgnoreCase("ft_boolean_syntax")) { size = "IN BOOLEAN MODE"; } if (size.equalsIgnoreCase("ft_max_word_len")) { size = "FULLTEXT"; } if (size.equalsIgnoreCase("ft_min_word_len")) { size = "FULLTEXT"; } if (size.equalsIgnoreCase("ft_query_expansion_limit")) { size = "WITH QUERY EXPANSION"; } if (size.equalsIgnoreCase("ft_stopword_file")) { size = ""; } if (size.equalsIgnoreCase("group_concat_max_len")) { size = "GROUP_CONCAT()"; } if (size.equalsIgnoreCase("have_archive")) { size = "mysqldARCHIVE"; } if (size.equalsIgnoreCase("have_bdb")) { size = "mysqldBDB"; } if (size.equalsIgnoreCase("have_blackhole_engine")) { size = "mysqldBLACKHOLE"; } if (size.equalsIgnoreCase("have_compress")) { size = "zlib"; } if (size.equalsIgnoreCase("have_crypt")) { size = "crypt()"; } if (size.equalsIgnoreCase("have_csv")) { size = "mysqldARCHIVE"; } if (size.equalsIgnoreCase("have_example_engine")) { size = "mysqldEXAMPLE"; } if (size.equalsIgnoreCase("have_federated_engine")) { size = "mysqldFEDERATED"; } if (size.equalsIgnoreCase("have_geometry")) { size = ""; } if (size.equalsIgnoreCase("have_innodb")) { size = "mysqldInnoDB"; } if (size.equalsIgnoreCase("have_isam")) { size = ""; } if (size.equalsIgnoreCase("have_ndbcluster")) { size = "mysqldNDB CLUSTER"; } if (size.equalsIgnoreCase("have_openssl")) { size = "mysqld/SSL()"; } if (size.equalsIgnoreCase("have_query_cache")) { size = "mysqld"; } if (size.equalsIgnoreCase("have_raid")) { size = "mysqldRAID"; } if (size.equalsIgnoreCase("have_rtree_keys")) { size = "RTREE"; } if (size.equalsIgnoreCase("have_symlink")) { size = ""; } if (size.equalsIgnoreCase("init_connect")) { size = ""; } if (size.equalsIgnoreCase("init_file")) { size = "--init-file"; } if (size.equalsIgnoreCase("init_slave")) { size = "SQL"; } if (size.equalsIgnoreCase("innodb_additional_mem_pool_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_autoextend_increment")) { size = ""; } if (size.equalsIgnoreCase("innodb_buffer_pool_awe_mem_mb")) { size = "32WindowsAWE"; } if (size.equalsIgnoreCase("innodb_buffer_pool_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_checksums")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_commit_concurrency")) { size = "innodb_commit_concurrency"; } if (size.equalsIgnoreCase("innodb_concurrency_tickets")) { size = "innodb_concurrency_tickets"; } if (size.equalsIgnoreCase("innodb_data_file_path")) { size = ""; } if (size.equalsIgnoreCase("innodb_data_home_dir")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_doublewrite")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_fast_shutdown")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_file_io_threads")) { size = "InnoDBI/O"; } if (size.equalsIgnoreCase("innodb_file_per_table")) { size = "InnoDB.ibd"; } if (size.equalsIgnoreCase("innodb_flush_log_at_trx_commit")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_flush_method")) { size = "InnoDBfsync()"; } if (size.equalsIgnoreCase("innodb_force_recovery")) { size = ""; } if (size.equalsIgnoreCase("innodb_lock_wait_timeout")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_locks_unsafe_for_binlog")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_log_arch_dir")) { size = " "; } if (size.equalsIgnoreCase("innodb_log_archive")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_buffer_size")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_log_file_size")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_files_in_group")) { size = ""; } if (size.equalsIgnoreCase("innodb_log_group_home_dir")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_max_dirty_pages_pct")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_max_purge_lag")) { size = "INSERT,UPDATEDELETE"; } if (size.equalsIgnoreCase("innodb_mirrored_log_groups")) { size = ""; } if (size.equalsIgnoreCase("innodb_open_files")) { size = "InnoDB.ibd"; } if (size.equalsIgnoreCase("innodb_support_xa")) { size = "InnoDBXA"; } if (size.equalsIgnoreCase("innodb_sync_spin_loops")) { size = "innodb_sync_spin_loops"; } if (size.equalsIgnoreCase("innodb_table_locks")) { size = "InnoDB"; } if (size.equalsIgnoreCase("innodb_thread_concurrency")) { size = "InnoDBInnoDB"; } if (size.equalsIgnoreCase("innodb_thread_sleep_delay")) { size = "InnoDBSHOW INNODB STATUS<datadir>/innodb_status"; } if (size.equalsIgnoreCase("interactive_timeout")) { size = ""; } if (size.equalsIgnoreCase("join_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("key_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("key_cache_age_threshold")) { size = "(sub-chain)(sub-chain)"; } if (size.equalsIgnoreCase("key_cache_block_size")) { size = ""; } if (size.equalsIgnoreCase("key_cache_division_limit")) { size = ""; } if (size.equalsIgnoreCase("language")) { size = ""; } if (size.equalsIgnoreCase("large_files_support")) { size = "mysqld"; } if (size.equalsIgnoreCase("large_page_size")) { size = "large_page_size"; } if (size.equalsIgnoreCase("large_pages")) { size = ""; } if (size.equalsIgnoreCase("license")) { size = ""; } if (size.equalsIgnoreCase("local_infile")) { size = "LOCALLOAD DATA INFILE"; } if (size.equalsIgnoreCase("log")) { size = ""; } if (size.equalsIgnoreCase("log_bin")) { size = ""; } if (size.equalsIgnoreCase("log_bin_trust_function_creators")) { size = ""; } if (size.equalsIgnoreCase("log_error")) { size = ""; } if (size.equalsIgnoreCase("log_slave_updates")) { size = ""; } if (size.equalsIgnoreCase("log_slow_queries")) { size = ""; } if (size.equalsIgnoreCase("log_warnings")) { size = ""; } if (size.equalsIgnoreCase("long_query_time")) { size = "Slow_queries"; } if (size.equalsIgnoreCase("low_priority_updates")) { size = "sqlSELECTLOCK TABLE READ"; } if (size.equalsIgnoreCase("lower_case_file_system")) { size = ""; } if (size.equalsIgnoreCase("lower_case_table_names")) { size = "1"; } if (size.equalsIgnoreCase("max_allowed_packet")) { size = "/"; } if (size.equalsIgnoreCase("max_binlog_cache_size")) { size = ""; } if (size.equalsIgnoreCase("max_binlog_size")) { size = ""; } if (size.equalsIgnoreCase("max_connect_errors")) { size = ""; } if (size.equalsIgnoreCase("max_connections")) { size = ""; } if (size.equalsIgnoreCase("max_delayed_threads")) { size = "INSERT DELAYED"; } if (size.equalsIgnoreCase("max_error_count")) { size = "SHOW ERRORSSHOW WARNINGS"; } if (size.equalsIgnoreCase("max_heap_table_size")) { size = "MEMORY (HEAP)"; } if (size.equalsIgnoreCase("max_insert_delayed_threads")) { size = "INSERT DELAYED(max_delayed_threads)"; } if (size.equalsIgnoreCase("max_join_size")) { size = "max_join_size"; } if (size.equalsIgnoreCase("max_length_for_sort_data")) { size = "filesort"; } if (size.equalsIgnoreCase("max_prepared_stmt_count")) { size = "max_prepared_stmt_count"; } if (size.equalsIgnoreCase("max_relay_log_size")) { size = ""; } if (size.equalsIgnoreCase("max_seeks_for_key")) { size = ""; } if (size.equalsIgnoreCase("max_sort_length")) { size = "BLOBTEXT"; } if (size.equalsIgnoreCase("max_sp_recursion_depth")) { size = "max_sp_recursion_depth"; } if (size.equalsIgnoreCase("max_tmp_tables")) { size = ""; } if (size.equalsIgnoreCase("max_user_connections")) { size = "MySQL"; } if (size.equalsIgnoreCase("max_write_lock_count")) { size = ""; } if (size.equalsIgnoreCase("multi_range_count")) { size = "multi_range_count"; } if (size.equalsIgnoreCase("myisam_data_pointer_size")) { size = ""; } if (size.equalsIgnoreCase("myisam_max_sort_file_size")) { size = "MyISAMMySQL"; } if (size.equalsIgnoreCase("myisam_recover_options")) { size = "myisam-recover"; } if (size.equalsIgnoreCase("myisam_repair_threads")) { size = "1Repair by sortingMyISAM"; } if (size.equalsIgnoreCase("myisam_sort_buffer_size")) { size = "REPAIR TABLECREATE INDEXALTER TABLEMyISAM"; } if (size.equalsIgnoreCase("myisam_stats_method")) { size = "MyISAMNULL"; } if (size.equalsIgnoreCase("named_pipe")) { size = ""; } if (size.equalsIgnoreCase("net_buffer_length")) { size = ""; } if (size.equalsIgnoreCase("net_read_timeout")) { size = ""; } if (size.equalsIgnoreCase("net_retry_count")) { size = ""; } if (size.equalsIgnoreCase("net_write_timeout")) { size = ""; } if (size.equalsIgnoreCase("new")) { size = "MySQL 4.04.1"; } if (size.equalsIgnoreCase("old_passwords")) { size = "MySQLpre-4.1-style"; } if (size.equalsIgnoreCase("open_files_limit")) { size = "mysqld"; } if (size.equalsIgnoreCase("optimizer_prune_level")) { size = " 0"; } if (size.equalsIgnoreCase("optimizer_search_depth")) { size = ""; } if (size.equalsIgnoreCase("pid_file")) { size = "ID (PID)"; } if (size.equalsIgnoreCase("prepared_stmt_count")) { size = "prepared_stmt_count"; } if (size.equalsIgnoreCase("port")) { size = "TCP/IP"; } if (size.equalsIgnoreCase("preload_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("protocol_version")) { size = "MySQL/"; } if (size.equalsIgnoreCase("query_alloc_block_size")) { size = ""; } if (size.equalsIgnoreCase("query_cache_limit")) { size = ""; } if (size.equalsIgnoreCase("query_cache_min_res_unit")) { size = "()"; } if (size.equalsIgnoreCase("query_cache_size")) { size = ""; } if (size.equalsIgnoreCase("query_cache_type")) { size = ""; } if (size.equalsIgnoreCase("query_cache_wlock_invalidate")) { size = "WRITE"; } if (size.equalsIgnoreCase("query_prealloc_size")) { size = ""; } if (size.equalsIgnoreCase("range_alloc_block_size")) { size = ""; } if (size.equalsIgnoreCase("read_buffer_size")) { size = "()"; } if (size.equalsIgnoreCase("read_only")) { size = "ON"; } if (size.equalsIgnoreCase("read_only")) { size = "ON"; } if (size.equalsIgnoreCase("relay_log_purge")) { size = ""; } if (size.equalsIgnoreCase("read_rnd_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("secure_auth")) { size = "--secure-authMySQL(4.1)"; } if (size.equalsIgnoreCase("shared_memory")) { size = "(Windows)"; } if (size.equalsIgnoreCase("shared_memory_base_name")) { size = "(Windows)"; } if (size.equalsIgnoreCase("server_id")) { size = ""; } if (size.equalsIgnoreCase("skip_external_locking")) { size = "mysqld"; } if (size.equalsIgnoreCase("skip_networking")) { size = "(TCP/IP)"; } if (size.equalsIgnoreCase("skip_show_database")) { size = "SHOW DATABASESSHOW DATABASES"; } if (size.equalsIgnoreCase("slave_compressed_protocol")) { size = "/"; } if (size.equalsIgnoreCase("slave_load_tmpdir")) { size = "LOAD DATA INFILE"; } if (size.equalsIgnoreCase("slave_net_timeout")) { size = "/"; } if (size.equalsIgnoreCase("slave_skip_errors")) { size = "()"; } if (size.equalsIgnoreCase("slave_transaction_retries")) { size = "SQLslave_transaction_retries"; } if (size.equalsIgnoreCase("slow_launch_time")) { size = "Slow_launch_threads"; } if (size.equalsIgnoreCase("sort_buffer_size")) { size = ""; } if (size.equalsIgnoreCase("sql_mode")) { size = "SQL"; } if (size.equalsIgnoreCase("storage_engine")) { size = "table_typeisMySQL 5.1,storage_engine"; } if (size.equalsIgnoreCase("sync_binlog")) { size = "sync_binlog'thMySQL"; } if (size.equalsIgnoreCase("sync_frm")) { size = "1,.frm"; } if (size.equalsIgnoreCase("system_time_zone")) { size = ""; } if (size.equalsIgnoreCase("table_cache")) { size = ""; } if (size.equalsIgnoreCase("table_type")) { size = "()"; } if (size.equalsIgnoreCase("thread_cache_size")) { size = ""; } if (size.equalsIgnoreCase("thread_stack")) { size = ""; } if (size.equalsIgnoreCase("time_format")) { size = ""; } if (size.equalsIgnoreCase("time_zone")) { size = ""; } if (size.equalsIgnoreCase("tmp_table_size")) { size = "MySQLMyISAM"; } if (size.equalsIgnoreCase("tmpdir")) { size = ""; } if (size.equalsIgnoreCase("transaction_alloc_block_size")) { size = "()"; } if (size.equalsIgnoreCase("transaction_prealloc_size")) { size = "transaction_alloc_blocks"; } if (size.equalsIgnoreCase("tx_isolation")) { size = ""; } if (size.equalsIgnoreCase("updatable_views_with_limit")) { size = "LIMIT"; } if (size.equalsIgnoreCase("version")) { size = ""; } if (size.equalsIgnoreCase("version_bdb")) { size = "BDB"; } if (size.equalsIgnoreCase("version_comment")) { size = "configure--with-commentMySQL"; } if (size.equalsIgnoreCase("version_compile_machine")) { size = "MySQL"; } if (size.equalsIgnoreCase("version_compile_os")) { size = "MySQL"; } if (size.equalsIgnoreCase("wait_timeout")) { size = ""; } tmpLabel = new Label(0, row, String.valueOf(i + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, free, p_labelFormat); sheet.addCell(tmpLabel); row++; } } // row = row + 2; this.addEventReport(sheet, reportHash, row); row++; // addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } /** * Excel * * @param sheet * @param row * @return * @throws WriteException * @throws RowsExceededException */ private void addEventListToExcel(WritableSheet sheet, int row) throws WriteException, RowsExceededException { WritableCellFormat red_labelFormat = new WritableCellFormat(); WritableCellFormat orange_labelFormat = new WritableCellFormat(); WritableCellFormat yellow_labelFormat = new WritableCellFormat(); red_labelFormat.setBackground(jxl.format.Colour.RED); orange_labelFormat.setBackground(jxl.format.Colour.ORANGE); yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW); Label tmpLabel; row = row + 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; int index = 0; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); List list = (ArrayList) reportHash.get("list"); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { p_labelFormat = this.colorChange(i); index++; EventList eventlist = (EventList) list.get(i); Date cc = eventlist.getRecordtime().getTime(); Integer eventid = eventlist.getId(); String eventlocation = eventlist.getEventlocation(); String content = eventlist.getContent(); String level = String.valueOf(eventlist.getLevel1()); String status = String.valueOf(eventlist.getManagesign()); String s = status; String showlevel = null; String act = ""; if ("1".equals(level)) { showlevel = ""; } else if ("2".equals(level)) { showlevel = ""; } else { showlevel = ""; } if ("0".equals(status)) { status = ""; } if ("1".equals(status)) { status = ""; } if ("2".equals(status)) { status = ""; } String rptman = eventlist.getReportman(); String rtime1 = _sdf.format(cc); tmpLabel = new Label(0, row, String.valueOf(index), p_labelFormat); sheet.addCell(tmpLabel); if ("3".equals(level)) { tmpLabel = new Label(1, row, showlevel, red_labelFormat); sheet.addCell(tmpLabel); } else if ("2".equals(level)) { tmpLabel = new Label(1, row, showlevel, orange_labelFormat); sheet.addCell(tmpLabel); } else { tmpLabel = new Label(1, row, showlevel, yellow_labelFormat); sheet.addCell(tmpLabel); } tmpLabel = new Label(3, row, content, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, rtime1, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, rptman, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, status, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } } /** * PDF * * @param document * @throws DocumentException * @throws IOException */ private void addEventLisToPdf(Document document) throws DocumentException, IOException { // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Cell cell; Table eventListTable = new Table(6); this.setTableFormat(eventListTable); float[] eventListWidths = { 220f, 220f, 440f, 220f, 220f, 220f }; eventListTable.setWidths(eventListWidths); // eventListTable.setWidthPercentage(100); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(6); this.setCellFormat(cell, true); eventListTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); eventListTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); eventListTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); eventListTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); eventListTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); eventListTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); eventListTable.addCell(cell); int index = 0; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); List list = (ArrayList) reportHash.get("list"); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { index++; EventList eventlist = (EventList) list.get(i); Date cc = eventlist.getRecordtime().getTime(); Integer eventid = eventlist.getId(); String eventlocation = eventlist.getEventlocation(); String content = eventlist.getContent(); String level = String.valueOf(eventlist.getLevel1()); String status = String.valueOf(eventlist.getManagesign()); String s = status; String showlevel = null; String act = ""; if ("1".equals(level)) { showlevel = ""; } else if ("2".equals(level)) { showlevel = ""; } else { showlevel = ""; } if ("0".equals(status)) { status = ""; } if ("1".equals(status)) { status = ""; } if ("2".equals(status)) { status = ""; } String rptman = eventlist.getReportman(); String rtime1 = _sdf.format(cc); cell = new Cell(new Phrase(String.valueOf(index), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventListTable.addCell(cell); if ("3".equals(level)) { cell = new Cell(new Phrase(showlevel, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setBackgroundColor(Color.red); eventListTable.addCell(cell); } else if ("2".equals(level)) { cell = new Cell(new Phrase(showlevel, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setBackgroundColor(Color.orange); eventListTable.addCell(cell); } else { cell = new Cell(new Phrase(showlevel, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setBackgroundColor(Color.yellow); eventListTable.addCell(cell); } cell = new Cell(new Phrase(content, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventListTable.addCell(cell); cell = new Cell(new Phrase(rtime1, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventListTable.addCell(cell); cell = new Cell(new Phrase(rptman, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventListTable.addCell(cell); cell = new Cell(new Phrase(status, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // eventListTable.addCell(cell); } } document.add(eventListTable); } /** * DOC * * @param document * @param titleFont * @param contextFont * @throws BadElementException * @throws DocumentException */ private void addEventListToDoc(Document document, Font titleFont, Font contextFont) throws BadElementException, DocumentException { Cell cell; // Table eventTable = new Table(6); this.setTableFormat(eventTable); // float[] eventWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; // eventTable.setWidths(eventWidths); // eventTable.setWidth(100); // 90% // eventTable.setAlignment(Element.ALIGN_CENTER);// // eventTable.setAutoFillEmptyCells(true); // // eventTable.setBorderWidth(1); // // eventTable.setBorderColor(new Color(0, 125, 255)); // // eventTable.setPadding(2);// // eventTable.setSpacing(0);// // eventTable.setBorder(2);// // eventTable.endHeaders(); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); cell.setColspan(6); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); eventTable.addCell(cell); int index = 0; java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm"); List list = (ArrayList) reportHash.get("list"); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { index++; EventList eventlist = (EventList) list.get(i); Date cc = eventlist.getRecordtime().getTime(); Integer eventid = eventlist.getId(); String eventlocation = eventlist.getEventlocation(); String content = eventlist.getContent(); String level = String.valueOf(eventlist.getLevel1()); String status = String.valueOf(eventlist.getManagesign()); String s = status; String showlevel = null; String act = ""; if ("1".equals(level)) { showlevel = ""; } else if ("2".equals(level)) { showlevel = ""; } else { showlevel = ""; } if ("0".equals(status)) { status = ""; } if ("1".equals(status)) { status = ""; } if ("2".equals(status)) { status = ""; } String rptman = eventlist.getReportman(); String rtime1 = _sdf.format(cc); cell = new Cell(new Phrase(String.valueOf(index), contextFont)); this.setCellFormat(cell, false); eventTable.addCell(cell); cell = new Cell(new Phrase(showlevel, contextFont)); this.setCellFormat(cell, false); if ("3".equals(level)) { cell.setBackgroundColor(Color.red); } else if ("2".equals(level)) { cell.setBackgroundColor(Color.orange); } else { cell.setBackgroundColor(Color.yellow); } eventTable.addCell(cell); cell = new Cell(new Phrase(content, contextFont)); this.setCellFormat(cell, false); eventTable.addCell(cell); cell = new Cell(new Phrase(rtime1, contextFont)); this.setCellFormat(cell, false); eventTable.addCell(cell); cell = new Cell(new Phrase(rptman, contextFont)); this.setCellFormat(cell, false); eventTable.addCell(cell); cell = new Cell(new Phrase(status, contextFont)); this.setCellFormat(cell, false); eventTable.addCell(cell); } } document.add(eventTable); } /** * @author sunqichang/ * * * @param sheet * @param reportHash */ protected void createReportTitle(WritableSheet sheet, Hashtable reportHash) { Label tmpLabel = null; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String hostname = (String) reportHash.get("equipname"); Calendar colTime = (Calendar) reportHash.get("time"); Date cc = new Date(); if (colTime != null) cc = colTime.getTime(); tmpLabel = new Label(0, 0, hostname + "", labelFormat); try { sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 9, 0); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat); sheet.mergeCells(0, 1, 9, 1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ":" + sdf.format(cc), labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 2, 9, 2); } catch (RowsExceededException e) { SysLogger.error("", e); } catch (WriteException e) { SysLogger.error("", e); } } /** * @author sunqichang/ * * cpuExcel * @param sheet * @param ip * @param reportHash */ protected void createPingAndCpu(WritableSheet sheet, String ip, Hashtable reportHash) { Label tmpLabel = null; Hashtable CPU = (Hashtable) reportHash.get("CPU"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String Ping = (String) reportHash.get("Ping"); // String ip = (String) reportHash.get("ip"); String newip = doip(ip); try { tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 4, 0, 12); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, Ping + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, 6, 9, 7, file)); tmpLabel = new Label(0, 14, "CPU", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 14, 0, 22); tmpLabel = new Label(1, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 15, (String) CPU.get("cpu") + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 15, (String) CPU.get("cpumax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 15, (String) CPU.get("avgcpu"), p_labelFormat); sheet.addCell(tmpLabel); // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, 16, 9, 7, file)); int[] row = { 4, 5, 14, 15 }; for (int x : row) { sheet.mergeCells(1, x, 3, x); sheet.mergeCells(4, x, 6, x); sheet.mergeCells(7, x, 9, x); } } catch (RowsExceededException e) { SysLogger.error("", e); } catch (WriteException e) { SysLogger.error("", e); } } /** * @author sunqichang/ * * * @param sheet * @param ip * @param reportHash */ protected void createMemory(WritableSheet sheet, String ip, Hashtable reportHash) { int allRow = 24; Label label = null; Label tmpLabel = null; String[] memoryItemch = { "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash"); // String ip = (String) reportHash.get("ip"); String newip = doip(ip); try { tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, allRow, 0, allRow + 10); // label = new Label(1, allRow, "", _labelFormat); sheet.addCell(label); int count = 0; for (int i = 0; i < memoryItemch.length; i++) { label = new Label(count + 2, allRow, memoryItemch[i], _labelFormat); sheet.addCell(label); sheet.mergeCells(count + 2, allRow, count + 2 + 1, allRow); count += 2; } File file; if (Memory != null && Memory.size() > 0) { // for (int i = 0; i < Memory.size(); i++) { p_labelFormat = colorChange(i); Hashtable mhash = (Hashtable) (Memory.get(new Integer(i))); String name = (String) mhash.get("name"); allRow = allRow + 1; label = new Label(1, allRow, name, p_labelFormat); sheet.addCell(label); int count1 = 0; for (int j = 0; j < memoryItem.length; j++) { String value = ""; if (mhash.get(memoryItem[j]) != null) { value = (String) mhash.get(memoryItem[j]); } label = new Label(count1 + 2, allRow, value, p_labelFormat); sheet.addCell(label); sheet.mergeCells(count1 + 2, allRow, count1 + 2 + 1, allRow); count1 += 2; } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); label = new Label(memoryItem.length + 4, allRow, value, p_labelFormat); sheet.addCell(label); sheet.mergeCells(memoryItem.length + 4, allRow, memoryItem.length + 4 + 1, allRow); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); label = new Label(memoryItem.length + 6, allRow, avgvalue, p_labelFormat); sheet.addCell(label); sheet.mergeCells(memoryItem.length + 6, allRow, memoryItem.length + 6 + 1, allRow); } } // end // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 1; sheet.addImage(new WritableImage(1, allRow, 9, 8, file)); } else { // String[] names = null; HostNodeDao dao = new HostNodeDao(); HostNode node = (HostNode) dao.findByCondition("ip_address", ip).get(0); // Monitoriplist monitor = monitorManager.getByIpaddress(ip); if (node.getSysOid().startsWith("1.3.6.1.4.1.311")) { names = new String[] { "PhysicalMemory", "VirtualMemory" }; } else { names = new String[] { "PhysicalMemory", "SwapMemory" }; } for (int i = 0; i < names.length; i++) { p_labelFormat = colorChange(i); String name = names[i]; allRow = allRow + 1; label = new Label(1, allRow, names[i], p_labelFormat); sheet.addCell(label); int count2 = 0; for (int j = 0; j < memoryItem.length; j++) { // String value = ""; label = new Label(j + 2, allRow, value, p_labelFormat); sheet.addCell(label); sheet.mergeCells(count2 + 2, allRow, count2 + 2 + 1, allRow); count2 += 2; } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); label = new Label(memoryItem.length + 4, allRow, value, p_labelFormat); sheet.addCell(label); } else { label = new Label(memoryItem.length + 4, allRow, value, p_labelFormat); sheet.addCell(label); } sheet.mergeCells(memoryItem.length + 4, allRow, memoryItem.length + 4 + 1, allRow); String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); label = new Label(memoryItem.length + 5, allRow, avgvalue, p_labelFormat); sheet.addCell(label); } else { label = new Label(memoryItem.length + 6, allRow, avgvalue, p_labelFormat); sheet.addCell(label); } sheet.mergeCells(memoryItem.length + 6, allRow, memoryItem.length + 6 + 1, allRow); } // end // file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "memory" + ".png"); // sheet,0,0,5,1,,, allRow = allRow + 1; sheet.addImage(new WritableImage(1, allRow, 9, 8, file)); } } catch (RowsExceededException e) { SysLogger.error("", e); } catch (WriteException e) { SysLogger.error("", e); } } /** * @author sunqichang/ * * * @param sheet * @param ip * @param reportHash */ protected void createDisk(WritableSheet sheet, String ip, Hashtable reportHash) { Label tmpLabel = null; int allRow = 36; String[] diskItem = { "AllSize", "UsedSize", "Utilization" }; String[] diskItemch = { "", "", "" }; Hashtable Disk = (Hashtable) reportHash.get("Disk"); // String ip = (String) reportHash.get("ip"); String newip = doip(ip); try { if (Disk != null && Disk.size() > 0) { // memoryRow = Disk.size(); tmpLabel = new Label(0, allRow, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, allRow, 0, allRow + Disk.size() + 9); // Label label = new Label(1, allRow, "", _labelFormat); sheet.addCell(label); sheet.mergeCells(1, allRow, 3, allRow); int count = 0; for (int i = 0; i < diskItemch.length; i++) { label = new Label(count + 4, allRow, diskItemch[i], _labelFormat); sheet.addCell(label); sheet.mergeCells(4 + count, allRow, 4 + count + 1, allRow); count += 2; } // for (int i = 0; i < Disk.size(); i++) { Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i))); String name = (String) diskhash.get("name"); allRow = allRow + 1; p_labelFormat = colorChange(i); label = new Label(1, allRow, name, p_labelFormat); sheet.addCell(label); sheet.mergeCells(1, allRow, 3, allRow); int count1 = 0; for (int j = 0; j < diskItem.length; j++) { String value = ""; if (diskhash.get(diskItem[j]) != null) { value = (String) diskhash.get(diskItem[j]); } label = new Label(count1 + 4, allRow, value, p_labelFormat); sheet.addCell(label); sheet.mergeCells(4 + count1, allRow, 4 + count1 + 1, allRow); count1 += 2; } } // end // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "disk" + ".png"); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, allRow + 1, 9, 9, file)); } } catch (RowsExceededException e) { SysLogger.error("", e); } catch (WriteException e) { SysLogger.error("", e); } } /** * @author sunqichang * @param sheet * @param ip * @param reportHash */ private void dbTitlePing(WritableSheet sheet, String ip, Hashtable reportHash) { String newip = doip(ip); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String hostname = (String) reportHash.get("dbname"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Label tmpLabel = null; try { tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 10, 0); sheet.mergeCells(0, 1, 10, 1); sheet.mergeCells(0, 2, 10, 2); // ip tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 4, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 4, 1, 4); sheet.mergeCells(2, 4, 3, 4); sheet.mergeCells(4, 4, 5, 4); sheet.mergeCells(6, 4, 7, 4); sheet.mergeCells(8, 4, 10, 4); tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, typename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5, runstr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 5, grade, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 5, 1, 5); sheet.mergeCells(2, 5, 3, 5); sheet.mergeCells(4, 5, 5, 5); sheet.mergeCells(6, 5, 7, 5); sheet.mergeCells(8, 5, 10, 5); // tmpLabel = new Label(0, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 7, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 7, 2, 7); sheet.mergeCells(3, 7, 5, 7); sheet.mergeCells(6, 7, 10, 7); tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 8, pingmin + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 8, pingconavg + "%", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 8, 2, 8); sheet.mergeCells(3, 8, 5, 8); sheet.mergeCells(6, 8, 10, 8); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(0, 9, 11, 8, file)); // allRow = allRow+7; } catch (Exception e) { SysLogger.error("", e); } } /** * @author sqc * @param sheet * @param report_has * @param row */ private void addEventReport(WritableSheet sheet, Hashtable reportHash, int row) { Label tmpLabel = null; try { tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 4, row); sheet.mergeCells(5, row, 10, row); row++; p_labelFormat = this.colorChange(0); tmpLabel = new Label(0, row, (String) reportHash.get("downnum"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, reportHash.get("count") + "", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 4, row); sheet.mergeCells(5, row, 10, row); row++; } catch (RowsExceededException e) { SysLogger.error("", e); } catch (WriteException e) { SysLogger.error("", e); } } public void createReport_cabinet(String filename, String room) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet(room + "", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); List cabinetlist = (List) reportHash.get("cabinetlist"); Integer index = (Integer) reportHash.get("startRow"); int startRow = 1; if (null != index) { startRow = index.intValue(); } Label tmpLabel = null; // tmpLabel = new Label(2, 0, room + "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "U", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, "U", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "U", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 1, "U%", _labelFormat); sheet.addCell(tmpLabel); Cabinet cabinet = null; for (int i = 0; i < cabinetlist.size(); i++) { cabinet = (Cabinet) cabinetlist.get(i); // row = row + (i); tmpLabel = new Label(0, 2 + i, 1 + i + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, cabinet.getName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2 + i, cabinet.getAllu(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2 + i, cabinet.getUseu(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2 + i, cabinet.getTempu(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 2 + i, cabinet.getRateu() + "", p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_cabinetPdf(String filename, String room) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // new File(filename) BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); // Paragraph title = new Paragraph(room + "", titleFont); // // title.setAlignment(Element.ALIGN_CENTER); // // title.setFont(titleFont); // document.add(title); List cabinetlist = (List) reportHash.get("cabinetlist"); // Paragraph context = new Paragraph(); // // // context.setAlignment(Element.ALIGN_LEFT); //// context.setFont(contextFont); // // // context.setSpacingBefore(5); // // // context.setFirstLineIndent(6); // document.add(context); // document.add(new Paragraph("\n")); PdfPTable aTable = new PdfPTable(6); PdfPCell cell = null; cell = new PdfPCell(new Phrase(room + "", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("U", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("U", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("U", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("U(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Cabinet cabinet = null; if (cabinetlist != null && cabinetlist.size() > 0) { for (int i = 0; i < cabinetlist.size(); i++) { cabinet = (Cabinet) cabinetlist.get(i); cell = new PdfPCell(new Phrase(1 + i + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String cc = cabinet.getName(); cell = new PdfPCell(new Phrase(cabinet.getName(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(cabinet.getAllu(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(cabinet.getUseu(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(cabinet.getTempu(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(cabinet.getRateu(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); } catch (Exception e) { // TODO: handle exception } } public void createReport_equipmentPdf(String filename, String roomname, String cabinetname, String uselect, String unumber, String rate) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // new File(filename) BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); // Paragraph title = new Paragraph(room + "", titleFont); // // title.setAlignment(Element.ALIGN_CENTER); // // title.setFont(titleFont); // document.add(title); List equipmentlist = (List) reportHash.get("equipmentlist"); // Paragraph context = new Paragraph(); // // // context.setAlignment(Element.ALIGN_LEFT); //// context.setFont(contextFont); // // // context.setSpacingBefore(5); // // // context.setFirstLineIndent(6); // document.add(context); // document.add(new Paragraph("\n")); PdfPTable aTable = new PdfPTable(6); PdfPCell cell = null; cell = new PdfPCell(new Phrase(roomname + cabinetname + "", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + roomname, titleFont)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + cabinetname, titleFont)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("U:" + uselect, titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + unumber, titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + rate, titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); EquipmentReport equipmentReport = null; if (equipmentlist != null && equipmentlist.size() > 0) { for (int i = 0; i < equipmentlist.size(); i++) { equipmentReport = (EquipmentReport) equipmentlist.get(i); cell = new PdfPCell(new Phrase(1 + i + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(equipmentReport.getEquipmentname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(equipmentReport.getEquipmentdesc(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(equipmentReport.getOperation(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(equipmentReport.getContactname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(equipmentReport.getContactphone(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); } catch (Exception e) { // TODO: handle exception } } public void createReport_OperEquipmentPdf(String filename, String opername, String contactname, String contactphone) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // new File(filename) BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); // Paragraph title = new Paragraph(room + "", titleFont); // // title.setAlignment(Element.ALIGN_CENTER); // // title.setFont(titleFont); // document.add(title); List equipmentlist = (List) reportHash.get("equipmentlist"); // Paragraph context = new Paragraph(); // // // context.setAlignment(Element.ALIGN_LEFT); //// context.setFont(contextFont); // // // context.setSpacingBefore(5); // // // context.setFirstLineIndent(6); // document.add(context); // document.add(new Paragraph("\n")); PdfPTable aTable = new PdfPTable(7); PdfPCell cell = null; cell = new PdfPCell(new Phrase(opername + "", titleFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + opername, titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + contactname, titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + contactphone, titleFont)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("U", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); OperCabinet operCabinet = null; if (equipmentlist != null && equipmentlist.size() > 0) { for (int i = 0; i < equipmentlist.size(); i++) { operCabinet = (OperCabinet) equipmentlist.get(i); cell = new PdfPCell(new Phrase(operCabinet.getRoomname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(operCabinet.getCabinetname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(operCabinet.getUseu(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(operCabinet.getEquipmentname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(operCabinet.getIpaddress(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(operCabinet.getContactname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(operCabinet.getContactphone(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); } catch (Exception e) { // TODO: handle exception } } public void createReport_cabinetWord(String filename, String room) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // new File(filename) BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); // title.setFont(titleFont); List cabinetlist = (List) reportHash.get("cabinetlist"); Paragraph context = new Paragraph(); // context.setAlignment(Element.ALIGN_CENTER); // context.setFont(contextFont); // // context.setSpacingBefore(0); // // context.setFirstLineIndent(6); // document.add(context); // document.add(new Paragraph("\n")); Table aTable = new Table(6); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(4);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase(room + "", titleFont)); cell.setRowspan(2); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U(%)", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Cabinet cabinet = null; if (cabinetlist != null && cabinetlist.size() > 0) { for (int i = 0; i < cabinetlist.size(); i++) { cabinet = (Cabinet) cabinetlist.get(i); cell = new Cell(new Phrase(1 + i + "", contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getName(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getAllu(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getUseu(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getTempu(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getRateu(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); } catch (Exception e) { // TODO: handle exception } } public void createReport_equipmentWord(String filename, String roomname, String cabinetname, String uselect, String unumber, String rate) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // new File(filename) BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); // title.setFont(titleFont); List equipmentlist = (List) reportHash.get("equipmentlist"); Paragraph context = new Paragraph(); // context.setAlignment(Element.ALIGN_CENTER); // context.setFont(contextFont); // // context.setSpacingBefore(0); // // context.setFirstLineIndent(6); // document.add(context); // document.add(new Paragraph("\n")); Table aTable = new Table(6); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(4);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase(roomname + cabinetname + "", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + roomname, titleFont)); cell.setColspan(3); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + cabinetname, titleFont)); cell.setColspan(3); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U:" + uselect, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + unumber, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + rate, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); EquipmentReport equipmentReport = null; if (equipmentlist != null && equipmentlist.size() > 0) { for (int i = 0; i < equipmentlist.size(); i++) { equipmentReport = (EquipmentReport) equipmentlist.get(i); cell = new Cell(new Phrase(1 + i + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getEquipmentname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getEquipmentdesc(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getOperation(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getContactname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getContactphone(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); } catch (Exception e) { // TODO: handle exception } } public void createReport_OperEquipmentWord(String filename, String opername, String contactname, String contactphone) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // new File(filename) BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); // title.setFont(titleFont); List equipmentlist = (List) reportHash.get("equipmentlist"); Paragraph context = new Paragraph(); // context.setAlignment(Element.ALIGN_CENTER); // context.setFont(contextFont); // // context.setSpacingBefore(0); // // context.setFirstLineIndent(6); // document.add(context); // document.add(new Paragraph("\n")); Table aTable = new Table(7); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(4);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase(opername + "", titleFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + opername, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + contactname, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + contactphone, titleFont)); cell.setColspan(3); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); OperCabinet operCabinet = null; if (equipmentlist != null && equipmentlist.size() > 0) { for (int i = 0; i < equipmentlist.size(); i++) { operCabinet = (OperCabinet) equipmentlist.get(i); cell = new Cell(new Phrase(operCabinet.getRoomname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getCabinetname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getUseu(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getEquipmentname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getIpaddress(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getCabinetname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getContactphone(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); } catch (Exception e) { // TODO: handle exception } } public void createReport_OperEquipment(String filename, String opername, String contactname, String contactphone) { if (impReport.getTable() == null) { fileName = null; return; } //TODO WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet(opername + "", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); List equipmentlist = (List) reportHash.get("equipmentlist"); Integer index = (Integer) reportHash.get("startRow"); int startRow = 1; if (null != index) { startRow = index.intValue(); } Label tmpLabel = null; // tmpLabel = new Label(2, 0, opername + "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, opername, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, contactname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 1, "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 1, contactphone, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2, "U", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 2, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 2, "", _labelFormat); sheet.addCell(tmpLabel); OperCabinet operCabinet = null; for (int i = 0; i < equipmentlist.size(); i++) { operCabinet = (OperCabinet) equipmentlist.get(i); // row = row + (i); tmpLabel = new Label(0, 3 + i, 1 + i + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 3 + i, operCabinet.getRoomname(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 3 + i, operCabinet.getCabinetname(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 3 + i, operCabinet.getUseu(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 3 + i, operCabinet.getIpaddress(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 3 + i, operCabinet.getContactname(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 3 + i, operCabinet.getContactphone(), p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_equipment(String filename, String roomname, String cabinetname, String uselect, String unumber, String rate) { if (impReport.getTable() == null) { fileName = null; return; } //TODO WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet(roomname + cabinetname + "", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); List equipmentlist = (List) reportHash.get("equipmentlist"); Integer index = (Integer) reportHash.get("startRow"); int startRow = 1; if (null != index) { startRow = index.intValue(); } Label tmpLabel = null; // tmpLabel = new Label(2, 0, roomname + cabinetname + "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, roomname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 1, "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 1, cabinetname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, "U", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2, uselect, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 2, "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 2, unumber, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 2, "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 2, rate, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 3, "U", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 3, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 3, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 3, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 3, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 3, "", _labelFormat); sheet.addCell(tmpLabel); EquipmentReport equipmentReport = null; for (int i = 0; i < equipmentlist.size(); i++) { equipmentReport = (EquipmentReport) equipmentlist.get(i); // row = row + (i); tmpLabel = new Label(0, 4 + i, 1 + i + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4 + i, equipmentReport.getEquipmentname(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4 + i, equipmentReport.getEquipmentdesc(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4 + i, equipmentReport.getOperation(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4 + i, equipmentReport.getContactname(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4 + i, equipmentReport.getContactphone(), p_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_ipallotlist(String filename, String[] value, Object key) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet = wb.createSheet("IP", 0); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.WHITE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.WHITE); Label tmpLabel = null; // tmpLabel = new Label(2, 0, key + ".*", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 1, "ip", p_labelFormat); sheet.addCell(tmpLabel); for (int i = 0; i < value.length; i++) { tmpLabel = new Label(0, 2 + i, i + 1 + "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 2 + i, value[i], b_labelFormat); sheet.addCell(tmpLabel); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } public void createReport_hosttop(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String jp = (String) reportHash.get("jp"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("disklist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; if (jp.equals("0")) { tmpLabel = new Label(0, 0, "CPU", labelFormat); } else if (jp.equals("1")) { tmpLabel = new Label(0, 0, "", labelFormat); } else if (jp.equals("2")) { tmpLabel = new Label(0, 0, "", labelFormat); } else { tmpLabel = new Label(0, 0, "errpt", labelFormat); } sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 3, 0); sheet.mergeCells(0, 1, 3, 1); sheet.mergeCells(0, 2, 3, 2); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); int row = 5; if (memlist != null && memlist.size() > 0) { for (int i = 0; i < memlist.size(); i++) { p_labelFormat = super.colorChange(i); List mlist = (List) memlist.get(i); row = row + (i); tmpLabel = new Label(0, 5 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5 + i, (String) mlist.get(0), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5 + i, (String) mlist.get(1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5 + i, (String) mlist.get(2), p_labelFormat); sheet.addCell(tmpLabel); } } /* * if(impReport.getChart()!=null){ ByteArrayOutputStream baos = new * ByteArrayOutputStream(); try { * ChartUtilities.writeChartAsPNG(baos, * impReport.getChart().getChart(),impReport.getChart().getWidth(),impReport.getChart().getHeight()); } * catch (IOException ioe){} WritableImage wi = new * WritableImage(2,10000 + 5, 8, 12, baos.toByteArray()); * sheet.addImage(wi); } */ wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } } }