当前位置: 首页>>代码示例>>PHP>>正文


PHP Billrun_Factory::db方法代码示例

本文整理汇总了PHP中Billrun_Factory::db方法的典型用法代码示例。如果您正苦于以下问题:PHP Billrun_Factory::db方法的具体用法?PHP Billrun_Factory::db怎么用?PHP Billrun_Factory::db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Billrun_Factory的用法示例。


在下文中一共展示了Billrun_Factory::db方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct(array $params = array())
 {
     $params['collection'] = Billrun_Factory::db()->queue;
     parent::__construct($params);
     $this->search_key = "stamp";
     $this->lines_coll = Billrun_Factory::db()->queueCollection();
 }
开发者ID:ngchie,项目名称:system,代码行数:7,代码来源:Queue.php

示例2: update

 /**
  * method to convert plans names into their refs
  * triggered before save the rate entity for edit
  * 
  * @param Mongodloid collection $collection
  * @param array $data
  * 
  * @return void
  * @todo move to model
  */
 public function update($data)
 {
     if (isset($data['rates'])) {
         $plansColl = Billrun_Factory::db()->plansCollection();
         $currentDate = new MongoDate();
         $rates = $data['rates'];
         //convert plans
         foreach ($rates as &$rate) {
             if (isset($rate['plans'])) {
                 $sourcePlans = (array) $rate['plans'];
                 // this is array of strings (retreive from client)
                 $newRefPlans = array();
                 // this will be the new array of DBRefs
                 unset($rate['plans']);
                 foreach ($sourcePlans as &$plan) {
                     $planEntity = $plansColl->query('name', $plan)->lessEq('from', $currentDate)->greaterEq('to', $currentDate)->cursor()->setReadPreference(Billrun_Factory::config()->getConfigValue('read_only_db_pref'))->current();
                     $newRefPlans[] = $planEntity->createRef($plansColl);
                 }
                 $rate['plans'] = $newRefPlans;
             }
         }
         $data['rates'] = $rates;
     }
     return parent::update($data);
 }
开发者ID:kalburgimanjunath,项目名称:system,代码行数:35,代码来源:Rates.php

示例3: __construct

 public function __construct()
 {
     // load the config data from db
     $this->collection = Billrun_Factory::db()->configCollection();
     $this->options = array('receive', 'process', 'calculate');
     $this->loadConfig();
 }
开发者ID:ngchie,项目名称:system,代码行数:7,代码来源:Config.php

示例4: calc

 public function calc()
 {
     Billrun_Factory::log()->log("Execute reset", Zend_Log::INFO);
     $rebalance_queue = Billrun_Factory::db()->rebalance_queueCollection();
     $limit = Billrun_Config::getInstance()->getConfigValue('resetlines.limit', 10);
     $offset = Billrun_Config::getInstance()->getConfigValue('resetlines.offset', '1 hour');
     $query = array('creation_date' => array('$lt' => new MongoDate(strtotime($offset . ' ago'))));
     $sort = array('creation_date' => 1);
     $results = $rebalance_queue->find($query)->sort($sort)->limit($limit);
     $billruns = array();
     $all_sids = array();
     foreach ($results as $result) {
         $billruns[$result['billrun_key']][] = $result['sid'];
         $all_sids[] = $result['sid'];
     }
     foreach ($billruns as $billrun_key => $sids) {
         $model = new ResetLinesModel($sids, $billrun_key);
         try {
             $ret = $model->reset();
             if (isset($ret['err']) && !is_null($ret['err'])) {
                 return FALSE;
             }
             $rebalance_queue->remove(array('sid' => array('$in' => $sids)));
         } catch (Exception $exc) {
             Billrun_Factory::log()->log('Error resetting sids ' . implode(',', $sids) . ' of billrun ' . $billrun_key . '. Error was ' . $exc->getTraceAsString(), Zend_Log::ALERT);
             return $this->setError($exc->getTraceAsString(), array('sids' => $sids, 'billrun_key' => $billrun_key));
         }
     }
     Billrun_Factory::log()->log("Success resetting sids " . implode(',', $all_sids), Zend_Log::INFO);
     return true;
 }
开发者ID:ngchie,项目名称:system,代码行数:31,代码来源:Rebalance.php

示例5: processFileForResponse

 /**
  * Process a given file and create a temporary response file to it.  
  * @param type $filePath the location of the file that need to be proceesed
  * @param type $logLine the log line that associated with the file to process.
  * @return boolean|string	return the temporary file path if the file should be responded to.
  * 							or false if the file wasn't processed into the DB yet.
  */
 protected function processFileForResponse($filePath, $logLine)
 {
     $logLine = $logLine->getRawData();
     $this->linesCount = $this->linesErrors = $this->totalChargeAmount = 0;
     $linesCollection = Billrun_Factory::db()->linesCollection();
     $dbLines = $linesCollection->query()->equals('file', $logLine['file']);
     //run only after the lines were processed by the billrun.
     if ($dbLines->count() == 0 || $linesCollection->query()->equals('file', $logLine['file'])->exists('billrun')->count() == 0) {
         return false;
     }
     //save file to a temporary location
     $responsePath = $this->workspace . rand();
     $srcFile = fopen($filePath, "r+");
     $file = fopen($responsePath, "w");
     $lines = "";
     foreach ($dbLines as $dbLine) {
         //alter data line
         $line = $this->updateLine($dbLine->getRawData(), $logLine);
         if ($line) {
             $this->linesCount++;
             $this->totalChargeAmount += floatval($dbLine->get('call_charge'));
             $lines .= $line . "\n";
         }
     }
     //alter lines
     fputs($file, $this->updateHeader(fgets($srcFile), $logLine) . "\n");
     fputs($file, $lines);
     //alter trailer
     fputs($file, $this->updateTrailer($logLine) . "\n");
     fclose($file);
     return $responsePath;
 }
开发者ID:ngchie,项目名称:system,代码行数:39,代码来源:Ilds.php

示例6: execute

 public function execute()
 {
     Billrun_Factory::log()->log("Execute reset", Zend_Log::INFO);
     $request = $this->getRequest()->getRequest();
     // supports GET / POST requests
     if (empty($request['sid'])) {
         return $this->setError('Please supply at least one sid', $request);
     }
     // remove the aids from current balance cache - on next current balance it will be recalculated and avoid to take it from cache
     if (isset($request['aid'])) {
         $this->cleanAccountCache($request['aid']);
     }
     $billrun_key = Billrun_Util::getBillrunKey(time());
     // Warning: will convert half numeric strings / floats to integers
     $sids = array_unique(array_diff(Billrun_Util::verify_array($request['sid'], 'int'), array(0)));
     if ($sids) {
         try {
             $rebalance_queue = Billrun_Factory::db()->rebalance_queueCollection();
             foreach ($sids as $sid) {
                 $rebalance_queue->insert(array('sid' => $sid, 'billrun_key' => $billrun_key, 'creation_date' => new MongoDate()));
             }
         } catch (Exception $exc) {
             Billrun_Util::logFailedResetLines($sids, $billrun_key);
             return FALSE;
         }
     } else {
         return $this->setError('Illegal sid', $request);
     }
     $this->getController()->setOutput(array(array('status' => 1, 'desc' => 'success', 'input' => $request)));
     return TRUE;
 }
开发者ID:ngchie,项目名称:system,代码行数:31,代码来源:ResetLines.php

示例7: __construct

 public function __construct()
 {
     $this->record_types = Billrun_Factory::config()->getConfigValue('016_one_way.identifications.record_types', array('30'));
     $this->filename = date('Ymd', time()) . '.TXT';
     $this->output_path = Billrun_Factory::config()->getConfigValue('016_one_way.export.path', '/var/www/billrun/workspace/016_one_way/Treated/') . DIRECTORY_SEPARATOR . $this->filename;
     $this->access_price = round(Billrun_Factory::config()->getConfigValue('016_one_way.access_price', 1.0), 2);
     $this->lines_coll = Billrun_Factory::db()->linesCollection();
 }
开发者ID:ngchie,项目名称:system,代码行数:8,代码来源:ildsOneWay.php

示例8: write

 /**
  * Execute write down the calculation output
  */
 public function write()
 {
     Billrun_Factory::dispatcher()->trigger('beforeCalculatorWriteData', array('data' => $this->data));
     $lines = Billrun_Factory::db()->linesCollection();
     foreach ($this->data as $item) {
         $item->save($lines);
     }
     Billrun_Factory::dispatcher()->trigger('afterCalculatorWriteData', array('data' => $this->data));
 }
开发者ID:ngchie,项目名称:system,代码行数:12,代码来源:Ilds.php

示例9: processFileForResponse

 protected function processFileForResponse($filePath, $logLine)
 {
     $tmpLogLine = $logLine->getRawData();
     $unprocessDBLines = Billrun_Factory::db()->linesCollection()->query()->notExists('billrun')->equals('file', $tmpLogLine['file']);
     //run only if theres promlematic lines in the file.
     if ($unprocessDBLines->count() == 0) {
         return false;
     }
     return parent::processFileForResponse($filePath, $logLine);
 }
开发者ID:ngchie,项目名称:system,代码行数:10,代码来源:014.php

示例10: loadRates

 /**
  * load the ggsn rates to be used later.
  */
 protected function loadRates()
 {
     $rates_coll = Billrun_Factory::db()->ratesCollection();
     $rates = $rates_coll->query($this->rateKeyMapping)->cursor()->setReadPreference(Billrun_Factory::config()->getConfigValue('read_only_db_pref'));
     $this->rates = array();
     foreach ($rates as $value) {
         $value->collection($rates_coll);
         $this->rates[] = $value;
     }
 }
开发者ID:ngchie,项目名称:system,代码行数:13,代码来源:Ggsn.php

示例11: __construct

 public function __construct($options = array())
 {
     $this->alertServer = isset($options['alertHost']) ? $options['alertHost'] : Billrun_Factory::config()->getConfigValue('fraudAlerts.alert.host', '127.0.0.1');
     $this->alertPath = isset($options['alertPath']) ? $options['alertPath'] : Billrun_Factory::config()->getConfigValue('fraudAlerts.alert.path', '/');
     $this->alertTypes = isset($options['alertTypes']) ? $options['alertTypes'] : Billrun_Factory::config()->getConfigValue('fraudAlerts.alert.types', array('nrtrde', 'ggsn', 'deposit', 'ilds', 'nsn'));
     $this->isDryRun = isset($options['dryRun']) ? $options['dryRun'] : Billrun_Factory::config()->getConfigValue('fraudAlerts.alert.dry_run', false);
     $this->startTime = time();
     $this->eventsCol = Billrun_Factory::db()->eventsCollection();
     $this->linesCol = Billrun_Factory::db()->linesCollection();
 }
开发者ID:ngchie,项目名称:system,代码行数:10,代码来源:fraudAlerts.php

示例12: insertToQueue

 protected function insertToQueue($entity)
 {
     $queue = Billrun_Factory::db()->queueCollection();
     if (!is_object($queue)) {
         Billrun_Factory::log()->log('Queue collection is not defined', Zend_Log::ALERT);
         return false;
     } else {
         return $queue->insert(array('stamp' => $entity['stamp'], 'type' => $entity['type'], 'urt' => $entity['urt'], 'calc_name' => false, 'calc_time' => false), array('w' => 1));
     }
 }
开发者ID:ngchie,项目名称:system,代码行数:10,代码来源:Credit.php

示例13: __construct

 public function __construct(array $params = array())
 {
     if (isset($params['collection'])) {
         unset($params['collection']);
     }
     parent::__construct($params);
     $this->collection = Billrun_Factory::db(Billrun_Factory::config()->getConfigValue('fraud.db'))->eventsCollection();
     $this->collection_name = 'events';
     $this->search_key = "stamp";
 }
开发者ID:ngchie,项目名称:system,代码行数:10,代码来源:Events.php

示例14: getBalancesVolume

 /**
  * method to receive the balances lines that over requested date usage
  * 
  * @return Mongodloid_Cursor Mongo cursor for iteration
  */
 public function getBalancesVolume($plan, $data_usage, $from_account_id, $to_account_id, $billrun)
 {
     $params = array('name' => $plan, 'time' => Billrun_Util::getStartTime($billrun));
     $plan_id = Billrun_Factory::plan($params);
     $id = $plan_id->get('_id')->getMongoID();
     $data_usage_bytes = Billrun_Util::megabytesToBytesFormat((int) $data_usage);
     $query = array('aid' => array('$gte' => (int) $from_account_id, '$lte' => (int) $to_account_id), 'billrun_month' => $billrun, 'balance.totals.data.usagev' => array('$gt' => (double) $data_usage_bytes), 'current_plan' => Billrun_Factory::db()->plansCollection()->createRef($id));
     //		print_R($query);die;
     return $this->collection->query($query)->cursor()->setReadPreference(Billrun_Factory::config()->getConfigValue('read_only_db_pref'))->hint(array('aid' => 1, 'billrun_month' => 1))->limit($this->size);
 }
开发者ID:ngchie,项目名称:system,代码行数:15,代码来源:Balances.php

示例15: loadRates

 /**
  * Caches the rates in the memory for fast computations
  */
 protected function loadRates()
 {
     $rates_coll = Billrun_Factory::db()->ratesCollection();
     $query = array('rates.service' => array('$exists' => 1));
     $rates = $rates_coll->query($query)->cursor()->setReadPreference(Billrun_Factory::config()->getConfigValue('read_only_db_pref'));
     $this->rates = array();
     foreach ($rates as $rate) {
         $rate->collection($rates_coll);
         $this->rates[] = $rate;
     }
 }
开发者ID:ngchie,项目名称:system,代码行数:14,代码来源:Service.php


注:本文中的Billrun_Factory::db方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。