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 */
|
/** Id do cliente */
|
||||||
$clientId = $ClientResult->client_id > 0 ? $ClientResult->client_id : $Client->getId();
|
$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 */
|
/** Exclui todas as estações de um determinado cliente */
|
||||||
if ($StationResult->station_id == 0) {
|
$Station->Delete($clientId);
|
||||||
|
|
||||||
if (!$Station->Save(
|
/** Cadastra a estação novamente */
|
||||||
null,
|
if (!$Station->Save(
|
||||||
$clientId,
|
null,
|
||||||
null,
|
$clientId,
|
||||||
trim($jsonLog->estacao),
|
null,
|
||||||
null,
|
trim($jsonLog->estacao),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
1,
|
null,
|
||||||
trim($jsonLog->server->sistema_operacional),
|
1,
|
||||||
trim($jsonLog->server->cpu),
|
trim($jsonLog->server->sistema_operacional),
|
||||||
trim($jsonLog->server->memory)
|
trim($jsonLog->server->cpu),
|
||||||
)) {
|
trim($jsonLog->server->memory)
|
||||||
|
)) {
|
||||||
|
|
||||||
/** Informo */
|
/** Informo */
|
||||||
throw new InvalidArgumentException($Station->getErrors(), 0);
|
throw new InvalidArgumentException($Station->getErrors(), 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Id da estação */
|
/** 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.)
|
// Percorre cada disco (C:, D:, etc.)
|
||||||
foreach ($jsonLog->disk as $drive => $details) {
|
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
|
// Percorre cada atributo do disco
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($details as $key => $value) {
|
foreach ($details as $key => $value) {
|
||||||
|
|
@ -162,24 +158,21 @@ try {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Exclui as antigas pastas */
|
||||||
|
$StationFolder->Delete($stationId);
|
||||||
|
|
||||||
// Percorre a pasta Ged
|
// Percorre a pasta Ged
|
||||||
foreach ($jsonLog->ged as $path => $details) {
|
foreach ($jsonLog->ged as $path => $details) {
|
||||||
|
|
||||||
/** Verifica se não é informação da partição */
|
/** Verifica se não é informação da partição */
|
||||||
if($path !== 'partition'){
|
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
|
// Percorre cada atributo da pasta
|
||||||
foreach ($details as $key => $value) {
|
foreach ($details as $key => $value) {
|
||||||
|
|
||||||
/** Grava uma nova pasta ou atualiza o atual */
|
/** Grava uma nova pasta ou atualiza o atual */
|
||||||
if (!$StationFolder->Save(
|
if (!$StationFolder->Save(
|
||||||
$stationFolderId,
|
0,
|
||||||
$stationId,
|
$stationId,
|
||||||
$path,
|
$path,
|
||||||
$value,
|
$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 */
|
/** Exclui os registros anteriores */
|
||||||
$Backup->Delete($clientId, $stationId);
|
$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 */
|
/** Consulta SQL */
|
||||||
$this->sql = 'delete from station
|
$this->sql = 'delete from station
|
||||||
where station_id = :station_id';
|
where client_id = :client_id';
|
||||||
|
|
||||||
/** Preparo o sql para receber os valores */
|
/** Preparo o sql para receber os valores */
|
||||||
$this->stmt = $this->connection->connect()->prepare($this->sql);
|
$this->stmt = $this->connection->connect()->prepare($this->sql);
|
||||||
|
|
||||||
/** Preencho os parâmetros do SQL */
|
/** Preencho os parâmetros do SQL */
|
||||||
$this->stmt->bindParam('client_id', $this->clientId);
|
$this->stmt->bindParam(':client_id', $this->clientId);
|
||||||
|
|
||||||
/** Executo o SQL */
|
/** Executo o SQL */
|
||||||
return $this->stmt->execute();
|
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 $field = null;
|
||||||
private $errors = [];
|
private $errors = [];
|
||||||
private $lastId = null;
|
private $lastId = null;
|
||||||
|
private $details = null;
|
||||||
|
private $clientId = null;
|
||||||
|
|
||||||
/** Construtor da classe */
|
/** Construtor da classe */
|
||||||
function __construct()
|
function __construct()
|
||||||
|
|
@ -287,26 +289,96 @@ class StationFolder
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Deleta um determinado registro no banco de dados */
|
/** Deleta um determinado registro no banco de dados */
|
||||||
function Delete(int $stationFolderId)
|
function Delete(int $stationId)
|
||||||
{
|
{
|
||||||
/** Parametros de entrada */
|
/** Parametros de entrada */
|
||||||
$this->stationFolderId = $stationFolderId;
|
$this->stationId = $stationId;
|
||||||
|
|
||||||
/** Consulta SQL */
|
/** Consulta SQL */
|
||||||
$this->sql = 'delete from station_folder
|
$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 */
|
/** Preparo o sql para receber os valores */
|
||||||
$this->stmt = $this->connection->connect()->prepare($this->sql);
|
$this->stmt = $this->connection->connect()->prepare($this->sql);
|
||||||
|
|
||||||
/** Preencho os parâmetros do 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 */
|
/** Executo o SQL */
|
||||||
return $this->stmt->execute();
|
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 */
|
/** Fecha uma conexão aberta anteriormente com o banco de dados */
|
||||||
function __destruct()
|
function __destruct()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue