Beispiel #1
0
  /**
   * Tai function cho Dababase
   *
   * @param _app
   * @param _queryser
   */
  public void queryToFunctions(AppCommon _app, QueryServer _queryser) {
    Date date;
    DateFormat dateFormat;

    // Bat buoc
    this.set_fileurl(_app.get_scriptUrl() + this.get_fileurl()); // Lay duong dan he thong cau hinh
    this.readScript(); // doc file
    this.set_define(_app.get_define());
    this.setquery(); // Set lai cau script lay

    dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
    date = new Date();
    this.set_startDate(dateFormat.format(date));
    CommandQuery.commandFunctions(_queryser.get_conn(), this.get_exquery());
    date = new Date();
    this.set_endDate(dateFormat.format(date));

    logger.info(
        "S["
            + this.get_startDate()
            + "], E["
            + this.get_endDate()
            + "]. Execute script successful with name: "
            + this.get_querynm());
  }
Beispiel #2
0
  /**
   * Lay gia tri dua vao define cua App
   *
   * @param _app
   * @param _queryser
   */
  public void queryToAppDefine(AppCommon _app, QueryServer _queryser) {
    Date date;
    DateFormat dateFormat;

    // Bat buoc
    this.set_fileurl(_app.get_scriptUrl() + this.get_fileurl()); // Lay duong dan he thong cau hinh
    this.readScript(); // doc file	
    this.set_define(_app.get_define());
    this
        .setquery(); // Set lai cau script lay - Lay define cua Query (neu cau set lai define cua
                     // Appcomon)
    // this.logQuery();

    dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
    date = new Date();
    this.set_startDate(dateFormat.format(date));

    _app.set_define(CommandQuery.queryGetVar(_queryser.get_conn(), this.get_exquery()));

    date = new Date();
    this.set_endDate(dateFormat.format(date));

    logger.info(
        "S["
            + this.get_startDate()
            + "], E["
            + this.get_endDate()
            + "]. queryToAppDefine successful with name: "
            + this.get_querynm());
  }
Beispiel #3
0
  /**
   * Thuc hien query to Excel
   *
   * @param _app
   * @param _queryser
   */
  public void queryToStringExcel(AppCommon _app, QueryServer _queryser) {
    Date date;

    DateFormat dateFormat;

    this.set_fileurl(_app.get_scriptUrl() + this.get_fileurl());
    // doc file
    this.readScript();
    this.set_define(_app.get_define());
    this.setquery(); // Set lai cau script lay

    dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
    date = new Date();
    this.set_startDate(dateFormat.format(date));

    try {
      CommandQuery.set_Excelrow(_app.get_excelrows()); // so dong excel
      CommandQuery.commandQueryStringExcel(
          _queryser.get_conn(),
          this.get_exquery(),
          true,
          false,
          _app.get_outurl_excel(this.get_querynm()));
      date = new Date();
      this.set_endDate(dateFormat.format(date));

      logger.info(
          "S["
              + this.get_startDate()
              + "], E["
              + this.get_endDate()
              + "]. Query successful: "
              + this.get_querynm()
              + " with url: "
              + _app.get_outurl_excel(this.get_querynm()));
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      date = new Date();
      this.set_endDate(dateFormat.format(date));
      logger.error(
          "S["
              + this.get_startDate()
              + "], E["
              + this.get_endDate()
              + "]. Query Fail: "
              + e.getMessage());
      e.printStackTrace();
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      date = new Date();
      this.set_endDate(dateFormat.format(date));
      logger.error(
          "S["
              + this.get_startDate()
              + "], E["
              + this.get_endDate()
              + "]. Query Fail: "
              + e.getMessage());
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      date = new Date();
      this.set_endDate(dateFormat.format(date));
      logger.error(
          "S["
              + this.get_startDate()
              + "], E["
              + this.get_endDate()
              + "]. Query Fail: "
              + e.getMessage());
      e.printStackTrace();
    }
  }