Exemplo n.º 1
0
  private void startProcess(String contextPath) {
    System.out.println("Start DCI web process");
    System.out.println("Init singleton objects");
    Singleton s = Singleton.getInstance();
    s.setContextPath(contextPath);
    APPubMethods method = new APPubMethods();

    System.out.println("JBoss log directory : " + System.getProperty("jboss.server.log.dir"));
    System.out.println("Build all datasource");
    method.setConnectionPool();
    if (s.getDatabaseStatus()) {
      System.out.println("Load System Config");
      method.loadSystemConfig();
      System.out.println("Check Current Version");
      new EKBVersionCheck();
      // method.checkKanBanLegend();//need move to patch class
      System.out.println("Load Multi Language");
      method.loadMultiLanguage();
      System.out.println("Multi Language Loaded");
      method.checkLicense();
      if (!s.getLicenseStatus()) {
        System.out.println("license check fail");
      }
    } else {
      System.out.println("set connection pool fail");
    }
  }
Exemplo n.º 2
0
  private void saveLangs(Connection conn, String[][] langs) throws Exception {
    PreparedStatement ps = null;
    boolean reconn = false;

    try {
      if (langs != null && langs.length > 0) {
        if (conn == null || conn.isClosed()) {
          conn = this.dbobj.getConnection(ConnectionType.SYS);
          reconn = true;
        }
        ps =
            conn.prepareStatement(
                this.cmd.deleteCusLang(),
                ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        ps.setString(1, langs[0][1]);
        ps.executeUpdate();

        this.dbctrl.closeConnection(null, ps, null);

        ps =
            conn.prepareStatement(
                this.cmd.addCusLang(),
                ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        for (int i = 0; i < langs.length; i++) {
          if (!DCIString.isNullOrEmpty(langs[i][2])) {
            ps.setString(1, langs[i][0]);
            ps.setString(2, langs[i][1]);
            ps.setString(3, langs[i][2]);
            ps.addBatch();
          }
        }

        ps.executeBatch();

        for (int i = 0; i < langs.length; i++) {
          if (DCIString.isNullOrEmpty(langs[i][2])) {
            Singleton.getInstance().removeMultiLanguage(langs[i][0], langs[i][1]);
          } else {
            Singleton.getInstance().addMultiLanguage(langs[i][0], langs[i][1], langs[i][2]);
          }
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      throw ex;
    } finally {
      if (reconn) {
        this.dbctrl.closeConnection(null, ps, conn);
      } else {
        this.dbctrl.closeConnection(null, ps, null);
      }
    }
  }
Exemplo n.º 3
0
  public HashMap<String, Object> getIntiData(String lang) {
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    HashMap<String, Object> datas = null;
    ArrayList<HashMap<String, Object>> groups = null;
    HashMap<String, Object> tmp = null;

    try {
      conn = this.dbobj.getConnection(ConnectionType.SYS);
      ps =
          conn.prepareStatement(
              this.cmd.getAllGroups(),
              ResultSet.TYPE_SCROLL_INSENSITIVE,
              ResultSet.CONCUR_READ_ONLY);

      rs = ps.executeQuery();
      groups = new ArrayList<HashMap<String, Object>>();

      while (rs.next()) {
        tmp = new HashMap<String, Object>();
        tmp.put("value", rs.getString("group_id"));
        if (rs.getInt("visible") == 1) {
          tmp.put(
              "label",
              rs.getString("group_name")
                  + "("
                  + Singleton.getInstance().getLanguage(lang, "enable")
                  + ")");
        } else {
          tmp.put(
              "label",
              rs.getString("group_name")
                  + "("
                  + Singleton.getInstance().getLanguage(lang, "disable")
                  + ")");
        }
        groups.add(tmp);
      }

      datas = new HashMap<String, Object>();
      datas.put("groups", groups);

    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      this.dbctrl.closeConnection(rs, ps, conn);
    }

    return datas;
  }
Exemplo n.º 4
0
  private String getMaxKey(Connection conn) {
    PreparedStatement ps = null;
    ResultSet rs = null;
    String key = null;
    boolean reconn = false;
    try {
      if (conn == null || conn.isClosed()) {
        conn = this.dbobj.getConnection(ConnectionType.SYS);
        reconn = true;
      }
      ps = conn.prepareStatement(this.cmd.maxKey(Singleton.getInstance().getSysDBType()));

      rs = ps.executeQuery();
      if (rs.next()) {
        if (DCIString.isNullOrEmpty(rs.getString(1)) || !DCIString.isInteger(rs.getString(1))) {
          key = "1";
        } else {
          key = String.valueOf(rs.getInt(1) + 1);
        }
      } else {
        key = "1";
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      key = "";
    } finally {
      if (reconn) {
        this.dbctrl.closeConnection(rs, ps, conn);
      } else {
        this.dbctrl.closeConnection(rs, ps, null);
      }
    }
    return key;
  }
Exemplo n.º 5
0
 private void stratTasks() {
   SystemTimer st = SystemTimer.getInstance();
   st.addTask(new UserCheck(), 10000);
   st.addTask(new MultiLanguageSync(), 1800000);
   st.addTask(new ConnectionCheck(), 180000);
   if (!Singleton.getInstance().isTestArea()) {
     st.addTask(new AppPushKanBan(), 180000);
   }
 }
Exemplo n.º 6
0
  private void clearAllUser(String ipAddr, Enumeration<String> sessions) {
    if (DCIString.isNullOrEmpty(ipAddr) || sessions == null) {
      // System.out.println("session destroyed");
    } else {
      String uid = null;
      String sessionName = null;
      Singleton s = Singleton.getInstance();

      while (sessions.hasMoreElements()) {
        sessionName = sessions.nextElement();
        // System.out.println(sessionName);
        if (sessionName.indexOf(DCIWebConstants.getUserInfoTag()) != -1) {
          uid = sessionName.replace(DCIWebConstants.getUserInfoTag(), "");
          s.removeLicenseUser(uid, ipAddr);
          s.removeOnlineUser(uid, ipAddr);
        }
      }
    }
  }
Exemplo n.º 7
0
  public HashMap<String, Object> getQueryColumns(String lang) {
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    HashMap<String, Object> datas = null;
    ArrayList<HashMap<String, Object>> cols = null;
    HashMap<String, Object> tmp = null;

    try {
      conn = this.dbobj.getConnection(ConnectionType.SYS);
      ps =
          conn.prepareStatement(
              this.cmd.getAllData(" and 1=2 "),
              ResultSet.TYPE_SCROLL_INSENSITIVE,
              ResultSet.CONCUR_READ_ONLY);

      ps.setString(1, lang);
      rs = ps.executeQuery();
      if (rs != null) {
        ResultSetMetaData rsmd = rs.getMetaData();
        cols = new ArrayList<HashMap<String, Object>>();
        for (int i = 1; i <= rsmd.getColumnCount(); i++) {
          if (!rsmd.getColumnName(i).toLowerCase().equals("icon_type")
              && !rsmd.getColumnName(i).toLowerCase().equals("icon_path")
              && !rsmd.getColumnName(i).toLowerCase().equals("lang_value")) {
            tmp = new HashMap<String, Object>();
            tmp.put("value", rsmd.getColumnName(i).toLowerCase());
            tmp.put(
                "label",
                Singleton.getInstance().getLanguage(lang, rsmd.getColumnName(i).toLowerCase()));
            cols.add(tmp);
          }
        }
      }

      datas = new HashMap<String, Object>();
      datas.put("cols", cols);

    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      this.dbctrl.closeConnection(rs, ps, conn);
    }

    return datas;
  }
Exemplo n.º 8
0
  public HashMap<String, Object> mapkeyCheck(String id, String key, String lang) {
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    HashMap<String, Object> result = null;

    try {

      conn = this.dbobj.getConnection(ConnectionType.SYS);
      ps =
          conn.prepareStatement(
              this.cmd.iconMapKey(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
      ps.setString(1, id);
      ps.setString(2, key);
      rs = ps.executeQuery();
      result = new HashMap<String, Object>();
      if (rs.next()) {
        result.put("success", false);
        result.put("msg", Singleton.getInstance().getLanguage(lang, "icon_map_key_exist"));
      } else {
        result.put("success", true);
        result.put("msg", "");
      }

    } catch (Exception ex) {
      ex.printStackTrace();
      if (result == null) {
        result = new HashMap<String, Object>();
      }
      result.put("success", false);
      result.put("msg", ex.getMessage());
    } finally {
      this.dbctrl.closeConnection(rs, ps, conn);
    }

    return result;
  }
Exemplo n.º 9
0
  @RequestMapping(method = RequestMethod.POST)
  public @ResponseBody HashMap<String, ArrayList<Object>> postMethod(
      HttpServletRequest request, HttpServletResponse response) {
    HashMap<String, ArrayList<Object>> parameters = null;
    String dcikey = request.getParameter(DCIWebConstants.getPostTagId());
    String action = request.getParameter("action");
    String uid = request.getParameter("uid");
    HashMap<String, String> parames = null;
    String conn_id = request.getParameter("conn_id");
    WPP001 wpp01 = null;

    if (dcikey != null && dcikey.equals(DCIWebConstants.getPostTagValue())) {
      wpp01 = new WPP001(conn_id);
      if (action.equals("init")) {
        parameters = new WPP001(conn_id).getComboBoxData();
      } else if (action.equals("query")) {
        parames = new HashMap<String, String>();
        parames.put("F001", request.getParameter("F001"));
        parames.put("F002", request.getParameter("F002"));
        parames.put("F003", request.getParameter("F003"));
        parames.put("F004", request.getParameter("F004"));
        parames.put("F005", request.getParameter("F005"));
        parameters = wpp01.query(parames);
      } else if (action.equals("sub")) {
        String subtype = request.getParameter("SubType");
        parames = new HashMap<String, String>();
        parames.put("TB001", request.getParameter("TB001"));
        parames.put("TB002", request.getParameter("TB002"));
        parames.put("TB003", request.getParameter("TB003"));
        parames.put("TB004", request.getParameter("TB004"));
        parames.put("TB005", request.getParameter("TB005"));
        parames.put("TB006", request.getParameter("TB006"));
        parames.put("TB007", request.getParameter("TB007"));
        parames.put("ORDERID", request.getParameter("ORDERID"));
        parameters =
            wpp01.buildSubGrid(
                subtype,
                parames,
                new APControl().getUserInfoFromSession(request.getSession(), uid, "lang"));
      } else if (action.equals("excel")) {
        parames = new HashMap<String, String>();
        parames.put("F001", request.getParameter("F001"));
        parames.put("F002", request.getParameter("F002"));
        parames.put("F003", request.getParameter("F003"));
        parames.put("F004", request.getParameter("F004"));
        parames.put("F005", request.getParameter("F005"));
        new PublicMethods()
            .downloadFile(
                request,
                response,
                wpp01.getExportData(
                    parames,
                    request.getParameter("cols"),
                    new APControl().getUserInfoFromSession(request.getSession(), uid, "lang")),
                action,
                Singleton.getInstance().getExpExcelName(WPP001.class));
      }
    }

    return parameters;
  }
Exemplo n.º 10
0
  public HashMap<String, Object> getAllData(
      String strpage, String strpagesize, String filter, String lang) {
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    HashMap<String, Object> datas = null;
    ArrayList<HashMap<String, Object>> items = null;
    HashMap<String, Object> tmp = null;
    Singleton s = Singleton.getInstance();
    int cnt = 0;
    int page = 0;
    int pagesize = 0;
    int totalRow = 0;
    try {
      conn = this.dbobj.getConnection(ConnectionType.SYS);
      ps =
          conn.prepareStatement(
              this.cmd.getAllData(filter),
              ResultSet.TYPE_SCROLL_INSENSITIVE,
              ResultSet.CONCUR_READ_ONLY);
      ps.setString(1, lang);
      rs = ps.executeQuery();
      items = new ArrayList<HashMap<String, Object>>();
      if (DCIString.isNullOrEmpty(strpage)) {
        page = 1;
      } else {
        page = Integer.parseInt(strpage);
      }
      if (DCIString.isNullOrEmpty(strpagesize)) {
        pagesize = APConstants.getDefaultpagesize();
      } else {
        pagesize = Integer.parseInt(strpagesize);
      }
      if (rs.next()) {
        rs.last();
        totalRow = rs.getRow();
        rs.beforeFirst();
        if ((page - 1) * pagesize <= totalRow) {
          if ((page - 1) * pagesize != 0) {
            rs.absolute((page - 1) * pagesize);
          }
          cnt = 1;
          while (rs.next()) {
            tmp = new HashMap<String, Object>();
            tmp.put("id", cnt);
            tmp.put("icon_id", rs.getString("icon_id"));
            tmp.put("icon_name", rs.getString("icon_name"));
            tmp.put("icon_show_name", s.getLanguage(lang, rs.getString("icon_name")));
            tmp.put("icon_map_key", rs.getString("icon_map_key"));
            tmp.put("icon_path", rs.getString("icon_path"));
            tmp.put("icon_type", rs.getString("icon_type"));
            tmp.put("icon_id_show", DCIString.Base64Encode(rs.getString("icon_id")));
            tmp.put(
                "icon_names",
                s.getLanguage("CHS", rs.getString("icon_name"))
                    + "$"
                    + s.getLanguage("CHT", rs.getString("icon_name")));
            items.add(tmp);
            cnt++;
            if (cnt > pagesize) {
              break;
            }
          }
        }
      } else {
        totalRow = 0;
      }

      datas = new HashMap<String, Object>();
      datas.put("items", items);
      datas.put("total", totalRow);

    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      this.dbctrl.closeConnection(rs, ps, conn);
    }

    // System.out.println("execute getAllUserInfo");

    return datas;
  }