/** 增加一个新的节点(用于发现之后,或者手动增加一个节点) */
  public void addNodes(String index, String image, String ip, String alias, String x, String y) {
    Element eleNode = new Element("node");
    Element eleId = new Element("id");
    Element eleImg = new Element("img");
    Element eleX = new Element("x");
    Element eleY = new Element("y");
    Element eleAlias = new Element("alias");
    Element eleInfo = new Element("info");
    Element eleMenu = new Element("menu");

    eleId.setText(index);
    eleImg.setText(image);
    eleX.setText(x);
    eleY.setText(y);
    eleAlias.setText(alias);
    StringBuffer msg = new StringBuffer(200);
    msg.append("<font color='green'>索引:");
    msg.append(index);
    msg.append("</font><br>");
    msg.append("描述:");
    msg.append(alias);
    msg.append("<br>");
    eleInfo.setText(msg.toString());
    eleMenu.setText(PanelNodeHelper.getMenuItem(index, ip));
    eleNode.addContent(eleId);
    eleNode.addContent(eleImg);
    eleNode.addContent(eleX);
    eleNode.addContent(eleY);
    eleNode.addContent(eleAlias);
    eleNode.addContent(eleInfo);
    eleNode.addContent(eleMenu);
    nodes.addContent(eleNode);
  }
  /** 更新所有info项和image项 */
  public void updateInfo(boolean isCustom) {
    I_HostLastCollectData hostlastmanager = new HostLastCollectDataManager();
    List list = nodes.getChildren();
    for (int i = 0; i < list.size(); i++) {
      Element eleNode = (Element) list.get(i);
      int id = Integer.valueOf(eleNode.getChildText("id")).intValue();
      int direction = Integer.valueOf(eleNode.getChildText("direction")).intValue();
      // Hashtable ipAllData = (Hashtable)ShareData.getSharedata().get(ipaddress);

      Vector vector = new Vector();
      String[] netInterfaceItem = {
        "index", "ifDescr", "ifSpeed", "ifOperStatus", "OutBandwidthUtilHdx", "InBandwidthUtilHdx"
      };
      try {
        vector = hostlastmanager.getInterface_share(ipaddress, netInterfaceItem, "index", "", "");
      } catch (Exception e) {
        e.printStackTrace();
      }
      SysLogger.info("######################################");
      SysLogger.info("######### " + ipaddress + "   ##############");
      SysLogger.info("######################################");
      if (vector != null && vector.size() > 0) {
        PortconfigDao dao = new PortconfigDao();
        try {
          for (int m = 0; m < vector.size(); m++) {
            String[] strs = (String[]) vector.get(m);
            String ifname = strs[1];
            String index = strs[0];
            String OutBandwidthUtilHdx = strs[4];
            String InBandwidthUtilHdx = strs[5];
            String portuse = "";
            Portconfig portconfig = null;
            try {
              portconfig = dao.getPanelByipandindex(ipaddress, index);
            } catch (Exception e) {

            }
            if (portconfig != null
                && portconfig.getLinkuse() != null
                && portconfig.getLinkuse().trim().length() > 0) {
              portuse = portconfig.getLinkuse();
            }
            if (Integer.parseInt(index) == id) {
              // 当前端口
              if (direction == 1) {
                // 向上方向的端口
                if (strs[3].equalsIgnoreCase("up")) {
                  // 端口启动
                  SysLogger.info(PanelNodeHelper.getUpUpImage(1));
                  eleNode.getChild("img").setText(PanelNodeHelper.getUpUpImage(1));
                } else {
                  // 端口未启动
                  SysLogger.info(PanelNodeHelper.getUpDownImage(1));
                  eleNode.getChild("img").setText(PanelNodeHelper.getUpDownImage(1));
                }

              } else {
                // 向下方向的端口
                if (strs[3].equalsIgnoreCase("up")) {
                  // 端口启动
                  SysLogger.info(PanelNodeHelper.getDownUpImage(1));
                  eleNode.getChild("img").setText(PanelNodeHelper.getDownUpImage(1));
                } else {
                  // 端口未启动
                  SysLogger.info(PanelNodeHelper.getDownDownImage(1));
                  eleNode.getChild("img").setText(PanelNodeHelper.getDownDownImage(1));
                }
              }

              eleNode.getChild("alias").setText(ifname);
              eleNode.getChild("ip").setText(ipaddress);

              StringBuffer msg = new StringBuffer(200);
              msg.append("<font color='green'>索引:");
              msg.append(id);
              msg.append("</font><br>");

              msg.append("描述:");
              msg.append(ifname);
              msg.append("<br>");

              msg.append("端口应用:");
              msg.append(portuse);
              msg.append("<br>");

              msg.append("入口流速:");
              msg.append(InBandwidthUtilHdx);
              msg.append("<br>");

              msg.append("出口流速:");
              msg.append(OutBandwidthUtilHdx);
              msg.append("<br>");

              SysLogger.info(msg.toString());
              eleNode.getChild("info").setText(msg.toString());
              eleNode.getChild("menu").setText(PanelNodeHelper.getMenuItem(index, ipaddress));
            }
          }
        } catch (Exception e) {

        } finally {
          dao.close();
        }
      }
      // nodes.addContent(i, eleNode);
    }

    if (isCustom) {
      writeXml();
      return;
    }
    writeXml();
  }
  /** 增加一个新的节点(用于发现之后,或者手动增加一个节点) */
  public void addNode(
      String index,
      String InBandwidthUtilHdx,
      String OutBandwidthUtilHdx,
      String image,
      String ip,
      String alias,
      String portuse,
      String x,
      String y) {
    Element eleNode = new Element("node");
    Element eleId = new Element("id");
    Element eleImg = new Element("img");
    Element eleX = new Element("x");
    Element eleY = new Element("y");
    Element eleIp = new Element("ip");
    Element eleAlias = new Element("alias");
    Element eleInfo = new Element("info");
    Element eleMenu = new Element("menu");

    eleId.setText(index);
    if (image == null) eleImg.setText(PanelNodeHelper.getMenuItem(index, ipaddress));
    else eleImg.setText(image);
    eleX.setText(x);
    eleY.setText(y);
    eleIp.setText(ip);
    eleAlias.setText(alias);
    StringBuffer msg = new StringBuffer(200);
    msg.append("<font color='green'>索引:");
    msg.append(index);
    msg.append("</font><br>");
    msg.append("描述:");
    msg.append(alias);
    msg.append("<br>");
    msg.append("应用:");
    msg.append(portuse);
    msg.append("<br>");
    msg.append("入口流速:");
    msg.append(InBandwidthUtilHdx);
    msg.append("<br>");

    msg.append("出口流速:");
    msg.append(OutBandwidthUtilHdx);
    msg.append("<br>");

    eleInfo.setText(msg.toString());
    eleMenu.setText(PanelNodeHelper.getMenuItem(index, ip));
    eleNode.addContent(eleId);
    eleNode.addContent(eleImg);
    eleNode.addContent(eleX);
    eleNode.addContent(eleY);
    eleNode.addContent(eleIp);
    eleNode.addContent(eleAlias);
    eleNode.addContent(eleInfo);
    eleNode.addContent(eleMenu);
    nodes.addContent(eleNode);
  }