コード例 #1
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;
  }
コード例 #2
0
ファイル: SendMO.java プロジェクト: chilinh12003/MyEclipse
  @Override
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {

    HashMap _option = new HashMap();
    String options = keyword.getOptions();
    _option = getParametersAsString(options);

    Collection messages = new ArrayList();
    try {
      String info = msgObject.getUsertext();
      String[] sTokens = replaceAllWhiteWithOne(info).split(" ");
      String sinfo = msgObject.getUsertext();

      msgObject.setUsertext(sinfo.replace(" ", "+"));
      if (SoapLiveSMS.getMessages(msgObject))
        Util.logger.info(msgObject.getUserid() + "@" + msgObject.getUsertext() + "OK");
      else Util.logger.info("Chua post duoc");
      return null;
    } catch (Exception e) {

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

    } finally {

    }
  }
コード例 #3
0
ファイル: SoiCau.java プロジェクト: chilinh12003/MyEclipse
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {
    Collection messages = new ArrayList();
    // String dbcontent = "textbase";
    String gameid = "soicau";
    String sServiceID = msgObject.getServiceid();
    String sMsg = replaceAllWhiteLetter(msgObject.getUsertext());

    // String COMPANY_NAME = "";
    String COMMAND_CODE = "INV";
    String sMsg1 = replaceAllWhiteWithOne(sMsg);
    sMsg1 = validMsgInput(sMsg1);
    // Lấy CAUXXX
    COMMAND_CODE = getCommandCode(sMsg1);

    try {

      // Neu ma tinh khong ton tai thi return luon
      if ("INV".equalsIgnoreCase(COMMAND_CODE)) {
        msgObject.setUsertext(
            "Tin sai cu phap. Hay soan tin:\n*CAU<MaTinh> gui "
                + sServiceID
                + " de soi cau.\n*XS<MaTinh> de xem Tuong thuat truc tiep ket qua");
        msgObject.setMsgtype(1);
        messages.add(new MsgObject(msgObject));
        return messages;
      }
      int companyId = getCompanyId(COMMAND_CODE);
      // Lay noi dung va tra ve
      String hour = getTimeLottery(companyId);

      // Neu thoi gian ma lon hon
      if (!isNewSession(hour)) {
        msgObject.setUsertext("Hien tai he thong chua cap nhat cho ngay moi. Vui long lien he lai");
      } else {
        String content = getContent(gameid, COMMAND_CODE);
        String[] sTokens = content.split("###");

        for (int i = 0; i < sTokens.length; i++) {
          if (!"".equalsIgnoreCase(sTokens[i])) {
            msgObject.setUsertext(sTokens[i]);
            if (i == 0) {
              msgObject.setMsgtype(1);
            } else {
              msgObject.setMsgtype(0);
            }
            msgObject.setContenttype(0);
            messages.add(new MsgObject(msgObject));
          }
        }
      }
      return messages;

    } catch (Exception e) {
      msgObject.setUsertext(
          "Tin sai cu phap. Hay soan tin:\n*CAU<MaTinh> gui "
              + sServiceID
              + " de soi cau.\n*XS<MaTinh> de xem Tuong thuat truc tiep ket qua");
    }
    return messages;
  }
コード例 #4
0
ファイル: Chan1nick.java プロジェクト: chilinh12003/MyEclipse
  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");
    }
  }
コード例 #5
0
ファイル: SoapFIDOLR.java プロジェクト: utcuong3010/vng
 private void writeLogInfo(MsgObject msgObject, String result, String message, int iRetries) {
   Util.logger.info(
       this.getClass().getName()
           + ".getMessages() - "
           + "Respone Code: ["
           + result
           + "]. "
           + message
           + ", Details: MO_ID: ["
           + msgObject.getMo_id()
           + "] UserID: ["
           + msgObject.getUserid()
           + "] ServiceID: ["
           + msgObject.getServiceid()
           + "] Keyword: ["
           + msgObject.getKeyword()
           + "] RequestID: ["
           + msgObject.getRequestid()
           + "] CommandCode: ["
           + msgObject.getKeyword()
           + "] RequestTime: ["
           + SOAPConstants.convertTimestampToString(msgObject.getTTimes(), SOAPConstants.DATE_TIME)
           + "] Online Retry countdown: "
           + iRetries);
 }
コード例 #6
0
  @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());
    }
  }
コード例 #7
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";

      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());
    }
  }
コード例 #8
0
ファイル: Chan1nick.java プロジェクト: chilinh12003/MyEclipse
  @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 {

    }
  }
コード例 #9
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());
    }
  }
コード例 #10
0
ファイル: Daugia.java プロジェクト: chilinh12003/MyEclipse
  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());
    }
  }
コード例 #11
0
ファイル: SDPtext.java プロジェクト: chilinh12003/MyEclipse
  @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());
    }
  }
コード例 #12
0
ファイル: SoapFIDOLR.java プロジェクト: utcuong3010/vng
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {
    int iRetries = 3;
    int iTimeout = SOAPConstants.RETRIES_TIME;
    Collection messages = new ArrayList();
    String result = "";

    if (!isOKConfig()) {
      msgObject.setUsertext(Constants._prop.getProperty("MESSAGE_SYSTEM_OVERLOAD"));
      msgObject.setMsgtype(CHARGE_BACK);
      messages.add(new MsgObject(msgObject));
      return messages;
    }
    if (!isAllowOperator(msgObject.getMobileoperator())) {
      msgObject.setUsertext(
          Constants._prop
              .getProperty(
                  "ADS_ONLY_SUPPORT_FOR_OPERATOR",
                  "Hien tai he thong chi ho tro cho thue bao Mobifone")
              .trim());
      msgObject.setMsgtype(CHARGE_BACK);
      messages.add(new MsgObject(msgObject));
      return messages;
    }

    if (!msgObject.getKeyword().equalsIgnoreCase(msgObject.getUsertext().split(" ")[0].trim())) {
      msgObject.setUsertext(INVALID_SYNTAX);
      msgObject.setMsgtype(CHARGE_BACK);
      messages.add(new MsgObject(msgObject));
      return messages;
    }

    KeywordWhiteList keywordWhiteList =
        WSConfigLoader.getInstance()
            .getKeywordWhiteListByKeywordServiceID(keyword.getKeyword() + msgObject.getServiceid());
    if (keywordWhiteList != null
        && !inWhiteList(keywordWhiteList.getWhiteList(), msgObject.getUserid())) {
      msgObject.setUsertext(keywordWhiteList.getMsgReturn());
      msgObject.setMsgtype(keywordWhiteList.getMsgType());
      messages.add(new MsgObject(msgObject));
      return messages;
    } else {
      keywordWhiteList =
          WSConfigLoader.getInstance()
              .getKeywordWhiteListByKeywordServiceID(
                  keyword.getKeyword() + msgObject.getServiceid() + msgObject.getMobileoperator());
      if (keywordWhiteList != null
          && !inWhiteList(keywordWhiteList.getWhiteList(), msgObject.getUserid())) {
        msgObject.setUsertext(keywordWhiteList.getMsgReturn());
        msgObject.setMsgtype(keywordWhiteList.getMsgType());
        messages.add(new MsgObject(msgObject));
        return messages;
      }
    }

    WSConfig wsConfig = WSConfigLoader.getInstance().getWSConfigByCpCode(FIDOL_CP_CODE);
    if (wsConfig == null) {
      Util.logger.warn(
          this.getClass().getName()
              + ".getMessages():  URL WebService for CPCODE:["
              + FIDOL_CP_CODE
              + "] Not Found");
      msgObject.setUsertext(Constants._prop.getProperty("MESSAGE_SYSTEM_OVERLOAD"));
      msgObject.setMsgtype(CHARGE_BACK);
      messages.add(new MsgObject(msgObject));
      return messages;
    }

    while (iRetries > 0) {
      try {
        result = sendMessageMO(msgObject, wsConfig);

        // 1 transaction OK!
        if ("1".equals(result)) {
          writeLogInfo(msgObject, result, "Send OK!", iRetries);
          return null;
        } else if ("-7".equals(result)) {
          writeLogError(msgObject, result, "Username & Password does not match", iRetries);
          msgObject.setMsgNotes(
              "Respone Code: [" + result + "]. Username & Password does not match");
          add2SMSSendFailed(msgObject);
          msgObject.setUsertext(Constants._prop.getProperty("MESSAGE_SYSTEM_OVERLOAD"));
          msgObject.setMsgtype(CHARGE_BACK);
          messages.add(new MsgObject(msgObject));
          return messages;
        } else if ("-6".equals(result)) {
          writeLogError(msgObject, result, "System Busy", iRetries);
          msgObject.setMsgNotes("Respone Code: [" + result + "]. System Busy");
          add2SMSSendFailed(msgObject);
          msgObject.setUsertext(Constants._prop.getProperty("MESSAGE_SYSTEM_OVERLOAD"));
          msgObject.setMsgtype(CHARGE_BACK);
          messages.add(new MsgObject(msgObject));
          return messages;
        } else {
          writeLogError(msgObject, result, "Going For Retry, Sleeping", iRetries);
          msgObject.setMsgNotes("Respone Code: [" + result + "]. Going For Retry, Sleeping");

          iRetries--;
          Thread.sleep(iTimeout * 1000);
          continue;
        }
      } catch (Exception e) {
        String message = "";
        message = (e != null) ? e.getMessage() : "NULL";

        Util.logger.error(
            this.getClass().getName()
                + ".getMessages()@"
                + "ERROR!: "
                + message
                + ". Got Respone Code: ["
                + result
                + "], Going For Retry, Sleeping,Details: MO_ID: ["
                + msgObject.getMo_id()
                + "] UserID: ["
                + msgObject.getUserid()
                + "] ServiceID: ["
                + msgObject.getServiceid()
                + "] Keyword: ["
                + msgObject.getKeyword()
                + "] RequestID: ["
                + msgObject.getRequestid()
                + "] CommandCode: ["
                + msgObject.getKeyword()
                + "] RequestTime: ["
                + SOAPConstants.convertTimestampToString(
                    msgObject.getTTimes(), SOAPConstants.DATE_TIME)
                + "] Online Retry countdown: "
                + iRetries);
        msgObject.setMsgNotes("Respone Code: [" + result + "]. " + message);

        iRetries--;
        Thread.sleep(iTimeout * 1000);
        continue;
      }
    }

    add2SMSSendFailed(msgObject);
    String returnMessage = Constants._prop.getProperty("MESSAGE_SYSTEM_OVERLOAD");
    msgObject.setUsertext(returnMessage);
    msgObject.setMsgtype(CHARGE_BACK);
    messages.add(msgObject);
    return messages;
  }
コード例 #13
0
ファイル: SoapFIDOLR.java プロジェクト: utcuong3010/vng
  private static BigDecimal add2SMSSendFailed(MsgObject msgObject) {
    BigDecimal result = msgObject.getRequestid();

    Util.logger.info(
        className
            + ".add2SMSSendFailed():"
            + msgObject.getUserid()
            + "@"
            + msgObject.getUsertext());
    String tablename = "sms_receive_error";
    String sSQLInsert =
        "insert into "
            + tablename
            + "(REQUEST_ID,USER_ID,SERVICE_ID,MOBILE_OPERATOR,COMMAND_CODE,INFO,RECEIVE_DATE,RESPONDED,CPID, NOTES)"
            + " values(?,?,?,?,?,?,?,?,?,?)";

    Connection connection = null;
    PreparedStatement ps = null;
    DBPool dbpool = new DBPool();
    try {
      connection = dbpool.getConnectionGateway();

      ps = connection.prepareStatement(sSQLInsert);
      // ps.setBigDecimal(1, msgObject.getRequestid());
      ps.setBigDecimal(1, new BigDecimal(msgObject.getMo_id()));
      ps.setString(2, msgObject.getUserid());
      ps.setString(3, msgObject.getServiceid());
      ps.setString(4, msgObject.getMobileoperator());
      ps.setString(5, msgObject.getKeyword());
      ps.setString(6, msgObject.getUsertext());
      ps.setTimestamp(7, msgObject.getTTimes());
      ps.setInt(8, 0);
      ps.setInt(9, msgObject.getCpid());

      String notes = msgObject.getMsgnotes();
      if (notes != null && notes.length() > 255) {
        notes = notes.substring(0, 254);
      }

      ps.setString(10, notes);
      if (ps.executeUpdate() != 1) {
        Util.logger.error(
            className
                + ".add2SMSSendFailed():"
                + msgObject.getUserid()
                + ":"
                + msgObject.getUsertext()
                + ":ps.executeUpdate failed");
        result = new BigDecimal(-1);
      }
      ps.close();
    } catch (SQLException e) {
      Util.logger.error(
          className
              + ".add2SMSSendFailed():"
              + msgObject.getUserid()
              + ":"
              + msgObject.getUsertext()
              + ":Error add row from sms receive error:"
              + e.toString());
      result = new BigDecimal(-1);
    } catch (Exception e) {
      Util.logger.error(
          className
              + ".add2SMSSendFailed():"
              + msgObject.getUserid()
              + ":"
              + msgObject.getUsertext()
              + ":Error add row from sms receive error:"
              + e.toString());
      result = new BigDecimal(-1);
    } finally {
      dbpool.cleanup(connection);
    }

    return result;
  }
コード例 #14
0
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {
    try {

      Collection messages = new ArrayList();
      MsgObject mt = msgObject;

      String sUserid = msgObject.getUserid();
      String sKeyword = msgObject.getKeyword();
      String sServiceid = msgObject.getServiceid();

      String sMTReturn = mtReturn(sUserid, sServiceid, sKeyword);
      mt.setUsertext(sMTReturn);
      mt.setMsgtype(1);
      messages.add(new MsgObject(mt));
      return messages;
    } catch (Exception e) {
      // TODO: handle exception
      return null;

    } finally {
      ExecuteADVCR.add2queueADV(
          msgObject.getMsgtype(),
          msgObject.getServiceid(),
          msgObject.getUserid(),
          msgObject.getKeyword(),
          msgObject.getRequestid(),
          msgObject.getTTimes(),
          msgObject.getMobileoperator());
    }
  }
コード例 #15
0
  // Chay class va send noi dung cho khach hang
  private static int sendMT(MsgObject msgObject, String sclassname) {

    Connection connection = null;
    PreparedStatement statement = null;
    String sqlString = null;
    if ("".equalsIgnoreCase(msgObject.getUsertext().trim()) || msgObject.getUsertext() == null) {
      // Truong hop gui ban tin loi
      Util.logger.error(
          sclassname
              + "@sendMT@userid="
              + msgObject.getUserid()
              + "@serviceid="
              + msgObject.getServiceid()
              + "@requestid="
              + msgObject.getRequestid().toString()
              + "@message is null - LOST MESSAGE");
      return 1;
    }

    DBPool dbpool = new DBPool();

    Util.logger.info(
        sclassname
            + "@sendMT@userid="
            + msgObject.getUserid()
            + "@serviceid="
            + msgObject.getServiceid()
            + "@usertext="
            + msgObject.getUsertext()
            + "@messagetype="
            + msgObject.getMsgtype()
            + "@requestid="
            + msgObject.getRequestid().toString());

    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.crisis(
            sclassname
                + "@sendMT: Error connection == null"
                + msgObject.getUserid()
                + "@TO"
                + msgObject.getServiceid()
                + "@"
                + msgObject.getUsertext()
                + "@requestid="
                + msgObject.getRequestid().toString());
        return -1;
      }

      // USER_ID, SERVICE_ID, MOBILE_OPERATOR, COMMAND_CODE, CONTENT_TYPE,
      // INFO, MESSAGE_TYPE, REQUEST_ID
      sqlString =
          "INSERT INTO "
              + "ems_send_queue( USER_ID, SERVICE_ID, MOBILE_OPERATOR, COMMAND_CODE, CONTENT_TYPE, INFO,  MESSAGE_TYPE, REQUEST_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";

      // USER_ID, SERVICE_ID, MOBILE_OPERATOR, COMMAND_CODE,
      // CONTENT_TYPE, INFO, MESSAGE_TYPE, REQUEST_ID
      // Split các tin trước khi gửi

      String usertext = msgObject.getUsertext();

      String[] content = usertext.split("###");

      statement = connection.prepareStatement(sqlString);

      for (int i = 0; i < content.length; i++) {

        if (!"".equalsIgnoreCase(content[i])) {
          statement.setString(1, msgObject.getUserid());
          statement.setString(2, msgObject.getServiceid());
          statement.setString(3, msgObject.getMobileoperator());
          statement.setString(4, msgObject.getKeyword());
          statement.setInt(5, msgObject.getContenttype());
          statement.setString(6, content[i]);
          statement.setInt(7, msgObject.getMsgtype());
          statement.setBigDecimal(8, msgObject.getRequestid());

          if (statement.executeUpdate() != 1) {
            Util.logger.crisis(
                sclassname
                    + "@sendMT: Error@userid="
                    + msgObject.getUserid()
                    + "@serviceid="
                    + msgObject.getServiceid()
                    + "@usertext="
                    + msgObject.getUsertext()
                    + "@messagetype="
                    + msgObject.getMsgtype()
                    + "@requestid="
                    + msgObject.getRequestid().toString());

            return -1;
          }
          Thread.sleep(1000);
        }
      }
      return 1;
    } catch (SQLException e) {
      Util.logger.crisis(
          sclassname
              + "@sendMT: Error:@userid="
              + msgObject.getUserid()
              + "@serviceid="
              + msgObject.getServiceid()
              + "@usertext="
              + msgObject.getUsertext()
              + "@messagetype="
              + msgObject.getMsgtype()
              + "@requestid="
              + msgObject.getRequestid().toString()
              + "@"
              + e.toString());

      Util.logger.printStackTrace(e);

      return -1;
    } catch (Exception e) {
      Util.logger.crisis(
          sclassname
              + "@sendMT: Error:@userid="
              + msgObject.getUserid()
              + "@serviceid="
              + msgObject.getServiceid()
              + "@usertext="
              + msgObject.getUsertext()
              + "@messagetype="
              + msgObject.getMsgtype()
              + "@requestid="
              + msgObject.getRequestid().toString()
              + "@"
              + e.toString());
      Util.logger.printStackTrace(e);
      return -1;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }