@Override public void doIt() { System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Operando"); Connection c = null; try { Shared.createBackup( "articulo precio codigo_de_barras costo movimiento_inventario detalles_movimientos"); TotalPosWebService ws = new TotalPosWebServiceService().getTotalPosWebServicePort(); c = ConnectionDrivers.cpds.getConnection(); c.setAutoCommit(false); if (mode.equals("MM") || mode.equals("MMBackground")) { String ansListMM = ws.listMMwithPrices( Shared.getConfig("storePrefix") + Shared.getConfig("storeName"), Shared.getConfig("Z"), ConnectionDrivers.getLastMM()); // String ansListMM = ws.listMM("4900458128"); System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " ansListMM = " + ansListMM); String itemsNeeded = ConnectionDrivers.createNewMovement(c, ansListMM); ansListMM = null; System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " itemsNeeded = " + itemsNeeded); // Update prices too updatePrices(c, ws); // flagsC updateFlagC(c, ws); // Descriptions updateDescriptions(c, ws); System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Listo!"); } else if (mode.equals("Prices")) { updatePrices(c, ws); } else if (mode.equals("initialStock")) { String ansListMM = ws.getInitialStockWithPrices( Shared.getConfig("storePrefix") + Shared.getConfig("storeName"), Shared.getConfig("Z")); System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " ansListMM = " + ansListMM); ConnectionDrivers.getInitialStock(c, ansListMM); ConnectionDrivers.disableInitialStock(c); System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Listo!"); } else if (mode.equals("profitWorkers")) { System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Profit DB Name " + Shared.getConfig("profitDatabase")); String ans = ws.listEmployCode( Shared.getConfig("storeNameProfit"), Shared.getConfig("profitDatabase")); System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Ans = " + ans); ConnectionDrivers.updateEmployees(ans); } System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Haciendo el commit..."); c.commit(); System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Terminado commit Exitoso!"); if (!mode.equals("MMBackground")) { MessageBox msg = new MessageBox(MessageBox.SGN_SUCCESS, "Actualizado!"); msg.show(Shared.getMyMainWindows()); } else { System.exit(0); } } catch (Exception ex) { System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Comenzo la exception"); try { System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Haciendo Rollback"); c.rollback(); System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Reversado!"); MessageBox msg = new MessageBox( MessageBox.SGN_DANGER, "Ha ocurrido un error. No se ha guardado ningun cambio.", ex); msg.show(Shared.getMyMainWindows()); } catch (Exception ex1) { // We are in problems :( MessageBox msg = new MessageBox( MessageBox.SGN_DANGER, "Ha ocurrido un error. No se ha guardado ningun cambio.", ex); msg.show(Shared.getMyMainWindows()); System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Ha ocurrido un error. Haciendo Roll back..." + ex1.getMessage()); } } finally { try { c.close(); } catch (SQLException ex) { System.out.println( "[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Ha ocurrido un error cerrando la conexion. " + ex.getMessage()); } } }
public static void main(String[] args) { MessageBox mb = new MessageBox(); mb.show("Hello World", "JNI"); }