package reportbuilder; import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import javax.swing.JTextArea; public class ReportBuilder { public static String coreSubPath="ICOOP"; public static String coreName="ICORE"; public static String gcoopAllPath = "c:\\ICOOP_ALL\\"; public static String iReportObjectPathCore = ""; public static String iReportObjectPathCurrent = ""; public static String xmlConnectionString = ""; public static String xmlConfig = ""; public static String prefix = ""; public static String selectedPrinter=""; public static int portNumber = 0; public static int deleteTimeOut = 0; public static String saveReportPath = ""; public static int deleteTimeOutThread = 30; private static SimpleDateFormat messageTimeFormat = new SimpleDateFormat("dd/MM/yy HH:mm:ss", new Locale("th", "TH")); public static void writeMessage(String text) { if (textArea1.getDocument().getLength() > 10000) { textArea1.setText("-- Clear text " + textArea1.getDocument().getLength() + " bytes --\r\n"); } textArea1.append(messageTimeFormat.format(new Date()) + " :: > " + text + "\r\n"); textArea1.setCaretPosition(textArea1.getDocument().getLength()); } public static JTextArea textArea1; public static void main(String[] args) { java.util.Locale.setDefault(new Locale("en", "US")); try { prefix = args[0]; } catch (Exception ex) { return; } try { int timeThread = Integer.parseInt(args[1]); if (timeThread > 0) { deleteTimeOutThread = timeThread; } } catch (Exception ex) { } try{ gcoopAllPath = args[2]+"\\"; }catch(Exception ex){ gcoopAllPath = "C:\\ICOOP_ALL\\";} try{ coreName=args[3]; }catch(Exception ex){ coreName = "ICORE";} try{ coreSubPath=args[4]; }catch(Exception ex){ coreSubPath="ICOOP";} iReportObjectPathCore = gcoopAllPath + coreName + "\\"+coreSubPath+"\\iReport\\Reports\\"; iReportObjectPathCore = gcoopAllPath + prefix + "\\"+coreSubPath+"\\iReport\\Reports\\"; xmlConnectionString = gcoopAllPath + prefix + "\\"+coreSubPath+"\\XmlConfig\\server.connection_string.xml"; xmlConfig = gcoopAllPath + prefix + "\\"+coreSubPath+"\\XmlConfig\\xmlconf.constmap.xml"; if(args.length>=6&&args[5]!=null){//run Convert Oracle to Mysql if(args[5].equalsIgnoreCase("sms")){ System.out.println("Start SMS building"); try{ int connIndex=Integer.parseInt(args[6]); System.out.println("connect to connection index = "+connIndex); sendSMSBuilder.postMessageByConnectionIndex(connIndex); }catch(Exception ex){ ex.printStackTrace(); } }else{ String[] args_=new String[8]; args_[0]=args[5];//TABLES LIST args_[1]=args[6];//Connection Oracle Index args_[2]=args[7];//Connection Mysql Index args_[3]=args[8];//Convert Schema args_[4]=args[9];//Convert Data args_[5]=xmlConnectionString; try{args_[6]=args[10];}catch(Exception e){}//Print SQL try{args_[7]=args[11];}catch(Exception e){}//NUM of Data Convert to Commit ConvertOra2Mysql.main(args_); } }else{ try { XmlParserReport xml = new XmlParserReport(new File(xmlConfig)); for (int i = 0; i < xml.getRowCount(); i++) { String configCode = xml.getItemString(i, "config_code"); switch (configCode) { case "ireport.port": portNumber = Integer.parseInt(xml.getItemString(i, "config_value")); break; case "ireport.delete_pdf_timeout": deleteTimeOut = Integer.parseInt(xml.getItemString(i, "config_value")); break; case "ireport.save_path": saveReportPath = gcoopAllPath + prefix + "\\"+coreSubPath+"\\" + xml.getItemString(i, "config_value"); break; } } } catch (Exception ex) { return; } MainFrame frame = new MainFrame(); frame.setLocation(200, 150); frame.setVisible(true); writeMessage("" + xmlConfig + "\r\n"); writeMessage("iReport Builder for " + prefix + " port " + portNumber + "\r\n"); } } }