public byte[] GerarSped(string pDataIni, string pDataFim, string pVersao, string pFinalidade, string pPerfil, string pIdEmpresa, string pInventario, string pIdContador) { SpedFiscalDAL sped = new SpedFiscalDAL(); try { if (sped.GerarArquivoSpedFiscal(pDataIni, pDataFim, int.Parse(pVersao), int.Parse(pFinalidade), int.Parse(pPerfil), int.Parse(pIdEmpresa), int.Parse(pInventario), int.Parse(pIdContador))) { FileInfo fi = new FileInfo("C:\\T2Ti\\Arquivos\\SpedFiscal.txt"); FileStream fs = fi.OpenRead(); MemoryStream ms = new MemoryStream((int)fs.Length); fs.CopyTo(ms); fs.Close(); ms.Position = 0L; return(ms.ToArray()); } else { return(null); } } catch (Exception ex) { throw ex; } }
private void btnGerar_Click(object sender, EventArgs e) { try { if (Validacoes()) { this.Text = "Aguarde... Gerando Arquivo!"; lblObervacao.Text = "Aguarde... Gerando Arquivo!"; Application.DoEvents(); SpedFiscalDAL Sp = new SpedFiscalDAL(); Sp.errolog = false; Sp.GerarArquivoSpedFiscal(dtpkInicial.Text, dtpkFim.Text, cbVersaoLayout.SelectedIndex, cbFinalidadeArquivo.SelectedIndex, cbPerfilApreArquivo.SelectedIndex, 1, cbInventario.SelectedIndex, Convert.ToInt32(cbContador.SelectedValue.ToString())); // CaminhoArquivo = salvaArquivoTempLocal(documentoSelected); this.Text = "Sped Fiscal"; lblObervacao.Text = string.Empty; Application.DoEvents(); if (Sp.errolog) { if (File.Exists(Sp.pathLog)) { System.Diagnostics.Process.Start(Sp.pathLog); this.Close(); } } else if (File.Exists(BmsSoftware.ConfigSistema1.Default.PathInstall + @"\SpedFiscal.txt")) { System.Diagnostics.Process.Start(BmsSoftware.ConfigSistema1.Default.PathInstall + @"\SpedFiscal.txt"); } } } catch (Exception ex) { this.Text = "Sped Fiscal"; lblObervacao.Text = string.Empty; Application.DoEvents(); MessageBox.Show("Erro Técnico: " + ex.Message); } }