示例#1
0
 public Methods() {
   // TODO Auto-generated constructor stub
   alert.setSmtpIP(SystemContext.getConfig("config.himax.mail.ip"));
   alert.setSenderName(SystemContext.getConfig("config.himax.mail.sender.name"));
   alert.setSenderAddr(SystemContext.getConfig("config.himax.mail.sender.mail"));
   alert.setToMail(SystemContext.getConfig("config.himax.mail.admin.mail"));
   alert.setSubject(SystemContext.getConfig("config.himax.mail.subject"));
 }
  public CpYieldParser() {

    String fileInUrlLocal = SystemContext.getConfig("config.parser.path");
    String fileOutUrlLocal = SystemContext.getConfig("config.parser.finish.path");
    String fileErrorUrlLocal = SystemContext.getConfig("config.parser.error.path");

    logger.debug(fileInUrlLocal);
    logger.debug(fileOutUrlLocal);
    logger.debug(fileErrorUrlLocal);

    File fileInLocal = new File(fileInUrlLocal);
    File fileOutLocal = new File(fileOutUrlLocal);
    File fileErrorLocal = new File(fileErrorUrlLocal);

    this.fileInUrl = fileInLocal;
    this.fileOutUrl = fileOutLocal;
    this.fileErrorUrl = fileErrorLocal;

    // TODO Auto-generated constructor stub
    alert.setSmtpIP(SystemContext.getConfig("config.himax.mail.ip"));
    alert.setSenderName(SystemContext.getConfig("config.himax.mail.sender.name"));
    alert.setSenderAddr(SystemContext.getConfig("config.himax.mail.sender.mail"));
    alert.setToMail(SystemContext.getConfig("config.himax.mail.admin.mail"));
    alert.setSubject(SystemContext.getConfig("config.himax.mail.subject"));
  }
  /**
   * GET SMIC WIP FILEs
   *
   * @throws IOException
   */
  public void GetCpYieldFiles() {

    try {
      logger.debug("fileInUrl " + fileInUrl.getPath());
      List fileList = Methods.getFiles(fileInUrl);
      fileList = null != fileList ? fileList : new ArrayList();

      for (int i = 0; i < fileList.size(); i++) {
        File txtFile = (File) fileList.get(i);
        String fileName = txtFile.getName();
        // 1.0 Check File Status can read, write
        if (txtFile.canRead() && txtFile.canWrite()) {}

        // if (file_name.substring(4, 5).equals("B")) {
        // System.out.println(file_name+" is Bump's File");
        if (this.parserCpYieldTxt(txtFile) == false) {
          logger.info(fileName + " is Parser false");
          // alert.setSubject(SystemContext.getConfig("config.himax.mail.subject") + " - " +
          // fileName + " is Parser false");
          // alert.sendNoFile("CP Yield Parser fail:" + txtFile);
          Methods.copyFile(txtFile, new File(fileErrorUrl + "\\" + fileName));
          txtFile.delete();
        } else {

          // logger.info(fileName + " is Parser complete");
          // Methods.copyFile(txtFile, new File(fileOutUrl + "\\" + fileName));
          // txtFile.delete();
        }
        /*} else {
            logger.info(file_name + " is not Bump's File");
            alert.sendNoFile("ECOA This File is not Bump's File:" + excelFile);
            mod.copyFile(excelFile, new File(fileErrorUrl + "\\" + file_name));
            excelFile.delete();

            logger.info(file_name+" is not BUMP's File");
        }*/
      }
    } catch (Exception e) {
      StackTraceElement[] messages = e.getStackTrace();

      int length = messages.length;
      String error = "";
      alert.setSubject(
          SystemContext.getConfig("config.himax.mail.subject") + " - " + e.getMessage());
      for (int i = 0; i < length; i++) {
        error = error + "toString:" + messages[i].toString() + "\r\n";
      }
      alert.sendNoFile(error);
      e.printStackTrace();
      logger.error(error);
    }
  }