Added a new endpoint to supply the D: drive storage status to the front end

main
Felix Morales 3 months ago
parent aad941897f
commit 395d21d2e9
  1. 23
      Controllers/Dashboard/CorresponsalesController.cs
  2. 3
      DTO/Reportes/Alen/DTOEstadosCuentaAlenFilters.cs
  3. 3
      Repository/Reportes/Alen/EstadosCuentaAlenRepository.cs
  4. 1
      appsettings.Development.json
  5. 1
      appsettings.Staging.json
  6. 1
      appsettings.json

@ -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<IActionResult> GetTotalFreeSpace()
{
var diskName = _config.GetValue<string>("DataDisk");
//List<DashboardCorresponsales> diskData = new List<DashboardCorresponsales>();
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");
}
}
}

@ -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;} = "";
}

@ -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);

@ -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\\",

@ -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\\",

@ -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\\",

Loading…
Cancel
Save