本文整理汇总了PHP中Billrun_Factory::dispatcher方法的典型用法代码示例。如果您正苦于以下问题:PHP Billrun_Factory::dispatcher方法的具体用法?PHP Billrun_Factory::dispatcher怎么用?PHP Billrun_Factory::dispatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Billrun_Factory
的用法示例。
在下文中一共展示了Billrun_Factory::dispatcher方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: receive
/**
* General function to receive
*
* @return array list of files received
*/
public function receive()
{
foreach (Billrun_Factory::config()->getConfigValue('ilds.providers', array()) as $type) {
if (!file_exists($this->workspace . DIRECTORY_SEPARATOR . $type)) {
Billrun_Factory::log()->log("NOTICE : SKIPPING {$type} !!! directory " . $this->workspace . DIRECTORY_SEPARATOR . $type . " not found!!", Zend_Log::NOTICE);
continue;
}
$files = scandir($this->workspace . DIRECTORY_SEPARATOR . $type);
$ret = array();
static::$type = $type;
foreach ($files as $file) {
$path = $this->workspace . DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . $file;
if (is_dir($path) || $this->lockFileForReceive($file, $type) || !$this->isFileValid($file, $path)) {
continue;
}
$fileData = $this->getFileLogData($file, $type);
$fileData['path'] = $path;
if (!empty($this->backupPaths)) {
$backedTo = $this->backup($fileData['path'], $file, $this->backupPaths, FALSE, FALSE);
Billrun_Factory::dispatcher()->trigger('beforeReceiverBackup', array($this, &$fileData['path']));
$fileData['backed_to'] = $backedTo;
Billrun_Factory::dispatcher()->trigger('afterReceiverBackup', array($this, &$fileData['path']));
}
$this->logDB($fileData);
$ret[] = $fileData['path'];
}
$this->processType($type);
}
return $ret;
}
示例2: load
/**
* load the container the need to be generate
*/
public function load()
{
$billrun = Billrun_Factory::db()->billrunCollection();
$this->data = $billrun->query()->equals('stamp', $this->getStamp())->equals('source', 'ilds')->notExists('invoice_id');
Billrun_Factory::log()->log("aggregator entities loaded: " . $this->data->count(), Zend_Log::INFO);
Billrun_Factory::dispatcher()->trigger('afterGeneratorLoadData', array('generator' => $this));
}
示例3: load
/**
* load the container the need to be generate
*/
public function load()
{
$this->data = $this->collection->aggregate($this->aggregation_array);
//TODO how to perform it on the secondaries?
Billrun_Factory::log()->log("generator entities loaded: " . count($this->data), Zend_Log::INFO);
Billrun_Factory::dispatcher()->trigger('afterGeneratorLoadData', array('generator' => $this));
}
示例4: updateRow
public function updateRow($row)
{
Billrun_Factory::dispatcher()->trigger('beforeCalculatorWriteRow', array($row, $this));
$carrierOut = $this->detectCarrierOut($row);
$carrierIn = $this->detectCarrierIn($row);
$current = $row->getRawData();
$added_values = array($this->ratingField => $carrierOut ? $carrierOut->createRef(Billrun_Factory::db()->carriersCollection()) : $carrierOut, $this->ratingField . '_in' => $carrierIn ? $carrierIn->createRef(Billrun_Factory::db()->carriersCollection()) : $carrierIn);
$newData = array_merge($current, $added_values);
$row->setRawData($newData);
Billrun_Factory::dispatcher()->trigger('afterCalculatorWriteRow', array($row, $this));
return true;
}
示例5: updateRow
/**
* write the calculation into DB.
* @param $row the line CDR to update.
*/
public function updateRow($row)
{
Billrun_Factory::dispatcher()->trigger('beforeCalculatorWriteRow', array($row, $this));
$current = $row->getRawData();
$usage_type = $this->getLineUsageType($row);
$volume = $this->getLineVolume($row, $usage_type);
$rate = $this->getLineRate($row, $usage_type);
$added_values = array('usaget' => $usage_type, 'usagev' => $volume, $this->ratingField => $rate ? $rate->createRef() : $rate);
$newData = array_merge($current, $added_values);
$row->setRawData($newData);
Billrun_Factory::dispatcher()->trigger('afterCalculatorWriteRow', array($row, $this));
return true;
}
示例6: updateRow
/**
* Write the calculation into DB
*/
public function updateRow($row)
{
Billrun_Factory::dispatcher()->trigger('beforeCalculatorUpdateRow', array($row, $this));
//Billrun_Factory::log()->log("Line start : getLineZone start : ".microtime(true));
$rate = $this->getLineZone($row, $row['usaget']);
//Billrun_Factory::log()->log(" getLineZone end : ".microtime(true));
$current = $row->getRawData();
$added_values = array($this->ratingField => $rate instanceof Mongodloid_Entity ? $rate->createRef() : $rate);
$newData = array_merge($current, $added_values);
$row->setRawData($newData);
Billrun_Factory::dispatcher()->trigger('afterCalculatorUpdateRow', array($row, $this));
return $row;
}
示例7: load
/**
* load the data to aggregate
*/
public function load()
{
$billrun_key = $this->getStamp();
$subscriber = Billrun_Factory::subscriber();
$filename = $billrun_key . '_leftover_aggregator_input';
Billrun_Factory::log()->log("Loading file " . $filename, Zend_Log::INFO);
$billrun_end_time = Billrun_Util::getEndTime($billrun_key);
$this->data = $subscriber->getListFromFile('files/' . $filename, $billrun_end_time);
if (!count($this->data)) {
Billrun_Factory::log()->log("No accounts were found for leftover aggregator", Zend_Log::ALERT);
}
if (is_array($this->data)) {
$this->data = array_slice($this->data, $this->page * $this->size, $this->size, TRUE);
}
Billrun_Factory::log()->log("aggregator entities loaded: " . count($this->data), Zend_Log::INFO);
Billrun_Factory::dispatcher()->trigger('afterAggregatorLoadData', array('aggregator' => $this));
}
示例8: logDB
/**
* method to log the processing
*
* @todo refactoring this method
*/
protected function logDB($fileData)
{
$log = Billrun_Factory::db()->logCollection();
Billrun_Factory::dispatcher()->trigger('beforeLogReceiveFile', array(&$fileData, $this));
$query = array('stamp' => $fileData['stamp'], 'received_time' => array('$exists' => false));
$addData = array('received_hostname' => Billrun_Util::getHostName(), 'received_time' => date(self::base_dateformat));
$update = array('$set' => array_merge($fileData, $addData));
if (empty($query['stamp'])) {
Billrun_Factory::log()->log("Billrun_Receiver::logDB - got file with empty stamp : {$fileData['stamp']}", Zend_Log::NOTICE);
return FALSE;
}
$result = $log->update($query, $update, array('w' => 1));
if ($result['ok'] != 1 || $result['n'] != 1) {
Billrun_Factory::log()->log("Billrun_Receiver::logDB - Failed when trying to update a file log record " . $fileData['file_name'] . " with stamp of : {$fileData['stamp']}", Zend_Log::NOTICE);
}
return $result['n'] == 1 && $result['ok'] == 1;
}
示例9: respond
/**
* general function to receive
*
* @return mixed
*/
public function respond()
{
Billrun_Factory::dispatcher()->trigger('beforeResponse', array('type' => self::$type, 'responder' => &$this));
$retPaths = array();
foreach ($this->getProcessedFilesForType(self::$type) as $filename => $logLine) {
$filePath = $this->workspace . DIRECTORY_SEPARATOR . self::$type . DIRECTORY_SEPARATOR . $filename;
if (!file_exists($filePath)) {
Billrun_Factory::log()->log("NOTICE : SKIPPING {$filename} for type : " . self::$type . "!!! ,path - {$filePath} not found!!", Zend_Log::NOTICE);
continue;
}
$responseFilePath = $this->processFileForResponse($filePath, $logLine, $filename);
if ($responseFilePath) {
$retPaths[] = $this->respondAFile($responseFilePath, $this->getResponseFilename($filename, $logLine), $logLine);
}
}
Billrun_Factory::dispatcher()->trigger('afterResponse', array('type' => self::$type, 'responder' => &$this));
return $retPaths;
}
示例10: handleFile
/**
* Move the file to the workspace.
*
* @param string $srcPath The original file position
* @param string $filename the filename
*
* @return mixed the new path if success, else false
*/
protected function handleFile($srcPath, $filename)
{
Billrun_Factory::log('Relocate receive handle file ' . $filename, Zend_Log::INFO);
$srcPath = parent::handleFile($srcPath, $filename);
Billrun_Factory::dispatcher()->trigger('beforeRelocateFileHandling', array($this, &$srcPath, $filename));
$newPath = $this->workspace . DIRECTORY_SEPARATOR . static::$type;
if (!file_exists($newPath)) {
mkdir($newPath, 0777, true);
}
$newPath .= DIRECTORY_SEPARATOR . $filename;
$ret = $this->moveFiles ? copy($srcPath, $newPath) && unlink($srcPath) : copy($srcPath, $newPath);
if ($this->preserve_timestamps) {
$timestamp = filemtime($srcPath);
Billrun_Util::setFileModificationTime($newPath, $timestamp);
}
Billrun_Factory::dispatcher()->trigger('afterRelocateFileHandling', array($this, &$srcPath, &$newPath, $filename, $ret));
return $ret ? $newPath : FALSE;
}
示例11: parseData
/**
* method to parse data
*
* @param array $line data line
*
* @return array the data array
*/
protected function parseData($line)
{
if (!isset($this->data['header'])) {
Billrun_Factory::log()->log("No header found", Zend_Log::ERR);
return false;
}
$data_type = strtolower($this->getLineType($line, $this->parser->getSeparator()));
// can be moc or mtc
$this->parser->setStructure($this->{$data_type . "_structure"});
// for the next iteration
$this->parser->setLine($line);
Billrun_Factory::dispatcher()->trigger('beforeDataParsing', array(&$line, $this));
$row = $this->parser->parse();
$row['source'] = static::$type;
$row['log_stamp'] = $this->getFileStamp();
$row['file'] = basename($this->filePath);
$row['process_time'] = date(self::base_dateformat);
Billrun_Factory::dispatcher()->trigger('afterDataParsing', array(&$row, $this));
$this->data['data'][] = $row;
return $row;
}
示例12: updateRow
/**
* make the calculation
*/
public function updateRow($row)
{
Billrun_Factory::dispatcher()->trigger('beforeCalculatorUpdateRow', array($row, $this));
$pricingData = array();
$row->collection(Billrun_Factory::db()->linesCollection());
$zoneKey = $this->isLineIncoming($row) ? 'incoming' : $this->loadDBRef($row->get(Billrun_Calculator_Wholesale_Nsn::MAIN_DB_FIELD, true))['key'];
if (isset($row['usagev']) && $zoneKey) {
$rates = $this->getCarrierRateForZoneAndType($this->loadDBRef($row->get($this->isLineIncoming($row) ? 'wsc_in' : 'wsc', true)), $zoneKey, $row['usaget'], $this->isPeak($row) ? 'peak' : 'off_peak');
if ($rates) {
$pricingData = $this->getLinePricingData($row['usagev'], $rates);
//todo add peak/off peak to the data.
$row->setRawData(array_merge($row->getRawData(), $pricingData));
} else {
Billrun_Factory::log()->log(" Failed finding rate for row : " . print_r($row['stamp'], 1), Zend_Log::DEBUG);
}
} else {
Billrun_Factory::log()->log($this->count++ . " no usagev or zone : {$row['usagev']} && {$zoneKey} for line with stamp: " . $row['stamp'], Zend_Log::NOTICE);
return false;
}
Billrun_Factory::dispatcher()->trigger('afterCalculatorUpdateRow', array($row, $this));
return $row;
}
示例13: updateRow
public function updateRow($row)
{
Billrun_Factory::dispatcher()->trigger('beforeCalculatorUpdateRow', array($row, $this));
//@TODO change this be be configurable.
$pricingData = array();
$row->collection(Billrun_Factory::db()->linesCollection());
$zoneKey = $this->isLineIncoming($row) ? 'incoming' : $this->loadDBRef($row->get(Billrun_Calculator_Wholesale_Nsn::MAIN_DB_FIELD, true))['key'];
if (isset($row['usagev']) && $zoneKey) {
$carir = $this->loadDBRef($row->get(in_array($row->get('wsc', true), $this->nrCarriers) ? 'wsc' : 'wsc_in', true));
$rates = $this->getCarrierRateForZoneAndType($carir, $zoneKey, $row['usaget']);
if (!$rates) {
Billrun_Factory::log()->log(" Failed finding rate for row : " . print_r($row['stamp'], 1), Zend_Log::DEBUG);
return false;
}
$pricingData = $this->getLinePricingData($row['usagev'], $rates);
$row->setRawData(array_merge($row->getRawData(), $pricingData));
} else {
Billrun_Factory::log()->log(" No usagev or zone : {$row['usagev']} && {$zoneKey} for line with stamp: " . $row['stamp'], Zend_Log::NOTICE);
return false;
}
Billrun_Factory::dispatcher()->trigger('afterCalculatorUpdateRow', array($row, $this));
return $row;
}
示例14: process
public function process()
{
if ($this->isQueueFull()) {
Billrun_Factory::log()->log("Billrun_Processor_Base_BlockedSeperatedBinary: queue size is too big", Zend_Log::INFO);
return FALSE;
} else {
// run all over the file with the parser helper
if (!is_resource($this->fileHandler)) {
Billrun_Factory::log()->log("Resource is not configured well", Zend_Log::ERR);
return false;
}
$this->data['trailer'] = array();
$this->data['header'] = $this->buildHeader(false);
Billrun_Factory::dispatcher()->trigger('beforeProcessorParsing', array($this));
while (!$this->processFinished()) {
if ($this->parse() === FALSE) {
Billrun_Factory::log()->log("Billrun_Processor: cannot parse", Zend_Log::ERR);
return false;
}
}
$this->data['trailer'] = $this->buildTrailer($this->data['trailer']);
Billrun_Factory::dispatcher()->trigger('afterProcessorParsing', array($this));
$this->prepareQueue();
Billrun_Factory::dispatcher()->trigger('beforeProcessorStore', array($this));
if ($this->store() === FALSE) {
Billrun_Factory::log()->log("Billrun_Processor: cannot store the parser lines", Zend_Log::ERR);
return false;
}
if ($this->logDB() === FALSE) {
Billrun_Factory::log()->log("Billrun_Processor: cannot log parsing action", Zend_Log::WARN);
}
Billrun_Factory::dispatcher()->trigger('afterProcessorStore', array($this));
$this->backup();
Billrun_Factory::dispatcher()->trigger('afterProcessorBackup', array($this, &$this->filePath));
return count($this->data['data']);
}
}
示例15: parseFooter
/**
* method to parse footer
*
* @param array $line footer line
*
* @return array the footer array
*/
protected function parseFooter($line)
{
if (isset($this->data['trailer'])) {
Billrun_Factory::log()->log("double trailer", Zend_Log::ERR);
return false;
}
$this->parser->setStructure($this->trailer_structure);
$this->parser->setLine($line);
Billrun_Factory::dispatcher()->trigger('beforeFooterParsing', array($line, $this));
$trailer = $this->parser->parse();
$trailer['source'] = static::$type;
$trailer['type'] = self::$type;
$trailer['header_stamp'] = $this->data['header']['stamp'];
$trailer['file'] = basename($this->filePath);
$trailer['process_time'] = date(self::base_dateformat);
Billrun_Factory::dispatcher()->trigger('afterFooterParsing', array($trailer, $this));
$this->data['trailer'] = $trailer;
return $trailer;
}