public override async Task Executar(CancellationToken cancellationToken = default) { using (var proxy = new ProxyDoServico(this.Conexao)) { var lotes = await proxy.Buscador.Lotes(new() { DataInicial = DateTime.Now.AddDays(-20), DataFinal = DateTime.Now, BaseDaData = "Criacao", Paginador = new() { PaginaAtual = 1, RegistrosPorPagina = 10 } }, cancellationToken); foreach (var l in lotes.Dados) { Console.WriteLine($"Id: {l.Id}"); Console.WriteLine($"Data: {l.Data:dd/MM/yyyy}"); Console.WriteLine($"Tags: {l.Tags}"); Console.WriteLine(); } } }
public override async Task Executar(CancellationToken cancellationToken = default) { using (var proxy = new ProxyDoServico(this.Conexao)) { //Retorna todas as informações de um determinado lote. var lote = await proxy.Lotes.Detalhes(new("06202cf4-281d-46a5-bd81-975c15f58d94"), cancellationToken); if (lote != null) { Console.WriteLine($"Status: {lote.Status}"); //Percorre os Documentos, suas Assinaturas e os Assinantes. foreach (var documento in lote.Documentos) { Console.WriteLine($"Documento: {documento.NomeDoArquivo}"); foreach (var assinatura in documento.Assinaturas) { Console.WriteLine($"Perfil: {assinatura.Perfil}"); foreach (var assinante in assinatura.Assinantes) { Console.WriteLine($"Assinante: {assinante.Entidade.Nome}"); } } } } } }
public override async Task Executar(CancellationToken cancellationToken = default) { using (var proxy = new ProxyDoServico(this.Conexao)) { var contratante = await proxy.Contratantes.Detalhes(this.CodigoDoContratante, cancellationToken); if (contratante != null) { Console.WriteLine(contratante.Entidade.Nome); } } }
public override async Task Executar(CancellationToken cancellationToken = default) { using (var proxy = new ProxyDoServico(this.Conexao)) { var novaChave = await proxy.Aplicacoes.RenovarChave(Guid.Parse("e4005970-f755-4d6d-8f71-f7a4937c5f9d"), cancellationToken); Console.WriteLine(novaChave); //Armazenar para futuras requisições; this.ChaveDeIntegracao = novaChave; } }
public override async Task Executar(CancellationToken cancellationToken = default) { using (var proxy = new ProxyDoServico(this.Conexao)) { //Retorna o pacote, contendo o arquivo de manifesto.xml, arquivos originais e assinados. var pacote = await proxy.Lotes.Pacote(new("06202cf4-281d-46a5-bd81-975c15f58d94"), cancellationToken); Console.WriteLine(pacote.Lote.Id); foreach (var a in pacote.Arquivos) { File.WriteAllBytes(a.Item1, a.Item2); } } }
public override async Task Executar(CancellationToken cancellationToken = default) { using (var proxy = new ProxyDoServico(this.Conexao)) { //Listando as notificações de um determinado lote var loteId = Guid.Parse("..."); var notificacoes = await proxy.Lotes.Notificacoes(loteId, cancellationToken); //Solicitando o replay das notificações foreach (var n in notificacoes) { await proxy.Notificacoes.Replay(n.Id, cancellationToken); } } }
public override async Task Executar(CancellationToken cancellationToken = default) { var id = "39c0a7b5"; using (var proxy = new ProxyDoServico(this.Conexao)) { var requisicaoId = Guid.Empty; foreach (var dump in await proxy.Dumps.Relacao(id, cancellationToken)) { Console.WriteLine($"{dump.Data}: {dump.RequisicaoId} ({dump.Formato})"); requisicaoId = dump.RequisicaoId; } Console.WriteLine(); Console.WriteLine(await proxy.Dumps.Conteudo(id, requisicaoId, cancellationToken)); } }
public override async Task Executar(CancellationToken cancellationToken = default) { using (var proxy = new ProxyDoServico(this.Conexao)) { var relatorio = await proxy.Status.Atualizar(cancellationToken); Console.WriteLine($"Status Geral: {relatorio.Status} - Duração: {relatorio.Duracao} ms"); Console.WriteLine("--------- SERVIÇOS ---------"); foreach (var s in relatorio.Servicos) { Console.WriteLine($"Serviço: {s.Nome}"); Console.WriteLine($"Status: {s.Status}"); Console.WriteLine($"Mensagem: {s.Mensagem}"); Console.WriteLine($"Duração: {s.Duracao} ms"); Console.WriteLine(); } } }
public override async Task Executar(CancellationToken cancellationToken = default) { using (var proxy = new ProxyDoServico(this.Conexao)) { await proxy.Aplicacoes.Atualizar(new() { Id = Guid.Parse("E4005970-F755-4D6D-8F71-F7A4937C5F9D"), Ativa = true, Configuracao = new() { AcompanhamentoAoVivo = true, DocumentosDoPacote = "Assinado;Manifesto", EventosReportados = "Lote", FormatoDeCallback = "JSON", HeadersDeCallback = "AppKey=123", IPsAutorizados = "127.0.0.1", PosicaoDoCarimbo = "Rodapé" } }, cancellationToken); } }
public override async Task Executar(CancellationToken cancellationToken = default) { using (var proxy = new ProxyDoServico(this.Conexao)) { //Retorna todas as informações de um determinado documento, exceto seus arquivos (bytes[]). var documento = await proxy.Documentos.Detalhes(new Guid("0007EF79-EB33-4A31-9FF1-069424192FFF"), cancellationToken); if (documento != null) { Console.WriteLine($"Status: {documento.Status}"); //Individualmente, cada método a seguir retorna: arquivo origninal, assinado e o manifesto. File.WriteAllBytes(documento.NomeDoArquivo, await proxy.Documentos.Original(documento.Id)); if (documento.Status == "Assinado") { File.WriteAllBytes(documento.NomeDoArquivoAssinado, await proxy.Documentos.Assinado(documento.Id)); File.WriteAllBytes(documento.NomeDoArquivoDeManifesto, await proxy.Documentos.Manifesto(documento.Id)); } } } }
public override async Task Executar(CancellationToken cancellationToken = default) { using (var proxy = new ProxyDoServico(this.Conexao)) { //Percorre os planos contratados. foreach (var pc in await proxy.Financeiro.Planos(cancellationToken)) { Console.WriteLine(pc.Plano.Nome); Console.WriteLine(pc.Plano.Quantidade); } //Percorre os últimos 12 fechamentos realizados. foreach (var f in await proxy.Financeiro.Fechamentos(cancellationToken)) { Console.WriteLine($"Período: {f.Mes:00}/{f.Ano}"); Console.WriteLine($"Valor: {f.ValorTotal:N2}"); Console.WriteLine($"Status: {f.Status}"); //Detalhes sobre o fechamento. var fechamento = await proxy.Financeiro.Fechamento(f.Id, cancellationToken); if (fechamento != null) { Console.WriteLine($" - Qtde. de Lotes: {fechamento.QtdeDeLotes}"); Console.WriteLine($" - Qtde. de Documentos: {fechamento.QtdeDeDocumentos}"); Console.WriteLine($" - Qtde. de Assinaturas: {fechamento.QtdeDeAssinaturas}"); Console.WriteLine($" - Plano Contratato: {fechamento.Plano.Nome}"); //Demonstrativo do consumo. var demonstrativo = await proxy.Financeiro.Demonstrativo(f.Id, cancellationToken); if ((demonstrativo?.Length ?? 0) > 0) { File.WriteAllBytes($"{fechamento.Mes:00}-{fechamento.Ano}.pdf", demonstrativo); } } } } }
public override async Task Executar(CancellationToken cancellationToken = default) { //Reinicializa o log. File.Delete("Log.txt"); var arquivo = File.ReadAllBytes("Exemplo/ContratoDeLocacao1.pdf"); //Gera, para cada requisição, um Guid para correlacionar os logs do cliente com o do serviço. var geradorDeRastreio = new RastreioComGuid(); //Contexto do log. O conteúdo é descarregado na conclusão do bloco using. using (var loggerEmArquivo = new LogEmTexto(new StreamWriter("Log.txt", true))) { using (var proxy = new ProxyDoServico(this.Conexao, loggerEmArquivo, geradorDeRastreio)) { var pacote = new Pacote(new() { Aplicacao = new() { Contratante = new() { Id = this.CodigoDoContratante, Entidade = new() { Nome = "White House - USA", Documento = "95038850000195", Email = "*****@*****.**" } } }, Entidade = new() { Nome = "White House - USA", Documento = "14175773000113", Email = "*****@*****.**" }, DataDeExpiracao = DateTime.Now.AddDays(10), Documentos = new List <Documento>() { new Documento() { NomeDoArquivo = "ContratoDeLocacao1.pdf", Descricao = "Contrato de Locação 1", Tipo = Documento.Tipos.Contrato, Tags = "contratoId=123", FormatoDoArquivo = "PDF", ConteudoOriginal = arquivo, TamanhoDoArquivo = arquivo.Length, PadraoDeAssinatura = Constantes.PadroesDeAssinatura.CAdES, PoliticaDeAssinatura = "PA_AD_RB_v2_3", Assinaturas = new List <Assinatura>() { new () { Perfil = "Locador", QtdeMinima = 1, Assinantes = new List <Assinante>() { new () { Entidade = new () { Nome = "Israel Aece", Documento = "28387365823", Email = "*****@*****.**" }, Notificar = true, Obrigatorio = false } } } } } }, Observadores = new List <Observador>() { new() { Email = "*****@*****.**" }, new() { Email = "*****@*****.**" } },
public override async Task Executar(CancellationToken cancellationToken = default) { //Arquivo a ser enviado para coleta de assinatura(s). //var arquivo = File.ReadAllBytes("Exemplo/ContratoDeLocacao.pdf"); //Criação do proxy de comunicação com o serviço. using (var proxy = new ProxyDoServico(this.Conexao)) { var pacote = new Pacote(new() { Aplicacao = new() { Contratante = new() { Id = this.CodigoDoContratante, Entidade = new() { Nome = "White House - USA", Documento = "95038850000195", Email = "*****@*****.**" } } }, Entidade = new() { Nome = "White House - USA", Documento = "14175773000113", Email = "*****@*****.**" }, DataDeExpiracao = DateTime.Now.AddDays(10), Documentos = new List <Documento>() { new Documento() { NomeDoArquivo = "ContratoDeLocacao1.pdf", Descricao = "Contrato de Locação 1", Tipo = Documento.Tipos.Contrato, Tags = "contratoId=123", FormatoDoArquivo = "PDF", ConteudoOriginal = File.ReadAllBytes("Exemplo/ContratoDeLocacao1.pdf"), TamanhoDoArquivo = File.ReadAllBytes("Exemplo/ContratoDeLocacao1.pdf").Length, PadraoDeAssinatura = Constantes.PadroesDeAssinatura.CAdES, PoliticaDeAssinatura = "PA_AD_RB_v2_3", Assinaturas = new List <Assinatura>() { new() { Perfil = "Locador", QtdeMinima = 1, Assinantes = new List <Assinante>() { new() { Entidade = new() { Nome = "Jack Bauer", Documento = "57863748070", Email = "*****@*****.**" }, Notificar = true, Obrigatorio = false } } } } } }, Observadores = new List <Observador>() { new() { Email = "*****@*****.**" }, new() { Email = "*****@*****.**" } },
public override async Task Executar(CancellationToken cancellationToken = default) { //Arquivo a ser enviado para coleta de assinatura(s). var arquivo = File.ReadAllBytes("Exemplo/NFe.xml"); var padraoDeAssinatura = Constantes.PadroesDeAssinatura.XAdES; //Posicionamento da assinatura no documento. var posicao = new Posicao("Enveloped", "infNFe"); //Criação do proxy de comunicação com o serviço. using (var proxy = new ProxyDoServico(this.Conexao)) { var pacote = new Pacote(new() { Aplicacao = new() { Contratante = new() { Id = this.CodigoDoContratante, Entidade = new() { Nome = "White House - USA", Documento = "95038850000195", Email = "*****@*****.**" } } }, Entidade = new() { Nome = "White House - USA", Documento = "14175773000113", Email = "*****@*****.**" }, DataDeExpiracao = DateTime.Now.AddDays(10), Documentos = new List <Documento>() { new Documento() { NomeDoArquivo = "NFe.xml", Descricao = "Nota Fiscal", Tipo = Documento.Tipos.NotaFiscal, Tags = "declaracaoId=123", FormatoDoArquivo = "XML", ConteudoOriginal = arquivo, TamanhoDoArquivo = arquivo.Length, PadraoDeAssinatura = padraoDeAssinatura, Assinaturas = new List <Assinatura>() { new() { Perfil = "Emitente", QtdeMinima = 2, Assinantes = new List <Assinante>() { new() { Entidade = new() { Nome = "Israel Aece", Documento = "28387365823", Email = "*****@*****.**" }, Notificar = true, Obrigatorio = true, Posicao = posicao }, new() { Entidade = new() { Nome = "Juliano Aece", Documento = "32757138847", Email = "*****@*****.**" }, Notificar = true, Obrigatorio = true, Posicao = posicao } } } } } }, Tags = "processo=456" });
public override async Task Executar(CancellationToken cancellationToken = default) { //Arquivo a ser enviado para coleta de assinatura(s). var arquivo = File.ReadAllBytes("Exemplo/Declaracao.pdf"); var padraoDeAssinatura = Constantes.PadroesDeAssinatura.PAdES; //Posicionamento da assinatura no documento. var posicao = new Posicao(1, 140F, 240F); //Criação do proxy de comunicação com o serviço. using (var proxy = new ProxyDoServico(this.Conexao)) { var pacote = new Pacote(new() { Aplicacao = new() { Contratante = new() { Id = this.CodigoDoContratante, Entidade = new() { Nome = "White House - USA", Documento = "95038850000195", Email = "*****@*****.**" } } }, Entidade = new() { Nome = "White House - USA", Documento = "14175773000113", Email = "*****@*****.**" }, DataDeExpiracao = DateTime.Now.AddDays(10), Documentos = new List <Documento>() { new Documento() { NomeDoArquivo = "Declaracao.pdf", Descricao = "Declaração", Tipo = Documento.Tipos.Declaracao, Tags = "declaracaoId=123", FormatoDoArquivo = "PDF", ConteudoOriginal = arquivo, TamanhoDoArquivo = arquivo.Length, PadraoDeAssinatura = padraoDeAssinatura, Assinaturas = new List <Assinatura>() { new() { Perfil = "Declarante", QtdeMinima = 1, Assinantes = new List <Assinante>() { new() { Entidade = new() { Nome = "Jack Bauer", Documento = "57863748070", Email = "*****@*****.**" }, Notificar = true, Obrigatorio = false, Posicao = posicao } } } } } }, Tags = "processo=456" });
public override async Task Executar(CancellationToken cancellationToken = default) { using (var proxy = new ProxyDoServico(this.Conexao)) { var pacote = new Pacote(new() { Aplicacao = new() { Contratante = new() { Id = this.CodigoDoContratante, Entidade = new() { Nome = "White House - USA", Documento = "95038850000195", Email = "*****@*****.**" } } }, Entidade = new() { Nome = "White House - USA", Documento = "14175773000113", Email = "*****@*****.**" }, DataDeExpiracao = DateTime.Now.AddDays(10), Documentos = new List <Documento>() { new Documento() { NomeDoArquivo = "ContratoDeLocacao1.pdf", Descricao = "Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxontrato de Locação 1", Tipo = Documento.Tipos.Contrato, Tags = "contratoId=123", FormatoDoArquivo = "PDF", ConteudoOriginal = File.ReadAllBytes("Exemplo/ContratoDeLocacao1.pdf"), TamanhoDoArquivo = File.ReadAllBytes("Exemplo/ContratoDeLocacao1.pdf").Length, PadraoDeAssinatura = Constantes.PadroesDeAssinatura.CAdES, PoliticaDeAssinatura = "PA_AD_RB_v2_3", Assinaturas = new List <Assinatura>() { new() { Perfil = "Locador", QtdeMinima = 1, Assinantes = new List <Assinante>() { new () { Entidade = new() { Nome = "Jack Bauer", Documento = "57863748070", Email = "*****@*****.**" }, Notificar = true, Obrigatorio = false } } } } } } }); try { var urlDoLote = await proxy.Lotes.Upload(pacote, cancellationToken); } catch (ErroNaRequisicao ex) { Console.WriteLine($"Mensagem: {ex.Message}"); Console.WriteLine($"Link: {ex.HelpLink}"); foreach (var chave in ex.Data.Keys) { Console.WriteLine($"{chave}: {ex.Data[chave]}"); } } } }
public override async Task Executar(CancellationToken cancellationToken = default) { var arquivo = Encoding.UTF8.GetBytes(Arquivo); using (var proxy = new ProxyDoServico(this.Conexao)) { var pacote = new Pacote(new() { Aplicacao = new() { Contratante = new() { Id = this.CodigoDoContratante, Entidade = new() { Nome = "White House - USA", Documento = "95038850000195", Email = "*****@*****.**" } } }, Entidade = new() { Nome = "White House - USA", Documento = "14175773000113", Email = "*****@*****.**" }, DataDeExpiracao = DateTime.Now.AddDays(10), Documentos = new List <Documento>() { new Documento() { NomeDoArquivo = "Duplicatas.csv", Descricao = "Relação de Duplicatas", Tipo = Documento.Tipos.Duplicata, FormatoDoArquivo = "CSV", ConteudoOriginal = arquivo, TamanhoDoArquivo = arquivo.Length, PadraoDeAssinatura = Constantes.PadroesDeAssinatura.CAdES, PoliticaDeAssinatura = "PA_AD_RB_v2_3", Template = "Duplicata", Assinaturas = new List <Assinatura>() { new() { Perfil = "Representante", QtdeMinima = 1, Assinantes = new List <Assinante>() { new() { Entidade = new() { Nome = "Jack Bauer", Documento = "57863748070", Email = "*****@*****.**" }, Notificar = true, Obrigatorio = false } } } } } }, Tags = "operacao=123" });
public override async Task Executar(CancellationToken cancellationToken = default) { //Criação do proxy de comunicação com o serviço. using (var proxy = new ProxyDoServico(this.Conexao)) { var lote = new Lote() { Aplicacao = new() { Contratante = new() { Id = this.CodigoDoContratante, Entidade = new() { Nome = "White House - USA", Documento = "95038850000195", Email = "*****@*****.**" } } }, Entidade = new() { Nome = "White House - USA", Documento = "14175773000113", Email = "*****@*****.**" }, DataDeExpiracao = DateTime.Now.AddDays(10), Documentos = new List <Documento>() { new Documento() { NomeDoArquivo = "ContratoDeLocacao1.pdf", Descricao = "Contrato de Locação 1", Tipo = Documento.Tipos.Contrato, Tags = "contratoId=123", FormatoDoArquivo = "PDF", Download = new () { Url = "http://*****:*****@ctu.com" }, Notificar = true, Obrigatorio = false } } } } } },