Ejemplo n.º 1
0
 /**
  * @param $period
  * @return HeartbeatReport
  */
 public static function create($period)
 {
     $report = new HeartbeatReport();
     $report->period = new CDbExpression('NOW()- INTERVAL 1 ' . self::periodList($period));
     $report->status = 'create';
     $report->save();
     return $report->report_id;
 }
Ejemplo n.º 2
0
 public function actionHeartbeatReport()
 {
     $report = HeartbeatReport::getReport($_GET['report_id']);
     $data = new GetStatistics($report->report_id);
     if ($_GET['download']) {
         $data->downloadExcel($report);
     }
     $this->render('heartbeat_report', array('report' => $report, 'data' => $data));
 }
 /**
  * Main function
  * @return bool
  */
 private function work()
 {
     $this->_logger->log(__METHOD__);
     try {
         $this->report = HeartbeatReport::getReport(HeartbeatReport::create($this->period));
         $stat = new GetStatistics($this->report);
         if (!$stat->push($this->report->report_id)) {
             $this->report->status('push_err');
             return false;
         }
         $excel_path = $stat->saveExcel($this->report);
         if ($excel_path === false) {
             $this->report->status('exel_err');
             return false;
         }
         $this->report->status('sending');
         if ($excel_path !== false && !$this->emailSend($excel_path)) {
             $this->report->status('email_err');
             return false;
         }
         if ($excel_path !== false && !$this->ftpSend($excel_path)) {
             $this->report->ftpStatus('ftp_err');
             return false;
         }
         return true;
     } catch (Exception $e) {
         $this->_logger->log(__METHOD__ . "ERROR: ", $e->getMessage());
         return false;
     }
 }