Пример #1
0
 public function __construct($options)
 {
     parent::__construct($options);
     if (isset($options['separator'])) {
         $this->setSeparator((string) $options['separator']);
     }
 }
Пример #2
0
 public function indexAction()
 {
     die;
     // don't enter this by mistake
     $parser = Billrun_Parser::getInstance(array('type' => 'separator', 'separator' => ","));
     $parser->setSeparator(",");
     $import = Billrun_Processor::getInstance(array('type' => 'importzones', 'parser' => $parser, 'path' => '/home/shani/Documents/S.D.O.C/BillRun/backups/zone.csv'));
     if ($import === FALSE) {
         exit('cannot load import processor');
     }
     $import->setBackupPath(array());
     // no backup
     $importData = $import->process();
     $merge = Billrun_Processor::getInstance(array('type' => 'mergerates', 'parser' => $parser, 'path' => '/home/shani/Documents/S.D.O.C/BillRun/backups/tariff_v2_filtered.csv'));
     if ($merge === FALSE) {
         exit('cannot load merge processor');
     }
     $merge->setBackupPath(array());
     // no backup
     $mergeData = $merge->process();
     $mergePackage = Billrun_Processor::getInstance(array('type' => 'mergezonepackage', 'parser' => $parser, 'path' => '/home/shani/Documents/S.D.O.C/BillRun/backups/zone_group_element.csv'));
     if ($mergePackage === FALSE) {
         exit('cannot load merge processor');
     }
     $mergePackage->setBackupPath(array());
     // no backup
     $mergePackageData = $mergePackage->process();
     $merge_intl_networks = Billrun_Processor::getInstance(array('type' => 'mergeintlnetworks', 'parser' => $parser, 'path' => '/home/shani/Documents/S.D.O.C/BillRun/backups/mobile_network.csv'));
     if ($merge_intl_networks === FALSE) {
         exit('cannot load import processor');
     }
     $merge_intl_networks->setBackupPath(array());
     // no backup
     $importMapData = $merge_intl_networks->process();
     $wholesale = Billrun_Processor::getInstance(array('type' => 'wholesaleoutrates', 'parser' => $parser, 'path' => '/home/shani/Documents/S.D.O.C/BillRun/backups/wholesale/wsalein_tariff_out_v2.csv'));
     if ($wholesale === FALSE) {
         exit('cannot load import processor' . PHP_EOL);
     }
     $wholesale->setBackupPath(array());
     // no backup
     $importWholesaleZones = $wholesale->process();
     $wholesalein = Billrun_Processor::getInstance(array('type' => 'wholesaleinrates', 'parser' => $parser, 'path' => '/home/shani/Documents/S.D.O.C/BillRun/backups/wholesale/wsalein_tariff_in_v2.csv'));
     if ($wholesalein === FALSE) {
         exit('cannot load import processor' . PHP_EOL);
     }
     $wholesalein->setBackupPath(array());
     // no backup
     $importWholesaleIn = $wholesalein->process();
     $this->getView()->title = "BillRun | The best open source billing system";
     $this->getView()->content = "Data import count: " . count($importWholesaleZones) . "<br />" . PHP_EOL . "Data merge count: " . count($mergeData) . "<br />" . "Data merge package count: " . count($mergePackageData) . "<br />" . "Data merge package count: " . count($mergePackageData) . "<br />" . "Merge intl. networks count: " . $importMapData . "<br />" . PHP_EOL;
 }
Пример #3
0
 /**
  * method to set the parser of the processor
  * 
  * @param Billrun_Parser|string|array $parser the parser to use by the processor or its name.
  *
  * @return mixed the processor itself (for concatening methods)
  */
 public function setParser($parser)
 {
     if (is_object($parser)) {
         $this->parser = $parser;
     } else {
         $parser = is_array($parser) ? $parser : array('type' => $parser);
         $this->parser = Billrun_Parser::getInstance($parser);
     }
     return $this;
 }
Пример #4
0
 /**
  * @see Billrun_Plugin_Interface_IParser::parseData
  */
 public function parseData($type, $line, Billrun_Parser &$parser)
 {
     if ($type != $this->getName()) {
         return FALSE;
     }
     $data = array();
     $offset = 0;
     $data['record_length'] = $this->parseField(substr($line, $offset, 2), array('decimal' => 2));
     $offset += 2;
     $data['record_type'] = $this->parseField(substr($line, $offset, 1), array('bcd_encode' => 1));
     $offset += 1;
     //Billrun_Factory::log()->log("Record_type : {$data['record_type']}",Zend_log::DEBUG);
     if (isset($this->nsnConfig[$data['record_type']])) {
         foreach ($this->nsnConfig[$data['record_type']] as $key => $fieldDesc) {
             if ($fieldDesc) {
                 if (isset($this->nsnConfig['fields'][$fieldDesc])) {
                     $length = intval(current($this->nsnConfig['fields'][$fieldDesc]), 10);
                     $data[$key] = $this->parseField(substr($line, $offset, $length), $this->nsnConfig['fields'][$fieldDesc]);
                     /* if($data['record_type'] == "12") {//DEBUG...
                     	  Billrun_Factory::log()->log("Data $key : {$data[$key]} , offset: ".  dechex($offset),Zend_log::DEBUG);
                     	  } */
                     $offset += $length;
                 } else {
                     throw new Exception("Nsn:parse - Couldn't find field: {$fieldDesc}  ");
                 }
             }
         }
         $data['urt'] = new MongoDate(Billrun_Util::dateTimeConvertShortToIso((string) (isset($data['charging_start_time']) && $data['charging_start_time'] ? $data['charging_start_time'] : $data['call_reference_time']), date("P", strtotime($data['call_reference_time']))));
     }
     //Use the  actual charing time duration instead of the  duration  that  was set by the switch
     if (isset($data['duration'])) {
         $data['org_dur'] = $data['duration'];
         // save the original duration.
     }
     if (isset($data['charging_end_time']) && isset($data['charging_start_time']) && (strtotime($data['charging_end_time']) > 0 && strtotime($data['charging_start_time']) > 0)) {
         $data['duration'] = strtotime($data['charging_end_time']) - strtotime($data['charging_start_time']);
     }
     //Remove  the  "10" in front of the national call with an international prefix
     //		if (isset($data['in_circuit_group_name']) && preg_match("/^RCEL/", $data['in_circuit_group_name']) && strlen($data['called_number']) > 10 && substr($data['called_number'], 0, 2) == "10") { // will fail when in_circuit_group_name is empty / called_number length is exactly 10
     if (isset($data['out_circuit_group']) && in_array($data['out_circuit_group'], array('2100', '2101', '2499')) && substr($data['called_number'], 0, 2) == "10") {
         $data['called_number'] = substr($data['called_number'], 2);
     } else {
         if (in_array($data['record_type'], array('30', '31')) && preg_match($this->ild_called_number_regex, $data['called_number'])) {
             $data['ild_prefix'] = substr($data['called_number'], 0, 3);
             $data['called_number'] = substr($data['called_number'], 3);
         }
     }
     $parser->setLastParseLength($data['record_length']);
     //@TODO add unifiom field translation. ('record_opening_time',etc...)
     return isset($this->nsnConfig[$data['record_type']]) ? $data : false;
 }
Пример #5
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;
 }