Adicionado a tabela de partição do GED
This commit is contained in:
parent
849894cf15
commit
2ed24b6e38
3 changed files with 119 additions and 45 deletions
80
vendor/action/log/log_save.php
vendored
80
vendor/action/log/log_save.php
vendored
|
|
@ -81,48 +81,44 @@ try {
|
|||
/** Id do cliente */
|
||||
$clientId = $ClientResult->client_id > 0 ? $ClientResult->client_id : $Client->getId();
|
||||
|
||||
/** Consulta se a estação já foi cadastrada */
|
||||
$StationResult = $Station->Search($clientId, $jsonLog->estacao);
|
||||
|
||||
/** Verifica se a estação já foi cadastrada */
|
||||
if ($StationResult->station_id == 0) {
|
||||
/** Exclui todas as estações de um determinado cliente */
|
||||
$Station->Delete($clientId);
|
||||
|
||||
if (!$Station->Save(
|
||||
null,
|
||||
$clientId,
|
||||
null,
|
||||
trim($jsonLog->estacao),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
1,
|
||||
trim($jsonLog->server->sistema_operacional),
|
||||
trim($jsonLog->server->cpu),
|
||||
trim($jsonLog->server->memory)
|
||||
)) {
|
||||
/** Cadastra a estação novamente */
|
||||
if (!$Station->Save(
|
||||
null,
|
||||
$clientId,
|
||||
null,
|
||||
trim($jsonLog->estacao),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
1,
|
||||
trim($jsonLog->server->sistema_operacional),
|
||||
trim($jsonLog->server->cpu),
|
||||
trim($jsonLog->server->memory)
|
||||
)) {
|
||||
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException($Station->getErrors(), 0);
|
||||
}
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException($Station->getErrors(), 0);
|
||||
}
|
||||
|
||||
/** Id da estação */
|
||||
$stationId = $StationResult->station_id > 0 ? $StationResult->station_id : $Station->getId();
|
||||
$stationId = $Station->getId();
|
||||
|
||||
|
||||
/** Exclui antigas unidades */
|
||||
$StationDisk->Delete($stationId);
|
||||
|
||||
// Percorre cada disco (C:, D:, etc.)
|
||||
foreach ($jsonLog->disk as $drive => $details) {
|
||||
|
||||
/** Consulta se o disco já foi cadastrado */
|
||||
$StationDiskResult = $StationDisk->Search($stationId, $drive);
|
||||
|
||||
/** Prepara o Id da estação */
|
||||
$stationDiskId = $StationDiskResult->station_disk_id > 0 ? $StationDiskResult->station_disk_id : 0;
|
||||
|
||||
// Percorre cada atributo do disco
|
||||
$i = 0;
|
||||
foreach ($details as $key => $value) {
|
||||
|
|
@ -162,24 +158,21 @@ try {
|
|||
}
|
||||
}
|
||||
|
||||
/** Exclui as antigas pastas */
|
||||
$StationFolder->Delete($stationId);
|
||||
|
||||
// Percorre a pasta Ged
|
||||
foreach ($jsonLog->ged as $path => $details) {
|
||||
|
||||
/** Verifica se não é informação da partição */
|
||||
if($path !== 'partition'){
|
||||
|
||||
/** Consulta se o disco já foi cadastrado */
|
||||
$StationFolderResult = $StationFolder->Search($stationId, $path);
|
||||
|
||||
/** Prepara o Id da estação */
|
||||
$stationFolderId = $StationFolderResult->station_folder_id > 0 ? $StationFolderResult->station_folder_id : 0;
|
||||
|
||||
// Percorre cada atributo da pasta
|
||||
foreach ($details as $key => $value) {
|
||||
|
||||
/** Grava uma nova pasta ou atualiza o atual */
|
||||
if (!$StationFolder->Save(
|
||||
$stationFolderId,
|
||||
0,
|
||||
$stationId,
|
||||
$path,
|
||||
$value,
|
||||
|
|
@ -193,6 +186,15 @@ try {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/** Deleta os dados da partição */
|
||||
$StationFolder->DeletePartition($clientId, $stationId);
|
||||
|
||||
/** Grava os detalhes da partição GED */
|
||||
$StationFolder->SavePartition($jsonLog->ged->{'partition'},
|
||||
$clientId,
|
||||
$stationId);
|
||||
|
||||
/** Exclui os registros anteriores */
|
||||
$Backup->Delete($clientId, $stationId);
|
||||
|
||||
|
|
|
|||
4
vendor/model/Station.class.php
vendored
4
vendor/model/Station.class.php
vendored
|
|
@ -356,13 +356,13 @@ class Station
|
|||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'delete from station
|
||||
where station_id = :station_id';
|
||||
where client_id = :client_id';
|
||||
|
||||
/** Preparo o sql para receber os valores */
|
||||
$this->stmt = $this->connection->connect()->prepare($this->sql);
|
||||
|
||||
/** Preencho os parâmetros do SQL */
|
||||
$this->stmt->bindParam('client_id', $this->clientId);
|
||||
$this->stmt->bindParam(':client_id', $this->clientId);
|
||||
|
||||
/** Executo o SQL */
|
||||
return $this->stmt->execute();
|
||||
|
|
|
|||
80
vendor/model/StationFolder.class.php
vendored
80
vendor/model/StationFolder.class.php
vendored
|
|
@ -33,6 +33,8 @@ class StationFolder
|
|||
private $field = null;
|
||||
private $errors = [];
|
||||
private $lastId = null;
|
||||
private $details = null;
|
||||
private $clientId = null;
|
||||
|
||||
/** Construtor da classe */
|
||||
function __construct()
|
||||
|
|
@ -287,26 +289,96 @@ class StationFolder
|
|||
}
|
||||
|
||||
/** Deleta um determinado registro no banco de dados */
|
||||
function Delete(int $stationFolderId)
|
||||
function Delete(int $stationId)
|
||||
{
|
||||
/** Parametros de entrada */
|
||||
$this->stationFolderId = $stationFolderId;
|
||||
$this->stationId = $stationId;
|
||||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'delete from station_folder
|
||||
where station_folder_id = :station_folder_id';
|
||||
where station_id = :station_id';
|
||||
|
||||
/** Preparo o sql para receber os valores */
|
||||
$this->stmt = $this->connection->connect()->prepare($this->sql);
|
||||
|
||||
/** Preencho os parâmetros do SQL */
|
||||
$this->stmt->bindParam('station_folder_id', $this->stationFolderId);
|
||||
$this->stmt->bindParam(':station_id', $this->stationId);
|
||||
|
||||
/** Executo o SQL */
|
||||
return $this->stmt->execute();
|
||||
|
||||
}
|
||||
|
||||
/** Deleta um determinado registro no banco de dados */
|
||||
function DeletePartition(int $clientId, int $stationId)
|
||||
{
|
||||
/** Parametros de entrada */
|
||||
$this->clientId = $clientId;
|
||||
$this->stationId = $stationId;
|
||||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'delete from station_folder_partition
|
||||
where client_id = :client_id
|
||||
and station_id = :station_id';
|
||||
|
||||
/** Preparo o sql para receber os valores */
|
||||
$this->stmt = $this->connection->connect()->prepare($this->sql);
|
||||
|
||||
/** Preencho os parâmetros do SQL */
|
||||
$this->stmt->bindParam(':client_id', $this->clientId);
|
||||
$this->stmt->bindParam(':station_id', $this->stationId);
|
||||
|
||||
/** Executo o SQL */
|
||||
return $this->stmt->execute();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** Cadastra os dados da partição */
|
||||
public function SavePartition(object $details, int $clientId, int $stationId)
|
||||
{
|
||||
/** Parametros */
|
||||
$this->details = $details;
|
||||
$this->clientId = $clientId;
|
||||
$this->stationId = $stationId;
|
||||
|
||||
/** Consulta SQL */
|
||||
$this->sql = 'insert into station_folder_partition(client_id,
|
||||
station_id,
|
||||
details
|
||||
) values (:client_id,
|
||||
:station_id,
|
||||
:details)';
|
||||
|
||||
/** Preparo o sql para receber os valores */
|
||||
$this->stmt = $this->connection->connect()->prepare($this->sql);
|
||||
|
||||
try{
|
||||
|
||||
/** Inicia a transação */
|
||||
$this->connection->connect()->beginTransaction();
|
||||
|
||||
/** Preencho os parâmetros do SQL */
|
||||
$this->stmt->bindParam('client_id', $this->clientId);
|
||||
$this->stmt->bindParam('station_id', $this->stationId);
|
||||
$this->stmt->bindParam('details', $this->details);
|
||||
|
||||
/** Executo o SQL */
|
||||
$this->stmt->execute();
|
||||
|
||||
|
||||
}catch(\Exception $exception) {
|
||||
|
||||
/** Desfaz a transação */
|
||||
$this->connection->connect()->rollback();
|
||||
|
||||
/** Captura o erro */
|
||||
array_push($this->errors, $exception->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Fecha uma conexão aberta anteriormente com o banco de dados */
|
||||
function __destruct()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue