示例#1
0
 public function _initPlugin(Yaf_Dispatcher $dispatcher)
 {
     // set include paths of the system.
     set_include_path(get_include_path() . PATH_SEPARATOR . Yaf_Loader::getInstance()->getLibraryPath());
     /* register a billrun plugin system from config */
     $config = Yaf_Application::app()->getConfig();
     if (isset($config->plugins)) {
         $plugins = $config->plugins->toArray();
         $dispatcher = Billrun_Dispatcher::getInstance();
         foreach ($plugins as $plugin) {
             Billrun_Log::getInstance()->log("Load plugin " . $plugin, Zend_log::DEBUG);
             $dispatcher->attach(new $plugin());
         }
     }
     if (isset($config->chains)) {
         $chains = $config->chains->toArray();
         $dispatcherChain = Billrun_Dispatcher::getInstance(array('type' => 'chain'));
         foreach ($chains as $chain) {
             Billrun_Log::getInstance()->log("Load plugin " . $chain, Zend_log::DEBUG);
             $dispatcherChain->attach(new $chain());
         }
     }
     // make the base action auto load (required by controllers actions)
     Yaf_Loader::getInstance(APPLICATION_PATH . '/application/helpers')->registerLocalNamespace('Action');
 }
示例#2
0
 /**
  * send  processing results by email.
  */
 protected function sendProcessingSummary($logs)
 {
     Billrun_Log::getInstance()->log("Generate Processing result to email", Zend_Log::INFO);
     $emailMsg = "";
     foreach ($logs as $type => $val) {
         $name = strtoupper($type);
         if (!isset($val['last_received'])) {
             $emailMsg .= strtoupper($type) . " no files were processed or recevied";
             continue;
         }
         if ($val['warning']) {
             $smsMsg = "WARNNING! : it seems the server stopped processing {$name}";
             $emailMsg .= $smsMsg . PHP_EOL . PHP_EOL;
             $this->sendSmsOnFailure($smsMsg);
         }
         if ($val['alert']) {
             $smsMsg = "ALERT! : didn't processed {$name} longer then the configured time";
             $emailMsg .= $smsMsg . PHP_EOL . PHP_EOL;
             $this->sendSmsOnFailure($smsMsg);
         }
         if (Billrun_Factory::config()->getConfigValue('emailAlerts.processing.send_report_regularly', false)) {
             $seq = $this->getFileSequenceData($val['last_received']['file_name'], $type);
             $emailMsg .= strtoupper($type) . " recevied Index : " . $seq['seq'] . " receving date : " . $val['last_received']['received_time'] . PHP_EOL;
         }
     }
     if (!$emailMsg) {
         return false;
     }
     $email_recipients = Billrun_Factory::config()->getConfigValue('emailAlerts.processing.recipients', array());
     $date = date(Billrun_Base::base_dateformat);
     return $this->sendMail("Processing status " . $date, $emailMsg, $email_recipients);
 }
示例#3
0
 /**
  * Log a message at a priority the the main Billrun Log
  *
  * @param  string   $message   Message to log
  * @param  integer  $priority  Priority of message
  * @param  mixed    $extras    Extra information to log in event
  * @return void
  * @throws Zend_Log_Exception
  */
 protected function log($message, $priority, $extras = null)
 {
     Billrun_Log::getInstance()->log($message, $priority, $extras);
 }
示例#4
0
文件: Factory.php 项目: ngchie/system
 /**
  * method to retrieve the log instance
  * 
  * @param string [Optional] $message message to log
  * @param int [Optional] $priority message to log
  * 
  * @return Billrun_Log
  */
 public static function log()
 {
     if (!self::$log) {
         self::$log = Billrun_Log::getInstance();
     }
     $args = func_get_args();
     if (count($args) > 0) {
         $message = (string) $args[0];
         if (!isset($args[1])) {
             $priority = Zend_Log::DEBUG;
         } else {
             $priority = (int) $args[1];
         }
         self::$log->log($message, $priority);
     }
     return self::$log;
 }
示例#5
0
 /**
  * Mark the lines that generated the event as dealt with.
  * @param type $event the event that relate to the lines.
  */
 protected function markEventLines($event)
 {
     //mark deposit for the lines on the current imsi
     Billrun_Log::getInstance()->log("Fraud alerts mark event lines " . $event['deposit_stamp'], Zend_Log::INFO);
     $imsi = isset($event['imsi']) && $event['imsi'] ? $event['imsi'] : null;
     $msisdn = isset($event['msisdn']) && $event['msisdn'] ? $event['msisdn'] : null;
     $lines_where = array();
     if ($imsi) {
         $lines_where['imsi'] = $imsi;
     }
     if ($msisdn) {
         $lines_where['msisdn'] = $msisdn;
     }
     //		if (isset($event['effects'])) {
     //			$lines_where[$event['effects']['key']] = $event['effects']['filter'];
     //		} else {
     //			$lines_where['type'] = $event['source'];
     //		}
     //
     $lines_where['process_time'] = array('$gt' => date(Billrun_Base::base_dateformat, Billrun_Util::getLastChargeTime()));
     $lines_where['process_time'] = array('$lt' => date(Billrun_Base::base_dateformat, $this->startTime));
     $lines_where['deposit_stamp'] = array('$exists' => false);
     if (!($imsi || $msisdn)) {
         Billrun_Log::getInstance()->log("fraudAlertsPlugin::markEventLines cannot find IMSI nor NDC_SN on event, marking CDR lines with event_stamp of : " . print_r($event['stamps'], 1), Zend_Log::INFO);
         $lines_where['event_stamp'] = array('$in' => $event['stamps']);
     }
     // the update will done manually due to performance with collection update (not supported with hint)
     // @TODO: when update command will suport hint will use update (see remark code after foreach loop)
     $rows = $this->linesCol->query($lines_where)->cursor()->hint(array('imsi' => 1));
     foreach ($rows as $row) {
         $row->collection($this->linesCol);
         $row->set('deposit_stamp', $event['deposit_stamp']);
         $row->save($this->linesCol);
     }
     // forward compatibility
     //			$lines_update_set = array(
     //					'$set' => array( 'deposit_stamp' => $event['deposit_stamp'] )
     //			);
     //			$update_options = array( 'multiple' => 1 );
     //
     //			$this->linesCol->update($lines_where, $lines_update_set, $update_options);
 }
示例#6
0
文件: Cli.php 项目: ngchie/system
 /**
  * method to add output to the stream and log
  * 
  * @param string $content the content to add
  */
 public function addOutput($content)
 {
     Billrun_Log::getInstance()->log($content, Zend_Log::INFO);
 }