public function run($args)
 {
     //        $this->logger = LoggerFactory::getFileLogger('ReportSendTest');
     $this->logger = LoggerFactory::getConsoleLogger();
     //        $processedReportsModel = new ScheduleTypeReportProcessed();
     //        $reports = $processedReportsModel->getUnsentReports();
     //
     //
     //        $reports = $processedReportsModel->findByUIDsWithDestinations($reports['uids']);
     //
     //
     //        $this->logger->log(__METHOD__.' reports:'.print_r($reports['result'],1));
     //
     //
     //        foreach ($reports['result'] as $reportItem) {
     //            $this->sendReport($reportItem);
     //        }
     $scheduleTypeReportSendLog = new ScheduleTypeReportSendLog();
     $reports = $scheduleTypeReportSendLog->getUnsentReportItems();
     $result = $scheduleTypeReportSendLog->findByUIDsWithDestinations($reports['uids']);
     foreach ($result['result'] as $reportItem) {
         $this->sendReport($reportItem);
     }
     $this->logger->log(__METHOD__ . ' reports:' . print_r($reports['uids'], 1));
     $this->logger->log(__METHOD__ . ' reports:' . print_r($result, 1));
 }
 public function createReportSendLog()
 {
     $destinations = ScheduleTypeReportDestination::getList($this->schedule_type_report->ex_schedule_id);
     if (is_array($destinations)) {
         foreach ($destinations as $destItem) {
             $sendLog = ScheduleTypeReportSendLog::isExist($this->schedule_type_report_processed->getSavedPk(), $destItem->ex_schedule_destination_id);
             if (!$sendLog) {
                 $sendLog = new ScheduleTypeReportSendLog();
                 $sendLog->ex_schedule_processed_id = $this->schedule_type_report_processed->getSavedPk();
                 $sendLog->ex_schedule_destination_id = $destItem->ex_schedule_destination_id;
                 $sendLog->sent = 0;
                 $sendLog->save();
             }
         }
     }
 }
Beispiel #3
0
 protected function clientStep04()
 {
     $sendData = $this->msStatus();
     $sendData['not_searched_reports'] = array();
     if ($this->messageData['ms_status_processed'] == 1 && $this->messageData['ms_status'] == "slave") {
         $scheduleTypeReportSendLog = new ScheduleTypeReportSendLog();
         $notSentReports = $scheduleTypeReportSendLog->findByUIDsWithDestinations($this->messageData['not_sent_reports']);
         if (!is_null($notSentReports['uids'])) {
             foreach ($notSentReports['uids'] as $key => $uidItem) {
                 foreach ($this->messageData['not_sent_reports'] as $key2 => $uidItem2) {
                     if ($notSentReports['uids'][$key]['report_uid'] == $this->messageData['not_sent_reports'][$key2]['report_uid']) {
                         //if was found unsent reports with is_synchronized = 2
                         // get it to next circle with is_synchronized = 0
                         foreach ($notSentReports['result'] as $sendLogItem) {
                             if ($sendLogItem->report_processed->ex_schedule_processed_id == $key) {
                                 $sendLogItem->report_processed->is_synchronized = 0;
                                 $sendLogItem->report_processed->save();
                                 //we have new reports ^)
                                 $typeReportSendStatus = new TypeReportSendStatus();
                                 $typeReportSendStatus->newReportAdd();
                             }
                         }
                         unset($this->messageData['not_sent_reports'][$key2]);
                     }
                 }
             }
         }
         if (is_array($this->messageData['not_sent_reports'])) {
             $sendData['not_searched_reports'] = array_values($this->messageData['not_sent_reports']);
         } else {
             $sendData['not_searched_reports'] = array();
         }
     }
     $this->createClientMessage('04', 0, $sendData);
 }