Esempio n. 1
0
        private void TransmitirLote()
        {
            string sRet = "";

            sMsgTransmissao = "";
            try
            {
                if (Acesso.tipoWsNfse == Acesso.TP_WS_NFSE.GINFES)
                {
                    if (Acesso.TP_AMB_SERV == 2)
                    {
                        WebService.Itu_servicos_Homologacao.ServiceGinfesImplService objtrans = new WebService.Itu_servicos_Homologacao.ServiceGinfesImplService();
                        objtrans.ClientCertificates.Add(Acesso.cert_NFs);
                        objtrans.Timeout = 60000;
                        sRet             = objtrans.RecepcionarLoteRpsV3(NfeCabecMsg(), sLoteXml);
                    }
                    else if (Acesso.TP_AMB_SERV == 1)
                    {
                        WebService.Itu_servicos_Producao.ServiceGinfesImplService objtrans = new WebService.Itu_servicos_Producao.ServiceGinfesImplService();
                        objtrans.ClientCertificates.Add(Acesso.cert_NFs);
                        objtrans.Timeout = 60000;
                        sRet             = objtrans.RecepcionarLoteRpsV3(NfeCabecMsg(), sLoteXml);
                    }
                    else
                    {
                        throw new Exception("Cadastro de Empresa não configurado para enviar NFe-serviço");
                    }
                }
                else if (Acesso.tipoWsNfse == Acesso.TP_WS_NFSE.TIPLAN)
                {
                    WebService.riodasostras_Producao.Nfse nfse = new WebService.riodasostras_Producao.Nfse();
                    nfse.ClientCertificates.Add(Acesso.cert_NFs);
                    nfse.Timeout = 60000;

                    sRet = nfse.RecepcionarLoteRps(sLoteXml);
                }
                ConfiguraMsgdeTransmissao(sRet);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public string CancelaNfes(TcPedidoCancelamento objPedCanc)
        {
            try
            {
                string sRet = "";

                if (Acesso.tipoWsNfse == Acesso.TP_WS_NFSE.GINFES)
                {
                    if (Acesso.TP_AMB_SERV == 2)
                    {
                        WebService.Itu_servicos_Homologacao.ServiceGinfesImplService objtrans = new WebService.Itu_servicos_Homologacao.ServiceGinfesImplService();
                        objtrans.ClientCertificates.Add(Acesso.cert_NFs);
                        objtrans.Timeout = 60000;
                        sRet             = objtrans.CancelarNfse(MontaXmlCancelamentoHomo(objPedCanc));
                    }
                    else if (Acesso.TP_AMB_SERV == 1)
                    {
                        WebService.Itu_servicos_Producao.ServiceGinfesImplService objtrans = new WebService.Itu_servicos_Producao.ServiceGinfesImplService();
                        objtrans.ClientCertificates.Add(Acesso.cert_NFs);
                        objtrans.Timeout = 60000;
                        sRet             = objtrans.CancelarNfse(MontaXmlCancelamento(objPedCanc));
                    }
                    else
                    {
                        throw new Exception("Cadastro de Empresa não configurado para enviar NFe-serviço");
                    }
                }
                else
                {
                    WebService.riodasostras_Producao.Nfse nfse = new WebService.riodasostras_Producao.Nfse();
                    nfse.ClientCertificates.Add(Acesso.cert_NFs);
                    nfse.Timeout = 60000;
                    sRet         = nfse.CancelarNfse(MontaXmlCancelamento2(objPedCanc));
                }

                return(sRet);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        private void TransmitirLote()
        {
            string sRet = "";
            sMsgTransmissao = "";
            try
            {
                if (Acesso.tipoWsNfse == Acesso.TP_WS_NFSE.GINFES)
                {
                    if (Acesso.TP_AMB_SERV == 2)
                    {
                        WebService.Itu_servicos_Homologacao.ServiceGinfesImplService objtrans = new WebService.Itu_servicos_Homologacao.ServiceGinfesImplService();
                        objtrans.ClientCertificates.Add(Acesso.cert_NFs);
                        objtrans.Timeout = 60000;
                        sRet = objtrans.RecepcionarLoteRpsV3(NfeCabecMsg(), sLoteXml);
                    }
                    else if (Acesso.TP_AMB_SERV == 1)
                    {
                        WebService.Itu_servicos_Producao.ServiceGinfesImplService objtrans = new WebService.Itu_servicos_Producao.ServiceGinfesImplService();
                        objtrans.ClientCertificates.Add(Acesso.cert_NFs);
                        objtrans.Timeout = 60000;
                        sRet = objtrans.RecepcionarLoteRpsV3(NfeCabecMsg(), sLoteXml);
                    }
                    else
                    {
                        throw new Exception("Cadastro de Empresa não configurado para enviar NFe-serviço");
                    }
                }
                else if (Acesso.tipoWsNfse == Acesso.TP_WS_NFSE.TIPLAN)
                {
                    WebService.riodasostras_Producao.Nfse nfse = new WebService.riodasostras_Producao.Nfse();
                    nfse.ClientCertificates.Add(Acesso.cert_NFs);
                    nfse.Timeout = 60000;

                    sRet = nfse.RecepcionarLoteRps(sLoteXml);
                }
                ConfiguraMsgdeTransmissao(sRet);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public string CancelaNfes(TcPedidoCancelamento objPedCanc)
        {
            try
            {
                string sRet = "";

                if (Acesso.tipoWsNfse == Acesso.TP_WS_NFSE.GINFES)
                {
                    if (Acesso.TP_AMB_SERV == 2)
                    {
                        WebService.Itu_servicos_Homologacao.ServiceGinfesImplService objtrans = new WebService.Itu_servicos_Homologacao.ServiceGinfesImplService();
                        objtrans.ClientCertificates.Add(Acesso.cert_NFs);
                        objtrans.Timeout = 60000;
                        sRet = objtrans.CancelarNfse(MontaXmlCancelamentoHomo(objPedCanc));
                    }
                    else if (Acesso.TP_AMB_SERV == 1)
                    {
                        WebService.Itu_servicos_Producao.ServiceGinfesImplService objtrans = new WebService.Itu_servicos_Producao.ServiceGinfesImplService();
                        objtrans.ClientCertificates.Add(Acesso.cert_NFs);
                        objtrans.Timeout = 60000;
                        sRet = objtrans.CancelarNfse(MontaXmlCancelamento(objPedCanc));

                    }
                    else
                    {
                        throw new Exception("Cadastro de Empresa não configurado para enviar NFe-serviço");
                    }
                }
                else
                {
                    WebService.riodasostras_Producao.Nfse nfse = new WebService.riodasostras_Producao.Nfse();
                    nfse.ClientCertificates.Add(Acesso.cert_NFs);
                    nfse.Timeout = 60000;
                    sRet = nfse.CancelarNfse(MontaXmlCancelamento2(objPedCanc));
                }

                return sRet;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
0
        private string BuscaRetornoWebService(tcIdentificacaoPrestador Prestador)
        {
            try
            {
                if (Acesso.tipoWsNfse == Acesso.TP_WS_NFSE.GINFES)
                {
                    string sVerificacao = Pastas.GINFES + this.Protocolo + ".txt";

                    bool bValida = false;

                    if (File.Exists(sVerificacao))
                    {
                        StreamReader sr  = new StreamReader(sVerificacao);
                        string       sdt = sr.ReadToEnd();
                        sr.Close();

                        DateTime dtEnvio = Convert.ToDateTime(sdt).AddMinutes(6);
                        DateTime dtAtual = DateTime.Now;

                        if (dtEnvio > dtAtual)
                        {
                            throw new Exception("Aguarde mais alguns minutos para o buscar o retorno da Nota. Aproximadamente 6 minutos após o envio.");
                        }
                        else
                        {
                            bValida = true;
                        }
                    }
                    else
                    {
                        bValida = true;
                    }

                    string sretorno = "";
                    if (bValida)
                    {
                        if (Acesso.TP_AMB_SERV == 2)
                        {
                            WebService.Itu_servicos_Homologacao.ServiceGinfesImplService teste = new WebService.Itu_servicos_Homologacao.ServiceGinfesImplService();
                            teste.ClientCertificates.Add(Acesso.cert_NFs);
                            teste.Timeout = 60000;
                            string sret = teste.ConsultarSituacaoLoteRpsV3(NfeCabecMsg(), MontaXmlConsultarSituacaoLoteRps(Prestador));

                            WebService.Itu_servicos_Homologacao.ServiceGinfesImplService objtrans = new WebService.Itu_servicos_Homologacao.ServiceGinfesImplService();
                            objtrans.ClientCertificates.Add(Acesso.cert_NFs);
                            objtrans.Timeout = 60000;
                            return(objtrans.ConsultarLoteRpsV3(NfeCabecMsg(), MontaXmlConsultaLote(Prestador)));
                        }
                        else if (Acesso.TP_AMB_SERV == 1)
                        {
                            ConsultarSituacaoLoteRpsResposta objResposta;
                            try
                            {
                                WebService.Itu_servicos_Producao.ServiceGinfesImplService teste = new WebService.Itu_servicos_Producao.ServiceGinfesImplService();
                                teste.ClientCertificates.Add(Acesso.cert_NFs);
                                teste.Timeout = 60000;
                                string      sret = teste.ConsultarSituacaoLoteRpsV3(NfeCabecMsg(), MontaXmlConsultarSituacaoLoteRps(Prestador));
                                XmlDocument doc  = new XmlDocument();
                                doc.LoadXml(sret);
                                string sNmFile = Pastas.PROTOCOLOS + "//ConsultaSitLoteRps_" + this.Protocolo + ".xml";
                                if (File.Exists(sNmFile))
                                {
                                    File.Delete(sNmFile);
                                }
                                doc.Save(sNmFile);
                                objResposta = SerializeClassToXml.DeserializeClasse <ConsultarSituacaoLoteRpsResposta>(sNmFile);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }

                            if (objResposta != null)
                            {
                                if ((objResposta.Situacao == 4) || (objResposta.Situacao == 3))
                                {
                                    WebService.Itu_servicos_Producao.ServiceGinfesImplService objtrans = new WebService.Itu_servicos_Producao.ServiceGinfesImplService();
                                    objtrans.ClientCertificates.Add(Acesso.cert_NFs);
                                    objtrans.Timeout = 60000;
                                    sretorno         = objtrans.ConsultarLoteRpsV3(NfeCabecMsg(), MontaXmlConsultaLote(Prestador));
                                }
                                else
                                {
                                    if (objResposta.Situacao == 1)
                                    {
                                        throw new Exception("Lote ainda não recebido.");
                                    }
                                    else if (objResposta.Situacao == 2)
                                    {
                                        throw new Exception("Lote ainda não processado.");
                                    }
                                }
                            }
                        }

                        return(sretorno);
                    }
                    else
                    {
                        throw new Exception("Cadastro de Empresa não configurado para enviar NFe-serviço");
                    }
                }
                else
                {
                    WebService.riodasostras_Producao.Nfse nfse = new WebService.riodasostras_Producao.Nfse();
                    nfse.ClientCertificates.Add(Acesso.cert_NFs);
                    nfse.Timeout = 60000;
                    return(nfse.ConsultarLoteRps(MontaXmlConsultaLote2(Prestador)));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 6
0
        private string BuscaRetornoWebService(tcIdentificacaoPrestador Prestador)
        {
            try
            {

                if (Acesso.tipoWsNfse == Acesso.TP_WS_NFSE.GINFES)
                {
                    string sVerificacao = Pastas.GINFES + this.Protocolo + ".txt";

                    bool bValida = false;

                    if (File.Exists(sVerificacao))
                    {
                        StreamReader sr = new StreamReader(sVerificacao);
                        string sdt = sr.ReadToEnd();
                        sr.Close();

                        DateTime dtEnvio = Convert.ToDateTime(sdt).AddMinutes(6);
                        DateTime dtAtual = DateTime.Now;

                        if (dtEnvio > dtAtual)
                        {
                            throw new Exception("Aguarde mais alguns minutos para o buscar o retorno da Nota. Aproximadamente 6 minutos após o envio.");
                        }
                        else
                        {
                            bValida = true;
                        }
                    }
                    else
                    {
                        bValida = true;
                    }

                    string sretorno = "";
                    if (bValida)
                    {
                        if (Acesso.TP_AMB_SERV == 2)
                        {
                            WebService.Itu_servicos_Homologacao.ServiceGinfesImplService teste = new WebService.Itu_servicos_Homologacao.ServiceGinfesImplService();
                            teste.ClientCertificates.Add(Acesso.cert_NFs);
                            teste.Timeout = 60000;
                            string sret = teste.ConsultarSituacaoLoteRpsV3(NfeCabecMsg(), MontaXmlConsultarSituacaoLoteRps(Prestador));

                            WebService.Itu_servicos_Homologacao.ServiceGinfesImplService objtrans = new WebService.Itu_servicos_Homologacao.ServiceGinfesImplService();
                            objtrans.ClientCertificates.Add(Acesso.cert_NFs);
                            objtrans.Timeout = 60000;
                            return objtrans.ConsultarLoteRpsV3(NfeCabecMsg(), MontaXmlConsultaLote(Prestador));

                        }
                        else if (Acesso.TP_AMB_SERV == 1)
                        {
                            ConsultarSituacaoLoteRpsResposta objResposta;
                            try
                            {

                                WebService.Itu_servicos_Producao.ServiceGinfesImplService teste = new WebService.Itu_servicos_Producao.ServiceGinfesImplService();
                                teste.ClientCertificates.Add(Acesso.cert_NFs);
                                teste.Timeout = 60000;
                                string sret = teste.ConsultarSituacaoLoteRpsV3(NfeCabecMsg(), MontaXmlConsultarSituacaoLoteRps(Prestador));
                                XmlDocument doc = new XmlDocument();
                                doc.LoadXml(sret);
                                string sNmFile = Pastas.PROTOCOLOS + "//ConsultaSitLoteRps_" + this.Protocolo + ".xml";
                                if (File.Exists(sNmFile))
                                    File.Delete(sNmFile);
                                doc.Save(sNmFile);
                                objResposta = SerializeClassToXml.DeserializeClasse<ConsultarSituacaoLoteRpsResposta>(sNmFile);

                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }

                            if (objResposta != null)
                            {

                                if ((objResposta.Situacao == 4) || (objResposta.Situacao == 3))
                                {
                                    WebService.Itu_servicos_Producao.ServiceGinfesImplService objtrans = new WebService.Itu_servicos_Producao.ServiceGinfesImplService();
                                    objtrans.ClientCertificates.Add(Acesso.cert_NFs);
                                    objtrans.Timeout = 60000;
                                    sretorno = objtrans.ConsultarLoteRpsV3(NfeCabecMsg(), MontaXmlConsultaLote(Prestador));
                                }
                                else
                                {
                                    if (objResposta.Situacao == 1)
                                    {
                                        throw new Exception("Lote ainda não recebido.");
                                    }
                                    else if (objResposta.Situacao == 2)
                                    {
                                        throw new Exception("Lote ainda não processado.");
                                    }
                                }
                            }
                        }

                        return sretorno;
                    }
                    else
                    {
                        throw new Exception("Cadastro de Empresa não configurado para enviar NFe-serviço");
                    }
                }
                else
                {
                    WebService.riodasostras_Producao.Nfse nfse = new WebService.riodasostras_Producao.Nfse();
                    nfse.ClientCertificates.Add(Acesso.cert_NFs);
                    nfse.Timeout = 60000;
                    return nfse.ConsultarLoteRps(MontaXmlConsultaLote2(Prestador));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }