/**
  * @param $contractId
  * @return bool
  */
 public function execute($contractId)
 {
     $this->contract_id = $contractId;
     $contract = $this->contract->find($contractId);
     $startTime = Carbon::now();
     try {
         $this->logger->info("processing Contract", ['contractId' => $contractId]);
         list($writeFolderPath, $readFilePath) = $this->setup($contract);
         if ($this->process($writeFolderPath, $readFilePath)) {
             $pages = $this->page->buildPages($writeFolderPath);
             $this->page->savePages($contractId, $pages);
             $this->updateContractPdfStructure($contract, $writeFolderPath);
             $contract->text_status = Contract::STATUS_DRAFT;
             $contract->save();
             $this->logger->info("processing contract completed.", ['contractId' => $contractId]);
             $this->mailer->send(['email' => $contract->created_user->email, 'name' => $contract->created_user->name], "{$contract->title} processing contract completed.", 'emails.process_success', ['contract_title' => $contract->title, 'contract_id' => $contract->id, 'contract_detail_url' => route('contract.show', $contract->id), 'start_time' => $startTime->toDayDateTimeString(), 'end_time' => Carbon::now()->toDayDateTimeString()]);
             $this->contract->moveS3File($contract->file, sprintf('%s/%s', $contract->id, $contract->getS3PdfName()));
             $this->contract->updateFileName($contract);
             $this->uploadPdfsToS3($contract->id);
             $this->deleteContractFolder($contract->id);
             $this->contract->updateWordFile($contract->id);
             return true;
         }
     } catch (\Exception $e) {
         $this->processStatus(Contract::PROCESSING_FAILED);
         $this->mailer->send(['email' => $contract->created_user->email, 'name' => $contract->created_user->name], "{$contract->title} processing error.", 'emails.process_error', ['contract_title' => $contract->title, 'contract_id' => $contract->id, 'contract_detail_url' => route('contract.show', $contract->id), 'start_time' => $startTime->toDayDateTimeString(), 'error' => $e->getMessage()]);
         $this->logger->error("error processing contract.{$e->getMessage()}", ['contractId' => $contractId]);
         return false;
     }
     return false;
 }
 /**
  * Execute the console command.
  */
 public function fire()
 {
     $contracts = Contract::all();
     foreach ($contracts as $key => $contract) {
         $contractDir = $contract->id;
         if ($this->storage->disk('s3')->exists("{$contractDir}/{$contract->file}")) {
             try {
                 if ($this->renameS3ContractFileName($contract)) {
                     $this->contract->updateFileName($contract);
                     $this->info("done moving {$contractDir}/{$contract->file}");
                 }
             } catch (\Exception $e) {
                 $message = $e->getMessage();
                 $this->error("error moving {$contractDir}/{$contract->file}:{$message}");
             }
         } else {
             $this->error("{$contractDir}/{$contract->file} file does not exists");
         }
     }
     $this->call('nrgi:bulkindex');
 }