コード例 #1
0
 /// <summary>
 /// Deserializes workflow markup into an TEventoInfEventoDetEvento object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output TEventoInfEventoDetEvento object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out TEventoInfEventoDetEvento obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(TEventoInfEventoDetEvento);
     try
     {
         obj = Deserialize(xml);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
コード例 #2
0
ファイル: C_WebService.cs プロジェクト: luicesar/ACBr.Net.NFe
        public Cancelamento.TRetEnvEvento CancelaNFe(TNfeProc nota, string Justificativa, X509Certificate2 pCertificado, int numLote, int nSequencia, TAmb ambiente, out ACBr.Net.NFe.Cancelamento.TProcEvento procEvento)
        {
            XmlElement strRetorno = null;

            string arqPedCanc = _PastaLog + nota.NFe.infNFe.Id.Substring(3) + "-ped-evento.xml";
            string retPedCanc = _PastaLog + nota.NFe.infNFe.Id.Substring(3) + "-eve.xml";
            C_WebService.ListaUrl listaURL = default(C_WebService.ListaUrl);
            listaURL = WsUrls.BuscaURL(nota.NFe.infNFe.ide.cUF, ambiente);

            #region evento
            Cancelamento.TEvento evento = new Cancelamento.TEvento();
            evento.versao = "1.00";

            #region infEvento
            Cancelamento.TEventoInfEvento infEvento = new Cancelamento.TEventoInfEvento();
            infEvento.tpAmb = ambiente;
            infEvento.chNFe = nota.NFe.infNFe.Id.Substring(3);
            infEvento.cOrgao = nota.NFe.infNFe.ide.cUF;
            infEvento.dhEvento = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzzz");// +"-00:00";
            infEvento.Id = "ID" + "110111" + nota.NFe.infNFe.Id.Substring(3) + nSequencia.ToString("D2");
            infEvento.ItemElementName = Cancelamento.TipoDocumentoCanc.CNPJ;
            infEvento.Item = nota.NFe.infNFe.emit.Item;
            infEvento.nSeqEvento = nSequencia.ToString();
            infEvento.verEvento = Cancelamento.TEventoInfEventoVerEvento.Item100;
            infEvento.tpEvento = Cancelamento.TEventoInfEventoTpEvento.Cancelamento;

            #region detEvento
            Cancelamento.TEventoInfEventoDetEvento detEvento = new Cancelamento.TEventoInfEventoDetEvento();
            detEvento.descEvento = Cancelamento.TEventoInfEventoDetEventoDescEvento.Cancelamento;
            detEvento.nProt = nota.protNFe.infProt.nProt;
            detEvento.versao = Cancelamento.TEventoInfEventoDetEventoVersao.Item100;
            detEvento.xJust = Justificativa;
            #endregion detEvento

            infEvento.detEvento = detEvento;
            #endregion infEvento

            evento.infEvento = infEvento;

            XmlDocument xmldoc = new XmlDocument();
            xmldoc.LoadXml(Funcoes.RemoveNameSpaceFromXml(evento.Serialize()));
            xmldoc = CertificadoDigital.Assinar(xmldoc, "infEvento", pCertificado);
            xmldoc.Save(arqPedCanc);

            #endregion evento

            dynamic envEvento = GeraLoteEvento(arqPedCanc, numLote);

            try
            {
                RecepcaoEvento.nfeCabecMsg cab = new RecepcaoEvento.nfeCabecMsg();
                RecepcaoEvento.RecepcaoEvento wsMsg = default(RecepcaoEvento.RecepcaoEvento);

                // UF E VERSÃO DO CABEÇALHO
                cab.cUF = PegarCodigoUF(nota.NFe.infNFe.ide.cUF);
                cab.versaoDados = "1.00";

                //CABEÇALHO USADA PARA ENVIO DE LOTE
                wsMsg = new RecepcaoEvento.RecepcaoEvento(listaURL.UrlRecepcaoEvento);
                wsMsg.nfeCabecMsgValue = cab;
                wsMsg.Timeout = 100000;
                wsMsg.ClientCertificates.Add(pCertificado);
                wsMsg.SoapVersion = SoapProtocolVersion.Soap12;

                //RETORNO DA SEFAZ
                strRetorno = wsMsg.nfeRecepcaoEvento(envEvento);

                XmlDocument xmlRetorno = new XmlDocument();
                xmlRetorno.LoadXml(strRetorno.OuterXml);
                xmlRetorno.Save(retPedCanc);

                ACBr.Net.NFe.Cancelamento.TRetEnvEvento retCancNFe = ACBr.Net.NFe.Cancelamento.TRetEnvEvento.LoadFromFile(retPedCanc);

                //saída
                procEvento = new Cancelamento.TProcEvento();
                procEvento.evento = ACBr.Net.NFe.Cancelamento.TEvento.Deserialize(xmldoc.OuterXml);
                procEvento.retEvento = retCancNFe.retEvento[0];
                procEvento.versao = "1.00";

                return retCancNFe;
            }
            catch (Exception ex)
            {
                throw new System.InvalidOperationException("Erro ao cancelar NFe. Erro: " + ex.Message);
            }
        }
コード例 #3
0
 public static bool LoadFromFile(string fileName, out TEventoInfEventoDetEvento obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
コード例 #4
0
 public static bool LoadFromFile(string fileName, out TEventoInfEventoDetEvento obj, out System.Exception exception)
 {
     return LoadFromFile(fileName, Encoding.UTF8, out obj, out exception);
 }
コード例 #5
0
 /// <summary>
 /// Deserializes xml markup from file into an TEventoInfEventoDetEvento object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output TEventoInfEventoDetEvento object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, System.Text.Encoding encoding, out TEventoInfEventoDetEvento obj, out System.Exception exception)
 {
     exception = null;
     obj = default(TEventoInfEventoDetEvento);
     try
     {
         obj = LoadFromFile(fileName, encoding);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
コード例 #6
0
 public static bool Deserialize(string xml, out TEventoInfEventoDetEvento obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
コード例 #7
0
 /// <summary>
 /// Deserializes workflow markup into an TEventoInfEventoDetEvento object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output TEventoInfEventoDetEvento object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out TEventoInfEventoDetEvento obj, out System.Exception exception)
 {
     exception = null;
     obj = default(TEventoInfEventoDetEvento);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
コード例 #8
0
 public static bool LoadFromFile(string fileName, out TEventoInfEventoDetEvento obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
コード例 #9
0
 public static bool LoadFromFile(string fileName, out TEventoInfEventoDetEvento obj, out System.Exception exception)
 {
     return(LoadFromFile(fileName, Encoding.UTF8, out obj, out exception));
 }
コード例 #10
0
 /// <summary>
 /// Deserializes xml markup from file into an TEventoInfEventoDetEvento object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output TEventoInfEventoDetEvento object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, System.Text.Encoding encoding, out TEventoInfEventoDetEvento obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(TEventoInfEventoDetEvento);
     try
     {
         obj = LoadFromFile(fileName, encoding);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
コード例 #11
0
 public static bool Deserialize(string xml, out TEventoInfEventoDetEvento obj)
 {
     System.Exception exception = null;
     return(Deserialize(xml, out obj, out exception));
 }