Skip to content

Commit

Permalink
Merge pull request #1562 from ZeusAutomacao/integracao_hescules_outubro
Browse files Browse the repository at this point in the history
Integração com Hércules-ZeusFiscal/Master - Merge commit
  • Loading branch information
Valmir-Cunha authored Oct 31, 2024
2 parents 3ad4f1a + d033888 commit 12c7fa2
Show file tree
Hide file tree
Showing 63 changed files with 2,225 additions and 272 deletions.
32 changes: 32 additions & 0 deletions CTe.Classes/cteOSProc.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Xml.Serialization;
using CTe.Classes.Protocolo;
using CTe.Classes.Servicos.Tipos;
using DFe.Utils;

namespace CTe.Classes
{
[Serializable]
[XmlRoot(Namespace = "http://www.portalfiscal.inf.br/cte",
ElementName = "cteOSProc")]
public class cteOSProc
{
[XmlAttribute]
public versao versao { get; set; }

public CTe CTeOS { get; set; }

public protCTe protCTe { get; set; }


public static cteOSProc LoadXmlString(string xml)
{
return FuncoesXml.XmlStringParaClasse<cteOSProc>(xml);
}

public static cteOSProc LoadXmlArquivo(string caminhoArquivoXml)
{
return FuncoesXml.ArquivoXmlParaClasse<cteOSProc>(caminhoArquivoXml);
}
}
}
6 changes: 3 additions & 3 deletions CTe.Dacte.Base/CTe/CTeRetrato.frx
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ namespace FastReport
</DataBand>
<DataBand Name="dataBandObservacao" Top="953.9" Width="737.1" Height="82.05" CanGrow="true" CanShrink="true" CanBreak="true">
<ShapeObject Name="Shape9" Width="737.1" Height="82.05" CanGrow="true" CanShrink="true" GrowToBottom="true"/>
<TextObject Name="Text168" Left="4" Top="15.45" Width="727.65" Height="65.15" CanGrow="true" CanShrink="true" GrowToBottom="true" Text="[cteProc.CTe.infCte.compl.xObs]" Font="Times New Roman, 8.25pt"/>
<TextObject Name="Text168" Left="4" Top="15.45" Width="727.65" Height="65.15" CanGrow="true" CanShrink="true" AllowExpressions="False" GrowToBottom="true" Text="[cteProc.CTe.infCte.compl.xObs]" Font="Times New Roman, 8.25pt"/>
<TextObject Name="Text186" Left="-9.45" Top="26.9" Width="765.45" Height="18.9" CanGrow="true" CanShrink="true" GrowToBottom="true" Text="DOCUMENTO EMITIDO EM AMBIENTE DE HOMOLOGAÇÃO, SEM VALOR FISCAL" HorzAlign="Center" Font="Times New Roman, 12pt, style=Bold"/>
<TextObject Name="Text163" Left="1" Top="1.55" Width="734.1" Height="11.45" CanGrow="true" CanShrink="true" GrowToBottom="true" Text="OBSERVAÇÕES" HorzAlign="Center" Font="Times New Roman, 6.75pt"/>
<LineObject Name="Line45" Left="1" Top="13" Width="734.55" CanGrow="true" CanShrink="true" GrowToBottom="true"/>
Expand Down Expand Up @@ -1584,8 +1584,8 @@ namespace FastReport
<LineObject Name="Line46" Left="1" Top="14.45" Width="734.55"/>
<TextObject Name="Text173" Left="1" Top="14.9" Width="94.5" Height="39.8" Font="Arial Narrow, 6.75pt"/>
<TextObject Name="Text207" Left="94.5" Top="14.74" Width="348.65" Height="39.8" Font="Arial Narrow, 6.75pt"/>
<TextObject Name="Text208" Left="445.15" Top="14.9" Width="94.5" Height="39.8" Font="Arial Narrow, 6.75pt"/>
<TextObject Name="Text209" Left="538.1" Top="14.9" Width="198.45" Height="39.8" Text="123456789012345678901234567890123456789012345" Font="Arial Narrow, 6.75pt"/>
<TextObject Name="Text208" Left="445.15" Top="14.9" Width="94.5" Height="39.8" Font="Arial Narrow, 6.75pt" AllowExpressions="False"/>
<TextObject Name="Text209" Left="538.1" Top="14.9" Width="198.45" Height="39.8" Text="123456789012345678901234567890123456789012345" Font="Arial Narrow, 6.75pt" AllowExpressions="False"/>
<TextObject Name="Text165" Left="1" Top="2" Width="442.15" Height="11.45" Text="USO EXCLUSIVO DO EMISSOR DO CTE" HorzAlign="Center" Font="Times New Roman, 6.75pt"/>
<LineObject Name="Line47" Left="444.15" Top="1" Height="54.7"/>
<TextObject Name="Text166" Left="444.15" Top="2" Width="290.95" Height="11.45" Text="RESERVADO AO FISCO" HorzAlign="Center" Font="Times New Roman, 6.75pt"/>
Expand Down
48 changes: 27 additions & 21 deletions CTe.Servicos/ConsultaProtocolo/ConsultaProtcoloServico.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,54 +43,60 @@ public class ConsultaProtcoloServico
{
public retConsSitCTe ConsultaProtocolo(string chave, ConfiguracaoServico configuracaoServico = null)
{
var consSitCTe = ClassesFactory.CriarconsSitCTe(chave, configuracaoServico);
var configServico = configuracaoServico ?? ConfiguracaoServico.Instancia;

if (configuracaoServico.IsValidaSchemas)
consSitCTe.ValidarSchema(configuracaoServico);
var consSitCTe = ClassesFactory.CriarconsSitCTe(chave, configServico);

consSitCTe.SalvarXmlEmDisco(configuracaoServico);
if (configServico.IsValidaSchemas)
consSitCTe.ValidarSchema(configServico);

var webService = WsdlFactory.CriaWsdlConsultaProtocolo(configuracaoServico);
consSitCTe.SalvarXmlEmDisco(configServico);

var webService = WsdlFactory.CriaWsdlConsultaProtocolo(configServico);
var retornoXml = webService.cteConsultaCT(consSitCTe.CriaRequestWs());

var retorno = retConsSitCTe.LoadXml(retornoXml.OuterXml, consSitCTe);
retorno.SalvarXmlEmDisco(chave, configuracaoServico);
retorno.SalvarXmlEmDisco(chave, configServico);

return retorno;
}

public retConsSitCTe ConsultaProtocoloV4(string chave, ConfiguracaoServico configuracaoServico = null)
{
var consSitCTe = ClassesFactory.CriarconsSitCTe(chave, configuracaoServico);
var configServico = configuracaoServico ?? ConfiguracaoServico.Instancia;

var consSitCTe = ClassesFactory.CriarconsSitCTe(chave, configServico);

if (configuracaoServico.IsValidaSchemas)
consSitCTe.ValidarSchema(configuracaoServico);
if (configServico.IsValidaSchemas)
consSitCTe.ValidarSchema(configServico);

consSitCTe.SalvarXmlEmDisco(configuracaoServico);
consSitCTe.SalvarXmlEmDisco(configServico);

var webService = WsdlFactory.CriaWsdlConsultaProtocoloV4(configuracaoServico);
var webService = WsdlFactory.CriaWsdlConsultaProtocoloV4(configServico);
var retornoXml = webService.cteConsultaCT(consSitCTe.CriaRequestWs());

var retorno = retConsSitCTe.LoadXml(retornoXml.OuterXml, consSitCTe);
retorno.SalvarXmlEmDisco(chave, configuracaoServico);
retorno.SalvarXmlEmDisco(chave, configServico);

return retorno;
}

public async Task<retConsSitCTe> ConsultaProtocoloAsync(string chave, ConfiguracaoServico configuracaoServico = null)
{
var consSitCTe = ClassesFactory.CriarconsSitCTe(chave, configuracaoServico);

if (configuracaoServico.IsValidaSchemas)
consSitCTe.ValidarSchema(configuracaoServico);

consSitCTe.SalvarXmlEmDisco(configuracaoServico);

var webService = WsdlFactory.CriaWsdlConsultaProtocolo(configuracaoServico);
var configServico = configuracaoServico ?? ConfiguracaoServico.Instancia;

var consSitCTe = ClassesFactory.CriarconsSitCTe(chave, configServico);

if (configServico.IsValidaSchemas)
consSitCTe.ValidarSchema(configServico);

consSitCTe.SalvarXmlEmDisco(configServico);

var webService = WsdlFactory.CriaWsdlConsultaProtocolo(configServico);
var retornoXml = await webService.cteConsultaCTAsync(consSitCTe.CriaRequestWs());

var retorno = retConsSitCTe.LoadXml(retornoXml.OuterXml, consSitCTe);
retorno.SalvarXmlEmDisco(chave, configuracaoServico);
retorno.SalvarXmlEmDisco(chave, configServico);

return retorno;
}
Expand Down
40 changes: 22 additions & 18 deletions CTe.Servicos/ConsultaRecibo/ConsultaReciboServico.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,40 @@ public ConsultaReciboServico(string recibo)

public retConsReciCTe Consultar(ConfiguracaoServico configuracaoServico = null)
{
var consReciCTe = ClassesFactory.CriaConsReciCTe(_recibo, configuracaoServico);

if (configuracaoServico.IsValidaSchemas)
consReciCTe.ValidarSchema(configuracaoServico);

consReciCTe.SalvarXmlEmDisco(configuracaoServico);

var webService = WsdlFactory.CriaWsdlCteRetRecepcao(configuracaoServico);
var configServico = configuracaoServico ?? ConfiguracaoServico.Instancia;

var consReciCTe = ClassesFactory.CriaConsReciCTe(_recibo, configServico);

if (configServico.IsValidaSchemas)
consReciCTe.ValidarSchema(configServico);

consReciCTe.SalvarXmlEmDisco(configServico);

var webService = WsdlFactory.CriaWsdlCteRetRecepcao(configServico);
var retornoXml = webService.cteRetRecepcao(consReciCTe.CriaRequestWs());

var retorno = retConsReciCTe.LoadXml(retornoXml.OuterXml, consReciCTe);
retorno.SalvarXmlEmDisco(configuracaoServico);
retorno.SalvarXmlEmDisco(configServico);

return retorno;
}

public async Task<retConsReciCTe> ConsultarAsync(ConfiguracaoServico configuracaoServico = null)
{
var consReciCTe = ClassesFactory.CriaConsReciCTe(_recibo, configuracaoServico);

if (configuracaoServico.IsValidaSchemas)
consReciCTe.ValidarSchema(configuracaoServico);

consReciCTe.SalvarXmlEmDisco(configuracaoServico);

var webService = WsdlFactory.CriaWsdlCteRetRecepcao(configuracaoServico);
var configServico = configuracaoServico ?? ConfiguracaoServico.Instancia;

var consReciCTe = ClassesFactory.CriaConsReciCTe(_recibo, configServico);

if (configServico.IsValidaSchemas)
consReciCTe.ValidarSchema(configServico);

consReciCTe.SalvarXmlEmDisco(configServico);

var webService = WsdlFactory.CriaWsdlCteRetRecepcao(configServico);
var retornoXml = await webService.cteRetRecepcaoAsync(consReciCTe.CriaRequestWs());

var retorno = retConsReciCTe.LoadXml(retornoXml.OuterXml, consReciCTe);
retorno.SalvarXmlEmDisco(configuracaoServico);
retorno.SalvarXmlEmDisco(configServico);

return retorno;
}
Expand Down
1 change: 1 addition & 0 deletions CTe.Servicos/DistribuicaoDFe/ServicoCTeDistribuicaoDFe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public ServicoCTeDistribuicaoDFe(ConfiguracaoServico configuracaoServico, X509Ce
public RetornoCteDistDFeInt CTeDistDFeInteresse(string ufAutor, string documento, string ultNSU = "0", string nSU = "0", ConfiguracaoServico configuracaoServico = null)
{
var configServico = configuracaoServico ?? _configuracaoServico ?? ConfiguracaoServico.Instancia;

distDFeInt pedDistDFeInt;
XmlDocument dadosConsulta;
var ws = InicializaCTeDistDFeInteresse(documento, ultNSU, nSU, out pedDistDFeInt, out dadosConsulta, configServico);
Expand Down
6 changes: 3 additions & 3 deletions CTe.Servicos/EnviarCte/ServicoEnviarCte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class ServicoEnviarCte
public RetornoEnviarCte Enviar(int lote, Classes.CTe cte, ConfiguracaoServico configuracaoServico = null)
{
var configServico = configuracaoServico ?? ConfiguracaoServico.Instancia;

ServicoCTeRecepcao servicoRecepcao = new ServicoCTeRecepcao();

retEnviCte retEnviCte = servicoRecepcao.CTeRecepcao(lote, new List<Classes.CTe> {cte}, configServico);
retEnviCte retEnviCte = servicoRecepcao.CTeRecepcao(lote, new List<Classes.CTe> { cte }, configServico);

if (retEnviCte.cStat != 103)
{
Expand All @@ -28,7 +28,6 @@ public RetornoEnviarCte Enviar(int lote, Classes.CTe cte, ConfiguracaoServico co

retConsReciCTe retConsReciCTe = servicoConsultaRecibo.Consultar(configServico);


cteProc cteProc = null;
if (retConsReciCTe.cStat == 104)
{
Expand All @@ -54,6 +53,7 @@ public RetornoEnviarCte Enviar(int lote, Classes.CTe cte, ConfiguracaoServico co
public async Task<RetornoEnviarCte> EnviarAsync(int lote, Classes.CTe cte, ConfiguracaoServico configuracaoServico = null)
{
var configServico = configuracaoServico ?? ConfiguracaoServico.Instancia;

ServicoCTeRecepcao servicoRecepcao = new ServicoCTeRecepcao();

retEnviCte retEnviCte = await servicoRecepcao.CTeRecepcaoAsync(lote, new List<Classes.CTe> { cte }, configServico);
Expand Down
15 changes: 9 additions & 6 deletions CTe.Servicos/Eventos/EventoCancelamento.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,33 @@ public EventoCancelamento(CteEletronicoOS cte, int sequenciaEvento, string numer

public retEventoCTe Cancelar(ConfiguracaoServico configuracaoServico = null)
{
var configServico = configuracaoServico ?? ConfiguracaoServico.Instancia;
var evento = ClassesFactory.CriaEvCancCTe(_justificativa, _numeroProtocolo);

EventoEnviado = FactoryEvento.CriaEvento(CTeTipoEvento.Cancelamento, _sequenciaEvento, _cte.Chave(), _cte.infCte.emit.CNPJ, evento, configuracaoServico);
RetornoSefaz = new ServicoController().Executar(_cte, _sequenciaEvento, evento, CTeTipoEvento.Cancelamento, configuracaoServico);
EventoEnviado = FactoryEvento.CriaEvento(CTeTipoEvento.Cancelamento, _sequenciaEvento, _cte.Chave(), _cte.infCte.emit.CNPJ, evento, configServico);
RetornoSefaz = new ServicoController().Executar(_cte, _sequenciaEvento, evento, CTeTipoEvento.Cancelamento, configServico);

return RetornoSefaz;
}

public retEventoCTe CancelarOs(ConfiguracaoServico configuracaoServico = null)
{
var configServico = configuracaoServico ?? ConfiguracaoServico.Instancia;
var evento = ClassesFactory.CriaEvCancCTe(_justificativa, _numeroProtocolo);

EventoEnviado = FactoryEvento.CriaEvento(CTeTipoEvento.Cancelamento, _sequenciaEvento, _cteOs.Chave(), _cteOs.InfCte.emit.CNPJ, evento, configuracaoServico);
RetornoSefaz = new ServicoController().Executar(_cteOs, _sequenciaEvento, evento, CTeTipoEvento.Cancelamento, configuracaoServico);
EventoEnviado = FactoryEvento.CriaEvento(CTeTipoEvento.Cancelamento, _sequenciaEvento, _cteOs.Chave(), _cteOs.InfCte.emit.CNPJ, evento, configServico);
RetornoSefaz = new ServicoController().Executar(_cteOs, _sequenciaEvento, evento, CTeTipoEvento.Cancelamento, configServico);

return RetornoSefaz;
}

public async Task<retEventoCTe> CancelarAsync(ConfiguracaoServico configuracaoServico = null)
{
var configServico = configuracaoServico ?? ConfiguracaoServico.Instancia;
var evento = ClassesFactory.CriaEvCancCTe(_justificativa, _numeroProtocolo);

EventoEnviado = FactoryEvento.CriaEvento(CTeTipoEvento.Cancelamento, _sequenciaEvento, _cte.Chave(), _cte.infCte.emit.CNPJ, evento, configuracaoServico);
RetornoSefaz = await new ServicoController().ExecutarAsync(_cte, _sequenciaEvento, evento, CTeTipoEvento.Cancelamento, configuracaoServico);
EventoEnviado = FactoryEvento.CriaEvento(CTeTipoEvento.Cancelamento, _sequenciaEvento, _cte.Chave(), _cte.infCte.emit.CNPJ, evento, configServico);
RetornoSefaz = await new ServicoController().ExecutarAsync(_cte, _sequenciaEvento, evento, CTeTipoEvento.Cancelamento, configServico);

return RetornoSefaz;
}
Expand Down
3 changes: 2 additions & 1 deletion CTe.Servicos/Eventos/FactoryEvento.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class FactoryEvento
//Vou manter para evitar quebra de código pois a classe e o metodo são publicos
public static eventoCTe CriaEvento(CTeEletronico cte, CTeTipoEvento cTeTipoEvento, int sequenciaEvento, EventoContainer container, ConfiguracaoServico configuracaoServico = null)
{
return CriaEvento(cTeTipoEvento, sequenciaEvento, cte.Chave(), cte.infCte.emit.CNPJ, container, configuracaoServico);
var configServico = configuracaoServico ?? ConfiguracaoServico.Instancia;
return CriaEvento(cTeTipoEvento, sequenciaEvento, cte.Chave(), cte.infCte.emit.CNPJ, container, configServico);
}

public static eventoCTe CriaEvento(CTeTipoEvento cTeTipoEvento, int sequenciaEvento, string chave, string cnpj, EventoContainer container, ConfiguracaoServico configuracaoServico = null)
Expand Down
Loading

0 comments on commit 12c7fa2

Please sign in to comment.