?? backuparchiveresultaction.java
字號:
/**
備份文件表
*/
package com.stsc.archive.backup;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import java.util.Properties;
import org.apache.struts.util.MessageResources;
import com.stsc.util.STPoolDataSet;
import com.stsc.util.STResultSet;
import java.util.Date;
import java.text.SimpleDateFormat;
import com.stsc.archive.manage.*;
public final class BackupArchiveResultAction extends Action
{
public ActionForward perform(ActionMapping mapping,ActionForm form,
HttpServletRequest req,HttpServletResponse res)
{
ActionErrors errors = new ActionErrors();
if(!Constants.hasPopedom(req, 1))
{
System.out.println("不能進入:你沒有系統管理員這個權限!");
errors.add("err", new ActionError("error.nopopedom"));
saveErrors(req, errors);
return (new ActionForward(mapping.getInput()));
}
String[] temp=req.getParameterValues("serialno");
if(temp!=null && temp.length>0)
{
fArchiveVector archVector = new fArchiveVector();
String strLog = " "; //記錄備份的文件序號
for(int i=0; i<temp.length; i++)
{
//得到一條記錄
fArchive arch = new fArchive();
if( arch.getDataFromDb(Integer.parseInt(temp[i])) )
{
archVector.add(arch);
strLog += temp[i] + ", ";
}
}
/**
得到備份文件
*/
String backupFilename = req.getParameter("backupFilename");
if( (backupFilename == null) || (backupFilename.length() < 1) )
{
errors.add("backupFilename", new ActionError("error.backup.backupFilename"));
saveErrors(req, errors);
return (new ActionForward(mapping.getInput()));
}
//簡單驗證,沒考慮大小寫問題
if(backupFilename.indexOf(".xml") == -1)
{
backupFilename += ".xml";
}
Properties dbBase = new Properties();
dbBase.setProperty("dsJndiName", Constants.ARCHIVE_DBSOURCE_KEY);
STPoolDataSet data = new STPoolDataSet();
String sql = "SELECT BackupRoute FROM fOfficalText";
STResultSet rs = data.getSTResult(sql, dbBase);
if (rs!=null && rs.next())
{
String backupRoute = rs.getString("BackupRoute");
backupFilename = backupRoute + "backupArchive\\" + backupFilename;
}
else
{
backupFilename = "backupArchive\\" + backupFilename;
}
//獲得日志文件路徑文件名,2003.6.6
String logfile = Constants.LOGFILEPATHNAME_KEY;
logfile = CommonSql.getBackupPath() + logfile; //add 6.6
try
{
ReadWritefArchiveXML writexml = new ReadWritefArchiveXML();
if(writexml.writeXMLFile(backupFilename, archVector))
{
LogBean log = new LogBean();
HttpSession session = req.getSession();
User userInfo = (User)(session.getAttribute(Constants.CURRENT_USER_KEY));
if(userInfo != null)
{
log.setUsername(userInfo.getEnterName());
System.out.println(userInfo.getEnterName());
}
log.setAction("文件表備份");
log.setContent("備份文件序號為:" + strLog + "的數據到文件:" + backupFilename);
System.out.println(log.getContent());
AppendLogXml logxml = new AppendLogXml(logfile, log);
}
}catch(Exception e)
{
System.out.println("寫"+backupFilename+"出錯!");
errors.add("abnormity", new ActionError("error.backup.abnormity"));
}
}
if(errors.empty())
{
return mapping.findForward("success");
}
else
{
saveErrors(req, errors);
return (new ActionForward(mapping.getInput()));
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -