Example #1
0
  public static String getMobileOperatorNew(String userid, int type) {

    String tmpOperator = "-";
    Connection connection = null;
    DBPool dbpool = new DBPool();
    try {

      connection = dbpool.getConnection("gateway");

      String query =
          "SELECT operator FROM icom_isdnseries WHERE prefix= substr('"
              + userid
              + "',1, length(prefix)) ";
      if (type == 1 || type == 0) {
        query += " and type=" + type;
      }

      Vector result = DBUtil.getVectorTable(connection, query);
      for (int i = 0; i < result.size(); i++) {
        Vector item = (Vector) result.elementAt(i);
        tmpOperator = (String) item.elementAt(0);
      }

      return tmpOperator;
    } catch (Exception ex) {
      Util.logger.sysLog(
          LogValues.INFORMATIVE,
          "Utils",
          "getMobileOperator: Get MobileOpereator Failed" + ex.toString());
      return tmpOperator;
    } finally {
      dbpool.cleanup(connection);
    }
  }
Example #2
0
  private void sendGifMsg(
      String serviceid,
      String userid,
      String operator,
      String service,
      String mtcontent,
      BigDecimal requestid,
      int contenttype) {
    try {

      MsgObject msg = new MsgObject();
      msg.setContenttype(contenttype);
      msg.setUserid(userid);
      msg.setMobileoperator(operator);
      msg.setMsgtype(0);
      msg.setRequestid(requestid);
      msg.setServiceid(serviceid);
      msg.setKeyword(service);
      msg.setUsertext(mtcontent);

      DBUtil.sendMT(msg);

    } catch (Exception ex) {
      Util.logger.sysLog(2, this.getClass().getName(), "Send gif Failed");
    }
  }
Example #3
0
  private static boolean isexist(String userid, String mlist) {
    Connection connection;
    PreparedStatement statement;
    DBPool dbpool;
    connection = null;
    statement = null;
    dbpool = new DBPool();
    try {

      connection = dbpool.getConnectionGateway();

      String query3 = "select * from " + mlist + " where user_id='" + userid + "' ";

      Util.logger.info(query3);
      Vector result3 = DBUtil.getVectorTable(connection, query3);
      if (result3.size() > 0) {
        Vector item = (Vector) result3.elementAt(0);
        return true;
        // tempMilisec = (String) item.elementAt(0);
      }
      return false;

    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      Util.logger.printStackTrace(e);
      return true;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      Util.logger.printStackTrace(e);
      return true;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #4
0
  public static String getContent(String Code) {
    // tach lastcode

    String content;
    Connection connection = null;
    DBPool dbpool = new DBPool();
    String query =
        "select Content from [IComStore].[dbo].[SDPText] where Code = '"
            + Code
            + "'  order by CreateDate desc";

    try {
      connection = dbpool.getConnection("store");
      Vector result = DBUtil.getVectorTable(connection, query);

      Util.logger.info("DBUtil.getCode: queryStatement:" + query);

      if (result.size() > 0) {
        Vector item = (Vector) result.elementAt(0);
        content = item.elementAt(0).toString();
        return content;
      }

    } catch (Exception ex) {
      Util.logger.info("DBUtil.getCode: getContent: Failed" + ex.getMessage());
      Util.logger.printStackTrace(ex);
      return "";
    } finally {
      dbpool.cleanup(connection);
    }
    return "";
  }
Example #5
0
  private int insertData2cancel(
      String user_id,
      String service_id,
      String command_code,
      String mlist,
      MsgObject msgObject,
      String mtfree,
      int msgtype,
      String Service_ss_id,
      String mt_count) {
    int ireturn = 1;
    Connection connection = null;
    DBPool dbpool = new DBPool();
    // long lmilisec = System.currentTimeMillis();
    String sqlInsert =
        "Insert into "
            + mlist
            + "_cancel(user_id, service_id, date,command_code,request_id, message_type,mobile_operator,mt_free,mt_count) values ('"
            + user_id
            + "','"
            + service_id
            + "','"
            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())
            + "','"
            + Service_ss_id
            + "','"
            + msgObject.getRequestid()
            + "','"
            + msgtype
            + "','"
            + msgObject.getMobileoperator()
            + "',"
            + mtfree
            + ","
            + mt_count
            + ")";

    try {

      connection = dbpool.getConnectionGateway();

      if (DBUtil.executeSQL(connection, sqlInsert) < 0) {
        Util.logger.error(
            this.getClass().getName()
                + ""
                + ": uppdate Statement: Insert  "
                + mlist
                + " Failed:"
                + sqlInsert);
        ireturn = -1;
      }
    } catch (Exception ex) {
      Util.logger.error(this.getClass().getName() + ":Insert  " + mlist + " Failed");
      ireturn = -1;
      Util.logger.printStackTrace(ex);
    } finally {
      dbpool.cleanup(connection);
    }
    return ireturn;
  }
  /* tim ma so cac bai hat */
  private static List<String> findBirth(String birthday) {
    List<String> lstresult = new ArrayList<String>();
    int code = 0;
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;

    DBPool dbpool = new DBPool();

    try {
      connection = dbpool.getConnection("VOVTV");
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return lstresult;
      }

      String sqlSelect =
          "SELECT NickName FROM [dbo].NickName WHERE Brithday LIKE '" + birthday + "'";

      Util.logger.info("SEARCH THEO BIRTHDAY AND ADDRESS  : " + sqlSelect);
      Vector result = DBUtil.getVectorTable(connection, sqlSelect);

      Util.logger.info("DBUtil.getCode: queryStatement:" + sqlSelect);

      for (int iIndex = 0; iIndex < result.size(); iIndex++) {
        Vector vtRow = (Vector) result.elementAt(iIndex);
        String nick = (String) vtRow.elementAt(0);
        lstresult.add(nick);
      }
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return lstresult;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return lstresult;
    } finally {
      dbpool.cleanup(rs);
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
    return lstresult;
  }
Example #7
0
  // Lay noi dung ben EVN - Happy Info
  @SuppressWarnings("unchecked")
  private String getInfo(String dbcontent) {

    Connection connection = null;
    DBPool dbpool = new DBPool();
    String result1 = "";

    try {

      connection = dbpool.getConnection(dbcontent);

      String query =
          "SELECT content FROM icom_textbase_data  where gameid='dovui'  Order by rand() limit 1;";

      Vector result = DBUtil.getVectorTable(connection, query);
      if (result.size() == 0) {
        // return null;
        return result1;
      } else {

        for (int i = 0; i < result.size(); i++) {

          Vector item = (Vector) result.elementAt(i);
          return (String) item.elementAt(0);
        }
      }

    } catch (Exception ex) {
      Util.logger.info(this.getClass().getName() + "getInfo: Failed" + ex.getMessage());
      Util.logger.printStackTrace(ex);

    } finally {
      dbpool.cleanup(connection);
    }
    return null;
  }
  @Override
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {

    String ismtadd = "1";
    try {
      Collection messages = new ArrayList();

      String infoid = "";
      String sKeyword = msgObject.getKeyword();
      String inv_telco =
          "Hien tai dich vu chua ho tro mang cua ban, moi ban quay lai sau.DTHT 1900571566";

      HashMap _option = new HashMap();
      String options = keyword.getOptions();
      String numberid = "8x51";
      String dtbase = "gateway";
      String last_msg = "MCA tencasy gui 8751.DTHT 1900571566";

      try {
        Util.logger.sysLog(2, this.getClass().getName(), "options: " + options);
        _option = getParametersAsString(options);
        numberid = getString(_option, "numberid", numberid);
        dtbase = getString(_option, "dtbase", dtbase);
        inv_telco = getString(_option, "inv_telco", inv_telco);
        last_msg = getString(_option, "last_msg", last_msg);
        ismtadd = getString(_option, "ismtadd", ismtadd);

      } catch (Exception e) {
        Util.logger.sysLog(2, this.getClass().getName(), "Error: " + e.toString());
        throw new Exception("Wrong config in options");
      }

      /*kiem tra thue bao khach hang*/
      if ("VIETTEL".equalsIgnoreCase(msgObject.getMobileoperator())
          || "VIETEL".equalsIgnoreCase(msgObject.getMobileoperator())) {
        infoid = "viettel";
      } else if (("VMS".equalsIgnoreCase(msgObject.getMobileoperator()))
          || "mobifone".equalsIgnoreCase(msgObject.getMobileoperator())) {
        infoid = "mobifone";
      } else if (("GPC".equalsIgnoreCase(msgObject.getMobileoperator()))
          || ("VINAPHONE".equalsIgnoreCase(msgObject.getMobileoperator()))) {
        infoid = "vinaphone";
      } else if (("GTEL".equalsIgnoreCase(msgObject.getMobileoperator()))
          || ("Beeline".equalsIgnoreCase(msgObject.getMobileoperator()))) {
        infoid = "beeline";
      } else {
        infoid = "other";
      }

      if ("other".equalsIgnoreCase(infoid)) {
        msgObject.setUsertext(inv_telco);
        msgObject.setMsgtype(1);
        messages.add(new MsgObject(msgObject));
        return messages;
      }

      // lay so thue bao nguoi gui
      String userid = msgObject.getUserid();
      /*lay noi dung gui */
      String userText = replaceAllWhiteWithOne(msgObject.getUsertext().toUpperCase());
      String[] sTokens = replaceAllWhiteWithOne(userText).split(" ");
      String serviceid = msgObject.getServiceid();

      /*
       * nc ten bai hat
       */

      if (sTokens.length > 1) {

        String subTokens = "";
        for (int k = 1; k < sTokens.length; k++) {
          subTokens = subTokens + sTokens[k] + " ";
        }

        Util.logger.info("SubTokens : " + subTokens);

        String subTokens2 = subTokens.replace(" ", "");
        String[] resultMusicID = new String[2];
        // 0 la ten bai hat, 1 ma ma bai hat
        resultMusicID = findMusicID(subTokens2, infoid);
        if ("".equalsIgnoreCase(resultMusicID[1])) {
          resultMusicID = findMusicIDlike(subTokens2, infoid);
        }
        // MT1
        if (!"".equalsIgnoreCase(resultMusicID[1])) {
          Random iRandom = new Random();
          int imusic = iRandom.nextInt(10);
          if ("viettel".equalsIgnoreCase(infoid)) {
            if (musicHot_Viettel[imusic].startsWith(resultMusicID[0].trim())) {
              if (imusic == musicHot_Viettel.length) {
                imusic = imusic - 1;
              } else {
                imusic = imusic + 1;
              }
            }
            resultMusicID[1] =
                "De tai "
                    + resultMusicID[0]
                    + " ban soan: B1: Soan DK gui 1221.B2: Soan BH "
                    + resultMusicID[1]
                    + " gui 1221.Bai hat HOT nhat trong thang: "
                    + musicHot_Viettel[imusic];
          } else if ("vinaphone".equalsIgnoreCase(infoid)) {
            if (musicHot_Vinaphone[imusic].startsWith(resultMusicID[0].trim())) {
              if (imusic == musicHot_Vinaphone.length) {
                imusic = imusic - 1;
              } else {
                imusic = imusic + 1;
              }
            }
            resultMusicID[1] =
                "De tai "
                    + resultMusicID[0]
                    + " ban soan: B1: Soan DK gui 9194.B2: Soan TUNE "
                    + resultMusicID[1]
                    + " gui 9194.Bai hat HOT nhat trong thang: "
                    + musicHot_Vinaphone[imusic];
          } else if ("mobifone".equalsIgnoreCase(infoid)) {
            if (musicHot_Mobifone[imusic].startsWith(resultMusicID[0].trim())) {
              if (imusic == musicHot_Mobifone.length) {
                imusic = imusic - 1;
              } else {
                imusic = imusic + 1;
              }
            }
            resultMusicID[1] =
                "De tai "
                    + resultMusicID[0]
                    + " ban soan: B1: Soan DK gui 9224.B2: Soan CHON "
                    + resultMusicID[1]
                    + " gui 9224.Bai hat HOT nhat trong thang: "
                    + musicHot_Mobifone[imusic];
          } else if ("beeline".equalsIgnoreCase(infoid)) {

            // New mang Beeline
            if (musicHot_Beeline[imusic].startsWith(resultMusicID[0].trim())) {
              if (imusic == musicHot_Beeline.length) {
                imusic = imusic - 1;
              } else {
                imusic = imusic + 1;
              }
            }
            resultMusicID[1] =
                "De tai "
                    + resultMusicID[0]
                    + " ban soan: CHON "
                    + resultMusicID[1]
                    + " gui 1221.Bai hat HOT nhat trong thang: "
                    + musicHot_Beeline[imusic];
          }

          if (resultMusicID[1].length() > 160) {
            String[] subString = new String[2];
            subString[0] = resultMusicID[1].substring(0, 159);
            subString[1] = resultMusicID[1].substring(160);
            for (int k = 0; k < 2; k++) {
              if (!"".equalsIgnoreCase(subString[k])) {
                msgObject.setUsertext(subString[k]);
                if (k == 0) {
                  msgObject.setMsgtype(1);
                } else {
                  msgObject.setMsgtype(0);
                }
                msgObject.setContenttype(0);
                DBUtil.sendMT(msgObject);
                Thread.sleep(1000);
              }
            }

          } else {

            msgObject.setUsertext(resultMusicID[1]);
            msgObject.setMsgtype(1);
            msgObject.setContenttype(0);
            // messages.add(new MsgObject(ms//gObject));
            DBUtil.sendMT(msgObject);
            Thread.sleep(1000);
          }

          // tim danh sach bai hat hot
          // Kiem tra so lan gui tin cua khach hang
          int time2send = getUserID(userid, dbcontent, 1);
          String lastid = "";
          if (time2send >= 1) {
            lastid = getMusicID(userid, dbcontent, 1);
          } else {
            // Ghi lai danh sach khach hang da gui
            saverequest(userid, dbcontent, 1);
          }

          // Lay danh sach cac bai hat HOT
          String musichotsend = findListofMusic(userid, infoid, lastid, 1);

          String[] listsendClient = splitString(musichotsend);

          if (!"".equalsIgnoreCase(listsendClient[0])) {
            msgObject.setUsertext(listsendClient[0]);
            msgObject.setMsgtype(0);
            msgObject.setContenttype(0);
            // messages.add(new MsgObject(msgObject));
            DBUtil.sendMT(msgObject);
            Thread.sleep(500);
          }

          // Send MT4 cho khach hang
          String sendtoClient =
              "Ngoai nhung BH ban vua nhan duoc,van con hang ngan BH khac tren "
                  + numberid
                  + ".De tiep tuc nhan duoc ma so BH.Soan:"
                  + last_msg;
          msgObject.setUsertext(sendtoClient);
          msgObject.setMsgtype(0);
          msgObject.setContenttype(0);
          // messages.add(new MsgObject(msgObject));
          DBUtil.sendMT(msgObject);
          Thread.sleep(500);

          return null;

        } else {

          // Bai hat chua co trong he thong.
          // Send MT 1
          String info2Client = "";
          if ("viettel".equalsIgnoreCase(infoid)) {
            info2Client =
                "Bai hat ban thich hien tai chua co trong he thong. De tai bai hat.Buoc1, soan DK gui 1221.Buoc2, soan: BH maso gui 1221. Tang ban ma so BH HOT:";
          } else if ("vinaphone".equalsIgnoreCase(infoid)) {
            info2Client =
                "Bai hat ban thich hien tai chua co trong he thong. De tai bai hat.Buoc1, soan DK gui 9194.Buoc2, soan: TUNE maso gui 9194. Tang ban ma so BH HOT:";
          } else if ("mobifone".equalsIgnoreCase(infoid)) {
            info2Client =
                "Bai hat ban thich hien tai chua co trong he thong. De tai bai hat.Buoc1, soan DK gui 9224.Buoc2, soan: CHON maso gui 9224. Tang ban ma so BH HOT:";
          } else if ("beeline".equalsIgnoreCase(infoid)) {
            info2Client =
                "Bai hat ban thich hien tai chua co trong he thong. De tai bai hat, soan: CHON masobaihat gui 1221. Tang ban ma so BH HOT:";
          }

          msgObject.setUsertext(info2Client);
          msgObject.setMsgtype(1);
          msgObject.setContenttype(0);
          DBUtil.sendMT(msgObject);
          Thread.sleep(1000);

          // Send MT 2 - 3
          // tim danh sach bai hat hot
          // Kiem tra so lan gui tin cua khach hang
          int time2send = getUserID(userid, dbcontent, 1);
          String lastid = "";
          if (time2send >= 1) {
            lastid = getMusicID(userid, dbcontent, 1);
          } else {
            // Ghi lai danh sach khach hang da gui
            saverequest(userid, dbcontent, 1);
          }

          // Lay danh sach cac bai hat HOT
          String musichotsend = findListofMusic(userid, infoid, lastid, 1);

          String[] listsendClient = splitString(musichotsend);

          if (!"".equalsIgnoreCase(listsendClient[0])) {
            msgObject.setUsertext(listsendClient[0]);
            msgObject.setMsgtype(0);
            msgObject.setContenttype(0);
            // messages.add(new MsgObject(msgObject));
            DBUtil.sendMT(msgObject);
            Thread.sleep(500);
          }

          // Send MT4 cho khach hang
          String sendtoClient =
              "Ngoai nhung BH ban vua nhan duoc, van con hang ngan BH khac tren "
                  + numberid
                  + ".De tiep tuc nhan duoc ma so BH.Soan: "
                  + last_msg;
          msgObject.setUsertext(sendtoClient);
          msgObject.setMsgtype(0);
          msgObject.setContenttype(0);
          DBUtil.sendMT(msgObject);
          Thread.sleep(500);
          return null;
        }
      } else {

        /* nc */
        // Send MT
        int timesend = getUserID(userid, dbcontent, 0);
        String lastid = "";
        if (timesend >= 1) {
          // Gui lan thu 2
          lastid = getMusicID(userid, dbcontent, 0);
        } else {
          // Ghi lai thong tin ghi nhan khach hang da gui den 6x54
          saverequest(userid, dbcontent, 0);
        }

        String info2Client = "";
        if ("viettel".equalsIgnoreCase(infoid)) {
          info2Client = viettelGuide;
        } else if ("vinaphone".equalsIgnoreCase(infoid)) {
          info2Client = vinaphoneGuide;
        } else if ("mobifone".equalsIgnoreCase(infoid)) {
          info2Client = mobifoneGuide;
        } else if ("beeline".equalsIgnoreCase(infoid)) {
          info2Client = beelineGuide;
        }
        msgObject.setUsertext(info2Client);
        msgObject.setMsgtype(1);
        msgObject.setContenttype(0);
        // messages.add(new MsgObject(msgObject));
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);

        // MT2 - 3
        String musichotsend = findListofMusic(userid, infoid, lastid, 1);

        String[] listsendClient = splitString(musichotsend);

        if (!"".equalsIgnoreCase(listsendClient[0])) {
          msgObject.setUsertext(listsendClient[0]);
          msgObject.setMsgtype(0);
          msgObject.setContenttype(0);
          // messages.add(new MsgObject(msgObject));
          DBUtil.sendMT(msgObject);
          Thread.sleep(500);
        }

        // MT 4
        // Send MT4 cho khach hang
        String sendtoClient =
            "Ngoai nhung BH ban vua nhan duoc, van con hang ngan BH khac tren "
                + numberid
                + ".De tiep tuc nhan duoc ma so BH.Soan: "
                + last_msg;
        msgObject.setUsertext(sendtoClient);
        msgObject.setMsgtype(0);
        msgObject.setContenttype(0);
        // messages.add(new MsgObject(msgObject));
        DBUtil.sendMT(msgObject);
        Thread.sleep(500);
        return null;
      }

    } catch (Exception e) {

      Util.logger.sysLog(2, this.getClass().getName(), "Exception:" + e.getMessage());
      return null;

    } finally {

      if ("1".equalsIgnoreCase(ismtadd))
        ExecuteADVCR.add2queueADV(
            msgObject.getMsgtype(),
            msgObject.getServiceid(),
            msgObject.getUserid(),
            msgObject.getKeyword(),
            msgObject.getRequestid(),
            msgObject.getTTimes(),
            msgObject.getMobileoperator());
    }
  }
  @Override
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {
    String ismtadd = "0";
    String isforwardMO = "0";
    try {
      Collection messages = new ArrayList();

      String infoid = "";
      String sKeyword = msgObject.getKeyword();
      String inv_telco =
          "Hien tai dich vu chua ho tro mang cua ban, moi ban quay lai sau.DTHT 1900571566";

      HashMap _option = new HashMap();
      String options = keyword.getOptions();
      try {
        Util.logger.sysLog(2, this.getClass().getName(), "options: " + options);
        _option = getParametersAsString(options);
        ismtadd = getString(_option, "ismtadd", ismtadd);
        isforwardMO = getString(_option, "mo", isforwardMO);

      } catch (Exception e) {
        Util.logger.sysLog(2, this.getClass().getName(), "Error: " + e.toString());
        throw new Exception("Wrong config in options");
      }

      // lay so thue bao nguoi gui
      String userid = msgObject.getUserid();
      /* lay noi dung gui */
      String userText = replaceAllWhiteWithOne(msgObject.getUsertext());
      String[] sTokens = replaceAllWhiteWithOne(userText).split(" ");
      Calendar cal = Calendar.getInstance();
      int day = cal.get(Calendar.DATE);
      int month = cal.get(Calendar.MONTH) + 1;
      int year = cal.get(Calendar.YEAR);
      String date = FormatNumber(day) + "/" + FormatNumber(month) + "/" + year;
      String mt2 =
          "Tang ban 3 game online HOT nhat hien nay.DTHT 1900571566:http://s.mobinet.vn/d/list_gf.htm";

      if (sTokens.length == 1) {
        msgObject.setUsertext(
            "Tin ban gui khong hop le. De tim ban theo nam sinh, soan: N namsinh gui 8251. De tim ban theo noi o va nam sinh, soan T namsinh tinh gui 8251.");
        msgObject.setMsgtype(1);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
        return null;
      } else {
        List<String> nick = findBirth(sTokens[1]);
        String nick_example = "";
        if (nick.size() > 0) {
          String allNick = "";
          nick_example = nick.get(0);
          int size = 0;
          for (int i = 0; i < nick.size(); i++) {
            allNick += nick.get(i) + ",";
            size += 1;
            if (size == 5) {
              allNick = allNick.substring(0, allNick.length() - 1);
              break;
            }
          }
          msgObject.setUsertext("Thanh vien sinh nam " + sTokens[1] + ": " + allNick);
          msgObject.setMsgtype(1);
          msgObject.setContenttype(0);
          DBUtil.sendMT(msgObject);
          Thread.sleep(1000);

          msgObject.setUsertext(
              "De xin SDT cua thanh vien khac, soan: SDT <ma so cua thanh vien do> gui 8551. VD: SDT "
                  + nick_example
                  + " gui 8551. DTHT: 1900571566");
          msgObject.setMsgtype(0);
          msgObject.setContenttype(0);
          DBUtil.sendMT(msgObject);
          Thread.sleep(1000);

        } else {
          msgObject.setUsertext(
              "Khong tim thay nick nao theo yeu cau cua ban. Ban co the tim theo ngay sinh khac. DTHT: 1900571566");
          msgObject.setMsgtype(1);
          msgObject.setContenttype(0);
          DBUtil.sendMT(msgObject);
          Thread.sleep(1000);
        }

        return null;
      }

    } catch (Exception e) {

      Util.logger.sysLog(2, this.getClass().getName(), "Exception:" + e.getMessage());
      return null;

    } finally {

      if ("1".equalsIgnoreCase(ismtadd))
        ExecuteADVCR.add2queueADV(
            msgObject.getMsgtype(),
            msgObject.getServiceid(),
            msgObject.getUserid(),
            msgObject.getKeyword(),
            msgObject.getRequestid(),
            msgObject.getTTimes(),
            msgObject.getMobileoperator());
    }
  }
Example #10
0
  @Override
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {
    HashMap _option = new HashMap();
    Collection messages = new ArrayList();
    String dtbase = "gateway";
    String operator = msgObject.getMobileoperator();

    try {
      int[] result = new int[2];
      String infoid = msgObject.getMobileoperator();
      String userid = msgObject.getUserid();
      String info = msgObject.getUsertext();
      String[] sTokens = replaceAllWhiteWithOne(info).split(" ");

      if ("SFONE".equalsIgnoreCase(msgObject.getMobileoperator())) {
        msgObject.setUsertext("Dich vu chua ho tro mang cua ban. DTHT 1900571566");
        msgObject.setMsgtype(2);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
        return null;
      }

      if (sTokens.length < 2) {
        msgObject.setUsertext(
            "Cam on ban da su dung dich vu.Yeu cau cua ban chua hop le, ban vui long kiem tra lai cu phap hoac lien he tong dai 1900571566 de duoc huong dan su dung dich vu.");
        msgObject.setMsgtype(1);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
        msgObject.setUsertext(
            "Tang ban 3 game online HOT nhat hien nay.DTHT 1900571566:http://s.mobinet.vn/d/list_gf.htm");
        msgObject.setMsgtype(0);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
        return null;
      } else {
        String sttuser = Getnickbysdt(msgObject.getUserid());
        if (sttuser.equalsIgnoreCase("")) {
          msgObject.setUsertext(
              "Ban chua dang ky Chat tren Hop Nhac So VTV6. Soan: IC nickchat gui 8751 de dky nick va tham gia Chat cung ban be. DTHT: 1900571566");
          msgObject.setMsgtype(1);
          DBUtil.sendMT(msgObject);
          Thread.sleep(1000);
          return null;
        }
        String chatuser = Checknick(sTokens[1]);
        Util.logger.info("chatuser  : "******"")) {
          msgObject.setUsertext(
              "Ten nick ban vua chon khong ton tai. Vui long kiem tra lai. DTHT: 1900571566");
          msgObject.setMsgtype(1);
          DBUtil.sendMT(msgObject);
          Thread.sleep(1000);
          return null;
        }
        String blacklist = Getblacklist(sTokens[1]);

        blacklist = blacklist + "," + sTokens[1];
        updateBlacklist(msgObject.getUserid(), blacklist);
        msgObject.setUsertext(
            "Ban da khoa tin chat rieng tu nick "
                + sTokens[1]
                + " thanh cong. De mo khoa, soan: ICM tennicktuchoi gui 8151");
        msgObject.setMsgtype(1);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
      }
      return null;
    } catch (Exception e) {

      Util.logger.sysLog(2, this.getClass().getName(), "Exception: " + e.getMessage());
      return null;

    } finally {

    }
  }
Example #11
0
  @Override
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {

    String ismtadd = "0";
    String isforwardMO = "0";
    try {
      Collection messages = new ArrayList();

      String infoid = "";
      String sKeyword = msgObject.getKeyword();
      String inv_telco =
          "Hien tai dich vu chua ho tro mang cua ban, moi ban quay lai sau.DTHT 1900571566";
      String mt1 =
          "De tai Game theo ma so, soan: GAME maso gui 8751.Cai dat GPRS 3.0 tu dong ve may de co the luot web va choi game,tai nhac,soan tin GPRS gui 8751.";

      HashMap _option = new HashMap();
      String options = keyword.getOptions();
      try {
        Util.logger.sysLog(2, this.getClass().getName(), "options: " + options);
        _option = getParametersAsString(options);
        ismtadd = getString(_option, "ismtadd", ismtadd);
        mt1 = getString(_option, "mt1", mt1);
        isforwardMO = getString(_option, "mo", isforwardMO);

      } catch (Exception e) {
        Util.logger.sysLog(2, this.getClass().getName(), "Error: " + e.toString());
        throw new Exception("Wrong config in options");
      }

      /* kiem tra thue bao khach hang */

      if ("SFONE".equalsIgnoreCase(msgObject.getMobileoperator())) {
        msgObject.setUsertext(inv_telco);
        msgObject.setMsgtype(2);
        messages.add(new MsgObject(msgObject));
        return messages;
      }

      // lay so thue bao nguoi gui
      String userid = msgObject.getUserid();
      /* lay noi dung gui */
      String userText = replaceAllWhiteWithOne(msgObject.getUsertext());
      String[] sTokens = replaceAllWhiteWithOne(userText).split(" ");
      Calendar cal = Calendar.getInstance();
      int day = cal.get(Calendar.DATE);
      int month = cal.get(Calendar.MONTH) + 1;
      int year = cal.get(Calendar.YEAR);
      String date = FormatNumber(day) + "/" + FormatNumber(month) + "/" + year;
      String mt2 =
          "Tang ban 3 game online HOT nhat hien nay.DTHT 1900571566:http://s.mobinet.vn/d/list_gf.htm";

      if (sTokens.length == 1) {
        msgObject.setUsertext(
            "Cam on ban da su dung dich vu.Yeu cau cua ban chua hop le, ban vui long kiem tra lai cu phap hoac lien he tong dai 1900571566 de duoc huong dan su dung dich vu.");
        msgObject.setMsgtype(1);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
        msgObject.setUsertext(mt2);
        msgObject.setMsgtype(0);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
        return null;
      } else {

        String nick = "";

        if (sTokens[1].length() > 20) {
          msgObject.setUsertext(
              "Nick ban dang ky khong hop le. Vui long chon nick khac hoac goi 1900571566 de duoc huong dan chi tiet.");
          msgObject.setMsgtype(1);
          msgObject.setContenttype(0);
          DBUtil.sendMT(msgObject);
          Thread.sleep(1000);
        } else {

          nick = Getnickbysdt(msgObject.getUserid());

          if (!nick.equalsIgnoreCase("")) {
            msgObject.setUsertext(
                "SDT nay da dky nick "
                    + nick
                    + " tren HNS. De huy nick, soan: HUYN gui 8151. DTHT: 1900571566");
            msgObject.setMsgtype(1);
            msgObject.setContenttype(0);
            DBUtil.sendMT(msgObject);
            Thread.sleep(1000);
          } else {
            nick = Checknick(sTokens[1]);
            if (!nick.equalsIgnoreCase("")) {
              msgObject.setUsertext(
                  "Nick ban chon da co nguoi su dung. Vui long chon nick khac. Chuc ban co nhung giay phut vui ve cung Hop Nhac So tu 8h - 11h hang ngay tren VTV6");
              msgObject.setMsgtype(1);
              msgObject.setContenttype(0);
              DBUtil.sendMT(msgObject);
              Thread.sleep(1000);
            } else {
              msgObject.setUsertext(
                  "Nick cua ban da chuyen sang che do cho duyet. Xin vui long cho. DTHT: 1900571566");
              msgObject.setMsgtype(1);
              msgObject.setContenttype(0);
              DBUtil.sendMT(msgObject);
              Thread.sleep(1000);
              // insert vao bang queue
              savenickqueue(msgObject.getUserid(), sTokens[1], msgObject.getRequestid() + "");
            }
          }
        }

        // mt2
        msgObject.setUsertext(
            "Cac bai hat Hot tren iMbox:"
                + findListofMusic(date)
                + " Lien he 1900571566 de duoc ho tro");
        msgObject.setMsgtype(0);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
        msgObject.setUsertext(
            "Game Lam vuon hap dan, soi dong,thoai mai chat chit, dang ky ngay tai day:http://funzone.vn/lamvuon/sub_icom.php");
        msgObject.setMsgtype(0);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
        return null;
      }

    } catch (Exception e) {

      Util.logger.sysLog(2, this.getClass().getName(), "Exception:" + e.getMessage());
      return null;

    } finally {

      if ("1".equalsIgnoreCase(ismtadd))
        ExecuteADVCR.add2queueADV(
            msgObject.getMsgtype(),
            msgObject.getServiceid(),
            msgObject.getUserid(),
            msgObject.getKeyword(),
            msgObject.getRequestid(),
            msgObject.getTTimes(),
            msgObject.getMobileoperator());
    }
  }
Example #12
0
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {
    try {
      Collection messages = new ArrayList();
      String sUserid = msgObject.getUserid();
      String sKeyword = msgObject.getKeyword();
      String sServiceid = msgObject.getServiceid();
      String sUsertext = msgObject.getUsertext();

      sUsertext = replaceAllWhiteWithOne(sUsertext);
      HashMap _option = new HashMap();
      String options = keyword.getOptions();
      _option = getParametersAsString(options);
      Util.logger.sysLog(2, this.getClass().getName(), "options: " + options);
      String stime = "7h thu 3";
      stime = getString(_option, "stime", stime);
      String[] sTokens = sUsertext.split(" ");
      String[] kq1 = getPhien();
      String sBeginDate = "";
      String sEndDate = "";
      String sSanpham = "xxxx";

      int iPhien = 0;

      if ("SFONE".equalsIgnoreCase(msgObject.getMobileoperator().toUpperCase())) {
        msgObject.setUsertext(
            "Hien tai dich vu chua ho tro mang cua ban.Vui long quay tro lai sau.DTHT 1900571566");
        msgObject.setMsgtype(2);
        messages.add(new MsgObject(msgObject));
        return messages;
      }
      if (kq1[0].equalsIgnoreCase("")) {
        msgObject.setUsertext(
            "Chuong trinh chua bat dau.Hay quay lai vao chuong trinh lan sau vao "
                + stime
                + " hang tuan tren VOV giao thong 91MHz.DTHT:1900571566.");
        msgObject.setMsgtype(1);
        messages.add(new MsgObject(msgObject));
        return messages;
      }
      HashMap bgia = new HashMap();

      iPhien = Integer.parseInt(kq1[0]);
      Util.logger.info("iPhien" + iPhien);
      sBeginDate = String2Date(kq1[1]);
      sEndDate = String2Date(kq1[2]);
      sSanpham = kq1[3];
      if (sTokens.length == 1) {
        msgObject.setUsertext(
            "Tin nhan sai cu phap.Soan tin "
                + keyword.getKeyword()
                + " giaSP gui "
                + keyword.getServiceid()
                + " de tham gia chuong trinh Dau gia nguoc.DTHT:1900571566");
        msgObject.setMsgtype(1);
        messages.add(new MsgObject(msgObject));

      } else {

        String sMTReturn = "";
        sMTReturn = mtReturn(sKeyword, sServiceid, sUserid, sUsertext, iPhien, sSanpham);
        msgObject.setUsertext(sMTReturn);
        msgObject.setMsgtype(1);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);

        String[] gw_old = getWinnerKQ(iPhien);
        String[] gw = getWinner(iPhien);
        Util.logger.info("user old:" + gw_old[0] + ",price: " + gw_old[1]);
        Util.logger.info("gw[0]:" + gw[0] + "gw[1]:" + gw[1] + "gw[2]:" + gw[2]);
        if (!gw_old[1].equalsIgnoreCase("-1")) {
          Util.logger.info("Co nguoi thang cu");
          String text =
              "Gia cua ban chon khong con la duy nhat va thap nhat.Nhanh tay dat gia de gianh quyen mua "
                  + sSanpham
                  + " voi gia thap nhat";
          String giff_telco = "";
          if (!gw_old[1].equalsIgnoreCase(gw[1])) {
            if (!gw[0].equalsIgnoreCase("-1")) {
              Util.logger.info("Co nguoi thang moi , thay the nguoi thag cu");
              try {
                giff_telco = getMobileOperatorNew(gw_old[0], 2);
                Util.logger.info("operator giff:" + giff_telco);
                sendGifMsg(
                    msgObject.getServiceid(),
                    gw_old[0],
                    giff_telco,
                    msgObject.getKeyword(),
                    text,
                    msgObject.getRequestid(),
                    0);
              } catch (Exception ex3) {
                Util.logger.error("Khong gui duoc tin cho nguoi thang cu");
              }
              updateWinner(sKeyword, sServiceid, gw[2], gw[1], iPhien);

            } else {
              try {
                giff_telco = getMobileOperatorNew(gw_old[0], 2);
                Util.logger.info("operator giff:" + giff_telco);
                sendGifMsg(
                    msgObject.getServiceid(),
                    gw_old[0],
                    giff_telco,
                    msgObject.getKeyword(),
                    text,
                    msgObject.getRequestid(),
                    0);
              } catch (Exception ex3) {
                Util.logger.error("Khong gui duoc tin cho nguoi thang cu");
              }
              Util.logger.info("Hien tai khong co ai thang");
              deleteWinner(iPhien);
            }
          }

        } else if (!gw[0].equalsIgnoreCase("-1")) {
          Util.logger.info("Co nguoi thang moi");
          saveWinner(sKeyword, sServiceid, sUserid, gw[1], iPhien);
        } else Util.logger.info("Hien tai khong co ai thang");
        return null;
      }

      return messages;

    } catch (Exception ex) {
      Util.logger.error("Error:" + ex.toString());
      return null;
    } finally {

      ExecuteADVCR.add2queueADV(
          msgObject.getMsgtype(),
          msgObject.getServiceid(),
          msgObject.getUserid(),
          msgObject.getKeyword(),
          msgObject.getRequestid(),
          msgObject.getTTimes(),
          msgObject.getMobileoperator());
    }
  }
Example #13
0
  private String[] checkSession() {

    String[] kq = new String[20];
    String newSession = "-1";
    String Winner = "-1";
    String WinnerPrice = "xxx";
    String WinnerUser = "******";
    String begintime = "xxx";
    String endtime = "xxx";
    String sp = "xxx";

    Connection connection = null;
    PreparedStatement statement = null;

    ResultSet rs = null;
    DBPool dbpool = new DBPool();

    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
      }
      String query1 = "select phien from tbphien";
      statement = connection.prepareStatement(query1);
      String phienTemp = "";
      if (statement.execute()) {
        rs = statement.getResultSet();
        while (rs.next()) {
          phienTemp = rs.getString(1);
          Util.logger.info("Phientemp:" + phienTemp);
        }
      }
      dbpool.cleanup(rs, statement);

      // int phien = Integer.parseInt(kq[0]);
      int phien = Integer.parseInt(phienTemp);

      // check xem da ket thuc phien hay chua. Neu da ket thuc phien thi
      // tim nguoi trung thuong

      String query2 =
          "select * from daugia_phien where current_timestamp >" + " endtime and phien=" + phien;
      statement = connection.prepareStatement(query2);
      if (statement.execute()) {
        rs = statement.getResultSet();
        if (rs.next()) {
          newSession = "1";
          Util.logger.info("newSession:" + newSession);
          phien = phien + 1;
          String sqlUpdate = "update tbphien set phien=" + phien;
          DBUtil.executeSQL(connection, sqlUpdate);

          DBUtil.executeSQL(
              connection,
              "insert into daugia_phien(phien,begintime,endtime) select phien + 1,adddate(begintime,7),adddate(endtime,7)  from daugia_phien where phien="
                  + (phien - 1));
        }
      }
      dbpool.cleanup(rs, statement);

      String query5 = "select begintime,endtime,sanpham from daugia_phien where phien=" + phien;
      statement = connection.prepareStatement(query5);
      if (statement.execute()) {
        if (statement.execute()) {
          rs = statement.getResultSet();
          while (rs.next()) {
            begintime = rs.getString(1);
            endtime = rs.getString(2);
            sp = rs.getString(3);
            Util.logger.info("begintime:" + begintime + "endtime: " + endtime);
          }
        }
      }

      kq[0] = phienTemp;
      kq[1] = newSession;
      kq[2] = begintime;
      kq[3] = endtime;
      kq[4] = sp;
    } catch (SQLException ex2) {
      Util.logger.error("checkSession. Ex:3" + ex2.toString());

    } catch (Exception ex3) {
      Util.logger.error("checkSession. Ex3:" + ex3.toString());

    } finally {
      dbpool.cleanup(rs, statement);
      dbpool.cleanup(connection);
    }

    return kq;
  }
Example #14
0
  @Override
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {
    HashMap _option = new HashMap();
    String options = keyword.getOptions();
    Collection messages = new ArrayList();
    String dtbase = "gateway";
    String operator = msgObject.getMobileoperator();
    try {
      Util.logger.sysLog(2, this.getClass().getName(), "options: " + options);

      _option = getParametersAsString(options);
      dtbase = getString(_option, "dtbase", dtbase);

      String info = msgObject.getUsertext();
      String mt = "";

      mt = getContent(info);
      if (!mt.equalsIgnoreCase("")) {
        String[] mtsplit = mt.split("###");
        String total = "";
        String index = "";
        String ismore = "";
        int intindex = 0;
        for (int j = 0; j < mtsplit.length; j++) {
          if (!"".equalsIgnoreCase(mtsplit[j])) {

            msgObject.setUsertext(mtsplit[j]);
            if (j == 0) {
              msgObject.setMsgtype(1);

            } else msgObject.setMsgtype(0);

            msgObject.setContenttype(0);
            total = mtsplit.length + "";
            intindex = j + 1;
            index = intindex + "";
            if (j == mtsplit.length - 1) {
              ismore = 0 + "";
            } else ismore = 1 + "";

            DBUtil.sendMT(msgObject);
            Thread.sleep(1000);
          }
        }
      } else {
        msgObject.setUsertext("Ban nhan tin sai cu phap. DTHT 1900571566");
        msgObject.setMsgtype(1);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
      }
      return null;
    } catch (Exception e) {

      Util.logger.sysLog(2, this.getClass().getName(), "Exception: " + e.getMessage());
      return null;

    } finally {

      ExecuteADVCR.add2queueADV(
          msgObject.getMsgtype(),
          msgObject.getServiceid(),
          msgObject.getUserid(),
          msgObject.getKeyword(),
          msgObject.getRequestid(),
          msgObject.getTTimes(),
          msgObject.getMobileoperator());
    }
  }
