Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.82 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.FileInputStream;
  3. import java.io.IOException;
  4. import java.io.InputStreamReader;
  5. import java.nio.charset.StandardCharsets;
  6. import java.sql.*;
  7. import java.util.ArrayList;
  8.  
  9. public class StarApp {
  10.     private static ArrayList<String> sessionid;
  11.     private static ArrayList<String> ixnid;
  12.     private static ArrayList<String> customerid;
  13.     private static final String dburl = "jdbc:oracle:thin:@spb-voxdb-scan.scartel.dc:1521/chatdbvox.scartel.dc";
  14.     private static final String user_virtual_agent = "";
  15.     private static final String password_virtual_agent = "";
  16.  
  17.     private static final String user_ucs = "";
  18.     private static final String password_ucs = "";
  19.  
  20.     private static Connection con;
  21.     private static Statement stmt;
  22.     private static ResultSet rs;
  23.     private static PreparedStatement stmt_in;
  24.  
  25.  
  26.     public static void main(String[] args) {
  27.         StarApp starApp = new StarApp();
  28.         SOAPRequest soapRequest = new SOAPRequest();
  29.         /*sessionid = starApp.getSessionID();
  30.         ixnid = starApp.getIxnID(sessionid);
  31.         customerid = starApp.getCustomerIdByIxnID(ixnid);
  32.         for (int i = 0; i < customerid.size(); i++) {
  33.             System.out.println(customerid.get(i));
  34.         }
  35.         */
  36.         soapRequest.getCustomerIDFromCIS("133223d501b04cb591ddffefda1886e5");
  37.  
  38.  
  39.  
  40.  
  41.     }
  42.  
  43.     public ArrayList<String> getSessionID() {
  44.         ArrayList<String> sessionid = new ArrayList<String>();
  45.         try (BufferedReader reader = new BufferedReader(
  46.                 new InputStreamReader(
  47.                         new FileInputStream("C:\\Users\\mavramenko\\Desktop\\ID.txt"), StandardCharsets.UTF_8))) {
  48.             String line;
  49.             while ((line = reader.readLine()) != null) {
  50.                 sessionid.add(line);
  51.             }
  52.         } catch (IOException e) {
  53.             e.printStackTrace();
  54.         }
  55.  
  56.         return sessionid;
  57.     }
  58.  
  59.     public ArrayList<String> getIxnID(ArrayList<String> sessionid) {
  60.         ArrayList<String> ixid = new ArrayList<>();
  61.         String query = "";
  62.         try {
  63.             Class.forName("oracle.jdbc.OracleDriver");
  64.             con = DriverManager.getConnection(dburl, user_virtual_agent, password_virtual_agent);
  65.             stmt = con.createStatement();
  66.             for (int i = 0; i < sessionid.size(); i++) {
  67.                 query = "select sessionid from chat " +
  68.                         "where bot_sessionid = '" + sessionid.get(i) +
  69.                         "' and rownum = 1";
  70.                 System.out.println("get ixn id SQL: " + query);
  71.                 rs = stmt.executeQuery(query);
  72.  
  73.                 while (rs.next()) {
  74.                     ixid.add(rs.getString(1));
  75.                 }
  76.                 //Thread.sleep(2000);
  77.  
  78.             }
  79.         } catch (Exception e) {
  80.             e.printStackTrace();
  81.         } finally {
  82.             try {
  83.                 con.close();
  84.             } catch (SQLException e) {
  85.                 System.out.println(e);
  86.             }
  87.             try {
  88.                 stmt.close();
  89.             } catch (SQLException e) {
  90.                 System.out.println(e);
  91.             }
  92.             try {
  93.                 rs.close();
  94.             } catch (SQLException e) {
  95.                 System.out.println(e);
  96.             }
  97.         }
  98.  
  99.  
  100.         return ixid;
  101.     }
  102.  
  103.     public ArrayList<String> getCustomerIdByIxnID(ArrayList<String> ixnid) {
  104.         ArrayList<String> customerid = new ArrayList<>();
  105.         String query = "";
  106.         try {
  107.             Class.forName("oracle.jdbc.OracleDriver");
  108.             con = DriverManager.getConnection(dburl, user_ucs, password_ucs);
  109.             stmt = con.createStatement();
  110.             for (int i = 0; i < sessionid.size(); i++) {
  111.                 query = "select STRATTRIBUTE1 from CONTACT " +
  112.                         "where id = (SELECT CONTACTID " +
  113.                         "FROM interaction i" +
  114.                         " where i.id = '" + ixnid.get(i) + "') ";
  115.                 System.out.println("get customer SQL: " + query);
  116.                 rs = stmt.executeQuery(query);
  117.  
  118.                 while (rs.next()) {
  119.                     customerid.add(rs.getString(1));
  120.                 }
  121.                // Thread.sleep(2000);
  122.  
  123.             }
  124.         } catch (Exception e) {
  125.             e.printStackTrace();
  126.         } finally {
  127.             try {
  128.                 con.close();
  129.             } catch (SQLException e) {
  130.                 System.out.println(e);
  131.             }
  132.             try {
  133.                 stmt.close();
  134.             } catch (SQLException e) {
  135.                 System.out.println(e);
  136.             }
  137.             try {
  138.                 rs.close();
  139.             } catch (SQLException e) {
  140.                 System.out.println(e);
  141.             }
  142.         }
  143.  
  144.  
  145.         return customerid;
  146.     }
  147.  
  148.  
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement