예제 #1
0
        public static string[] GetConteudoExportacao(this IRelatorio relatorio,
                                                     RelatorioFormato?formato = null, int?larguraRelatorio = null)
        {
            _relatorio   = relatorio;
            _formato     = formato ?? relatorio.Formato ?? RelatorioFormato.Txt;
            _delimitador = _formato.GetDelimitador();

            var conteudos = new List <string>();

            InserirLinhaTracejada(conteudos);

            foreach (var parte in relatorio.Partes)
            {
                var conteudosParte = parte.GetConteudoExportacao();

                foreach (var conteudo in conteudosParte)
                {
                    conteudos.Add(conteudo);
                    InserirLinhaEmBranco(conteudos);
                    InserirLinhaTracejada(conteudos);
                }
            }

            return(conteudos.ToArray());
        }
예제 #2
0
 public CaixaEletronicoProcessor(IDepositar depositar, ISacar sacar, IRelatorio relatorio)
 {
     _Cedulas   = Notas.ObterNotas();
     _deposito  = depositar;
     _saque     = sacar;
     _relatorio = relatorio;
 }
예제 #3
0
        static void Main(string[] args)
        {
            List <Proposta> propostas = new List <Proposta> {
                new Novo(12M),
                new Portabilidade(3, 325.72M)
            };

            foreach (Proposta proposta in propostas)
            {
                Console.WriteLine($"Meu tipo de operacao é: {proposta.QualOTipoOperacao()}");
                Console.WriteLine($"Meu valor corrigido é: {((IProposta)proposta).CorrigirValor()}");
            }

            IProposta propostaNovo = (IProposta)propostas[0];

            Console.WriteLine($"Valor Total = {propostaNovo.ObterValorCorrigido()}");
            propostaNovo.AtualizarValorParcela(6M);
            Console.WriteLine($"Após atualizar o valor da parcela para 6 o novo total é = {propostaNovo.CorrigirValor()}");

            IRelatorio relatorio = (IRelatorio)propostas[1];
            Resumo     resumo    = relatorio.GerarResumo();

            Console.WriteLine(string.Format("Operação de {0} é viável? {1}", resumo.TipoOperacao, resumo.Viavel));

            Console.ReadLine();
        }
예제 #4
0
        private void MontaLinha(IRelatorio relatorio)
        {
            if (relatorio is DLO)
            {
                this.MontaLinhaDLO(relatorio as DLO);
            }
            else
            {
                var linhasHtml = relatorio.Html.Skip(1).Select(tr => tr
                                                               .Elements("td")
                                                               .Select(td => td.InnerText.Trim())
                                                               .ToArray());

                int numeroDeLinhas = linhasHtml.Count();

                Linhas = new LinhaDadosBCB[numeroDeLinhas];

                for (int i = 0; i < numeroDeLinhas; i++)
                {
                    string[] linhaArray = linhasHtml.ElementAt(i);

                    //se for rodapé
                    if (linhaArray.Length == 1)
                    {
                        Linhas[i] = new LinhaDadosBCB(linhaArray[0]);
                        continue;
                    }

                    Linhas[i] = new LinhaDadosBCB(linhaArray[0],
                                                  linhaArray[1],
                                                  linhaArray[2]);
                }
            }
        }
예제 #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            ICatalogo  catalogo  = serviceProvider.GetService <ICatalogo>();
            IRelatorio relatorio = serviceProvider.GetService <IRelatorio>();

            app.Run(relatorio.Imprimir);
        }
예제 #6
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            ICatalogo  catalogo  = serviceProvider.GetService <ICatalogo>();
            IRelatorio relatorio = serviceProvider.GetService <IRelatorio>();

            app.Run(async(context) =>
            {
                await relatorio.Imprimir(context);
            });
        }
예제 #7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            IListaDePacientes details = serviceProvider.GetService <IListaDePacientes>();

            IRelatorio relatorio = serviceProvider.GetService <IRelatorio>();

            app.Run(async(context) =>
            {
                await relatorio.Imprimir(context);
            });
        }
예제 #8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            ICatalogo  catalogo  = serviceProvider.GetService <ICatalogo>();
            IRelatorio relatorio = serviceProvider.GetService <IRelatorio>();

            app.Run(async(context) =>
            {
                await context.Response.WriteAsync("Livraria do Ygor\r\n");

                await relatorio.Imprimir(context);
            });
        }
        //This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider)// IServiceProvider serviceProvider ->> esse parametro é responsavel em obter as intancias das classes catalogo e relatorio
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }



            ICatalogo  catalogo  = serviceProvider.GetService <ICatalogo>();// serviceProvider.GetService pede a instacia da classe catalogo no lugar do operador NEW
            IRelatorio relatorio = serviceProvider.GetService <IRelatorio>();

            app.Run(async(context) =>
            {
                relatorio.Imprimir(context);
            });
        }
예제 #10
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            IRelatorio relatorio = serviceProvider.GetService <IRelatorio>();

            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    await relatorio.Imprimir(context);
                });
            });
        }
예제 #11
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider) // local onde vai utilizar os serviços adicionados acima
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            ICatalogo  catalogo  = serviceProvider.GetService <ICatalogo>();
            IRelatorio relatorio = serviceProvider.GetService <IRelatorio>();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    await relatorio.Imprimir(context);
                });
            });
        }
예제 #12
0
        public IEnumerable <HtmlNodeCollection> RetornaNodeRelatorio(IRelatorio relatorio)
        {
            if (string.IsNullOrEmpty(paginaRenderizada))
            {
                paginaRenderizada = RetornaPaginaRenderizada(relatorio.Url);
            }

            HtmlDocument html = new HtmlDocument();

            html.LoadHtml(paginaRenderizada);

            List <HtmlNodeCollection> noTabelas = new List <HtmlNodeCollection>();

            for (int i = 1; i < relatorio.NumeroTabelas + 1; i++)
            {
                string path = string.Format(relatorio.XPath, relatorio is DLO ? i - 1 : i);

                yield return(html.DocumentNode.SelectNodes(path));
            }
        }
예제 #13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            ICatalogo  catalogo  = serviceProvider.GetService <ICatalogo>();
            IRelatorio relatorio = serviceProvider.GetService <IRelatorio>();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    await relatorio.Imprimir(context);
                    await context.Response.WriteAsync("Ohaiyo sekai good morning world!");
                });
            });
        }
예제 #14
0
        // Utilização dos serviços adicionados (Definindo o fluxo de chamadas)
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            // Utilizando injeção de dependencia
            // GetService devolve uma instancia da classe relacionada a interface selecionada
            ICatalogo  catalogo  = serviceProvider.GetService <ICatalogo>();
            IRelatorio relatorio = serviceProvider.GetService <IRelatorio>();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    await relatorio.Imprimir(context);
                });
            });
        }
예제 #15
0
        /// <summary>
        /// Abre um relatório e exibe no design
        /// </summary>
        /// <param name="relatorio">relatório que deverá ser carregado e exibido para visualização</param>
        /// <param name="filters">Filtros que deverão ser usados no relatório</param>
        /// <exception cref="ReportObjectInvalid">Lançada quando o objeto do relatório que deverá ser exibido é inválido</exception>
        public static void OpenViewer(IRelatorio relatorio, IEnumerable<FilterItem> filters)
        {
            if(relatorio.IsNullOrEmpty())
                throw new ReportObjectInvalid();

            DialogFilterResult dfr = DialogFilter.Show(relatorio, filters);

            if(dfr.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                return;

            if(filters != null)
            {
                foreach(FilterItem item in filters)
                {
                    dfr.FilterItems.Add(item);
                }
            }

            Reader.RdlReader reader = new Reader.RdlReader();
            reader.OpenReport(dfr);
            reader.Show();
        }
예제 #16
0
 public frmDialogSave(List <SqlColumn> colunas, IRelatorio relatorio)
     : this(colunas)
 {
     if (relatorio != null)
     {
         foreach (IFiltro item in relatorio.Filtros)
         {
             grdFiltros.Rows.Add(new object[]
             {
                 item,
                 item.Apelido,
                 Convert.ToString(item.NomeReal),
                 Convert.ToString(item.Tipo),
                 Convert.ToBoolean(item.Obrigatorio),
                 item.Valor,
                 Convert.ToString(item.Comparacao),
                 Convert.ToString(item.Classificacao),
                 item.Valor,
                 item.Valor2
             });
         }
     }
 }
        //ServiceProvider é um agente da injeção de dependências para prover os serviços da aplicação
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            ICatalogo catalogo = serviceProvider.GetService <ICatalogo>();

            //Pelo fato do Catalogo também ser um serviço gerenciado pela injeção de dependências ele não precisa ser passado como parâmetro obrigatório
            //no construtor da classe Relatorio
            IRelatorio relatorio = serviceProvider.GetService <IRelatorio>();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    await relatorio.Imprimir(context);
                });
            });
        }
예제 #18
0
 /// <summary>
 /// Abre um relatório e exibe no design
 /// </summary>
 /// <param name="relatorio">relatório que deverá ser carregado e exibido para visualização</param>
 /// <exception cref="ReportObjectInvalid">Lançada quando o objeto do relatório que deverá ser exibido é inválido</exception>
 public static void OpenViewer(IRelatorio relatorio)
 {
     OpenViewer(relatorio, null);
 }
예제 #19
0
        public static SaveDialogResult Show(string title, OpenPOS.GUID group, List <SqlColumn> colunas, IRelatorio relatorio)
        {
            frmDialogSave save         = new frmDialogSave(colunas, relatorio);
            RdlDesigner   _rdlDesigner = save.Parent as RdlDesigner;

            save.txtTitle.Text = title;
            save.sfGroup.SetValue(group.ToString());
            save.ShowDialog();
            SaveDialogResult result = save.Result;

            save.Close();
            save.Dispose();
            return(result);
        }
예제 #20
0
 public static bool VerificaMudanca(IRelatorio relatorio, ref string textoTabelas)
 {
     return(MontaTextoESalvaArquivo(relatorio, ref textoTabelas));
 }
예제 #21
0
        private static string MontaTabelasESalvaArquivos(IRelatorio relatorio, StringBuilder textoTabelas, BinaryFormatter binario)
        {
            int     i           = 0;
            int     somaMudadas = 0;
            Crawler crawler     = new Crawler();

            foreach (HtmlNodeCollection noTabela in crawler.RetornaNodeRelatorio(relatorio))
            {
                int mudadas = 0;

                StringBuilder textoTabela = new StringBuilder(string.Format(ConstStringHtml.tituloTabela, relatorio.NomeTabelas[i]));

                //Não mova esse i++ de lugar!!
                i++;

                if (noTabela == null)
                {
                    return(string.Empty);
                }

                relatorio.Html = noTabela;

                string nomeArquivo = string.Format(ConstStringHtml.nomeBinTabelas, relatorio.Nome, i);

                DadosBCB dadosBCB = new DadosBCB(relatorio);

                if (!File.Exists(nomeArquivo))
                {
                    Stream tmp = File.Create(nomeArquivo);
                    tmp.Close();
                }

                using (Stream stream = File.OpenRead(nomeArquivo))
                {
                    DadosBCB dadoRecuperadosBCB = null;

                    if (!(stream.Length == 0))
                    {
                        dadoRecuperadosBCB = (DadosBCB)binario.Deserialize(stream);
                    }

                    textoTabela.Append(ConstStringHtml.abreTabela + ConstStringHtml.abreTR);

                    textoTabela.Append(Formatador.PrintaCabecalho(relatorio.Cabecalho) + "</tr>");

                    textoTabela.Append(Formatador.RetornaTextoTabela(ref mudadas, dadosBCB, dadoRecuperadosBCB) + "</table>");
                }

                using (Stream stream = File.OpenWrite(nomeArquivo))
                {
                    binario.Serialize(stream, dadosBCB);
                }

                somaMudadas += mudadas;
                if (mudadas == 0)
                {
                    textoTabela.Clear();

                    if (i == relatorio.NumeroTabelas && somaMudadas == 0)
                    {
                        textoTabela.Append(string.Format(ConstStringHtml.nenuhmaAlteracao, relatorio.Nome));
                    }
                }

                textoTabelas.Append(textoTabela);
            }

            return(textoTabelas.ToString());
        }