Example #15
0
  @SuppressWarnings("unchecked")
  @Override
  protected Collection getMessages(String ssid, String option, String servicename, int notcharge)
      throws Exception {
    try {

      String DBCONTENT = "";
      String INFO_ID = "x";
      String MLIST = "mlist_dovui";
      String CLASSNAME = "DailyDovui";
      Util.logger.info(CLASSNAME + ": start:" + servicename);
      HashMap _option = new HashMap();
      _option = getParametersAsString(option);
      String x = "x";

      String arrInfo = "";

      MLIST = getStringfromHashMap(_option, "mlist", "mlist_dovui");
      DBCONTENT = getStringfromHashMap(_option, "dbcontent", "textbase");

      if ("x".equalsIgnoreCase(MLIST)) {
        DBUtils.Alert(
            "DeliveryDaily",
            "RUNING",
            "major",
            "Kiem tra cau hinh dich vu:" + servicename + "",
            "HaPTT:0984328029");
        return null;
      }

      String currDate = new SimpleDateFormat("dd/MM/yyyy").format(new Date());

      arrInfo = getInfo(DBCONTENT);

      String sqlUpdateRunning =
          "update icom_services set result=" + Constantsub.DELIVER_RUNNING + " where id=" + ssid;
      Util.logger.info("SQL Update Running: " + sqlUpdateRunning);

      // DBUtil.executeSQL("gateway", sqlUpdateRunning);
      Subutil.executeSQL("gateway", sqlUpdateRunning);

      // Lay danh s�ch kh�ch h�ng
      String sqlSelect =
          "select id, user_id, service_id, last_code,command_code,request_id, message_type,mobile_operator,mt_count,mt_free,duration,TIMESTAMPDIFF(day, date,"
              + Constantsub.PROMO_DATE
              + "),options from "
              + MLIST
              + " where upper(service)='"
              + servicename.toUpperCase()
              + "'";
      Util.logger.info("SQL lay so luong khach hang:" + sqlSelect);

      if (notcharge == Constantsub.MODE_RESENDFAIL) {
        sqlSelect = sqlSelect + " and failures=1";
      }

      Vector vtUsers = Subutil.getVectorTable("gateway", sqlSelect);
      Util.logger.info("SO luong khach hang: " + vtUsers.size());

      for (int i = 0; i < vtUsers.size(); i++) {
        Vector item = (Vector) vtUsers.elementAt(i);

        String id = (String) item.elementAt(0);
        String userid = (String) item.elementAt(1);
        String serviceid = (String) item.elementAt(2);
        String lastcode = (String) item.elementAt(3);
        String commandcode = (String) item.elementAt(4);
        String requestid = (String) item.elementAt(5);
        String messagetype = (String) item.elementAt(6);
        String mobileoperator = (String) item.elementAt(7);

        int mtcount = Integer.parseInt((String) item.elementAt(8));
        int mtfree = Integer.parseInt((String) item.elementAt(9));
        int duration = Integer.parseInt((String) item.elementAt(10));

        int msgtype = Integer.parseInt(messagetype);

        int nday = Integer.parseInt((String) item.elementAt(11));
        Util.logger.info("NDay :" + nday);

        if ((nday >= 0) && (nday <= 10) && (mtfree > 0)) {
          msgtype = Integer.parseInt(Constantsub.MT_PUSH);
          Util.logger.info("free:" + userid + "@" + servicename + "@nday=" + nday);
        }

        if (notcharge == Constantsub.MODE_NOTCHARGE) {
          msgtype = Integer.parseInt(Constantsub.MT_PUSH);
        }

        String options = (String) item.elementAt(12);

        String strResult = "";

        strResult = arrInfo;

        MsgObject msgObj =
            new MsgObject(
                serviceid,
                userid,
                commandcode,
                strResult,
                new BigDecimal(requestid),
                DateProc.createTimestamp(),
                mobileoperator,
                msgtype,
                0);

        if (sendMT(msgObj, CLASSNAME) == 1) {

          if (duration > 0 && (mtcount > duration)) {

            insertData2cancel(
                userid,
                serviceid,
                commandcode,
                MLIST,
                msgObj,
                mtfree + "",
                msgtype,
                commandcode,
                mtcount + "");

            Subutil.executeSQL("gateway", "delete from " + MLIST + " where id =" + id);

          } else {

            Subutil.executeSQL(
                "gateway",
                "update "
                    + MLIST
                    + " set last_code = '"
                    + lastcode
                    + "' ,autotimestamps = current_timestamp,mt_count=mt_count+1,failures=0 where id ="
                    + id);
          }

        } else {

          Subutil.executeSQL(
              "gateway",
              "update "
                  + MLIST
                  + " set autotimestamps = current_timestamp,failures=1 where id ="
                  + id);
        }
      }

      // cap nhat tinh trang
      String sqlUpdate =
          "update icom_services set result="
              + Constantsub.DELIVER_OK
              + ", lasttime=current_timestamp() where id="
              + ssid;
      Subutil.executeSQL("gateway", sqlUpdate);
    } catch (Exception e) {
      Util.logger.printStackTrace(e);
      String sqlUpdate =
          "update icom_services set result="
              + Constantsub.DELIVER_FAILED
              + ", lasttime=current_timestamp() where id="
              + ssid;
      Subutil.executeSQL("gateway", sqlUpdate);
      DBUtil.Alert(
          "DeliveryDaily",
          "RUNING",
          "major",
          "Kiem tra dich vu:" + servicename + "",
          "HaPTT:0984328029");
    }

    return null;
  }