?? constant.java
字號(hào):
/**
* <p>Title: 卓博營運(yùn)支撐系統(tǒng)</p>
*
* <p>Description: 為本企業(yè)內(nèi)部運(yùn)作提供支撐,為企業(yè)資源的E化管理提供解決方案</p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: 卓博信息科技有限公司</p>
*
* @author Henry
* @version 1.0
*/
package com.jobcn.control;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.HashMap;
import java.util.List;
import java.awt.Font;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
/** Constant.java
* function: 系統(tǒng)初始化類
* describe:
*/
public final class Constant {
private static String getContent() {
StringBuilder sb = new StringBuilder();
sb.append(" <system>\r\n");
sb.append(" <systemName>"
+ InitConstant.systemName + "</systemName>\r\n"
);
sb.append(" <aboutText>"
+ InitConstant.aboutText + "</aboutText>\r\n"
);
sb.append(" <systemIconPath>"
+ InitConstant.systemIconPath + "</systemIconPath>\r\n"
);
sb.append(" <trayIconPath>"
+ InitConstant.trayIconPath + "</trayIconPath>\r\n"
);
sb.append(" <systemConfPath>"
+ InitConstant.systemConfPath + "</systemConfPath>\r\n"
);
sb.append(" <taskConfPath>"
+ InitConstant.taskConfPath + "</taskConfPath>\r\n"
);
sb.append(" <logPath>"
+ InitConstant.logPath + "</logPath>\r\n"
);
sb.append(" <mailServers>"
+ InitConstant.mailServers + "</mailServers>\r\n"
);
sb.append(" </system>\r\n");
sb.append(" <tasks>\r\n");
String[] packNames = InitConstant.packNames.split(",");
String[] packPaths = InitConstant.packPaths.split(",");
for (int i=0;i<packNames.length;i++) {
sb.append(" <task>\r\n");
sb.append(" <name>"
+ packNames[i] + "</name>\r\n"
);
sb.append(" <path>"
+ packPaths[i] + "</path>\r\n"
);
sb.append(" </task>\r\n");
}
sb.append(" </tasks>\r\n");
return sb.toString();
}
private static String getSystemValue(String elementName) {
return systemFields.element(elementName).getText();
}
private static String[] getTasksArrayValue(String elementName) {
String[] result = new String[tasks.size()];
for (int j = 0; j < tasks.size(); j++) {
result[j] = ((Element)tasks.get(j)).element(elementName).getText();
}
return result;
}
private static SAXReader reader;
private static Document doc;
private static Element root, systemFields, tasksFields;
private static List tasks;
private static String systemTag = "system", tasksTag = "tasks";
private static final File file = new File(InitConstant.systemConfPath);
public static final String logInitText =
"<?xml version=\"1.0\" encoding=\"gb2312\"?>\r\n<log>\r\n</log>";
static {
if(!file.exists()) {
file.getParentFile().mkdir();
StringBuilder sb = new StringBuilder();
sb.append("<?xml version=\"1.0\" encoding=\"gb2312\"?>\r\n");
sb.append("<Constants>\r\n");
sb.append(getContent());
sb.append("</Constants>\r\n");
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
writer.write(sb.toString());
writer.flush();
writer.close();
sb = null;
} catch (IOException e) {
e.printStackTrace();
}
}
reader = new SAXReader();
try {
doc = reader.read(file);
root = doc.getRootElement();
systemFields = root.element(systemTag);
tasksFields = root.element(tasksTag);
tasks = tasksFields.elements();
} catch (DocumentException e) {
e.printStackTrace();
}
// 初始化日志文件
File logFile = new File(systemFields.element("logPath").getText());
if (!logFile.exists()) {
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(logFile));
bw.write(logInitText);
bw.flush();
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static final String[] taskListData = InitConstant.taskListData.split(",");
public static final String[] generalData = InitConstant.generalData.split(",");
public static final String[] stepData = InitConstant.stepData.split(",");
public static final String[] attempData = InitConstant.attempData.split(",");
public static final String[] attempType = InitConstant.attempType.split(",");
public static final String[] notifyData = InitConstant.notifyData.split(",");
public static final String[] generalType = InitConstant.generalType.split(",");
public static final String[] stepType = InitConstant.stepType.split(",");
public static final String[] stepSuccessAction = InitConstant.stepSuccessAction.split(",");
public static final String[] stepFailureAction = InitConstant.stepFailureAction.split(",");
public static final String[] notifyType = InitConstant.notifyType.split(",");
public static final String[] notifyExecResult = InitConstant.notifyExecResult.split(",");
public static final String[] weekOfMonth = InitConstant.weekOfMonth.split(",");
public static final String[] dayOfWeek = InitConstant.dayOfWeek.split(",");
public static final String[] months = InitConstant.months.split(",");
public static final String[] generalXmlField = InitConstant.generalXmlField.split(",");
public static final String[] stepXmlField = InitConstant.stepXmlField.split(",");
public static final String[] attempXmlField = InitConstant.attempXmlField.split(",");
public static final String[] notifyXmlField = InitConstant.notifyXmlField.split(",");
public static final Font systemFont = new Font("", Font.PLAIN, 12);
public static final String systemName = getSystemValue("systemName");
public static final String aboutText = getSystemValue("aboutText");
public static final Icon systemIcon = new ImageIcon(getSystemValue("systemIconPath"));
public static final ImageIcon trayIcon = new ImageIcon(getSystemValue("trayIconPath"));
public static final String systemConfPath = getSystemValue("systemConfPath");
public static final String taskConfPath = getSystemValue("taskConfPath");
public static final String logPath = getSystemValue("logPath");
public static final String[] mailServers = getSystemValue("mailServers").split(",");
// 以下以 'STEP_TYPE_' 開頭的字段值與stepType中元素位置需一一對(duì)應(yīng)
public static final int STEP_TYPE_MONITOR = 0;
public static final int STEP_TYPE_COPY = 1;
public static final int STEP_TYPE_BACKUP = 2;
public static final int STEP_TYPE_OTHER = 3;
// stepPack 與 stepPath 需一一對(duì)應(yīng)
public static final String[] stepPack = getTasksArrayValue("name");
public static final String[] stepPath = getTasksArrayValue("path");
public static HashMap<Integer, String[]> packMap = new HashMap<Integer, String[]>();
public static HashMap<Integer, String> typeMap = new HashMap<Integer, String>();
static {
for (int i = 0; i < stepType.length; i++) {
typeMap.put(new Integer(i), stepType[i]);
}
}
static {
for (int i = 0; i < stepPack.length; i++) {
packMap.put(new Integer(i), new String[]{stepPack[i], stepPath[i]});
}
}
// 靜態(tài)常量類
private static final class InitConstant {
public static final String systemName = "任務(wù)管理系統(tǒng) V1.0";
public static final String aboutText =
"<html><b>歡迎使用任務(wù)管理系統(tǒng)<BR>"
+"版本:v1.0<BR>作者:Henry</b><BR><BR><BR>"
+"版權(quán)所有:1999-2006東莞市卓博信息科技有限公司 粵B2-20040458";
public static final String systemIconPath = "img/taskManager.jpg";
public static final String trayIconPath = "img/taskManager.jpg";
public static final String systemConfPath = "conf/sys/config.xml";
public static final String taskConfPath = "conf/task/";
public static final String logPath = "log/message.xml";
public static final String taskListData =
"序號(hào),任務(wù)名稱,任務(wù)類型,描述,創(chuàng)建時(shí)間,上次修改時(shí)間,啟動(dòng)/中止";
public static final String generalData =
"名稱,分類,描述,創(chuàng)建時(shí)間,上次修改時(shí)間";
public static final String stepData =
"序號(hào),步驟名稱,類型,別名,路徑,成功時(shí),失敗時(shí),輸出文件";
public static final String attempData =
"序號(hào),調(diào)度名稱,調(diào)度類型,執(zhí)行頻率,創(chuàng)建時(shí)間,上次更新時(shí)間";//,"啟用"};
public static final String attempType = "自動(dòng),一次,重復(fù)";
public static final String notifyData =
"郵件方式,郵件方式條件,郵件地址,抄送,即時(shí)方式,即時(shí)條件,在線ID";
public static final String generalType = "類型一,類型二,類型三,類型四";
public static final String stepType = "監(jiān)控,復(fù)制,備份,其他";
// stepPack 與 stepPath 需一一對(duì)應(yīng)
public static final String packNames =
"復(fù)制一,復(fù)制二,復(fù)制三,復(fù)制四,監(jiān)控WEB服務(wù)器";
public static final String packPaths =
"com.jobcn.task.SALEDeptCusTractList_dest,"
+"com.jobcn.task.SALEDept_TP,"
+"com.jobcn.task.SALEDeptCusTractList,"
+"com.jobcn.task.SALEPerCusTractList,"
+"com.jobcn.task.ServerMonitor";
public static final String stepSuccessAction =
"退出報(bào)告成功的步驟,退出報(bào)告失敗的步驟,轉(zhuǎn)到下一步,轉(zhuǎn)到第一步";
public static final String stepFailureAction =
"退出報(bào)告成功的步驟,退出報(bào)告失敗的步驟,轉(zhuǎn)到下一步,轉(zhuǎn)到第一步";
public static final String notifyType = "電子郵件,即時(shí)通信";
public static final String notifyExecResult =
"當(dāng)任務(wù)執(zhí)行成功時(shí),當(dāng)任務(wù)執(zhí)行失敗時(shí),當(dāng)任務(wù)完成時(shí)";
public static final String weekOfMonth =
"第一個(gè),第二個(gè),第三個(gè),第四個(gè),最后一個(gè)";
public static final String dayOfWeek =
"星期一,星期二,星期三,星期四,星期五,星期六,星期日";
public static final String months =
"一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月"
;
public static final String generalXmlField =
"name,type,desc,create,update";
public static final String stepXmlField =
"id,name,type,byname,path,successAction,failureAction,outputFile";
public static final String attempXmlField =
"id,attempName,execCode,intervalType,createDate,"
+"updateDate,execDate,execHour,execMinute,"
+"intervalCode,anyDayJI,anyWeekJI,anyMonthSelectCode,"
+"anyDayOfMonthJI,anyWeekOfMonthJI,anyDayOfWeekJI,"
+"hourOrMinuteJI,hourOrMinute,endTypeCode,"
+"endHour,endMinute,periodHour,periodMinute,startDate,"
+"startHour,startMinute,endDateCode,endDate,"
+"selectWeeks,selectMonths,enable";
public static final String notifyXmlField =
"isMail,mailAction,address,cc,isOnline,"
+"onlineAction,onlineID";
public static final String mailServers =
"192.168.60.130,192.168.60.131,192.168.60.129";
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -