80 lines
3.6 KiB
Plaintext
80 lines
3.6 KiB
Plaintext
<%@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=GBK"%>
|
|
<%@ include file="/IncludeBegin.jsp"%><%
|
|
AmarsoftUpload myAmarsoftUpload = new AmarsoftUpload();
|
|
myAmarsoftUpload.initialize(pageContext);
|
|
myAmarsoftUpload.upload();
|
|
|
|
String sDocNo = (String)myAmarsoftUpload.getRequest().getParameter("DocNo"); //文档编号
|
|
String sFileName = (String)myAmarsoftUpload.getRequest().getParameter("FileName"); //文件名称
|
|
//得到不带路径的文件名
|
|
sFileName = StringFunction.getFileName(sFileName);
|
|
sFileName = URLDecoder.decode(URLDecoder.decode(sFileName,"UTF-8"),"UTF-8");
|
|
|
|
//定义数据库操作变量
|
|
SqlObject so = null;
|
|
String sNewSql = "";
|
|
String sFileSaveMode = CurConfig.getConfigure("FileSaveMode");
|
|
String sFileSavePath = CurConfig.getConfigure("FileSavePath");
|
|
String sFileNameType = CurConfig.getConfigure("FileNameType");
|
|
|
|
BizObjectManager bm = JBOFactory.getBizObjectManager("jbo.sys.DOC_ATTACHMENT");
|
|
String trueTable = ((BizObjectTableMapper)bm).getTable(); //取得真实的表名
|
|
String sAttachmentNo = DBKeyHelp.getSerialNo(trueTable,"AttachmentNo");
|
|
BizObject bo = bm.newObject();
|
|
bo.setAttributeValue("DocNo", sDocNo).setAttributeValue("AttachmentNo", sAttachmentNo);
|
|
bm.saveObject(bo);
|
|
|
|
if (!myAmarsoftUpload.getFiles().getFile(0).isMissing()){
|
|
try {
|
|
java.util.Date dateNow = new java.util.Date();
|
|
SimpleDateFormat sdfTemp = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
|
|
String sBeginTime=sdfTemp.format(dateNow);
|
|
|
|
if(sFileSaveMode.equals("Disk")){ //存放文件服务器中
|
|
String sFullPath = FileNameHelper.getFullPath(sDocNo, sAttachmentNo,sFileName, sFileSavePath, sFileNameType, application);
|
|
myAmarsoftUpload.getFiles().getFile(0).saveAs(sFullPath);
|
|
//得到带相对路径的文件名
|
|
String sFilePath = FileNameHelper.getFilePath(sDocNo,sAttachmentNo,sFileName,sFileNameType);
|
|
bo.setAttributeValue("FilePath",sFilePath);
|
|
bo.setAttributeValue("FullPath",sFullPath);
|
|
}
|
|
dateNow = new java.util.Date();
|
|
String sEndTime=sdfTemp.format(dateNow);
|
|
|
|
bo.setAttributeValue("FileSaveMode",sFileSaveMode);
|
|
bo.setAttributeValue("FileName",sFileName);
|
|
bo.setAttributeValue("ContentType",DataConvert.toString(myAmarsoftUpload.getFiles().getFile(0).getContentType()));
|
|
bo.setAttributeValue("ContentLength",DataConvert.toString(String.valueOf(myAmarsoftUpload.getFiles().getFile(0).getSize())));
|
|
bo.setAttributeValue("BeginTime",sBeginTime);
|
|
bo.setAttributeValue("EndTime",sEndTime);
|
|
bo.setAttributeValue("InputUser",CurUser.getUserID());
|
|
bo.setAttributeValue("InputOrg",CurUser.getOrgID());
|
|
bm.saveObject(bo);
|
|
|
|
if(sFileSaveMode.equals("Table")){ //存放数据表中
|
|
myAmarsoftUpload.getFiles().getFile(0).fileToField(Sqlca,"update "+trueTable+" set DocContent=? where DocNo='"+sDocNo+"' and AttachmentNo='"+sAttachmentNo+"'");
|
|
}
|
|
myAmarsoftUpload = null;
|
|
}catch(Exception e){
|
|
out.println("An error occurs : " + e.toString());
|
|
bm.deleteObject(bo);
|
|
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"%> |