Example usage for java.util Hashtable keySet

List of usage examples for java.util Hashtable keySet

Introduction

In this page you can find the example usage for java.util Hashtable keySet.

Prototype

Set keySet

To view the source code for java.util Hashtable keySet.

Click Source Link

Document

Each of these fields are initialized to contain an instance of the appropriate view the first time this view is requested.

Usage

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_iisAll(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;//www .  j a v a2s.  c  o  m
        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);
        }
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_weball(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/*ww  w . j ava  2 s  .  co m*/
        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) {
        }
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_monthweball(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/*from   www . j a  va 2 s  . c  om*/
        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) {
        }
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_syball(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/*from ww  w.jav a 2s. c o  m*/
        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) {
        }
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_oraall(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/*from   ww w .ja  va  2s  . com*/
        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) {
        }
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author sqc/*  w w  w. j  av  a 2 s.  co  m*/
 * @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);
        }
    }

}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_db2all(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/* w ww.  j av  a2 s  .  c om*/
        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) {
        }
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_sqlall(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/*w  w  w .j ava 2  s. c  o m*/
        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) {
        }
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_sqlall2(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;//w  w w  .ja  v a  2 s.  c  om
        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);
        }
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_monthnetworkall(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;/*  ww  w. j  av  a  2s .  c  om*/
        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) {
        }
    }
}