Exemplo n.º 1
0
 /**
  * @see Billrun_Plugin_Interface_IParser::parseData
  */
 public function parseData($type, $data, \Billrun_Parser &$parser)
 {
     if ($this->getName() != $type) {
         return FALSE;
     }
     $asnObject = Asn_Base::parseASNString($data);
     $parser->setLastParseLength($asnObject->getDataLength() + self::RECORD_PADDING);
     $type = $asnObject->getType();
     $cdrLine = false;
     if (isset($this->ggsnConfig[$type])) {
         $cdrLine = $this->getASNDataByConfig($asnObject, $this->ggsnConfig[$type], $this->ggsnConfig['fields']);
         if ($cdrLine && !isset($cdrLine['record_type'])) {
             $cdrLine['record_type'] = $type;
         }
         //convert to unified time GMT  time.
         $timeOffset = isset($cdrLine['ms_timezone']) ? $cdrLine['ms_timezone'] : date('P');
         $cdrLine['urt'] = new MongoDate(Billrun_Util::dateTimeConvertShortToIso($cdrLine['record_opening_time'], $timeOffset));
         if (is_array($cdrLine['rating_group'])) {
             $fbc_uplink_volume = $fbc_downlink_volume = 0;
             $cdrLine['org_fbc_uplink_volume'] = $cdrLine['fbc_uplink_volume'];
             $cdrLine['org_fbc_downlink_volume'] = $cdrLine['fbc_downlink_volume'];
             $cdrLine['org_rating_group'] = $cdrLine['rating_group'];
             foreach ($cdrLine['rating_group'] as $key => $rateVal) {
                 if (isset($this->ggsnConfig['rating_groups'][$rateVal])) {
                     $fbc_uplink_volume += $cdrLine['fbc_uplink_volume'][$key];
                     $fbc_downlink_volume += $cdrLine['fbc_downlink_volume'][$key];
                 }
             }
             $cdrLine['fbc_uplink_volume'] = $fbc_uplink_volume;
             $cdrLine['fbc_downlink_volume'] = $fbc_downlink_volume;
             $cdrLine['rating_group'] = 0;
         } else {
             if ($cdrLine['rating_group'] == 10) {
                 return false;
             }
         }
     } else {
         Billrun_Factory::log()->log("couldn't find  definition for {$type}", Zend_Log::INFO);
     }
     //Billrun_Factory::log()->log($asnObject->getType() . " : " . print_r($cdrLine,1) ,  Zend_Log::DEBUG);
     return $cdrLine;
 }
Exemplo n.º 2
0
 /**
  * @see Billrun_Plugin_Interface_IProcessor::processData
  */
 public function processData($type, $fileHandle, \Billrun_Processor &$processor)
 {
     if ($this->getName() != $type) {
         return FALSE;
     }
     $processorData =& $processor->getData();
     $bytes = '';
     do {
         $bytes .= fread($fileHandle, self::FILE_READ_AHEAD_LENGTH);
     } while (!feof($fileHandle));
     $parsedData = Asn_Base::parseASNString($bytes);
     $processorData['header'] = $processor->buildHeader($parsedData);
     //$bytes = substr($bytes, $processor->getParser()->getLastParseLength());
     if (!isset($this->tap3Config[$this->fileVersion])) {
         Billrun_Factory::log("Processing tap3 file {$processor->filename} with non supported version : {$this->fileVersion}", Zend_log::NOTICE);
         throw new Exception("Processing tap3 file {$processor->filename} with non supported version : {$this->fileVersion}");
     }
     $trailer = $processor->buildTrailer($parsedData);
     $this->initExchangeRates($trailer);
     if (empty($this->currentFileHeader['notification']) || !empty($this->currentFileHeader['header'])) {
         foreach ($parsedData->getData() as $record) {
             if (in_array($record->getType(), $this->tap3Config['config']['data_records'])) {
                 foreach ($record->getData() as $key => $data) {
                     $row = $processor->buildDataRow($data);
                     if ($row) {
                         $row['file_rec_num'] = $key + 1;
                         $processorData['data'][] = $row;
                     }
                 }
             } else {
                 if (!isset($this->tap3Config['header'][$record->getType()]) && !isset($this->tap3Config['trailer'][$record->getType()])) {
                     Billrun_Factory::log()->log('No config for type : ' . $record->getType(), Zend_Log::DEBUG);
                 }
             }
         }
     } else {
         Billrun_Factory::log()->log('Got notification/empty file : ' . $processor->filename . ' , moving on...', Zend_Log::INFO);
     }
     $processorData['trailer'] = $trailer;
     return true;
 }
Exemplo n.º 3
0
 /**
  * @see Billrun_Plugin_Interface_IProcessor::processData
  */
 public function processData($type, $fileHandle, \Billrun_Processor &$processor)
 {
     if ($this->getName() != $type) {
         return FALSE;
     }
     $processorData =& $processor->getData();
     $bytes = '';
     do {
         $bytes .= fread($fileHandle, self::FILE_READ_AHEAD_LENGTH);
     } while (!feof($fileHandle));
     $parsedData = Asn_Base::parseASNString($bytes);
     $processorData['header'] = $processor->buildHeader($parsedData);
     //$bytes = substr($bytes, $processor->getParser()->getLastParseLength());
     foreach ($parsedData->getData() as $record) {
         if (in_array($record->getType(), $this->nsnConfig['config']['data_records'])) {
             foreach ($record->getData() as $key => $data) {
                 $row = $processor->buildDataRow($data);
                 if ($row) {
                     $row['file_rec_num'] = $key;
                     $processorData['data'][] = $row;
                 }
             }
         } else {
             //Billrun_Factory::log()->log(print_r($record,1) ,  Zend_Log::DEBUG);
         }
     }
     $processorData['trailer'] = $processor->buildTrailer($parsedData);
     return true;
 }