2018-06-25 13:53:47 +08:00

82 lines
2.6 KiB
Plaintext

<%@page import="jbo.app.APP_VERSION"%>
<%@page import="java.net.URLDecoder"%>
<%@page import="com.amarsoft.are.jbo.impl.BizObjectTableMapper"%>
<%@page import="com.amarsoft.awe.util.DBKeyHelp"%>
<%@page import="com.amarsoft.awe.common.attachment.*"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/IncludeBegin.jsp"%>
<%
AmarsoftUpload myAmarsoftUpload = new AmarsoftUpload();
myAmarsoftUpload.initialize(pageContext);
myAmarsoftUpload.upload();
// 用户ID
String USER_ID = (String) myAmarsoftUpload.getRequest()
.getParameter("usreid");
// 上传本地文件名称
String sFileName = (String) myAmarsoftUpload.getRequest()
.getParameter("FILENAME");
String id = CurPage.getParameter("id");
BizObjectManager bom = JBOFactory
.getBizObjectManager(APP_VERSION.CLASS_NAME);
BizObjectQuery boq = bom.createQuery("id=:id").setParameter(
"id", id);
BizObject bo = boq.getSingleResult(true);
if (null == bo) {
%>
<script type="text/javascript">
alert(getMessageText('AWEW1010'));
parent.AsDialog.ClosePage();
</script>
<%
return;
}
// 当前时间
java.util.Date dateNow = new java.util.Date();
SimpleDateFormat sdfTemp = new SimpleDateFormat("yyyy/MM/dd");
String date = sdfTemp.format(dateNow);
String date1 = date;
date1 = date1.replace("/", "");
String RandomName = date1 + "_" + sFileName;
String sFileSaveMode = CurConfig.getConfigure("FileSaveMode");
String sFileSavePath = CurConfig.getConfigure("FileSavePath");
String sFileNameType = CurConfig.getConfigure("FileNameType");
String sFullPath = "";
if (!myAmarsoftUpload.getFiles().getFile(0).isMissing()) {
try {
if (sFileSaveMode.equals("Disk")) {
// 获取全路径
sFullPath = sFileSavePath + "/" + RandomName;
// 保存服务器文件
myAmarsoftUpload.getFiles().getFile(0)
.saveAs(sFullPath);
bo.setAttributeValue("FILE_NAME", sFileName);
bo.setAttributeValue("IMAGE_PATH", sFullPath);
bo.setAttributeValue("MODIFICATOR", USER_ID);
bo.setAttributeValue("MODIFY_DATE", date);
bom.saveObject(bo);
}
} catch (Exception e) {
out.println("An error occurs : " + e.toString());
myAmarsoftUpload = null;
%>
<script type="text/javascript">
alert(getMessageText('AWEW1010'));//上传文件失败!
parent.AsDialog.ClosePage();
</script>
<%
}
}
%>
<script type="text/javascript">
alert(getMessageText('AWEW1013'));//上传文件成功!
parent.AsDialog.ClosePage();
//parent.reloadAttachment();
</script>
<%@ include file="/IncludeEnd.jsp"%>