package com.seeyon.apps.src_automatic.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import com.seeyon.apps.yonfintech.util.PropertiesUtil;



//import com.seeyon.ctp.util.PropertiesUtil;

public class ConfigKit {
	
	private static Long lastModify;
	
	private static String serviceUrl;
	
	private static String taskTime;
	
	private static String deptNo;
	
	public static synchronized String getServiceUrl() throws IOException {
		// 判断文件更新时间
		File f = new File(A8FolderKit.getApplicationFolder() + "ApacheJetspeed/webapps/seeyon/WEB-INF/cfgHome/plugin/nczc/nczc.properties");
		if(null == lastModify || lastModify.longValue() != f.lastModified()) {
			lastModify = f.lastModified();
			/**
			 * huangzhengguo
			 * 2022-10-09
			 */
			Properties prop = new Properties();
			prop.load(new FileInputStream(f));
//			Properties prop = PropertiesUtil.getFromFile(f);
			/**
			 * end
			 */
			serviceUrl = prop.getProperty("serviceUrl");
			taskTime = prop.getProperty("taskTime");
		}
		return serviceUrl;
	}
	
	public static synchronized String getTaskTime() throws IOException {
		// 判断文件更新时间
		File f = new File(A8FolderKit.getApplicationFolder() + "ApacheJetspeed/webapps/seeyon/WEB-INF/cfgHome/plugin/src_automatic/nczc.properties");
		if(null == lastModify || lastModify.longValue() != f.lastModified()) {
			lastModify = f.lastModified();
			/**
			 * huangzhengguo
			 * 2022-10-09
			 */
			Properties prop = new Properties();
			prop.load(new FileInputStream(f));
//			Properties prop = PropertiesUtil.getFromFile((CtpLocalFile) f);
			/**
			 * end
			 */
			serviceUrl = prop.getProperty("serviceUrl");
			taskTime = prop.getProperty("taskTime");
		}
		return taskTime;
	}
	
	public static synchronized String getDeptNo() throws IOException {
		// 判断文件更新时间
		File f = new File(A8FolderKit.getApplicationFolder() + "ApacheJetspeed/webapps/seeyon/WEB-INF/cfgHome/plugin/nczc/nczc.properties");
		if(null == lastModify || lastModify.longValue() != f.lastModified()) {
			lastModify = f.lastModified();
			/**
			 * huangzhengguo
			 * 2022-10-09
			 */
			Properties prop = new Properties();
			prop.load(new FileInputStream(f));
//			Properties prop = PropertiesUtil.getFromFile((CtpLocalFile) f);
			/**
			 * end
			 */
			serviceUrl = prop.getProperty("serviceUrl");
			taskTime = prop.getProperty("taskTime");
			deptNo = prop.getProperty("deptNo");
		}
		return deptNo;
	}
}
