Esempio n. 1
0
  // 이미지 서버
  public void viewImgaeSearch() {

    dtm.setRowCount(0);
    // 검색시 서버에서 이미지를 불러옵니다.
    ms_connect.setImageSetting();
    String query =
        "Select * From Ftp_Image Where path='"
            + Server_Config.getFTPMARTPATH()
            + "' and path_gubun='0' ";
    ArrayList<HashMap<String, String>> temp_map = ms_connect.connection(query);

    Iterator<HashMap<String, String>> iter = temp_map.iterator();
    int i = 1;
    while (iter.hasNext()) {
      HashMap<String, String> map = iter.next();
      Vector<String> item = new Vector<String>();
      item.add(String.valueOf(i++));
      item.add(map.get("Barcode"));
      item.add(map.get("Ext"));
      item.add(map.get("G_Name"));

      dtm.addRow(item);
    }

    label_show_image.setIcon(null);
  }
Esempio n. 2
0
  // 결과 저장합니다.
  public boolean resultCodeSave(String data) {

    JSONObject json = new JSONObject();
    String p_data = data.substring(10, data.length());
    try {
      json = (JSONObject) JSONValue.parseWithException(p_data);
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    String query = "Select * From e_AppInstall Where idx='" + json.get("idx") + "' ";
    String query_result = "";
    Ms_Connect mscon = new Ms_Connect();
    HashMap<String, String> map = mscon.selectQueryOne(query);

    if (map.size() <= 0) {
      query_result =
          "Insert into e_AppInstall (idx, mem_id, platform, devicetoken, deviceuid, devicename, devicemodel, deviceversion, hp_num, reg_time, cus_code) values("
              + "'"
              + json.get("idx")
              + "', '"
              + json.get("mem_id")
              + "', '"
              + json.get("platform")
              + "', '"
              + json.get("devicetoken")
              + "', '"
              + json.get("deviceuid")
              + "', '"
              + json.get("devicename")
              + "', '"
              + json.get("devicemodel")
              + "', '"
              + json.get("deviceversion")
              + "', '"
              + json.get("hp_num")
              + "', '"
              + json.get("reg_time")
              + "', '')";
      int result = mscon.connect_update(query_result);
      if (result == 0) {
        return true;
      } else {
        return false;
      }
    } else {
      if (map.get("idx").equals(json.get("idx"))) {
        query_result =
            "Update e_AppInstall Set mem_id='"
                + json.get("mem_id")
                + "', platform='"
                + json.get("platform")
                + "', devicetoken='"
                + json.get("devicetoken")
                + "', deviceuid='"
                + json.get("deviceuid")
                + "', devicename='"
                + json.get("devicename")
                + "', devicemodel='"
                + json.get("devicemodel")
                + "', deviceversion='"
                + json.get("deviceversion")
                + "', hp_num='"
                + json.get("hp_num")
                + "', reg_time='"
                + json.get("reg_time")
                + "' "
                + "Where idx='"
                + json.get("idx")
                + "' ";
        int result = mscon.connect_update(query_result);
        if (result == 0) {
          return true;
        } else {
          return false;
        }
      } else {
        return false;
      }
    }
  }
Esempio n. 3
0
  // 선택된 이미지를 삭제 합니다.
  private void ftp_image_delete() {

    // 커서 변경(모래시계)
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

    // 선택정보를 불러옵니다.
    int row = table_ftp_view.getSelectedRow();
    int col = table_ftp_view.getColumnCount();

    Vector<Object> temp = new Vector<Object>();

    for (int i = 0; i < col; i++) {
      temp.add(dtm.getValueAt(row, i));
    }

    FTPClient ftpConn = new FTPClient();

    try {
      ftpConn.connect(Server_Config.getFTPIP(), Server_Config.getFTPPORT());
      ftpConn.login(Server_Config.getFTPID(), Server_Config.getFTPPW());

    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block
      JOptionPane.showMessageDialog(this, "접속에 실패 했습니다.");
      e.printStackTrace();
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      return;
    }

    // 단독폴더 경로를 설정합니다.
    try {
      ftpConn.changeDirectory(Server_Config.getFTPMARTPATH());
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block

      JOptionPane.showMessageDialog(this, "디렉토리 변경에 실패 했습니다.");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      e.printStackTrace();
      return;
    } catch (NullPointerException e) {

      JOptionPane.showMessageDialog(this, "단독폴더경로 설정을 하셔야 합니다. 환경설정에서 설정해 주세요");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      e.printStackTrace();
      return;
    }

    String file_name = temp.get(1) + "." + temp.get(2);
    System.out.println(file_name);
    // 파일을 삭제합니다.

    try {
      ftpConn.deleteFile(file_name.trim());
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
      JOptionPane.showMessageDialog(this, "파일을 삭제 하지 못했습니다.");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      return;
    }

    // 서버에서 삭제 합니다.

    // 이미지디비에 파일을 삭제 하기 위해 쿼리를 작성합니다.
    String query =
        "Delete From Ftp_Image Where Barcode='"
            + temp.get(1).toString().trim()
            + "' and Path_Gubun='0' ";

    // 업로드한 정보를 매장 DB서버에 저장 합니다.
    /*if(!ms_connect.connect_errorCheck()){
    	JOptionPane.showMessageDialog(this, "디비에서 파일을 삭제하지 못했습니다.");
    	this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    	return;
    }*/

    ms_connect.setImageSetting();
    int result = ms_connect.connect_update(query);
    switch (result) {
      case 0:
        JOptionPane.showMessageDialog(this, "선택한 파일이 삭제 되었습니다.");
        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        viewImgaeSearch();
        break;
      default:
        JOptionPane.showMessageDialog(this, "삭제 하지 못했습니다.");
        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        break;
    }

    // 마무리합니다.
    try {
      if (ftpConn.isConnected()) {
        ftpConn.disconnect(true);
      }
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Esempio n. 4
0
  // 파일을 FTP서버로 업로드 합니다.
  private void uploadImage() {

    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

    // FTP로 이미지를 업로드 합니다.
    // FTP 서버에 접속 합니다.
    FTPClient ftpConn = new FTPClient();

    try {
      ftpConn.connect(Server_Config.getFTPIP(), Server_Config.getFTPPORT());
      ftpConn.login(Server_Config.getFTPID(), Server_Config.getFTPPW());
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block
      JOptionPane.showMessageDialog(this, "접속에 실패 했습니다.");
      e.printStackTrace();
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      return;
    }

    // 단독폴더 경로를 설정합니다.
    try {
      ftpConn.changeDirectory(Server_Config.getFTPMARTPATH());
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block
      // 디렉토리 없어서 오류가발생했다면
      String test;
      try {
        // 현재 디렉토리를 체크하고
        test = ftpConn.currentDirectory();
        System.out.println(test);
        // 그것이 루트 디렉토리라면
        if (test.equals("/")) {
          // 디렉토리를 생성한다.
          ftpConn.createDirectory(Server_Config.getFTPMARTPATH());
        }
      } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      JOptionPane.showMessageDialog(this, "디렉토리 변경에 실패 했습니다. 다시 시도해 주세요!");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      e.printStackTrace();
      return;
    } catch (NullPointerException e) {

      JOptionPane.showMessageDialog(this, "단독폴더경로 설정을 하셔야 합니다.");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      e.printStackTrace();
      return;
    }

    // 전송할 파일을 불러옵니다.
    List<String> temp = list_image.getSelectedValuesList();
    if (temp.size() <= 0) {
      JOptionPane.showMessageDialog(this, "업로드할 파일을 선택해 주세요!");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      return;
    }

    // 파일을 업로드 합니다.
    ArrayList<String> queryList = new ArrayList<String>();

    // 실패 파일을 저장합니다.
    ArrayList<String> uploadFail = new ArrayList<String>();

    for (String file : temp) {

      File tempFile = new File(text_path.getText(), file);

      if (fileSizeCheck(tempFile)) {
        try {
          ftpConn.upload(tempFile);
        } catch (IllegalStateException
            | IOException
            | FTPIllegalReplyException
            | FTPException
            | FTPDataTransferException
            | FTPAbortedException e) {
          // TODO Auto-generated catch block
          JOptionPane.showMessageDialog(this, "파일을 업로드 하지 못했습니다.");
          e.printStackTrace();
          this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          return;
        }

        // 이미지디비에 저장하기 위해 쿼리를 모아 둡니다.
        String query =
            "Insert into FTP_Image values('"
                + file.substring(0, file.indexOf("."))
                + "', '"
                + Server_Config.getFTPMARTPATH()
                + "', '0', '', '"
                + file.substring(file.indexOf(".") + 1, file.length())
                + "', '')";
        queryList.add(query);
      } else {
        // 업로드 실패시 저장합니다.
        uploadFail.add(tempFile.getName());
      }
    }

    // 저장할 상품이 있을때만 합니다.
    if (queryList.size() > 0) {
      ms_connect.setImageSetting();
      int result = ms_connect.connect_update(queryList);
      switch (result) {
        case 0:
          String queryOver =
              "Delete From Ftp_Image Where idx in( select a.idx as idx "
                  + "From Ftp_Image A INNER JOIN ( Select Min(idx) as idx, barcode, count(*) as overlapCount "
                  + "From Ftp_Image Where path_gubun='0' and path='"
                  + Server_Config.getFTPMARTPATH()
                  + "' Group by barcode Having count(*) > 1 ) B "
                  + "on a.barcode = b.barcode and A.idx <> B.idx and a.path_gubun='0' and path='"
                  + Server_Config.getFTPMARTPATH()
                  + "')";

          ms_connect.connect_update(queryOver);
          this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          JOptionPane.showMessageDialog(this, "저장이 완료 되었습니다.");
          // 검색창에 파일을 표시합니다.
          viewImgaeSearch();
          break;
        default:
          this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          JOptionPane.showMessageDialog(this, "저장을 완료 하지 못했습니다.");
          break;
      }
    }

    // 마무리합니다.
    try {
      if (ftpConn.isConnected()) {
        ftpConn.disconnect(true);
      }
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }