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


PHP Billrun_Factory类代码示例

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


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

示例1: __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

示例2: send

 /**
  * method to send
  * 
  * @param type $message
  * @param type $recipients
  * @return \Billrun_Sms|boolean
  */
 public function send($message, $recipients)
 {
     if (empty($message) || empty($recipients)) {
         Billrun_Factory::log()->log("can not send the sms, there are missing params - txt: " . $this->data['message'] . " recipients: " . print_r($this->data['recipients'], TRUE) . " from: " . $this->data['from'], Zend_Log::WARN);
         return false;
     }
     $unicode_text = $this->sms_unicode($message);
     if (!empty($message) && empty($unicode_text)) {
         $language = '1';
     } else {
         $language = '2';
     }
     // Temporary - make sure is not 23 chars long
     $text = str_pad($message, 24, '+');
     $period = 120;
     foreach ($recipients as $recipient) {
         $send_params = array('message' => $text, 'to' => $recipient, 'from' => $this->data['from'], 'language' => $language, 'username' => $this->data['user'], 'password' => $this->data['pwd'], 'acknowledge' => "false", 'period' => $period, 'channel' => "SRV");
         $url = $this->data['provisioning'] . "?" . http_build_query($send_params);
         $sms_result = Billrun_Util::sendRequest($url);
         $exploded = explode(',', $sms_result);
         $response = array('error-code' => empty($exploded[0]) ? 'error' : 'success', 'cause-code' => $exploded[1], 'error-description' => $exploded[2], 'tid' => $exploded[3]);
         Billrun_Factory::log()->log("phone: " . $recipient . " encoded_text: " . $message . " url: " . $url . " result" . print_R($response, 1), Zend_Log::INFO);
     }
     return $response['error-code'] == 'success' ? true : false;
 }
开发者ID:ngchie,项目名称:system,代码行数:32,代码来源:Sms.php

示例3: indexAction

 public function indexAction()
 {
     $this->redirect('admin');
     $this->getView()->title = "BillRun | The best open source billing system";
     $this->getView()->content = "Open Source Last Forever!";
     $this->getView()->favicon = Billrun_Factory::config()->getConfigValue('favicon');
 }
开发者ID:ngchie,项目名称:system,代码行数:7,代码来源:Index.php

示例4: execute

 /**
  * method that outputs account, subscribers and usage of requested accounts and requested date usage
  * it's called automatically by the api main controller
  */
 public function execute()
 {
     Billrun_Factory::log()->log("Execute data triggers", Zend_Log::INFO);
     $request = $this->getRequest()->getRequest();
     // supports GET / POST requests
     $params = array('plan', 'data_usage', 'from_account_id', 'to_account_id', 'billrun');
     foreach ($params as $param) {
         if (!isset($request[$param])) {
             $msg = 'Missing required parameter: ' . $param;
             Billrun_Factory::log()->log($msg, Zend_Log::ERR);
             $this->getController()->setOutput(array(array('status' => 0, 'desc' => 'failed', 'output' => $msg)));
             return;
         }
     }
     Billrun_Factory::log()->log("Request params Received: plan-" . $request['plan'] . ", data_usage-" . $request['data_usage'] . ", from_account_id-" . $request['from_account_id'] . ", to_account_id-" . $request['to_account_id'] . ", billrun-" . $request['billrun'], Zend_Log::INFO);
     $balances = new BalancesModel(array('size' => Billrun_Factory::config()->getConfigValue('balances.accounts.limit', 50000)));
     $results = $balances->getBalancesVolume($request['plan'], $request['data_usage'], $request['from_account_id'], $request['to_account_id'], $request['billrun']);
     if (empty($results)) {
         Billrun_Factory::log()->log('Some error happen, no result, received parameters: ' . print_r($request, true), Zend_Log::ERR);
         return;
     }
     $counter = 0;
     $accounts = array();
     foreach ($results as $result) {
         $accounts['aid'][$result['aid']]['subs'][$result['sid']] = Billrun_Util::byteFormat($result['balance']['totals']['data']['usagev'], 'MB', 2, false, '.', '');
         $counter++;
     }
     $this->getController()->setOutput(array(array('status' => 1, 'desc' => 'success', 'subscribers_count' => $counter, 'output' => $accounts)));
     return true;
 }
开发者ID:ngchie,项目名称:system,代码行数:34,代码来源:Datausage.php

示例5: execute

 /**
  * method to execute remove of billing lines (only credit and active)
  * it's called automatically by the api main controller
  */
 public function execute()
 {
     Billrun_Factory::log()->log("Execute api remove", Zend_Log::INFO);
     $request = $this->getRequest()->getRequest();
     // supports GET / POST requests
     Billrun_Factory::log()->log("Input: " . print_R($request, 1), Zend_Log::INFO);
     $stamps = array();
     foreach ($request['stamps'] as $line_stamp) {
         $clear_stamp = Billrun_Util::filter_var($line_stamp, FILTER_SANITIZE_STRING, FILTER_FLAG_ALLOW_HEX);
         if (!empty($clear_stamp)) {
             $stamps[] = $clear_stamp;
         }
     }
     if (empty($stamps)) {
         Billrun_Factory::log()->log("remove action failed; no correct stamps", Zend_Log::INFO);
         $this->getController()->setOutput(array(array('status' => false, 'desc' => 'failed - invalid stamps input', 'input' => $request)));
         return true;
     }
     $model = new LinesModel();
     $query = array('source' => 'api', 'stamp' => array('$in' => $stamps), '$or' => array(array('billrun' => array('$gte' => Billrun_Billrun::getActiveBillrun())), array('billrun' => array('$exists' => false))));
     $ret = $model->remove($query);
     if (!isset($ret['ok']) || !$ret['ok'] || !isset($ret['n'])) {
         Billrun_Factory::log()->log("remove action failed pr miscomplete", Zend_Log::INFO);
         $this->getController()->setOutput(array(array('status' => false, 'desc' => 'remove failed', 'input' => $request)));
         return true;
     }
     Billrun_Factory::log()->log("remove success", Zend_Log::INFO);
     $this->getController()->setOutput(array(array('status' => $ret['n'], 'desc' => 'success', 'input' => $request)));
 }
开发者ID:ngchie,项目名称:system,代码行数:33,代码来源:Remove.php

示例6: 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

示例7: 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));
 }
开发者ID:ngchie,项目名称:system,代码行数:10,代码来源:AggregatedCsv.php

示例8: getData

 /**
  * Get the data resource
  * 
  * @return Mongo Cursor
  */
 public function getData($filter_query = array())
 {
     $cursor = $this->collection->query($filter_query)->cursor()->setReadPreference(Billrun_Factory::config()->getConfigValue('read_only_db_pref'));
     $this->_count = $cursor->count();
     $resource = $cursor->sort($this->sort)->skip($this->offset())->limit($this->size);
     return $resource;
 }
开发者ID:ngchie,项目名称:system,代码行数:12,代码来源:Tabledate.php

示例9: 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

示例10: byimsitestAction

 public function byimsitestAction()
 {
     $working_dir = "/home/shani/Documents/S.D.O.C/BillRun/Files/Docs/Tests/";
     $row = 1;
     if (($handle = fopen($working_dir . "billing_crm_diff_with_sid_and_imsi-1.csv", "r")) !== FALSE) {
         while (($data = fgetcsv($handle, 0, "\t")) !== FALSE) {
             error_log($row);
             if ($row++ == 1) {
                 continue;
             }
             $this->subscriber = Billrun_Factory::subscriber();
             $params['time'] = "2013-10-24 23:59:59";
             $params['IMSI'] = $data[5];
             $params_arr[] = array('time' => $params['time'], 'DATETIME' => $params['time'], 'IMSI' => $params['IMSI']);
             $details = $this->subscriber->load($params);
             $data['normal_plan'] = $details->plan;
             $newCsvData[$data[4]] = $data;
         }
         fclose($handle);
         $list = Subscriber_Golan::requestList($params_arr);
         foreach ($list as $arr) {
             $newCsvData[$arr['subscriber_id']]['bulk_plan'] = $arr['plan'];
         }
         $handle = fopen('/tmp/result.csv', 'w');
         foreach ($newCsvData as $line) {
             fputcsv($handle, $line);
         }
         fclose($handle);
     }
 }
开发者ID:ngchie,项目名称:system,代码行数:30,代码来源:Rpcchecker.php

示例11: isOn

 protected function isOn()
 {
     if (Billrun_Factory::config()->getConfigValue($this->getRequest()->action)) {
         return true;
     }
     return false;
 }
开发者ID:ngchie,项目名称:system,代码行数:7,代码来源:Base.php

示例12: execute

 /**
  * method to execute the query
  * it's called automatically by the api main controller
  */
 public function execute()
 {
     Billrun_Factory::log()->log("Execute api query billrun", Zend_Log::INFO);
     $request = $this->getRequest()->getRequest();
     // supports GET / POST requests
     Billrun_Factory::log()->log("Input: " . print_R($request, 1), Zend_Log::INFO);
     if (!isset($request['aid'])) {
         $this->setError('Require to supply aid or sid', $request);
         return true;
     }
     $find = array();
     $max_list = 1000;
     if (isset($request['aid'])) {
         $aids = Billrun_Util::verify_array($request['aid'], 'int');
         if (count($aids) > $max_list) {
             $this->setError('Maximum of aid is ' . $max_list, $request);
             return true;
         }
         $find['aid'] = array('$in' => $aids);
     }
     if (isset($request['billrun'])) {
         $find['billrun_key'] = $this->getBillrunQuery($request['billrun']);
     }
     $options = array('sort' => array('aid', 'billrun_key'));
     $cacheParams = array('fetchParams' => array('options' => $options, 'find' => $find));
     $this->setCacheLifeTime(604800);
     // 1 week
     $results = $this->cache($cacheParams);
     Billrun_Factory::log()->log("query success", Zend_Log::INFO);
     $ret = array(array('status' => 1, 'desc' => 'success', 'input' => $request, 'details' => $results));
     $this->getController()->setOutput($ret);
 }
开发者ID:ngchie,项目名称:system,代码行数:36,代码来源:Billrun.php

示例13: initThings

 protected function initThings()
 {
     $config_path = Billrun_Factory::config()->getConfigValue('compare.config_path', '/var/www/billrun/conf/compare/config.ini');
     $config = (new Yaf_Config_Ini($config_path))->toArray();
     $this->included_accounts = array_unique(isset($config['include_accounts']) ? $config['include_accounts'] : array());
     $this->excluded_accounts = array_unique(isset($config['exclude_accounts']) ? $config['exclude_accounts'] : array());
     $this->excluded_ndcsns = array_unique(isset($config['exclude_ndcsns']) ? $config['exclude_ndcsns'] : array());
 }
开发者ID:ngchie,项目名称:system,代码行数:8,代码来源:Compare.php

示例14: respondAFile

 protected function respondAFile($responseFilePath, $fileName, $logLine)
 {
     Billrun_Factory::log()->log("Responding on : {$fileName}", Zend_Log::DEBUG);
     $data = $logLine->getRawData();
     $data['response_time'] = time();
     $logLine->setRawData($data);
     $logLine->save();
     return $responseFilePath;
 }
开发者ID:ngchie,项目名称:system,代码行数:9,代码来源:FilesResponder.php

示例15: addAlertData

 /**
  * Add data that is needed to use the event object/DB document later
  * @param Array|Object $event the event to add fields to.
  * @return Array|Object the event object with added fields
  */
 protected function addAlertData(&$newEvent)
 {
     $newEvent['units'] = 'MIN';
     $newEvent['value'] = $newEvent['total'];
     $newEvent['threshold'] = Billrun_Factory::config()->getConfigValue('ilds.threshold', 100);
     $newEvent['event_type'] = 'ILDS';
     $newEvent['msisdn'] = $newEvent['caller_phone_no'];
     return $newEvent;
 }
开发者ID:ngchie,项目名称:system,代码行数:14,代码来源:ilds.php


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