Compare commits

..

No commits in common. 'b68cffe74148d95eb3ed7d32a37b4fe2404b0adf' and 'dcff6f0e911e1cb24668749a523dce29c5293abd' have entirely different histories.

  1. 9
      Contracts/ArchivoElectronico/IArchivoElectronicoRepository.cs
  2. 5
      Contracts/ArchivoElectronico/IArchivoElectronicoService.cs
  3. 1
      Contracts/Utils/IFileManagerRepository.cs
  4. 6
      Controllers/AuthController.cs
  5. 11
      Controllers/FileManagerController.cs
  6. 93
      Controllers/Utils/ArchivoElectronicoController.cs
  7. 11
      Models/Reportes/RptPedimentosPagadosAEO.cs
  8. 6
      Program.cs
  9. 31
      Repository/ArchivoElectronicoRepository.cs
  10. 11
      Repository/Utils/FileManagerRepository.cs
  11. 7
      Services/ArchivoElectronicoService.cs

@ -1,9 +0,0 @@
using CORRESPONSALBackend.DTO.ArchivoElectronico;
using GEMCO.Backend.Models.Reportes;
namespace CORRESPONSALBackend.Contracts.ArchivoElectronico{
public interface IArchivoElectronicoRepository
{
public Task<List<RptPedimentosPagadosAEO>> getRptPedimentoPagadosAEO(DTOAEPeriodo dTOData);
}
}

@ -1,5 +0,0 @@
namespace CORRESPONSALBackend.Contracts.ArchivoElectronico{
public interface IArchivoElectronicoService{
}
}

@ -12,6 +12,5 @@ namespace CORRESPONSALBackend.Contracts.Utils
public Task<FileManager> UpdateFileNameById(long id, string newFileName); public Task<FileManager> UpdateFileNameById(long id, string newFileName);
public Task<IEnumerable<FileManager>> GetFilesByProcessId(int process); public Task<IEnumerable<FileManager>> GetFilesByProcessId(int process);
public Task<FileManager> UpdateFileProcessById(long fileId, int process); public Task<FileManager> UpdateFileProcessById(long fileId, int process);
public Task<IEnumerable<FileManager>> GetTraficoFiles(int idTrafico);
} }
} }

@ -133,10 +133,10 @@ namespace CORRESPONSALBackend.Controllers
{ {
DTOPINData PINData = await _usuariosRepo.CreatePIN(IdUser); DTOPINData PINData = await _usuariosRepo.CreatePIN(IdUser);
string htmlContent = $@"<table> string htmlContent = $@"<table>
<tr><td>Estimado usuario, mediante este correo se le notifica que está en proceso de cambiar su contraseña.</td></tr> <tr><td>Estimado usuario, mediante este correo se le notifica que esta en proceso de cambiar su contraseña</td></tr>
<tr><td>Se ha generado un PIN para poder cambiar su contraseña. PIN : <b>{PINData.PIN}</b> </td></tr> <tr><td>Se ha generado un PIN para poder cambiar su contraseña. PIN : <b>{PINData.PIN}</b> </td></tr>
<tr><td>El PIN tiene un tiempo de vida de 10 minutos, a partir de su generación.</td></tr> <tr><td>El PIN tiene un tiempo de vida de 10 minutos, a partir de su generacion, despues de ese tiempo caduca</td></tr>
<tr><td>Si usted <b>NO</b> es quien ha activando este mecanismo, favor de ponerse en contacto con personal de GEMCO.</td></tr> <tr><td>Si usted <b>no</b> es quien ha activando este mecanismo, favor de ponerse en contacto con personal de ZINC</td></tr>
</table>"; </table>";
if (PINData.PIN > 0) if (PINData.PIN > 0)
{ {

@ -430,16 +430,5 @@ namespace CORRESPONSALBackend.Controllers
return BadRequest(ex.Message); return BadRequest(ex.Message);
} }
} }
[HttpGet("FileListByReferencia")]
public async Task<IActionResult> GeFileListByReferencia([FromQuery] string referencia){
try{
var trafico = await _traficosRepository.GetByReferencia(referencia);
var fileList = await _Repo.GetTraficoFiles(trafico.id);
return Ok(fileList);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
} }
} }

@ -1,93 +0,0 @@
using CORRESPONSALBackend.Contracts.ArchivoElectronico;
using CORRESPONSALBackend.Contracts.Corresponsalias;
using CORRESPONSALBackend.Contracts.Utils;
using CORRESPONSALBackend.DTO.ArchivoElectronico;
using CORRESPONSALBackend.Models.Utils;
using CORRESPONSALBackend.Repository.Utils;
using GEMCO.Backend.Models.Reportes;
using Microsoft.AspNetCore.Mvc;
namespace CORRESPONSALBackend.Controllers.Utils{
[Route("api/[controller]")]
[ApiController]
public class ArchivoElectronicoController : ControllerBase {
private readonly IArchivoElectronicoRepository _AERepo;
private readonly IConfiguration _config;
private readonly IFilePaths4ProcessRepository _RepoRelativePath;
private readonly string RootPathCorresponsales;
private readonly ICorresponsaliasTraficosRepository _traficosRepository;
private readonly IFileManagerRepository _fileManagerRepo;
public ArchivoElectronicoController(IArchivoElectronicoRepository AERepo, IConfiguration config,
ICorresponsaliasTraficosRepository traficosRepository, IFilePaths4ProcessRepository RepoRelativePath,
IFileManagerRepository fileManagerRepo){
_AERepo = AERepo;
_traficosRepository = traficosRepository;
_config = config;
_RepoRelativePath = RepoRelativePath;
_fileManagerRepo = fileManagerRepo;
RootPathCorresponsales = _config.GetValue<string>("AllFiles");
}
[HttpGet]
[Route("RptArchivoElectronicoOficial")]
public async Task<List<RptPedimentosPagadosAEO>> GetReporteArchivElectronicoOficial([FromQuery] DTOAEPeriodo DTOData)
{
List<RptPedimentosPagadosAEO> data = await _AERepo.getRptPedimentoPagadosAEO(DTOData);
return data;
}
[HttpPost]
[Route("DownloadZippedArchivosOficiales")]
public async Task<IActionResult> DownloadZippedArchivosOficiales([FromBody] DTOAEPeriodoSeleccion data){
try{
//Se obtiene la ruta donde se alojará temporalmente el zip
FilePaths4Process tempFilesRelativePath = await _RepoRelativePath.getPaths4ProcessById(44); // Path: Corresponsales\Zips\Facturacion\Entregas\
var tempFilesPath = RootPathCorresponsales + tempFilesRelativePath.Path;// Path: C:data\Corresponsales\Zips\Clientes\ArchivosElectronicos
string tempFolderName = "ReporteArchivosElectronicos";//Nombre del folder Temporal
string tempFolderPath= tempFilesPath + $"{tempFolderName}\\";//ruta del folder temporal Path: C:data\Corresponsales\Zips\Clientes\ArchivosElectronicos\ReporteArchivosElectronicos
string zipFileName = $"{tempFolderName}.zip";//Nombre del zip final
var zipFilePath = tempFilesPath + zipFileName;//Ruta del zip final Path: C:data\Corresponsales\Zips\Clientes\ArchivosElectronicos\ReporteArchivosElectronicos.zip
if(System.IO.File.Exists(zipFilePath)){//Si ya existe un zip de una descarga anterior lo borra
System.IO.File.Delete(zipFilePath);
}
if(System.IO.Directory.Exists(tempFolderPath)){//Si ya existe la carpeta temporal de una descarga anterior la borra
System.IO.Directory.Delete(tempFolderPath, true);
}
System.IO.Directory.CreateDirectory(tempFolderPath);//Se crea el folder temporal donde se pondran los archivos oficiales
foreach(var referencia in data.Referencias){
var trafico = await _traficosRepository.GetByReferencia(referencia);
string folderAE = tempFolderPath + $"{referencia}\\";//Se obtiene el nombre de la subcarpeta del AE de cada referencia
if(System.IO.Directory.Exists(folderAE)){//Si existe la carpeta se borra
System.IO.Directory.Delete(folderAE);
}
System.IO.Directory.CreateDirectory(folderAE);//Se crea la carpeta
//Obtener la lista de archivos de la referencia actual.
var filesLog = await _fileManagerRepo.GetTraficoFiles(trafico.id);
var filteredFilesLog = filesLog.Where(x => new List<int>(){2,10,11,12,13,14,15,19,17,18,37,38,39,41}.Contains(x.Proceso));
foreach(var fileLog in filteredFilesLog){
FilePaths4Process fileRelativePath = await _RepoRelativePath.getPaths4ProcessById(fileLog.Proceso);//Se obtiene la ruta relativa donde debe estar alojado el archivo
var filePath = RootPathCorresponsales + fileRelativePath.Path + fileLog!.NombreArchivo;//Ahora se obtiene la ruta completa del archivo.
if(System.IO.File.Exists(filePath)){
var bytes = await System.IO.File.ReadAllBytesAsync(filePath);
var originalFileStream = new MemoryStream(bytes);
using(var tempFileStream = System.IO.File.Create(folderAE + fileLog.NombreArchivo)){
await originalFileStream.CopyToAsync(tempFileStream);
}
}
}
}
System.IO.Compression.ZipFile.CreateFromDirectory(tempFolderPath, zipFilePath);//Se comprime la carpeta con los archivos electronicos de las referencias
Directory.Delete(tempFolderPath, true);//Se borra el folder temporal
var zipBytes = await System.IO.File.ReadAllBytesAsync(zipFilePath);
var zipStream = new MemoryStream(zipBytes);
return File(zipStream, "application/zip", zipFileName);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
}
}

@ -1,11 +0,0 @@
namespace GEMCO.Backend.Models.Reportes
{
public class RptPedimentosPagadosAEO
{
public string Referencia { set; get; } = null!;
public int Aduana { get; set; } = 0;
public int Patente { get; set; } = 0;
public int Pedimento { get; set; } = 0;
public string FechaPago { set; get; } = null!;
}
}

@ -52,8 +52,6 @@ using CORRESPONSALBackend.Repository.Reportes.CuentasCerradas;
using CORRESPONSALBackend.Services.Reportes.CuentasCerradas; using CORRESPONSALBackend.Services.Reportes.CuentasCerradas;
using CORRESPONSALBackend.Contracts.Reportes; using CORRESPONSALBackend.Contracts.Reportes;
using CORRESPONSALBackend.Services.Reportes; using CORRESPONSALBackend.Services.Reportes;
using CORRESPONSALBackend.Contracts.ArchivoElectronico;
using CORRESPONSALBackend.Services;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@ -94,9 +92,6 @@ builder.Services.AddScoped<ICorresponsaliasPedimentoPartidasRepository, Correspo
builder.Services.AddScoped<ICorresponsaliasCuentasComplementarias, CorresponsaliasCuentaComplementariaRepository>(); builder.Services.AddScoped<ICorresponsaliasCuentasComplementarias, CorresponsaliasCuentaComplementariaRepository>();
builder.Services.AddScoped<ICorresponsaliasPedimentosConsolidadosRepository, CorresponsaliasPedimentosConsolidadosRepository>(); builder.Services.AddScoped<ICorresponsaliasPedimentosConsolidadosRepository, CorresponsaliasPedimentosConsolidadosRepository>();
builder.Services.AddScoped<ICorresponsaliasSolicitudesRepository, CorresponsaliasSolicitudesRepository>(); builder.Services.AddScoped<ICorresponsaliasSolicitudesRepository, CorresponsaliasSolicitudesRepository>();
builder.Services.AddScoped<ITraficosClientesService, TraficosClientesService>();
builder.Services.AddScoped<IArchivoElectronicoRepository, ArchivoElectronicoRepository>();
builder.Services.AddScoped<IArchivoElectronicoService, ArchivoElectronicoService>();
//Clientes //Clientes
builder.Services.AddScoped<ICasaCuervoRepository, CasaCuervoRepository>(); builder.Services.AddScoped<ICasaCuervoRepository, CasaCuervoRepository>();
@ -117,6 +112,7 @@ builder.Services.AddScoped<ITiposMercanciaRepository, TiposMercanciaRepository>(
builder.Services.AddScoped<ICatCentrosCostosRepository, CatCentrosCostosRepository>(); builder.Services.AddScoped<ICatCentrosCostosRepository, CatCentrosCostosRepository>();
builder.Services.AddScoped<ICatClavesPedimentosRepository, CatClavesPedimentosRepository>(); builder.Services.AddScoped<ICatClavesPedimentosRepository, CatClavesPedimentosRepository>();
builder.Services.AddScoped<ICatTiposContenedoresRepository, CatTiposContenedoresRepository>(); builder.Services.AddScoped<ICatTiposContenedoresRepository, CatTiposContenedoresRepository>();
builder.Services.AddScoped<ITraficosClientesService, TraficosClientesService>();
//Utilerias //Utilerias
builder.Services.AddScoped<IFileManagerRepository, FileManagerRepository>(); builder.Services.AddScoped<IFileManagerRepository, FileManagerRepository>();

@ -1,31 +0,0 @@
using System.Data;
using CORRESPONSALBackend.Context;
using CORRESPONSALBackend.Contracts.ArchivoElectronico;
using CORRESPONSALBackend.DTO.ArchivoElectronico;
using Dapper;
using GEMCO.Backend.Models.Reportes;
namespace CORRESPONSALBackend.Repository{
public class ArchivoElectronicoRepository : IArchivoElectronicoRepository
{
private readonly DapperContext _context;
public ArchivoElectronicoRepository(DapperContext context) { _context = context; }
public async Task<List<RptPedimentosPagadosAEO>> getRptPedimentoPagadosAEO(DTOAEPeriodo data)
{
var query = "getRptArchivoElectronicoOficial";
using (var connection = _context.CreateConnection())
{
var entrada = await connection.QueryAsync<RptPedimentosPagadosAEO>(query,
new
{
@Anio = data.Anio,
@Mes = data.Mes,
@NoCliente = data.NoCliente,
@TipoOperacion = data.TipoOperacion
},
commandType: CommandType.StoredProcedure);
return entrada.ToList();
}
}
}
}

@ -122,16 +122,5 @@ namespace CORRESPONSALBackend.Repository.Utils
commandType: CommandType.StoredProcedure); commandType: CommandType.StoredProcedure);
return entrada.FirstOrDefault(); return entrada.FirstOrDefault();
} }
public async Task<IEnumerable<FileManager>> GetTraficoFiles(int idTrafico){
string query = "[Utils.FileManager.GetTraficoFiles]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<FileManager>(query, new
{
@idtrafico = idTrafico
},
commandType: CommandType.StoredProcedure);
return entrada.ToList();
}
} }
} }

@ -1,7 +0,0 @@
using CORRESPONSALBackend.Contracts.ArchivoElectronico;
namespace CORRESPONSALBackend.Services{
public class ArchivoElectronicoService : IArchivoElectronicoService{
}
}
Loading…
Cancel
Save