leonardo 2015-05-06 12:58:54 +00:00
parent 9c9df7e9b9
commit 5089a1e704
1 changed files with 66 additions and 26 deletions

View File

@ -825,28 +825,76 @@ public class EditarPuntoVentaController extends MyGenericForwardComposer {
DAO.getInstance().setDBConnection(myConn); DAO.getInstance().setDBConnection(myConn);
String strEmpresas = DAO.getInstance().obterConstante("EMPRESAS_INTEGRACAO"); String strEmpresas = DAO.getInstance().obterConstante("EMPRESAS_INTEGRACAO");
for (String empresaId : strEmpresas.split(",")){ if (checkTodosPuntosVenta.isChecked()){
TotvsService.cadastrarTituloAReceber(checkTodosPuntosVenta.isChecked() ? null : puntoVenta.getPuntoventaId(), dateInicio, dateFim, myConn, Integer.parseInt(empresaId)); for (Integer puntoventaId : DAO.getInstance().obterListaPuntoVenta()){
for (String empresaId : strEmpresas.split(",")){
try{
TotvsService.cadastrarTituloAReceber(puntoventaId, dateInicio, dateFim, myConn, Integer.parseInt(empresaId));
if (!checkSimulaIntegracion.isChecked()) {
myConn.commit();
} else {
logResult.setText(sb != null ? sb.toString() : "");
TotvsService.setSb(null);
myConn.rollback();
}
}catch (Exception e){
log.error("Erro ao integrar Empresa " + empresaId + " - Ponto de venda " + puntoventaId,e);
if (myConn != null) {
try {
myConn.rollback();
} catch (SQLException e1) {
log.error("Erro rollback", e1);
}
}
}finally {
if (myConn != null) {
try {
myConn.close();
} catch (SQLException e) {
log.error("Erro ao fechar a conexão", e);
}
}
}
}
}
} else {
for (String empresaId : strEmpresas.split(",")){
try{
TotvsService.cadastrarTituloAReceber(puntoVenta.getPuntoventaId(), dateInicio, dateFim, myConn, Integer.parseInt(empresaId));
if (!checkSimulaIntegracion.isChecked()) {
myConn.commit();
} else {
logResult.setText(sb != null ? sb.toString() : "");
TotvsService.setSb(null);
myConn.rollback();
}
}catch (Exception e){
log.error("Erro ao integrar Empresa " + empresaId + " - Ponto de venda " + puntoVenta.getPuntoventaId(),e);
if (myConn != null) {
try {
myConn.rollback();
} catch (SQLException e1) {
log.error("Erro rollback", e1);
}
}
}finally {
if (myConn != null) {
try {
myConn.close();
} catch (SQLException e) {
log.error("Erro ao fechar a conexão", e);
}
}
}
}
} }
if (!checkSimulaIntegracion.isChecked()) {
myConn.commit();
} else {
logResult.setText(sb != null ? sb.toString() : "");
TotvsService.setSb(null);
myConn.rollback();
}
} catch (Exception e) { } catch (Exception e) {
log.error("Erro ao integrar",e); log.error("Erro ao integrar",e);
if (myConn != null) {
try {
myConn.rollback();
} catch (SQLException e1) {
log.error("Erro rollback", e1);
}
}
if (e instanceof WrongValueException) { if (e instanceof WrongValueException) {
throw (WrongValueException) e; throw (WrongValueException) e;
} }
@ -858,14 +906,6 @@ public class EditarPuntoVentaController extends MyGenericForwardComposer {
Labels.getLabel("editarPuntoVentaController.window.title"), Labels.getLabel("editarPuntoVentaController.window.title"),
Messagebox.OK, Messagebox.ERROR); Messagebox.OK, Messagebox.ERROR);
} finally {
if (myConn != null) {
try {
myConn.close();
} catch (SQLException e) {
log.error("Erro ao fechar a conexão", e);
}
}
} }
} }