예제 #22
0
 public static RelatorioFormato GetFormato(this IRelatorio relatorio,
                                           RelatorioFormato?formato = null)
 {
     return(formato ?? relatorio.Formato ?? RelatorioFormato.Txt);
 }
예제 #23
0
        public static bool MontaTextoESalvaArquivo(IRelatorio relatorio, ref string textoTabelas)
        {
            int             i           = 0;
            int             somaMudadas = 0;
            BinaryFormatter binario     = new BinaryFormatter();

            textoTabelas += string.Format(ConstStringHtml.tituloEUrl, relatorio.Nome, relatorio.Url);

            foreach (HtmlNodeCollection noTabela in Crawler.RetornaNodeHTML(relatorio))
            {
                int mudadas = 0;

                string textoTabela = string.Format(ConstStringHtml.tituloTabela, relatorio.NomeTabelas[i]);

                //Não mova esse i++ de lugar!!
                i++;

                if (noTabela == null)
                {
                    textoTabela += Formatador.PrintaLinha(new LinhaDadosBCB("Erro na leitura do nó", "Verifique o serviço", "Tabela " + i.ToString()));
                    somaMudadas++;
                    continue;
                }

                relatorio.Html = noTabela;

                string nomeArquivo = string.Format(ConstStringHtml.nomeBin, relatorio.Nome, i);

                DadosBCB dadosBCB = new DadosBCB(relatorio);

                if (!File.Exists(nomeArquivo))
                {
                    Stream tmp = File.Create(nomeArquivo);
                    tmp.Close();
                }

                using (Stream stream = File.OpenRead(nomeArquivo))
                {
                    DadosBCB dadoRecuperadosBCB = null;

                    if (!(stream.Length == 0))
                    {
                        dadoRecuperadosBCB = (DadosBCB)binario.Deserialize(stream);
                    }

                    textoTabela += ConstStringHtml.abreTabela + ConstStringHtml.abreTR;

                    textoTabela += Formatador.PrintaCabecalho(relatorio.Cabecalho);

                    textoTabela += "</tr>";
                    textoTabela += MontaTextoTabela(ref mudadas, dadosBCB, dadoRecuperadosBCB);
                    textoTabela += "</table>";
                }

                using (Stream stream = File.OpenWrite(nomeArquivo))
                {
                    binario.Serialize(stream, dadosBCB);
                }

                somaMudadas += mudadas;
                if (mudadas == 0)
                {
                    textoTabela = string.Empty;

                    if (i == relatorio.NumeroTabelas && somaMudadas == 0)
                    {
                        textoTabela = string.Format(ConstStringHtml.nenuhmaAlteracao, relatorio.Nome);
                    }
                }

                textoTabelas += textoTabela;
            }

            return(!(somaMudadas == 0));
        }
예제 #24
0
 public DadosBCB(IRelatorio relatorio)
 {
     MontaLinha(relatorio);
     DataVerificacao = DateTime.Now;
 }
예제 #25
0
 public static string GetNomeArquivo(this IRelatorio relatorio, string nomeArquivo = null)
 {
     return(nomeArquivo ?? relatorio.NomeArquivo);
 }
예제 #26
0
 public static string GetNomeImpressora(this IRelatorio relatorio, string nomeImpressora = null)
 {
     return(nomeImpressora ?? relatorio.NomeImpressora);
 }
예제 #27
0
 public Servico()
 {
     ComunicacaoSerial = new ComunicacaoSerial();
     Configuracoes     = new Configuracoes();
     Relatorio         = new Relatorio();
 }
예제 #28
0
 public static void GerarRelatorio(IRelatorio relatorio)
 {
     relatorio.GerarRelatorio();
 }