public class DrpToOAInfo {
@PersistenceContext
EntityManager entityManager;
private final static String CONFIGURETION_FILE = "send_message_zh.properties";
private static Properties properties = null;
public static Properties readConfiguretion()
{
if (properties == null)
{
try
{
properties = new Properties();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream inputStream = null;
if (cl != null)
{
inputStream = cl.getResourceAsStream(CONFIGURETION_FILE);
}
if (inputStream != null)
{
properties.load(inputStream);
inputStream.close();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
return properties;
}
/**
*
* @param type 接收者類型
* @param id 接收者id
* @param name 接收者名稱
* @param contentVariable 內容中的變動部分
* @param url IP地址、端口號、項目
* @param value 生產計劃單號
* @param configureInformType 通知類型
*/
public static void sendMessage(int type,
String id,
String name,
Object[] contentVariable,
String url,
Object[] value,
String configureInformType)
{
String applictionName = "";
String content = "";
String URL = "";
ReceiveType rt = ReceiveType.DEPARTMENT;
//讀取資源文件
Properties properties = readConfiguretion();
applictionName = properties.getProperty("system.module.appliction.name");
content = MessageFormat.format(properties.getProperty(configureInformType), contentVariable);
URL = url + MessageFormat.format(properties.getProperty(configureInformType + ".url"), value);;
if(type == 0)
{
rt = ReceiveType.PEOPLE;
}
if(type == 1)
{
rt = ReceiveType.DEPARTMENT;
}
if(type == 2)
{
rt = ReceiveType.ROLE;
}
System.out.println("******************************************");
System.out.println("* 類型:"+rt);
System.out.println("* ID:"+id);
System.out.println("* 接收者名稱:"+name);
System.out.println("* 內容:"+content);
System.out.println("* url:"+URL);
System.out.println("******************************************");
StartupMessage sm = new StartupMessage(applictionName, rt,"117", "tonywu", id, name, content, URL);
SendMessage s = new SendMessage();
s.sendMessage(sm);
}
/**
* 從request中得到地址中的參數,
* @param taskID 接收者類型
* @param processorID 處理者ID
* @param processorName 處理者名稱
* @param processorTime 處理時間
*/
public static void overMessage(String[] processorInfo)
{
// 讀取資源文件
Properties properties = readConfiguretion();
String applictionName = properties.getProperty("system.module.appliction.name");
// Calendar date = Calendar.getInstance();
// String t = date.get(Calendar.YEAR)+"-"+date.get(Calendar.MONTH)+"-"+date.get(Calendar.DATE);
BeOverMessage bm = new BeOverMessage(applictionName, processorInfo[1],
"117", "tonywu",new Date());
System.out.println("******************************************");
System.out.println("* taskID類型:"+processorInfo[1]);
System.out.println("* processorIDID:"+processorInfo[2]);
System.out.println("* processorName接收者名稱:"+processorInfo[3]);
System.out.println("* 時間:"+new Date());
System.out.println("******************************************");
SendMessage s = new SendMessage();
s.sendMessage(bm);
}
}