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.
 
 
 
 
 

98 righe
2.4 KiB

<?php
namespace App\Console\Commands\Preservation;
use App\Models\Main\Tenant;
use Illuminate\Console\Command;
use App\Classes\PreservationClass;
use Illuminate\Support\Facades\DB;
use App\Jobs\Preservation\GetFilesJob;
use App\Jobs\Preservation\SendPackageJob;
use App\Models\Tenant\Conservazione\Conservazione;
use App\Jobs\Preservation\CheckPreservationStatusJob;
class SendAllScheduledCollectionsCommand extends Command
{
/**
* Tenant id
*
* @var Int
*/
private $tenant;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'preservation:send-all
{--T|tenant= : Tenant Identifier}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send all scheduled 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::find($this->tenant);
$collections = Conservazione::where("stato", "<", 20)->get();
foreach($collections as $collection) {
if ($collection->items()->count() < 1) {
$this->info("Retrieving files for package #{$collection->codice}");
GetFilesJob::dispatchSync($this->tenant, $collection->codice);
}
if($collection->items()->count() > 0) {
$preservation = new PreservationClass($tenant->codice, $collection->codice);
$preservation->enableDebugging();
if($collection->items()->where('stato', '<>', '20')->count() < 1) {
$this->info("Checking the status of package #{$collection->codice}");
$preservation->checkPreservationStatus();
} else {
$this->info("Sending package #{$collection->codice}");
$preservation->pushCollection();
}
}
}
return 0;
}
}