ARSoftware.Cfdi.DescargaMasiva
3.0.0
dotnet add package ARSoftware.Cfdi.DescargaMasiva --version 3.0.0
NuGet\Install-Package ARSoftware.Cfdi.DescargaMasiva -Version 3.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ARSoftware.Cfdi.DescargaMasiva" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ARSoftware.Cfdi.DescargaMasiva --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ARSoftware.Cfdi.DescargaMasiva, 3.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ARSoftware.Cfdi.DescargaMasiva as a Cake Addin
#addin nuget:?package=ARSoftware.Cfdi.DescargaMasiva&version=3.0.0
// Install ARSoftware.Cfdi.DescargaMasiva as a Cake Tool
#tool nuget:?package=ARSoftware.Cfdi.DescargaMasiva&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ARSoftware.Cfdi.DescargaMasiva
Este proyecto es una libreria que expone clases y servicios para descargar los CFDI de forma masiva utilizando el web service del SAT.
Este proyecto te permite realizar las siguiente peticiones al web service:
Instalacion
Puedes instalarlo utilizando NuGet
dotnet add package ARSoftware.Cfdi.DescargaMasiva
Ejemplo
Agregar servicios
IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
// Agregar servicios de descarga masiva con el proveedor de servicios
services.AddCfdiDescargaMasivaServices();
})
.Build();
Crear X509Certificate2 del certificado PFX
var rutaCertificadoPfx = @"C:\AR Software\CFDI Descarga Masiva\certificado.pfx";
var certificadoPassword = "12345678a";
byte[] certificadoPfx = await File.ReadAllBytesAsync(rutaCertificadoPfx, cancellationToken);
logger.LogInformation("Creando el certificado SAT con el certificado PFX y contrasena.");
X509Certificate2 certificadoSat = X509Certificate2Helper.GetCertificate(certificadoPfx, certificadoPassword);
Peticion De Autenticacion
logger.LogInformation("Buscando el servicio de autenticacion en el contenedor de servicios (Dependency Injection).");
var autenticacionService = host.Services.GetRequiredService<IAutenticacionService>();
logger.LogInformation("Creando solicitud de autenticacion.");
var autenticacionRequest = AutenticacionRequest.CreateInstance();
logger.LogInformation("Enviando solicitud de autenticacion.");
AutenticacionResult autenticacionResult =
await autenticacionService.SendSoapRequestAsync(autenticacionRequest, certificadoSat, cancellationToken);
if (!autenticacionResult.AccessToken.IsValid)
{
logger.LogError("La solicitud de autenticacion no fue exitosa. FaultCode:{0} FaultString:{1}",
autenticacionResult.FaultCode,
autenticacionResult.FaultString);
throw new Exception();
}
logger.LogInformation("La solicitud de autenticacion fue exitosa. AccessToken:{0}", autenticacionResult.AccessToken.DecodedValue);
Peticion De Solicitud
// Paremetros para buscar CFDIs recibidos por rango de fecha
DateTime fechaInicio = DateTime.Today;
DateTime fechaFin = DateTime.Today;
TipoSolicitud tipoSolicitud = TipoSolicitud.Cfdi;
var rfcEmisor = "";
var rfcReceptores = new List<string> { "AAA010101AAA" };
var rfcSolicitante = "AAA010101AAA";
logger.LogInformation("Buscando el servicio de solicitud de descarga en el contenedor de servicios (Dependency Injection).");
var solicitudService = host.Services.GetRequiredService<ISolicitudService>();
logger.LogInformation("Creando solicitud de solicitud de descarga.");
var solicitudPorRangoFecha = SolicitudRequest.CreateInstance(fechaInicio,
fechaFin,
tipoSolicitud,
rfcEmisor,
rfcReceptores,
rfcSolicitante,
autenticacionResult.AccessToken);
logger.LogInformation("Enviando solicitud de solicitud de descarga.");
SolicitudResult solicitudResult = await solicitudService.SendSoapRequestAsync(solicitudPorRangoFecha, certificadoSat, cancellationToken);
if (string.IsNullOrEmpty(solicitudResult.RequestId))
{
logger.LogError("La solicitud de solicitud de descarga no fue exitosa. RequestStatusCode:{0} RequestStatusMessage:{1}",
solicitudResult.RequestStatusCode,
solicitudResult.RequestStatusMessage);
throw new Exception();
}
logger.LogInformation("La solicitud de solicitud de descarga fue exitosa. RequestId:{0}", solicitudResult.RequestId);
Peticion De Verificacion
logger.LogInformation("Buscando el servicio de verificacion en el contenedor de servicios (Dependency Injection).");
var verificaSolicitudService = host.Services.GetRequiredService<IVerificacionService>();
logger.LogInformation("Creando solicitud de verificacion.");
var verificacionRequest = VerificacionRequest.CreateInstance(solicitudResult.RequestId, rfcSolicitante, autenticacionResult.AccessToken);
logger.LogInformation("Enviando solicitud de verificacion.");
VerificacionResult verificacionResult = await verificaSolicitudService.SendSoapRequestAsync(verificacionRequest,
certificadoSat,
cancellationToken);
if (verificacionResult.DownloadRequestStatusNumber != EstadoSolicitud.Terminada.Value.ToString())
{
logger.LogError(
"La solicitud de verificacion no fue exitosa. DownloadRequestStatusNumber:{0} RequestStatusCode:{1} RequestStatusMessage:{2}",
verificacionResult.DownloadRequestStatusNumber,
verificacionResult.RequestStatusCode,
verificacionResult.RequestStatusMessage);
if (verificacionResult.DownloadRequestStatusNumber == EstadoSolicitud.Aceptada.Value.ToString())
logger.LogInformation(
"Es estado de la solicitud es Aceptada. Mandar otra solicitud de verificaion mas tarde para que el servicio web pueda procesar la solicitud.");
else if (verificacionResult.DownloadRequestStatusNumber == EstadoSolicitud.EnProceso.Value.ToString())
logger.LogInformation(
"Es estado de la solicitud es En Proceso. Mandar otra solicitud de verificaion mas tarde para que el servicio web pueda procesar la solicitud.");
throw new Exception();
}
logger.LogInformation("La solicitud de verificacion fue exitosa.");
foreach (string idsPaquete in verificacionResult.PackageIds)
logger.LogInformation("PackageId:{0}", idsPaquete);
Peticion De Descarga
logger.LogInformation("Buscando el servicio de verificacion en el contenedor de servicios (Dependency Injection).");
var descargarSolicitudService = host.Services.GetRequiredService<IDescargaService>();
foreach (string? idsPaquete in verificacionResult.PackageIds)
{
logger.LogInformation("Creando solicitud de descarga.");
var descargaRequest = DescargaRequest.CreateInstace(idsPaquete, rfcSolicitante, autenticacionResult.AccessToken);
logger.LogInformation("Enviando solicitud de descarga.");
DescargaResult descargaResult = await descargarSolicitudService.SendSoapRequestAsync(descargaRequest,
certificadoSat,
cancellationToken);
var rutaDescarga = @"C:\AR Software\CFDI Descarga Masiva\CFDIs";
string fileName = Path.Combine(rutaDescarga, $"{idsPaquete}.zip");
byte[] paqueteContenido = Convert.FromBase64String(descargaResult.Package);
logger.LogInformation("Guardando paquete descargado en un archivo .zip en la ruta de descarga.");
using FileStream fileStream = File.Create(fileName, paqueteContenido.Length);
await fileStream.WriteAsync(paqueteContenido, 0, paqueteContenido.Length, cancellationToken);
}
Aplicacion De Descarga Masiva
Si buscas una aplicacion ya lista para hacer la descarga masiva de CFDIs te recomiendo mi aplicacion Manejador Documentos CFDI.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Ardalis.SmartEnum (>= 2.1.0)
- Microsoft.Extensions.Http (>= 6.0.0)
- System.Security.Cryptography.Xml (>= 6.0.1)
-
net6.0
- Ardalis.SmartEnum (>= 2.1.0)
- Microsoft.Extensions.Http (>= 6.0.0)
- System.Security.Cryptography.Xml (>= 6.0.1)
-
net7.0
- Ardalis.SmartEnum (>= 2.1.0)
- Microsoft.Extensions.Http (>= 6.0.0)
- System.Security.Cryptography.Xml (>= 6.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
3.0.0 | 538 | 4/6/2023 | |
3.0.0-beta1 | 111 | 3/21/2023 | |
2.1.0-beta1 | 108 | 3/16/2023 | |
2.0.0 | 452 | 8/29/2022 | |
2.0.0-beta.7 | 92 | 8/28/2022 | |
2.0.0-beta.6 | 100 | 8/27/2022 | |
2.0.0-beta.5 | 94 | 8/27/2022 | |
2.0.0-beta.4 | 87 | 8/26/2022 | |
2.0.0-beta.3 | 90 | 8/26/2022 | |
2.0.0-beta.2 | 100 | 8/25/2022 | |
2.0.0-beta | 125 | 8/24/2022 | |
2.0.0-alpha | 118 | 8/20/2022 | |
1.0.2-alpha | 179 | 4/27/2022 | |
1.0.1 | 825 | 3/10/2020 | |
1.0.0 | 708 | 3/7/2020 |