Ajustes para trasmitir expedientes

This commit is contained in:
2026-03-06 12:56:41 -07:00
parent dcfd606a1c
commit c52344d7f8
13 changed files with 924 additions and 401 deletions

View File

@@ -117,7 +117,9 @@ namespace EFCDesk.Classes
}
public static string CrearEndpointpedimentoDesk()
{
return @"/api/v1/customs/pedimentos/bulk-create-pedimento_desk/";
// return @"/api/v1/customs/pedimentos/bulk-create-pedimento_desk/";
// return @"/api/v1/customs/pedimentos/bulk-upload-record-zip/";
return @"/api/v1/customs/pedimentos/bulk-upload-record-zip-async/";
}
/// <summary>
/// Espera hasta que todos los archivos dentro de la carpeta estén libres (no en uso)
@@ -360,5 +362,53 @@ namespace EFCDesk.Classes
}
}
public static string CrearZipMultipleArchivos(string[] rutasArchivos, string nombreArchivoZip, bool autoLimpiar = false)
{
string tempRoot = Path.Combine(Path.GetTempPath(), "temp-efc-desk");
string tempFolder = Path.Combine(tempRoot, Guid.NewGuid().ToString().ToLower().Replace("-", "").Substring(0, 8));
Directory.CreateDirectory(tempFolder);
string zipPath = Path.Combine(tempFolder, nombreArchivoZip);
try
{
using (var zip = ZipFile.Open(zipPath, ZipArchiveMode.Create))
{
foreach (var rutaArchivo in rutasArchivos)
{
if (File.Exists(rutaArchivo))
{
zip.CreateEntryFromFile(rutaArchivo, Path.GetFileName(rutaArchivo));
}
}
}
return zipPath;
}
catch (Exception ex)
{
Globales.logger.LogError("Helpers - CrearZipMultipleArchivos", ex);
return "";
}
finally
{
if (autoLimpiar)
{
try
{
System.Threading.Thread.Sleep(3000);
if (Directory.Exists(tempFolder))
{
Directory.Delete(tempFolder, true);
}
}
catch (Exception ex)
{
Globales.logger.LogError("Helpers - No se pudo limpiar carpeta temporal en CrearZipMultipleArchivos", ex);
}
}
}
}
}
}