DFe.NET
DFe.NET copied to clipboard
Como usar os pacotes NUGET para imprimir Dacte, Damdfe, e Danfe
Criei um projeto, intalei os pacotes nuget abaixo para trabalhar com a biblioteca para fazer impressão dos documentos auxíliares Dacte, Damdfe, e Danfe com base nos respectivos XMLs.
Install-Package Zeus.Net.NFe.NFCe -Version 1.0.1.1149
Install-Package Zeus.Net.MDFe -Version 1.0.0.1149
Install-Package Zeus.Net.CTe -Version 1.0.0.1149
Tentei seguir as instruções na pagina inicial do projeto, tentei seguir os exemplos nos projetos demo, mas não consegui de forma alguma chegar a imprimir algum documento.
Já tentei com projeto .netcore 3.1, .net 5 e .net fk 4.7. De todo jeito que eu faço fica faltando dependências.
- Projeto com .netcore 3.1 ou .net 5
using CTe.Classes;
using CTe.Utils.CTe;
using DFe.Classes.Flags;
using DFe.Utils;
using NFe.Classes;
using NFe.Classes.Servicos.Consulta;
using NFe.Danfe.Base;
using NFe.Danfe.Base.NFCe;
using NFe.Danfe.Base.NFe;
using NFe.Danfe.Fast.Standard.NFCe;
using NFe.Danfe.Fast.Standard.NFe;
using NFe.Utils.NFe;
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace DFe.NET
{
class Program
{
private static string Caminho_do_arquivo_XML = @"E:\Repositorios\demos\DFe.NET\DFe.NET\DFe.NET\XMLs\NFe\NFe35220133216689000145550010000004721677368674.xml";
static void Main(string[] args)
{
var proc = new nfeProc().CarregarDeArquivoXml(Caminho_do_arquivo_XML);
var danfe = new DanfeFrNfce(proc, new ConfiguracaoDanfeNfce(NfceDetalheVendaNormal.UmaLinha, NfceDetalheVendaContigencia.UmaLinha, null/*Logomarca em byte[]*/), "00001", "XXXXXXXXXXXXXXXXXXXXXXXXXX");
danfe.Visualizar();
}
}
}
- Projeto com .net fk 4.7
using CTe.Classes;
using DFe.Utils;
using CTe.Dacte.Fast;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Zeus.Net.Fk4
{
class Program
{
private static string Caminho_do_arquivo_XML_CTE = @"E:\Repositorios\demos\DFe.NET\DFe.NET\DFe.NET\XMLs\NFe\NFe35220133216689000145550010000004721677368674.xml";
static void Main(string[] args)
{
var xml = Caminho_do_arquivo_XML_CTE;
cteProc cte = null;
try
{
cte = FuncoesXml.ArquivoXmlParaClasse<cteProc>(xml);
}
catch
{
cte = new cteProc() { CTe = FuncoesXml.ArquivoXmlParaClasse<CTe.Classes.CTe>(xml), protCTe = new CTe.Classes.Protocolo.protCTe() };
}
try
{
var rpt = new DacteFrCte(cte,
new ConfiguracaoDacte()
{
Logomarca = ImageToByte(pcbLogotipo.Image),
DocumentoCancelado = chbCancelado.Checked,
Desenvolvedor = txtDesenvolvedor.Text,
QuebrarLinhasObservacao = chbQuebrarLinhaObservacao.Checked
},
arquivoRelatorio: txtArquivo.Text);
return rpt;
}
catch (Exception ex)
{
Console.WriteLine("Configurar impressão");
}
}
}
}
O que eu preciso fazer para funcionar ?
Ainda não temos um pacote do Zeus da parte do DANFE, isso se deve a alguns problemas antigamente que hoje já estão resolvidos! O que eu faço hoje é buildar na mão mesmo, gerando um nuget meu privado para o zeus todo...
clono o Zeus:
git clone https://github.com/ZeusAutomacao/DFe.NET.git DFe.NET
dotnet build em cada uma dessas pastas:
dotnet build -c Release DFe.NET/DFe.Classes.Standard/DFe.Classes.Standard.csproj
dotnet build -c Release DFe.NET/DFe.Utils.Standard/DFe.Utils.Standard.csproj
dotnet build -c Release DFe.NET/DFe.Wsdl.Standard/DFe.Wsdl.Standard.csproj
dotnet build -c Release DFe.NET/NFe.Classes.Standard/NFe.Classes.Standard.csproj
dotnet build -c Release DFe.NET/NFe.Servicos.Standard/NFe.Servicos.Standard.csproj
dotnet build -c Release DFe.NET/NFe.Utils.Standard/NFe.Utils.Standard.csproj
dotnet build -c Release DFe.NET/NFe.Wsdl.Standard/NFe.Wsdl.Standard.csproj
dotnet build -c Release DFe.NET/NFe.Danfe.Base.Standard/NFe.Danfe.Base.Standard.csproj
dotnet build -c Release DFe.NET/NFe.Danfe.Fast.Standard/NFe.Danfe.Fast.Standard.csproj
crio 2 pacotes, um para nfe e outro para danfe usando dotnet pack utilizo os seguintes .nuspec e csproj
ex: dotnet pack seunome.NFe.csproj ex: dotnet pack seunome.NFe.Danfe.csproj
seunome.NFe.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<PlatformTarget>AnyCpu</PlatformTarget>
<Configurations>Release</Configurations>
<NoBuild>true</NoBuild>
<IncludeBuildOutput>false</IncludeBuildOutput>
<NuspecFile>seunome.NFe.nuspec</NuspecFile>
</PropertyGroup>
</Project>
seunome.NFe.nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>seunome.NFe</id>
<version>$version$</version>
<authors>seunome</authors>
<description>Biblioteca para geração de nf-e e nfc-e.</description>
</metadata>
<files>
<file src="..\DFe.NET\DFe.Classes.Standard\bin\Release\netstandard2.0\DFe.Classes.Standard.dll" target="lib\netstandard2.0\DFe.Classes.Standard.dll" />
<file src="..\DFe.NET\DFe.Utils.Standard\bin\Release\netstandard2.0\DFe.Utils.Standard.dll" target="lib\netstandard2.0\DFe.Utils.Standard.dll" />
<file src="..\DFe.NET\DFe.Wsdl.Standard\bin\Release\netstandard2.0\DFe.Wsdl.Standard.dll" target="lib\netstandard2.0\DFe.Wsdl.Standard.dll" />
<file src="..\DFe.NET\NFe.Classes.Standard\bin\Release\netstandard2.0\NFe.Classes.Standard.dll" target="lib\netstandard2.0\NFe.Classes.Standard.dll" />
<file src="..\DFe.NET\NFe.Servicos.Standard\bin\Release\netstandard2.0\NFe.Servicos.Standard.dll" target="lib\netstandard2.0\NFe.Servicos.Standard.dll" />
<file src="..\DFe.NET\NFe.Utils.Standard\bin\Release\netstandard2.0\NFe.Utils.Standard.dll" target="lib\netstandard2.0\NFe.Utils.Standard.dll" />
<file src="..\DFe.NET\NFe.Wsdl.Standard\bin\Release\netstandard2.0\NFe.Wsdl.Standard.dll" target="lib\netstandard2.0\NFe.Wsdl.Standard.dll" />
</files>
</package>
seunome.NFe.Danfe.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<PlatformTarget>AnyCpu</PlatformTarget>
<Configurations>Release</Configurations>
<NoBuild>true</NoBuild>
<IncludeBuildOutput>false</IncludeBuildOutput>
<NuspecFile>seunome.NFe.Danfe.nuspec</NuspecFile>
</PropertyGroup>
</Project>
seunome.NFe.Danfe.nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>seunome.NFe.Danfe</id>
<version>$version$</version>
<authors>seunome</authors>
<description>Biblioteca para geração de Danfe da nf-e e nfc-e.</description>
</metadata>
<files>
<file src="..\DFe.NET\NFe.Danfe.Base.Standard\bin\Release\netstandard2.0\NFe.Danfe.Base.Standard.dll" target="lib\netstandard2.0\NFe.Danfe.Base.Standard.dll" />
<file src="..\DFe.NET\NFe.Danfe.Fast.Standard\bin\Release\netstandard2.0\NFe.Danfe.Fast.Standard.dll" target="lib\netstandard2.0\NFe.Danfe.Fast.Standard.dll" />
</files>
</package>
@marcosgerene @robertorp Deviamos padronizar esses pacotes ai pelo menos pra versão nova do .net
Liberei uma alteração do arquivo .nuspec de NFe para ajudar na hora de montar os pacotes com as Danfes inclusas
Após alteracoes de build automático, o que precisa ser feito:
- Criar nuget separados para impressão.
- ex: Zeus.Net.NFe.NFCe.Danfe.OpenFastReport