gestione gare pubbliche
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

102 righe
2.5 KiB

<?php
namespace App\Console\Commands\Preservation;
use Carbon\Carbon;
use App\Models\Main\Tenant;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use App\Jobs\Preservation\GetFilesJob;
use Illuminate\Support\Facades\Config;
use App\Jobs\Preservation\MakeZipArchiveJob;
use App\Models\Tenant\Conservazione\Conservazione;
class SpecificTenantZipArchiverCommand extends Command
{
/**
* Tenant id
*
* @var Int
*/
private $tenant;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'preservation:make-zip-archives
{--T|tenant= : Tenant Identifier}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Make all collections';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$this->tenant = $this->option("tenant");
setup_db_connection();
config(['database.connections.mysql-tenant.database' => config('json.prefix_db') . "_ente{$this->tenant}"]);
DB::purge('mysql-tenant');
$tenant = Tenant::where("codice", $this->tenant)->first();
$collections = Conservazione::where("stato", "<", 20)
->orWhere("stato", 90);
if($collections->count() > 0) {
foreach($collections->cursor() as $collection) {
if($collection->archivio == "N" || $collection->archivio == "W") {
$this->info("Processing #{$collection->codice}");
$collection->stato = 20;
$collection->save();
if($collection->items()->count() < 1) {
$this->line("Getting files.");
$full_archive = true;
$proceed_with_next_job = false;
GetFilesJob::dispatchSync($tenant->codice, $collection->codice, $full_archive, $proceed_with_next_job);
}
$this->line("Archiving files.");
$collection->stato = 5;
$collection->save();
MakeZipArchiveJob::dispatchSync($tenant->codice, $collection->codice);
}
}
}
}
}