예제 #1
0
        private async void Analisar(object sender, RoutedEventArgs e)
        {
            if (UF == null || string.IsNullOrEmpty(Chave))
            {
                return;
            }
            var gerenciador = new GerenciadorGeral <ConsSitNFe, RetConsSitNFe>(UF, Operacoes.Consultar, Homologacao, isNFCe);
            var envio       = new ConsSitNFe(Chave, Homologacao);

            RetConsSitNFe resultado = default(RetConsSitNFe);

            X509Certificate2[] certs;
            using (var loja = new X509Store(StoreName.My, StoreLocation.CurrentUser))
            {
                loja.Open(OpenFlags.ReadOnly);
                certs = loja.Certificates.Cast <X509Certificate2>().ToArray();
            }
            Progresso progresso = null;

            progresso = new Progresso(async x =>
            {
                resultado = await gerenciador.EnviarAsync(envio, false, (X509Certificate2)x);
                await progresso.Update(5);
                return(true, resultado.DescricaoResposta);
            }, certs, "Subject", gerenciador.Etapas.Concat("Analisar resultado no banco de dados"));
            gerenciador.ProgressChanged += async(x, y) => await progresso.Update(y);

            await progresso.ShowAsync();

            if (resultado.StatusResposta == 100)
            {
                NFeDI nota = null;
                using (var leit = new BaseGeral.Repositorio.Leitura())
                {
                    nota = leit.ObterNota($"NFe{resultado.ChaveNFe}");
                }
                if (nota != null && nota.Status < 4)
                {
                    using (var esc = new BaseGeral.Repositorio.Escrita())
                    {
                        nota.Status = (int)StatusNota.Emitida;
                        var original = XElement.Parse(nota.XML).FromXElement <NFe>();
                        var novo     = new ProcessoNFe()
                        {
                            NFe     = original,
                            ProtNFe = resultado.Protocolo
                        };
                        nota.XML = novo.ToXElement().ToString();
                        esc.SalvarItemSimples(nota, DefinicoesTemporarias.DateTimeNow);
                    }
                }
            }
        }
예제 #2
0
        public NFeDI(ProcessoNFe nota, string xml)
        {
            if (nota.NFe.Informacoes.identificacao.Modelo == 65)
            {
                throw new Exception();
            }

            Id           = nota.NFe.Informacoes.Id;
            NomeCliente  = nota.NFe.Informacoes.destinatario.Nome;
            NomeEmitente = nota.NFe.Informacoes.Emitente.Nome;
            CNPJEmitente = nota.NFe.Informacoes.Emitente.CNPJ.ToString();
            DataEmissao  = DateTime.Parse(nota.NFe.Informacoes.identificacao.DataHoraEmissão).ToString("yyyy-MM-dd HH:mm:ss");
            NumeroNota   = nota.NFe.Informacoes.identificacao.Numero;
            SerieNota    = nota.NFe.Informacoes.identificacao.Serie;
            Status       = nota.ProtNFe != null ? (int)StatusNota.Emitida : nota.NFe.Signature != null ? (int)StatusNota.Assinada : (int)StatusNota.Salva;
            IsNFCe       = false;
            XML          = xml;
        }
예제 #3
0
 public DadosDANFE(ProcessoNFe processo)
 {
     Dados = processo;
 }