Пример #1
0
        private async void FrmVisualizarNotaFiscal_Load(object sender, EventArgs e)
        {
            string fileName       = (await HttpSolicitacaoCompras.GetSolicitacaoCompraById(idSolicitacao, usuarioLogado.token)).Anexo;
            string fileSavePcName = $@"{AppDomain.CurrentDomain.BaseDirectory}notasFiscais";
            var    file           = await HttpSolicitacaoCompras.DownloadNotaFiscal(fileName, usuarioLogado.token);

            File.WriteAllBytes(fileSavePcName, file);
            pdfReader.LoadFile(fileSavePcName);
        }
Пример #2
0
        private async Task <string> dowloadNotaFiscal(long idSolicitacao)
        {
            try
            {
                string fileName = (await HttpSolicitacaoCompras.GetSolicitacaoCompraById(idSolicitacao, usuarioLogado.token)).Anexo;
                var    file     = await HttpSolicitacaoCompras.DownloadNotaFiscal(fileName, usuarioLogado.token);

                saveFileDialog1.Title       = "Salvar PDF";
                saveFileDialog1.Filter      = "Pdf File|.pdf";
                saveFileDialog1.FilterIndex = 0;
                saveFileDialog1.DefaultExt  = ".pdf";
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    File.WriteAllBytes(saveFileDialog1.FileName, file);
                }
                return(saveFileDialog1.FileName);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
        }