Example #1
0
        public TRetConsStatServ StatusServico()
        {
            if (!Directory.Exists(Configuracao.PastaLog))
            {
                Directory.CreateDirectory(Configuracao.PastaLog);
            }

            /*Comentei pois não estava sendo utilizado*/
            //var listaURL = default(C_WebService.ListaUrl);
            //listaURL = WsUrls.BuscaURL(Configuracao.CodUF, Configuracao.Ambiente);

            /*
             * Mantive pos não sei se precisa executar, porem o retorno
             * não esta sendo utilizado em lugar nenhum
             */
            WsUrls.BuscaURL(Configuracao.CodUF, Configuracao.Ambiente);
            var ws         = new C_WebService(Configuracao.PastaLog);
            var consStatus = new TConsStatServ
            {
                tpAmb  = Configuracao.Ambiente,
                versao = Configuracao.Versao,
                cUF    = Configuracao.CodUF
            };

            try
            {
                return(ws.ConsultaStatusWs(consStatus, Certificado));
            }
            catch (Exception)
            {
                throw new Exception("Não foi possível consultar o status do servidor da Receita Federal. Favor tentar novamente.");
            }
        }
Example #2
0
 /// <summary>
 /// Deserializes workflow markup into an TConsStatServ object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output TConsStatServ 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 TConsStatServ obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(TConsStatServ);
     try
     {
         obj = Deserialize(xml);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
 public static bool LoadFromFile(string fileName, out TConsStatServ obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
 public static bool LoadFromFile(string fileName, out TConsStatServ obj, out System.Exception exception)
 {
     return LoadFromFile(fileName, Encoding.UTF8, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an TConsStatServ object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output TConsStatServ 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 TConsStatServ obj, out System.Exception exception)
 {
     exception = null;
     obj = default(TConsStatServ);
     try
     {
         obj = LoadFromFile(fileName, encoding);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 public static bool Deserialize(string xml, out TConsStatServ obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
 /// <summary>
 /// Deserializes workflow markup into an TConsStatServ object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output TConsStatServ 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 TConsStatServ obj, out System.Exception exception)
 {
     exception = null;
     obj = default(TConsStatServ);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Example #8
0
        public TRetConsStatServ ConsultaStatusWs(TConsStatServ consStatServ, X509Certificate2 cert)
        {
            XmlNode strRetorno = null;
            TRetConsStatServ retornoStatus = new TRetConsStatServ();
            C_WebService.ListaUrl listaURL = default(C_WebService.ListaUrl);
            listaURL = WsUrls.BuscaURL(consStatServ.cUF, consStatServ.tpAmb);

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

                //UF E VERSÃO DO CABEÇALHO
                cab.cUF = PegarCodigoUF(consStatServ.cUF);
                cab.versaoDados = consStatServ.versao;

                //CRIA UMA INSTANCIA DA CONEXÃO COM O WEBSERVICE
                wsMsg = new StatusServico2.NfeStatusServico2(listaURL.UrlNfeStatusServico);

                //ASSOCIA CABEÇALHO NFE
                wsMsg.nfeCabecMsgValue = cab;

                //DEFINE TEMPO MAXIMO DE ESPERA POR RETORNO
                wsMsg.Timeout = 100000;

                //ASSOCIA CERTIFICADO A CONEXAO WEBSERVICE
                wsMsg.ClientCertificates.Add(cert);

                //DEFINE PROTOCOLO USADO NA CONEXÃO
                //wsMsg.SoapVersion = SoapProtocolVersion.Soap12

                //CRIA UM NOVO DOCUMENTO XML                
                XmlDocument retornoXML = new XmlDocument();
                string nomeArquivoEnv = _PastaLog + System.DateTime.Now.ToString("yyyyMMddTHHmmss") + " -ped-sta.xml";
                string nomeArquivoRet = _PastaLog + System.DateTime.Now.ToString("yyyyMMddTHHmmss") + " -ret-sta.xml";

                XmlDocument dados = new XmlDocument();
                dados.LoadXml(Funcoes.RemoveNameSpaceFromXml(consStatServ.Serialize()));
                dados.Save(nomeArquivoEnv);

                //ENVIA CONSULTA PARA SEFAZ E OBTEM RETORNO EM FORMATO STRING
                strRetorno = wsMsg.nfeStatusServicoNF2(dados);
                retornoXML.LoadXml(strRetorno.OuterXml);
                retornoXML.Save(nomeArquivoRet);
                retornoStatus = TRetConsStatServ.LoadFromFile(nomeArquivoRet);

                return retornoStatus;

            }
            catch (Exception ex)
            {
                throw new System.InvalidOperationException("Erro ao consultar status do serviço. Erro: " + ex.Message);
            }
        }
Example #9
0
        public TRetConsStatServ StatusServico()
        {
            if (!Directory.Exists(Configuracao.PastaLog))
            {
                Directory.CreateDirectory(Configuracao.PastaLog);
            }

            /*Comentei pois não estava sendo utilizado*/
            //var listaURL = default(C_WebService.ListaUrl);            
            //listaURL = WsUrls.BuscaURL(Configuracao.CodUF, Configuracao.Ambiente);

            /*
             * Mantive pos não sei se precisa executar, porem o retorno 
             * não esta sendo utilizado em lugar nenhum
             */
            WsUrls.BuscaURL(Configuracao.CodUF, Configuracao.Ambiente);
            var ws = new C_WebService(Configuracao.PastaLog);
            var consStatus = new TConsStatServ
            {
                tpAmb = Configuracao.Ambiente,
                versao = Configuracao.Versao,
                cUF = Configuracao.CodUF
            };

            try
            {
                return ws.ConsultaStatusWs(consStatus, Certificado);
            }
            catch (Exception)
            {
                throw new Exception("Não foi possível consultar o status do servidor da Receita Federal. Favor tentar novamente.");
            }
        }
Example #10
0
 public static bool LoadFromFile(string fileName, out TConsStatServ obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
Example #11
0
 public static bool LoadFromFile(string fileName, out TConsStatServ obj, out System.Exception exception)
 {
     return(LoadFromFile(fileName, Encoding.UTF8, out obj, out exception));
 }
Example #12
0
 /// <summary>
 /// Deserializes xml markup from file into an TConsStatServ object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output TConsStatServ 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 TConsStatServ obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(TConsStatServ);
     try
     {
         obj = LoadFromFile(fileName, encoding);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
Example #13
0
 public static bool Deserialize(string xml, out TConsStatServ obj)
 {
     System.Exception exception = null;
     return(Deserialize(xml, out obj, out exception));
 }