comentar codigo enviado ... build quebrado.fixes bug#6829
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@50030 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
f6b58ea472
commit
409087e724
|
@ -1,26 +1,6 @@
|
|||
package com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import javax.activation.MimetypesFileTypeMap;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.zkoss.zul.Filedownload;
|
||||
|
||||
import com.rjconsultores.integracaoreceitadespesa.Arquivo;
|
||||
import com.rjconsultores.integracaoreceitadespesa.dao.*;
|
||||
import com.rjconsultores.integracaoreceitadespesa.entidades.DespesaReceita;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;
|
||||
|
||||
public class ItemMenuRelatorioArquivoBGM extends DefaultItemMenuSistema {
|
||||
|
||||
|
@ -34,72 +14,72 @@ public class ItemMenuRelatorioArquivoBGM extends DefaultItemMenuSistema {
|
|||
public String getClaveMenu() {
|
||||
return "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS.MENU.RELATORIOARQUIVOBGM";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ejecutar() {
|
||||
DataSource ds = null;
|
||||
try {
|
||||
ds = (DataSource)AppContext.getApplicationContext().getBean("dataSource");
|
||||
Totalbus totalbus = new Totalbus(ds.getConnection());
|
||||
String fileName = System.getProperty("jboss.server.log.dir") + "/arquivobgm.txt";
|
||||
String fileZip = System.getProperty("jboss.server.log.dir") + "/arquivobgm.zip";
|
||||
FileInputStream inputStream;
|
||||
Arquivo.GravaArquivo(fileName, totalbus.getDespesasReceitas(null, null));
|
||||
|
||||
excluirArquivosZip();
|
||||
compactarArquivo(fileZip, fileName);
|
||||
File file = new File(fileZip);
|
||||
if (file.exists()) {
|
||||
inputStream = new FileInputStream(file);
|
||||
Filedownload.save(inputStream, new MimetypesFileTypeMap().getContentType(file), file.getName());
|
||||
}
|
||||
file.delete();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
ds.getConnection().close();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void compactarArquivo(String arqSaida,String arqEntrada) throws IOException{
|
||||
int cont;
|
||||
byte[] dados = new byte[TAMANHO_BUFFER];
|
||||
BufferedInputStream origem = null;
|
||||
FileInputStream streamDeEntrada = null;
|
||||
FileOutputStream destino = null;
|
||||
ZipOutputStream saida = null;
|
||||
ZipEntry entry = null;
|
||||
try {
|
||||
destino = new FileOutputStream(new File(arqSaida));
|
||||
saida = new ZipOutputStream(new BufferedOutputStream(destino));
|
||||
File file = new File(arqEntrada);
|
||||
streamDeEntrada = new FileInputStream(file);
|
||||
origem = new BufferedInputStream(streamDeEntrada, TAMANHO_BUFFER);
|
||||
entry = new ZipEntry(file.getName());
|
||||
saida.putNextEntry(entry);
|
||||
while((cont = origem.read(dados, 0, TAMANHO_BUFFER)) != -1) {
|
||||
saida.write(dados, 0, cont);
|
||||
}
|
||||
origem.close();
|
||||
saida.close();
|
||||
} catch(IOException e) {
|
||||
throw new IOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void excluirArquivosZip(){
|
||||
File pasta = new File(System.getProperty("jboss.server.log.dir"));
|
||||
File[] arquivos = pasta.listFiles();
|
||||
|
||||
for(File arquivo : arquivos) {
|
||||
if(arquivo.getName().endsWith("zip")) {
|
||||
arquivo.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public void ejecutar() {
|
||||
// DataSource ds = null;
|
||||
// try {
|
||||
// ds = (DataSource)AppContext.getApplicationContext().getBean("dataSource");
|
||||
// Totalbus totalbus = new Totalbus(ds.getConnection());
|
||||
// String fileName = System.getProperty("jboss.server.log.dir") + "/arquivobgm.txt";
|
||||
// String fileZip = System.getProperty("jboss.server.log.dir") + "/arquivobgm.zip";
|
||||
// FileInputStream inputStream;
|
||||
// Arquivo.GravaArquivo(fileName, totalbus.getDespesasReceitas(null, null));
|
||||
//
|
||||
// excluirArquivosZip();
|
||||
// compactarArquivo(fileZip, fileName);
|
||||
// File file = new File(fileZip);
|
||||
// if (file.exists()) {
|
||||
// inputStream = new FileInputStream(file);
|
||||
// Filedownload.save(inputStream, new MimetypesFileTypeMap().getContentType(file), file.getName());
|
||||
// }
|
||||
// file.delete();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// try {
|
||||
// ds.getConnection().close();
|
||||
// } catch (Exception e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static void compactarArquivo(String arqSaida,String arqEntrada) throws IOException{
|
||||
// int cont;
|
||||
// byte[] dados = new byte[TAMANHO_BUFFER];
|
||||
// BufferedInputStream origem = null;
|
||||
// FileInputStream streamDeEntrada = null;
|
||||
// FileOutputStream destino = null;
|
||||
// ZipOutputStream saida = null;
|
||||
// ZipEntry entry = null;
|
||||
// try {
|
||||
// destino = new FileOutputStream(new File(arqSaida));
|
||||
// saida = new ZipOutputStream(new BufferedOutputStream(destino));
|
||||
// File file = new File(arqEntrada);
|
||||
// streamDeEntrada = new FileInputStream(file);
|
||||
// origem = new BufferedInputStream(streamDeEntrada, TAMANHO_BUFFER);
|
||||
// entry = new ZipEntry(file.getName());
|
||||
// saida.putNextEntry(entry);
|
||||
// while((cont = origem.read(dados, 0, TAMANHO_BUFFER)) != -1) {
|
||||
// saida.write(dados, 0, cont);
|
||||
// }
|
||||
// origem.close();
|
||||
// saida.close();
|
||||
// } catch(IOException e) {
|
||||
// throw new IOException(e.getMessage());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void excluirArquivosZip(){
|
||||
// File pasta = new File(System.getProperty("jboss.server.log.dir"));
|
||||
// File[] arquivos = pasta.listFiles();
|
||||
//
|
||||
// for(File arquivo : arquivos) {
|
||||
// if(arquivo.getName().endsWith("zip")) {
|
||||
// arquivo.delete();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue