Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.cookiss.drreportgenerator;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.InputStream;
- import java.util.Date;
- import java.util.Properties;
- import org.apache.log4j.Logger;
- import org.apache.log4j.PropertyConfigurator;
- import com.cookiss.drreportgenerator.helper.*;
- import com.cookiss.drreportgenerator.object.DatabaseConn;
- import com.cookiss.drreportgenerator.worker.Checker;
- public class Main {
- private static Logger logger = null;
- public static DatabaseConn mssqlDb;
- public static DatabaseConn mysqlDb;
- public static String outputReportPath;
- public static int numberOfSuccessReport = 0;
- public static void main(String[] args) {
- String input = "khibtiyah.com";
- boolean contain = contain(input, ".com");
- String removed = input.replaceAll(".c", "-");
- System.out.print(removed);
- }
- private static boolean contain(String input, String ext) {
- return input.contains(ext);
- }
- public static void main2(String[] args) {
- try {
- String currentWorkingDir = System.getProperty("user.dir");
- File dbPropFile = new File(currentWorkingDir, "config.properties");
- File logPropFile = new File(currentWorkingDir, "log4j.properties");
- if (!dbPropFile.exists() || !logPropFile.exists()) {
- System.out.println("-Config file not found.");
- App.exit();
- } else {
- // Configure properties file
- InputStream inl4j = new FileInputStream(logPropFile);
- Properties props = new Properties();
- props.load(inl4j);
- PropertyConfigurator.configure(props);
- inl4j.close();
- InputStream in = new FileInputStream(dbPropFile);
- Properties prop = new Properties();
- prop.load(in);
- in.close();
- System.out.println("-Configs file successfully loaded");
- // Initialize logger
- logger = Logger.getLogger(Main.class);
- // Get database connection
- mssqlDb = new DatabaseConn(); // db: cookiss, drX, drXb, drXc
- mssqlDb.url = prop.getProperty("mssql_url");
- mssqlDb.user = prop.getProperty("mssql_username");
- mssqlDb.password = prop.getProperty("mssql_password");
- mysqlDb = new DatabaseConn(); // db: (websms) cookiss3, 4, 5, fushion
- mysqlDb.url = prop.getProperty("mysql_url");
- mysqlDb.user = prop.getProperty("mysql_username");
- mysqlDb.password = prop.getProperty("mysql_password");
- // Get num of backward day
- int numOfBackwardDay = Integer.parseInt(prop.getProperty("numOfBackwardDay"));
- Date dateToCheck = DateTime.addDays(DateTime.now(), -numOfBackwardDay);
- // Get output report path
- outputReportPath = prop.getProperty("outputReportPath");
- // Get billingIds to process
- String[] billingIdList = prop.getProperty("billingIdList").split(",");
- logger.info("Number of report to process: " + billingIdList.length);
- // Run checker
- Checker checker = new Checker(dateToCheck, billingIdList);
- checker.run();
- logger.info(numberOfSuccessReport + " report successfully processed. DONE");
- }
- } catch (Exception e) {
- e.printStackTrace();
- App.exit();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement