Ejemplo n.º 1
0
 public void run() {
   int numOfCdrs = 0;
   // System.out.println("Getting data from queue table");
   Logger.info("CDRServer:", "Getting data from queue table");
   while (CDRServer.running) {
     try {
       this.readCDRinQueueEx();
       if ("VMS".equals(Preference.mobileOperator.toUpperCase())) {
         // CdrFileCopier4vms cdrcopy = new CdrFileCopier4vms();
         // System.out.println("Starting FTP");
         Logger.info("FTP:", " starting FTP cdr file");
         Ftp2CdrServer ftp = new Ftp2CdrServer(); // .start();
         ftp.runftp();
       } else {
         // System.out.println("Invalid mobile operator: " +
         // Preference.mobileOperator);
         Logger.info("Invalid mobile operator:", Preference.mobileOperator);
         exit();
       }
       sleep10Minutes();
     } catch (InterruptedException ex) {
     } catch (DBException ex) { // when lost connection to db
       // System.out.println("DBScanner::" + ex.getMessage());
       Logger.info("DBScanner:", ex.getMessage());
       try {
         dbTools.log_alert(
             "Billing system",
             "-> ERROR: Ket noi Database bi loi: " + ex.getMessage(),
             1,
             0,
             "serious",
             Preference.alert_person);
       } catch (Exception e) {
       }
       GatewayCDR.rebuildDBConnections(1); // 1 connection
     } catch (Exception ex) {
       // System.out.println("DBScanner::" + ex.getMessage());
       Logger.info("DBScanner:", ex.getMessage());
       try {
         // dbTools.log_alert(Preference.sourceAddressList.toString(),
         // "CDR->DBSCanner",
         // "<-" + Preference.mobileOperator + "-> ERROR: " +
         // ex.getMessage(),
         // 1, Preference.alert_person,
         // Preference.alert_mobile);
         dbTools.log_alert(
             "Billing system",
             "-> ERROR: Loi dinh dang MOBILE OPERATOR: " + ex.getMessage(),
             1,
             0,
             "serious",
             Preference.alert_person);
       } catch (Exception e) {
       }
     }
   }
 }
Ejemplo n.º 2
0
  public int readCDRinQueueEx() throws DBException {
    int numOfCdrs = 0;

    Collection collection = dbTools.getAllCDRsInQueueEx();
    // System.out.println("truoc khi chay collection"+collection.size());
    if ((collection != null) && (collection.size() > 0)) {
      numOfCdrs = collection.size();
      CDR cdr = null;
      BigDecimal cdrId = null;
      // System.out.println("truoc khi chay Iterator");
      for (Iterator it = collection.iterator(); it.hasNext(); ) {
        cdr = (CDR) it.next();
        cdrId = cdr.getId();
        // System.out.println("cdrId"+cdrId);
        if (cdr == null) { // removed by other processes
          // System.out.println("CDR is null (queueId=" + cdrId +
          // ")");
          Logger.info("CDR:", "CDR is null (queueId=" + cdrId + ")");
          continue;
        }
        // //////////////////////////////////
        cdr = dbTools.moveCDRFromQueueToLogEx(cdr);
        if (cdr != null) {
          CDRTool.add2CDRFileEx(cdr);
          System.out.print(
              cdr.getUserId() + "-->" + cdr.getServiceId() + ":" + cdr.getCommandCode() + "\t\t");

          if (col >= maxcols - 1) {
            System.out.println();
            col = 0;
          } else {
            col++;
          }
        } else {
          // System.out.println("CDR is null (queueId=" + cdrId +
          // ")");
          Logger.info("CDR:", "CDR is null (queueId=" + cdrId + ")");
        }
        // //////////////////////////////////
      } // end for
    }
    return numOfCdrs;
  }
Ejemplo n.º 3
0
  /** Them phat day ra file */
  public static int pushCDRinQueueEx8x99(String fromNum, String toNum) throws DBException {
    int numOfCdrs = 0;
    int maxcols = 2;
    int col = 0;
    DBTools dbTools = new DBTools();
    Collection collection = dbTools.getAllCDRsInLogEx8x99(fromNum, toNum);
    if ((collection != null) && (collection.size() > 0)) {
      numOfCdrs = collection.size();
      CDR cdr = null;
      BigDecimal cdrId = null;
      for (Iterator it = collection.iterator(); it.hasNext(); ) {
        cdr = (CDR) it.next();
        cdrId = cdr.getId();
        if (cdr == null) { // removed by other processes
          // System.out.println("CDR is null (queueId=" + cdrId +
          // ")");
          Logger.info("CDR:", "CDR is null (queueId=" + cdrId + ")");
          continue;
        }
        // //////////////////////////////////
        // cdr = dbTools.moveCDRFromQueueToLogEx(cdr);
        if (cdr != null) {
          CDRTool.add2CDRFile8x99ForPushVMS(cdr);
          System.out.print(
              cdr.getUserId() + "-->" + cdr.getServiceId() + ":" + cdr.getCommandCode() + "\t\t");

          if (col >= maxcols - 1) {
            System.out.println();
            col = 0;
          } else {
            col++;
          }
        } else {
          // System.out.println("CDR is null (queueId=" + cdrId +
          // ")");
          Logger.info("CDR:", "CDR is null (queueId=" + cdrId + ")");
        }
        // //////////////////////////////////
      } // end for
    }
    return numOfCdrs;
  }