From 395d21d2e99a0ae1087f46fda5cd8ffbc6696acc Mon Sep 17 00:00:00 2001 From: Felix Morales Date: Mon, 1 Jul 2024 16:49:46 -0500 Subject: [PATCH] Added a new endpoint to supply the D: drive storage status to the front end --- .../Dashboard/CorresponsalesController.cs | 23 +++++++++++++++++++ .../Alen/DTOEstadosCuentaAlenFilters.cs | 3 ++- .../Alen/EstadosCuentaAlenRepository.cs | 3 ++- appsettings.Development.json | 1 + appsettings.Staging.json | 1 + appsettings.json | 1 + 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Controllers/Dashboard/CorresponsalesController.cs b/Controllers/Dashboard/CorresponsalesController.cs index f04b0f0..592930c 100644 --- a/Controllers/Dashboard/CorresponsalesController.cs +++ b/Controllers/Dashboard/CorresponsalesController.cs @@ -2,6 +2,7 @@ using CORRESPONSALBackend.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; +using System.IO; namespace CORRESPONSALBackend.Controllers.Dashboard { @@ -69,5 +70,27 @@ namespace CORRESPONSALBackend.Controllers.Dashboard var traficos = await _Repo.SolicitudesElminarCuenta(); return traficos; } + + [HttpGet("GetDiskUsage")] + public async Task GetTotalFreeSpace() + { + var diskName = _config.GetValue("DataDisk"); + //List diskData = new List(); + foreach (DriveInfo drive in DriveInfo.GetDrives()) + { + if (drive.IsReady && drive.Name == diskName) + { + long driveFreeSpaceInGB = drive.TotalFreeSpace / 1024 / 1024 / 1024; + long driveTotalSpaceInGB = drive.TotalSize / 1024 / 1024 / 1024; + long driveTotalUsedSpaceInGB = driveTotalSpaceInGB - driveFreeSpaceInGB; + long usedStoragePercentage = driveTotalUsedSpaceInGB * 100 / driveTotalSpaceInGB; + return new OkObjectResult(new DashboardCorresponsales(){ + Total = Convert.ToInt32(usedStoragePercentage), + Descripcion = $"{driveTotalUsedSpaceInGB} GB usados de {driveTotalSpaceInGB} GB" + }); + } + } + return BadRequest("No se pudo obtener la informaciĆ³n de la unidad"); + } } } diff --git a/DTO/Reportes/Alen/DTOEstadosCuentaAlenFilters.cs b/DTO/Reportes/Alen/DTOEstadosCuentaAlenFilters.cs index 0f45c4d..204d022 100644 --- a/DTO/Reportes/Alen/DTOEstadosCuentaAlenFilters.cs +++ b/DTO/Reportes/Alen/DTOEstadosCuentaAlenFilters.cs @@ -5,7 +5,8 @@ namespace CORRESPONSALBackend.DTO.Reportes.Alen{ public string? Aduana {get;set;}=""; public string? Patente {get;set;}=""; public string? Pedimento {get;set;}=""; - public string? Fecha {get;set;}=""; + public string? Inicio {get;set;}=""; + public string? Fin {get;set;}=""; public string? Remitente {get;set;}=""; public string? Programado {get;set;} = ""; } diff --git a/Repository/Reportes/Alen/EstadosCuentaAlenRepository.cs b/Repository/Reportes/Alen/EstadosCuentaAlenRepository.cs index 9e861cd..7b04453 100644 --- a/Repository/Reportes/Alen/EstadosCuentaAlenRepository.cs +++ b/Repository/Reportes/Alen/EstadosCuentaAlenRepository.cs @@ -101,7 +101,8 @@ namespace CORRESPONSALBackend.Repository.Reportes.Alen{ filters.Aduana, filters.Patente, filters.Pedimento, - filters.Fecha, + filters.Inicio, + filters.Fin, filters.Remitente, filters.Programado }, commandType: CommandType.StoredProcedure); diff --git a/appsettings.Development.json b/appsettings.Development.json index 7782a34..6a4626b 100644 --- a/appsettings.Development.json +++ b/appsettings.Development.json @@ -8,6 +8,7 @@ "Microsoft.AspNetCore": "Warning" } }, + "DataDisk":"C:\\", "EmailServer": "gemcousa-com.mail.protection.outlook.com", "EmailPort": 25, "pathArchivoElectronico": "C:\\downs\\ArchivoElectronicoSIR\\www.gemcousa.com\\SIR-GEMCO\\DOCS-SIR\\", diff --git a/appsettings.Staging.json b/appsettings.Staging.json index 875b4c6..bd96dfe 100644 --- a/appsettings.Staging.json +++ b/appsettings.Staging.json @@ -8,6 +8,7 @@ "Microsoft.AspNetCore": "Warning" } }, + "DataDisk":"D:\\", "EmailServer": "gemcousa-com.mail.protection.outlook.com", "EmailPort": 25, "pathArchivoElectronico": "D:\\data\\ArchivoElectronicoSIR\\www.gemcousa.com\\SIR-GEMCO\\DOCS-SIR\\", diff --git a/appsettings.json b/appsettings.json index 82a247c..89096f4 100644 --- a/appsettings.json +++ b/appsettings.json @@ -19,6 +19,7 @@ "Subject": "JWTServiceAccessToken", "ExpirationHours": 4 }, + "DataDisk":"D:\\", "EmailServer": "gemcousa-com.mail.protection.outlook.com", "EmailPort": 25, "pathArchivoElectronico": "D:\\data\\ArchivoElectronicoSIR\\www.gemcousa.com\\SIR-GEMCO\\DOCS-SIR\\",