Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.06 KB | None | 0 0
  1. package com.cookiss.drreportgenerator;
  2.  
  3. import java.io.File;
  4. import java.io.FileInputStream;
  5. import java.io.InputStream;
  6. import java.util.Date;
  7. import java.util.Properties;
  8.  
  9. import org.apache.log4j.Logger;
  10. import org.apache.log4j.PropertyConfigurator;
  11.  
  12. import com.cookiss.drreportgenerator.helper.*;
  13. import com.cookiss.drreportgenerator.object.DatabaseConn;
  14. import com.cookiss.drreportgenerator.worker.Checker;
  15.  
  16. public class Main {
  17.  
  18.     private static Logger logger = null;
  19.  
  20.     public static DatabaseConn mssqlDb;
  21.     public static DatabaseConn mysqlDb;
  22.  
  23.     public static String outputReportPath;
  24.     public static int numberOfSuccessReport = 0;
  25.  
  26.     public static void main(String[] args) {
  27.         String input = "khibtiyah.com";
  28.  
  29.         boolean contain = contain(input, ".com");
  30.        
  31.         String removed = input.replaceAll(".c", "-");
  32.         System.out.print(removed);
  33.  
  34.     }
  35.  
  36.     private static boolean contain(String input, String ext) {
  37.         return input.contains(ext);
  38.     }
  39.  
  40.     public static void main2(String[] args) {
  41.         try {
  42.  
  43.             String currentWorkingDir = System.getProperty("user.dir");
  44.  
  45.             File dbPropFile = new File(currentWorkingDir, "config.properties");
  46.             File logPropFile = new File(currentWorkingDir, "log4j.properties");
  47.  
  48.             if (!dbPropFile.exists() || !logPropFile.exists()) {
  49.                 System.out.println("-Config file not found.");
  50.                 App.exit();
  51.             } else {
  52.  
  53.                 // Configure properties file
  54.                 InputStream inl4j = new FileInputStream(logPropFile);
  55.                 Properties props = new Properties();
  56.                 props.load(inl4j);
  57.                 PropertyConfigurator.configure(props);
  58.                 inl4j.close();
  59.  
  60.                 InputStream in = new FileInputStream(dbPropFile);
  61.                 Properties prop = new Properties();
  62.                 prop.load(in);
  63.                 in.close();
  64.  
  65.                 System.out.println("-Configs file successfully loaded");
  66.  
  67.                 // Initialize logger
  68.                 logger = Logger.getLogger(Main.class);
  69.  
  70.                 // Get database connection
  71.                 mssqlDb = new DatabaseConn(); // db: cookiss, drX, drXb, drXc
  72.                 mssqlDb.url = prop.getProperty("mssql_url");
  73.                 mssqlDb.user = prop.getProperty("mssql_username");
  74.                 mssqlDb.password = prop.getProperty("mssql_password");
  75.  
  76.                 mysqlDb = new DatabaseConn(); // db: (websms) cookiss3, 4, 5, fushion
  77.                 mysqlDb.url = prop.getProperty("mysql_url");
  78.                 mysqlDb.user = prop.getProperty("mysql_username");
  79.                 mysqlDb.password = prop.getProperty("mysql_password");
  80.  
  81.                 // Get num of backward day
  82.                 int numOfBackwardDay = Integer.parseInt(prop.getProperty("numOfBackwardDay"));
  83.                 Date dateToCheck = DateTime.addDays(DateTime.now(), -numOfBackwardDay);
  84.  
  85.                 // Get output report path
  86.                 outputReportPath = prop.getProperty("outputReportPath");
  87.  
  88.                 // Get billingIds to process
  89.                 String[] billingIdList = prop.getProperty("billingIdList").split(",");
  90.                 logger.info("Number of report to process: " + billingIdList.length);
  91.  
  92.                 // Run checker
  93.                 Checker checker = new Checker(dateToCheck, billingIdList);
  94.                 checker.run();
  95.  
  96.                 logger.info(numberOfSuccessReport + " report successfully processed. DONE");
  97.             }
  98.         } catch (Exception e) {
  99.             e.printStackTrace();
  100.             App.exit();
  101.         }
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement