|
|
@@ -0,0 +1,58 @@
|
|
|
+package openapi.tools;
|
|
|
+
|
|
|
+import p2.p2server.P2Server;
|
|
|
+import p2.pao.PaoRemote;
|
|
|
+import p2.pao.PaoSetRemote;
|
|
|
+import p2.util.P2Exception;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+public class FileUploadUtils {
|
|
|
+ public static void test(String siteid,String filename,String tablename,long onwerid) throws P2Exception {
|
|
|
+
|
|
|
+ PaoSetRemote doclinkSet = P2Server.getP2Server().getPaoSet("doclinks", P2Server.getP2Server().getSystemUserInfo());
|
|
|
+ doclinkSet.setWhere("document='"+filename+"' and ownertable='"+tablename+"' and ownerid="+onwerid);
|
|
|
+ doclinkSet.reset();
|
|
|
+ if(doclinkSet.isEmpty()){
|
|
|
+ PaoSetRemote docinfo = P2Server.getP2Server().getPaoSet("docinfo", P2Server.getP2Server().getSystemUserInfo());
|
|
|
+ docinfo.setInsertSite(siteid);
|
|
|
+ docinfo.reset();
|
|
|
+ PaoRemote newdocinfo = docinfo.addAtEnd();
|
|
|
+ newdocinfo.setValue("document", filename, 11L);
|
|
|
+ newdocinfo.setValue("description", "ϵͳµ¼Èë", 11L);
|
|
|
+ newdocinfo.setValue("createdate", new Date(), 11L);
|
|
|
+ newdocinfo.setValue("createby", "P2ADMIN", 11L);
|
|
|
+ newdocinfo.setValue("revision", 1, 11L);
|
|
|
+ newdocinfo.setValue("changeby","P2ADMIN", 11L);
|
|
|
+ newdocinfo.setValue("changedate", new Date(), 11L);
|
|
|
+ newdocinfo.setValue("doctype", "Attachments", 11L);
|
|
|
+ newdocinfo.setValue("urltype", "FILE", 11L);
|
|
|
+ newdocinfo.setValue("urlname", "URLNAME", 11L);
|
|
|
+ newdocinfo.setValue("printthrulinkdflt", 1, 11L);
|
|
|
+ newdocinfo.setValue("usedefaultfilepath", 0, 11L);
|
|
|
+ newdocinfo.setValue("show", 1, 11L);
|
|
|
+ newdocinfo.setValue("langcode", "ZH", 11L);
|
|
|
+ newdocinfo.setValue("postfix", filename.substring(filename.lastIndexOf(".") + 1).toUpperCase(), 11L);
|
|
|
+ newdocinfo.setValue("serialnumber", filename, 11L);
|
|
|
+ newdocinfo.setValue("ownertable",tablename, 11L);
|
|
|
+ newdocinfo.setValue("siteid", siteid, 11L);
|
|
|
+ PaoSetRemote doclinks = newdocinfo.getPaoSet("DOCLINKS");
|
|
|
+ if(doclinks.isEmpty()){
|
|
|
+ PaoRemote newdoclink = doclinks.addAtEnd();
|
|
|
+ newdoclink.setValue("document",filename,11l);
|
|
|
+ newdoclink.setValue("ownertable",tablename,11l);
|
|
|
+ newdoclink.setValue("ownerid",onwerid,11l);
|
|
|
+ newdoclink.setValue("doctype","Attachments",11l);
|
|
|
+ newdoclink.setValue("getlatestversion",1,11l);
|
|
|
+ newdoclink.setValue("printthrulink",1,11l);
|
|
|
+ newdoclink.setValue("copylinktowo",0,11l);
|
|
|
+ newdoclink.setValue("docinfoid",newdocinfo.getUniqueIDValue(),11l);
|
|
|
+ }
|
|
|
+
|
|
|
+ docinfo.save();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|