Пример #1
0
        private static async Task GerarDanfeSimplificadoPng()
        {
            Console.WriteLine(@"Digite o caminho do .xml (ex: C:\arquivos\35199227357619000192550010090001111381546999.xml):");
            string caminho = Console.ReadLine();

            //busca arquivo xml
            string xml = Funcoes.BuscarArquivoXml(caminho);

            try
            {
                var    report = GeraClasseDanfeSimplificadoFrNFe(xml);
                byte[] bytes  = report.ExportarPng();
                Funcoes.SalvaArquivoGerado(caminho, ".png", bytes);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        private static async Task GerarDanfeHtml()
        {
            Console.WriteLine(@"Digite o caminho do .xml (ex: C:\arquivos\35199227357619000192550010090001111381546999.xml):");
            string caminho = Console.ReadLine();

            //busca arquivo xml
            string xml = Funcoes.BuscarArquivoXml(caminho);

            using (MemoryStream stream = new MemoryStream()) // Create a stream for the report
            {
                try
                {
                    var    report = GeraClasseDanfeFrNFe(xml);
                    byte[] bytes  = report.ExportarHtml();
                    Funcoes.SalvaArquivoGerado(caminho, ".html", bytes);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Пример #3
0
        private static async Task TestePerformanceDanfeSimplificadoHtml()
        {
            Console.WriteLine(@"Digite o caminho do .xml (ex: C:\arquivos\35199227357619000192550010090001111381546999.xml):");
            string caminho = Console.ReadLine();

            Console.WriteLine(@"Quantidade de relatorios: (ex: 1000)");
            long quantidade = long.Parse(Console.ReadLine());

            Console.WriteLine(@"Salva Arquivos ?: (true = SIM, false = NAO)");
            bool salvaarquivos = bool.Parse(Console.ReadLine());

            //busca arquivo xml
            string xml = Funcoes.BuscarArquivoXml(caminho);

            using (MemoryStream stream = new MemoryStream()) // Create a stream for the report
            {
                try
                {
                    for (int i = 1; i <= quantidade; i++)
                    {
                        Console.Write("\n" + i);
                        //no futuro é interessante calcular o tempo dos metodos abaixo... por enquanto é só visual.
                        var    report = GeraClasseDanfeSimplificadoFrNFe(xml);
                        byte[] bytes  = report.ExportarHtml();
                        if (salvaarquivos)
                        {
                            Funcoes.SalvaArquivoGerado(caminho, ".html", bytes);
                        }

                        Console.WriteLine("...OK");
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }