Skip to content

Commit

Permalink
* Implementado tratamento do parâmetro (Número do lote) do comando /e…
Browse files Browse the repository at this point in the history
…nviar;

+ Adicionado parâmetro "tipo_documento" no comando /enviar, aceitando os seguintes valores: "D", "N" e "L", para indicar "Destinatário (nfeProc)", "Nfe" e "Lote (enviNFe3)";
* Correção no retorno do comando /recibo.
  • Loading branch information
adeniltonbs committed Aug 9, 2016
1 parent bdff842 commit e3aebad
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion NFe.Integracao/Enums/Comando.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ public enum Comando
Configurar,
Help
}
}
}
2 changes: 1 addition & 1 deletion NFe.Integracao/Enums/TipoXmlNFe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ public enum TipoXmlNFe
Lote,
Destinatario,
}
}
}
2 changes: 1 addition & 1 deletion NFe.Integracao/NFeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ public Classes.NFe Build()
return _nFe;
}
}
}
}
2 changes: 1 addition & 1 deletion NFe.Integracao/NFeFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,4 @@ public List<string> CapturarConteudoArquivoDeConfiguracoes()
return new List<string>(File.ReadAllLines(_pathArquivoConfiguracoes, Encoding.Unicode));
}
}
}
}
33 changes: 27 additions & 6 deletions NFe.Integracao/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static void Main(string[] args)
switch (args[i])
{
case "/?": listComandos.Add(new KeyValuePair<Comando, string>(Comando.Help,string.Empty)); break;
case "/enviar": listComandos.Add(new KeyValuePair<Comando, string>(Comando.EnviarNFe, string.Format("{0}#{1}", args[i + 1], args[i+2]))); break;
case "/enviar": listComandos.Add(new KeyValuePair<Comando, string>(Comando.EnviarNFe, string.Format("{0}#{1}#{2}", args[i + 1], args[i+2], args[i + 3]))); break;
case "/recibo": listComandos.Add(new KeyValuePair<Comando, string>(Comando.ConsultarReciboEnvio, args[i + 1])); break;
case "/status": listComandos.Add(new KeyValuePair<Comando, string>(Comando.StatusServico, string.Empty)); break;
case "/inutilizar": listComandos.Add(new KeyValuePair<Comando, string>(Comando.InutilizarNumeracao, string.Format("{0}#{1}#{2}#{3}#{4}#{5}", args[i + 1], args[i + 2], args[i + 3], args[i + 4], args[i + 5], args[i + 6]))); break;
Expand Down Expand Up @@ -289,7 +289,7 @@ private static void ImprimirHelp()
Console.WriteLine("");
Console.WriteLine("/config - zeus /config \"tipo_ambiente\" \"h\"");
Console.WriteLine("");
Console.WriteLine("/enviar - zeus /enviar \"C:\\meu_arquivo_xml.xml\"");
Console.WriteLine("/enviar - zeus /enviar \"C:\\meu_arquivo_xml.xml\" \"numero_do_lote\" \"tipo_documento(D=Destinatário - nfeProc; N=Nfe; L=Lote - enviNFe3\"");
Console.WriteLine("");
Console.WriteLine("/recibo - zeus /recibo \"número_do_recibo\"");
Console.WriteLine("");
Expand Down Expand Up @@ -420,10 +420,27 @@ private static bool ConsultarStatusServico(NFeFacade nfeFacade)
private static void EnviarNFe(NFeFacade nfeFacade, string dadosDoEnvio)
{
string strPathArquivoXml;
int numeroLote;
TipoXmlNFe tipoXml;

try
{
strPathArquivoXml = dadosDoEnvio.Split('#')[0];
var arrayStrDados = dadosDoEnvio.Split('#');
strPathArquivoXml = arrayStrDados[0];
numeroLote = int.Parse(arrayStrDados[1]);
switch (arrayStrDados[2])
{
case "D": tipoXml = TipoXmlNFe.Destinatario;
break;
case "N":
tipoXml = TipoXmlNFe.NFe;
break;
case "L":
tipoXml = TipoXmlNFe.Lote;
break;
default:
throw new ArgumentException();
}
}
catch
{
Expand Down Expand Up @@ -453,9 +470,9 @@ private static void EnviarNFe(NFeFacade nfeFacade, string dadosDoEnvio)
return;
}

var nfeBuilder = new NFeBuilder(strPathArquivoXml,TipoXmlNFe.NFe);
var nfeBuilder = new NFeBuilder(strPathArquivoXml, tipoXml);
Console.WriteLine("Preparando a NFe...");
var retorno = nfeFacade.EnviarNFe(1,nfeBuilder.Build());
var retorno = nfeFacade.EnviarNFe(numeroLote, nfeBuilder.Build());
if (retorno.Retorno.cStat == 103)
{
Console.WriteLine("#NFe#"+retorno.Retorno.infRec.nRec);
Expand Down Expand Up @@ -514,6 +531,10 @@ private static void ConsultarReciboDeEnvio(NFeFacade nfeFacade,string numeroReci
{
Console.WriteLine("#NFe#" + retornoConsultaProtocolo.Retorno.protNFe[0].infProt.nProt);
}
if (retornoConsultaProtocolo.Retorno.protNFe[0].infProt != null)
{
Console.WriteLine("#Erro#" + retornoConsultaProtocolo.Retorno.protNFe[0].infProt.xMotivo);
}
else
{
Console.WriteLine("#Erro#" + retornoConsultaProtocolo.Retorno.xMotivo);
Expand All @@ -526,4 +547,4 @@ private static void ConsultarReciboDeEnvio(NFeFacade nfeFacade,string numeroReci
}
}
}
}
}

0 comments on commit e3aebad

Please sign in to comment.