示例#1
0
 public function fileConvertAndUpdate()
 {
     $dir = "../files/";
     $num = 0;
     $documents_group = scandir($dir);
     foreach ($documents_group as $key => $value) {
         if ($value != "." && $value != "..") {
             $handler = new handler($dir, $value);
             if ($handler->getFileType() != NULL) {
                 try {
                     $document = Document::create(array('path' => $handler->getPath(), 'fileName' => $handler->getFileName(), 'fileType' => $handler->getFileType(), 'systemName' => $handler->getSystemName(), 'airlineName' => $handler->getAirlineName(), 'ticketNumber' => $handler->getTicketNumber(), 'dateString' => $handler->getDateString(), 'orderOfDay' => $handler->getOrderOfDay(), 'fileContent' => $handler->getFileContent(), 'dateOfFile' => $handler->getDateOfFile(), 'paxName' => $handler->getPaxName(), 'rloc' => $handler->getRloc(), 'ticketsType' => $handler->getTicketsType()));
                     $document->save();
                     $num++;
                     rename($dir . $value, "../done/" . $value);
                 } catch (Exception $e) {
                     $response['info'] = "fail";
                     $boolean = false;
                     echo $e;
                 }
             }
         }
     }
     //echo $num." files have been converted."; die;
     return $num;
 }