// Gui content theo cach nao // Neu content ngan thi phai split ra private static int sendMT(String type, MsgObject msgObject, String sclassname) { Connection connection = null; PreparedStatement statement = null; String sqlString = null; if ("".equalsIgnoreCase(msgObject.getUsertext().trim()) || msgObject.getUsertext() == null) { // Truong hop gui ban tin loi Util.logger.error( sclassname + "@sendMT@userid=" + msgObject.getUserid() + "@serviceid=" + msgObject.getServiceid() + "@requestid=" + msgObject.getRequestid().toString() + "@message is null - LOST MESSAGE"); return 1; } DBPool dbpool = new DBPool(); Util.logger.info( sclassname + "@sendMT@userid=" + msgObject.getUserid() + "@serviceid=" + msgObject.getServiceid() + "@usertext=" + msgObject.getUsertext() + "@messagetype=" + msgObject.getMsgtype() + "@requestid=" + msgObject.getRequestid().toString()); try { connection = dbpool.getConnectionGateway(); if (connection == null) { Util.logger.crisis( sclassname + "@sendMT: Error connection == null" + msgObject.getUserid() + "@TO" + msgObject.getServiceid() + "@" + msgObject.getUsertext() + "@requestid=" + msgObject.getRequestid().toString()); return -1; } // USER_ID, SERVICE_ID, MOBILE_OPERATOR, COMMAND_CODE, CONTENT_TYPE, // INFO, MESSAGE_TYPE, REQUEST_ID sqlString = "INSERT INTO " + Constants.tblMTQueue + "( USER_ID, SERVICE_ID, MOBILE_OPERATOR, COMMAND_CODE, CONTENT_TYPE, INFO, MESSAGE_TYPE, REQUEST_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; // USER_ID, SERVICE_ID, MOBILE_OPERATOR, COMMAND_CODE, // CONTENT_TYPE, INFO, MESSAGE_TYPE, REQUEST_ID if ("1".equalsIgnoreCase(type)) { // Truoc khi gui phai split String[] content = msgObject.getUsertext().split("###"); for (int i = 0; i < content.length; i++) { if (!"".equalsIgnoreCase(content[i])) { statement = connection.prepareStatement(sqlString); statement.setString(1, msgObject.getUserid()); statement.setString(2, msgObject.getServiceid()); statement.setString(3, msgObject.getMobileoperator()); statement.setString(4, msgObject.getKeyword()); statement.setInt(5, msgObject.getContenttype()); statement.setString(6, content[i]); if (i == 0) { statement.setInt(7, 1); } else { statement.setInt(7, 0); } statement.setBigDecimal(8, msgObject.getRequestid()); if (statement.executeUpdate() != 1) { Util.logger.crisis( sclassname + "@sendMT: Error@userid=" + msgObject.getUserid() + "@serviceid=" + msgObject.getServiceid() + "@usertext=" + msgObject.getUsertext() + "@messagetype=" + msgObject.getMsgtype() + "@requestid=" + msgObject.getRequestid().toString()); return -1; } } } return 1; } else { statement = connection.prepareStatement(sqlString); statement.setString(1, msgObject.getUserid()); statement.setString(2, msgObject.getServiceid()); statement.setString(3, msgObject.getMobileoperator()); statement.setString(4, msgObject.getKeyword()); statement.setInt(5, msgObject.getContenttype()); statement.setString(6, msgObject.getUsertext()); statement.setInt(7, msgObject.getMsgtype()); statement.setBigDecimal(8, msgObject.getRequestid()); if (statement.executeUpdate() != 1) { Util.logger.crisis( sclassname + "@sendMT: Error@userid=" + msgObject.getUserid() + "@serviceid=" + msgObject.getServiceid() + "@usertext=" + msgObject.getUsertext() + "@messagetype=" + msgObject.getMsgtype() + "@requestid=" + msgObject.getRequestid().toString()); return -1; } return 1; } } catch (SQLException e) { Util.logger.crisis( sclassname + "@sendMT: Error:@userid=" + msgObject.getUserid() + "@serviceid=" + msgObject.getServiceid() + "@usertext=" + msgObject.getUsertext() + "@messagetype=" + msgObject.getMsgtype() + "@requestid=" + msgObject.getRequestid().toString() + "@" + e.toString()); Util.logger.printStackTrace(e); return -1; } catch (Exception e) { Util.logger.crisis( sclassname + "@sendMT: Error:@userid=" + msgObject.getUserid() + "@serviceid=" + msgObject.getServiceid() + "@usertext=" + msgObject.getUsertext() + "@messagetype=" + msgObject.getMsgtype() + "@requestid=" + msgObject.getRequestid().toString() + "@" + e.toString()); Util.logger.printStackTrace(e); return -1; } finally { dbpool.cleanup(statement); dbpool.cleanup(connection); } }
public static String getContent5(MsgObject msgObject) { Connection connection = null; PreparedStatement statement = null; String sqlString = null; if ("".equalsIgnoreCase(msgObject.getUsertext().trim()) || msgObject.getUsertext() == null) { // Truong hop gui ban tin loi Util.logger.error( "getContent5@userid=" + msgObject.getUserid() + "@serviceid=" + msgObject.getServiceid() + "@requestid=" + msgObject.getRequestid().toString() + "@message is null - LOST MESSAGE"); return null; } DBPool dbpool = new DBPool(); Util.logger.info( "getContent5@userid=" + msgObject.getUserid() + "@serviceid=" + msgObject.getServiceid() + "@usertext=" + msgObject.getUsertext() + "@messagetype=" + msgObject.getMsgtype() + "@requestid=" + msgObject.getRequestid().toString()); try { connection = dbpool.getConnection("smscnt"); if (connection == null) { Util.logger.crisis( "getContent5: Error connection == null" + msgObject.getUserid() + "@TO" + msgObject.getServiceid() + "@" + msgObject.getUsertext() + "@requestid=" + msgObject.getRequestid().toString()); return null; } // USER_ID, SERVICE_ID, MOBILE_OPERATOR, COMMAND_CODE, CONTENT_TYPE, // INFO, MESSAGE_TYPE, REQUEST_ID sqlString = "INSERT INTO mo_queue( USER_ID, SERVICE_ID, MOBILE_OPERATOR, COMMAND_CODE, INFO, REQUEST_ID) VALUES (?, ?, ?, ?, ?, ?)"; // USER_ID, SERVICE_ID, MOBILE_OPERATOR, COMMAND_CODE, // CONTENT_TYPE, INFO, MESSAGE_TYPE, REQUEST_ID statement = connection.prepareStatement(sqlString); statement.setString(1, msgObject.getUserid()); statement.setString(2, msgObject.getServiceid()); statement.setString(3, msgObject.getMobileoperator()); statement.setString(4, msgObject.getKeyword()); statement.setString(5, msgObject.getUsertext()); statement.setBigDecimal(6, msgObject.getRequestid()); if (statement.executeUpdate() != 1) { Util.logger.crisis( "getContent5: Error@userid=" + msgObject.getUserid() + "@serviceid=" + msgObject.getServiceid() + "@usertext=" + msgObject.getUsertext() + "@messagetype=" + msgObject.getMsgtype() + "@requestid=" + msgObject.getRequestid().toString()); return null; } return null; } catch (SQLException e) { Util.logger.crisis( "getContent5: Error:@userid=" + msgObject.getUserid() + "@serviceid=" + msgObject.getServiceid() + "@usertext=" + msgObject.getUsertext() + "@messagetype=" + msgObject.getMsgtype() + "@requestid=" + msgObject.getRequestid().toString() + "@" + e.toString()); return null; } catch (Exception e) { Util.logger.crisis( "getContent5: Error:@userid=" + msgObject.getUserid() + "@serviceid=" + msgObject.getServiceid() + "@usertext=" + msgObject.getUsertext() + "@messagetype=" + msgObject.getMsgtype() + "@requestid=" + msgObject.getRequestid().toString() + "@" + e.toString()); return null; } finally { dbpool.cleanup(statement); dbpool.cleanup(connection); } }