private void importOnePage(IVPage page) {
    visio.IVShapes shapes = page.shapes();
    visio.IVShape shape = null;
    if (shapes.count() > 0) {
      String pattern =
          "(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])";
      Pattern p = Pattern.compile(pattern);
      Matcher m = null;
      Set<String> allDevIPs = new HashSet<String>();
      for (int i = 1; i <= shapes.count(); i++) {
        shape = shapes.item(i);
        m = p.matcher(shape.text());
        if (m.find()) {
          allDevIPs.add(m.group());
        }
      }

      visio.IVConnects connects = page.connects();
      // System.out.println(connects.count());

      if (connects.count() > 0) {
        List<String> list = new ArrayList<String>();
        for (int i = 1; i <= connects.count(); i++) {
          visio.IVConnect connect = connects.item(i);
          list.add(connect.fromSheet().text() + "_" + connect.toSheet().text());
          if (list.size() == 2) {
            String startPoint = list.get(0); // 起点Gi1/1-Fa0/1_192.168.1.1
            String endPoint = list.get(1); // 终点
            // Gi1/1-Fa0/1_192.168.1.2
            String[] intIP1 = startPoint.split("_"); // Gi1/1-Fa0/1,
            // 192.168.1.1

            String intsStr1 = intIP1[0]; // Gi1/1-Fa0/1
            String startIP = intIP1[1]; // 192.168.1.1
            // startIP = Regex.Match(startIP, pattern).ToString();
            m = p.matcher(startIP);
            if (m.find()) {
              startIP = m.group();
            }
            if (startIP == "") {
              list.clear();
              continue;
            }

            String[] intIP2 = endPoint.split("_"); // Gi1/1-Fa0/1,
            // 192.168.1.2
            String intsStr2 = intIP2[0]; // Gi1/1-Fa0/1
            String endIP = intIP2[1]; // 192.168.1.2
            // endIP = Regex.Match(endIP, pattern).ToString();
            m = p.matcher(endIP);
            if (m.find()) {
              endIP = m.group();
            }
            if (endIP == "") {
              list.clear();
              continue;
            }

            String startInt = "", endInt = "";

            if (intsStr1.equals(intsStr2)) // 按理说 这个if是多余的
            {
              // MySQLCommand comm = null;
              // /接口连接信息拆分成两部分,分别转换成全拼
              String[] ints = intsStr1.split("-");
              startInt = ints[0]; // Gi1/1(n)
              String startIndex = "", endIndex = ""; // 端口索引号
              String[] intstrIndex = split(startInt);

              startInt = intstrIndex[0]; // parseIntface(startInt);
              startIndex = intstrIndex[1];

              endInt = ints[1]; // Fa
              //								endInt = parseIntface(endInt);
              intstrIndex = split(endInt);
              endInt = intstrIndex[0]; // parseIntface(startInt);
              endIndex = intstrIndex[1];

              // /计算设备id
              HostNodeDao dao = new HostNodeDao();
              int startNodeID = 0, endNodeID = 0;
              startNodeID = dao.getNodeID(startIP);
              HostNode node = new HostNode();
              if (dao.getCountByIpaddress(startIP) == 0) {
                node.setId(startNodeID);
                node.setIpAddress(startIP);
                node.setSysName(startIP);
                node.setCommunity(startIP);
                node.setWriteCommunity(startIP);
                int _startIP = Integer.parseInt(startIP);
                node.setSnmpversion(_startIP);
                node.setBid(startIP);
                node.setCollecttype(_startIP);
                node.setAlias(startIP);
                dao.save(node);
              }
              dao = new HostNodeDao();
              endNodeID = dao.getNodeID(endIP);
              if (dao.getCountByIpaddress(endIP) == 0) {
                node.setId(endNodeID);
                node.setIpAddress(endIP);
                node.setSysName(endIP);
                node.setAlias(endIP);
                dao.save(node);
              }
              allDevIPs.remove(startIP);
              allDevIPs.remove(endIP);

              LinkDao linkDao = new LinkDao();
              boolean isLinkExists = linkDao.linkExists2(startNodeID, startInt, endNodeID, endInt);
              if (!isLinkExists) {
                Link vo = new Link();
                vo.setStartId(startNodeID);
                vo.setStartIp(startIP);
                vo.setStartDescr(startInt);
                vo.setStartIndex(startIndex);
                vo.setEndId(endNodeID);
                vo.setEndIp(endIP);
                vo.setEndDescr(endInt);
                vo.setEndIndex(endIndex);
                vo.setLinkName(startIP + "_" + startIndex + "/" + endIP + "_" + endIndex);
                linkDao.saveLinkOnly(vo);
              }
            }
            list.clear();
          }
        }
      }
      if (allDevIPs.size() > 0) {
        HostNode node = new HostNode();
        for (String ipaddress : allDevIPs) {
          HostNodeDao dao = new HostNodeDao();
          int nodeID = dao.getNodeID(ipaddress);
          if (null == dao.findByIpaddress(ipaddress)) {
            node.setId(nodeID);
            node.setIpAddress(ipaddress);
            node.setSysName(ipaddress);
            node.setAlias(ipaddress);
            dao.save(node);
          }
        }
      }
    }
  }
  private String importVisioTopo() {

    String flag = request.getParameter("flag");
    HostNode importVisioTopohostnode = new HostNode();
    List _list = new ArrayList();
    if ("1".equals(flag)) {

      String discrictid = "";
      String saveDirPath = ResourceCenter.getInstance().getSysPath() + "WEB-INF/macConfig";

      String community = getParaValue("community");
      String writecommunity = getParaValue("writecommunity");
      int snmpversion = getParaIntValue("snmpversion");
      int collecttype = 0;
      try {
        collecttype = getParaIntValue("collecttype");
      } catch (Exception e) {

      }
      String bid = getParaValue("bid");

      importVisioTopohostnode.setCommunity(community);
      importVisioTopohostnode.setWriteCommunity(writecommunity);
      importVisioTopohostnode.setSnmpversion(snmpversion);
      importVisioTopohostnode.setCollecttype(collecttype);
      importVisioTopohostnode.setBid(bid);

      session.setAttribute("importVisioTopohostnode", importVisioTopohostnode);

      return "/tool/importvisiotopo_list.jsp";
    }
    if ("2".equals(flag)) {
      String discrictid = "";
      String saveDirPath = ResourceCenter.getInstance().getSysPath() + "WEB-INF/macConfig";
      Fileupload fileupload = new Fileupload(saveDirPath);
      fileupload.doupload(request, 10000000);

      HostNode _importVisioTopohostnode =
          (HostNode) session.getAttribute("importVisioTopohostnode");

      List formFieldList = fileupload.getFormFieldList();

      if (null == formFieldList || formFieldList.size() == 0) {
        request.setAttribute("success", false);
      } else {
        for (int i = 0; i < formFieldList.size(); i++) {

          List formField = (List) formFieldList.get(i);
          String formFieldType = (String) formField.get(0);
          String formFieldName = (String) formField.get(1);
          String formFieldValue = (String) formField.get(2);

          if ("file".equals(formFieldType)) {
            if ("fileName".equals(formFieldName)) {
              visio.IVInvisibleApp app = ClassFactory.createInvisibleApp();
              try {
                IVDocument doc = app.documents().open(formFieldValue);
                IVPages pages = doc.pages();
                System.out.println(pages.count());

                for (int index = 1; index <= pages.count(); index++) {
                  IVPage page = pages.item(index);
                  System.out.println(page.nameU());
                  importOnePage(page);
                }
                request.setAttribute("success", true);
              } catch (Exception e) {
                e.printStackTrace();
                request.setAttribute("success", false);
              } finally {
                app.quit();
              }
            }
          }
        }
      }
      return "/tool/importvisiotopo_list.jsp";
    }
    return null;
  }