Exemple #1
0
  private void register() {
    ActionContext ctx = Cocit.getActionContext();

    if (ctx != null) {
      SoftService soft = ctx.getSoftService();

      this.proxyHost = soft.getConfig(ConfigManager.SMS_PROXY_HOST, "");
      this.proxyPort = soft.getConfig(ConfigManager.SMS_PROXY_PORT, 80);

      this.uid = soft.getConfig(ConfigManager.SMS_UID, "");
      this.pwd = soft.getConfig(ConfigManager.SMS_PWD, "");
      this.key = soft.getConfig("sms.key", "");

      try {

        emayClient = new Client(uid, key);
        int registResult = emayClient.registEx(pwd);

        Log.info(
            "EmaySmsClient.register: registResult=%s {uid:%s, pwd:%s, key:%s, proxyHost:%s, proxyPort:%s}",
            registResult, uid, pwd, key, proxyHost, proxyPort);

      } catch (Exception e) {
        Log.error(
            "EmaySmsClient.register: 失败!{uid:%s, pwd:%s, key:%s, proxyHost:%s, proxyPort:%s}",
            uid, pwd, key, proxyHost, proxyPort, e);
      }
    }
  }
Exemple #2
0
  @Override
  public List<String[]> receive() {

    if (emayClient == null) {
      register();
      // Log.info("EmaySmsClient.receive: 失败!{emayClient:null}");
      //
      // return null;
    }

    List result = new ArrayList();

    try {

      List<MO> moList = this.emayClient.getMO();
      if (moList != null) {
        for (MO mo : moList) {
          String[] arr = new String[3];

          arr[0] = mo.getMobileNumber();
          arr[1] = mo.getSentTime();
          arr[2] = mo.getSmsContent();

          Log.debug("%s/%s/%s", arr[0], arr[1], arr[2]);

          result.add(arr);
        }
      }

      Log.info("EmaySmsClient.receive: moList=%s", moList == null ? "<NULL>" : moList.size());

    } catch (Exception e) {
      Log.error("EmaySmsClient.receive: 失败!", e);

      result = null;
    }

    return result;
  }
Exemple #3
0
  @Override
  public Integer getBalance() {

    if (emayClient == null) {
      register();
      //
      // Log.error("EmaySmsClient.getBalance: 失败!{emayClient:null}");
      //
      // return null;
    }

    try {

      double ret = this.emayClient.getBalance();

      Log.info("EmaySmsClient.getBalance: ret=%s", ret);

      return new Double(ret * 10).intValue();
    } catch (Exception e) {
      Log.error("EmaySmsClient.getBalance: 失败!", e);
    }

    return null;
  }