1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
| Declare Function add_attachment PeopleCode FILE_ATTACH_WRK.ATTACHADD FieldChange; Declare Function delete_attachment PeopleCode FILE_ATTACH_WRK.ATTACHDELETE FieldChange;
Function c_add_attachment(&FSTP_URL_ID, &FSTP_URL_PATH_ID) Returns array of string
If &FSTP_URL_ID = "" Then &FSTP_URL_ID = "C_SFTP_URL"; End-If; If &FSTP_URL_PATH_ID = "" Then &FSTP_URL_PATH_ID = "C_SFTP_URL_PATH"; End-If; Local string &strATTACHSYSFILENAME, &strATTACHUSERFILE; Local array of string &retArrOfString = CreateArrayRept("", 0); Local string &sysFileName = "tencenCOS.log"; &fileLog = GetFile(GetURL(URL.C_TEMP_FILE_PATH) | "LOGS/" | &sysFileName, "A", "UTF8", %FilePath_Absolute); &fileLog.WriteLine("Begin ***** Datetime=" | %Datetime); &strATTACHSYSFILENAME = UuidGen(); add_attachment("URL." | &FSTP_URL_ID, &FILEEXTENSION, &SUBDIRECTORY, &FILESIZE, True, &recname, &strATTACHSYSFILENAME, &strATTACHUSERFILE, &MESSAGE_LVL, &RETCODE); rem WinMessage("&RETCODE=" | &RETCODE); If &RETCODE = 0 Then try Local string &serFilePath = GetURL(@("url." | &FSTP_URL_PATH_ID)) | &strATTACHSYSFILENAME; Local JavaObject &fileOperator = CreateJavaObject("com.qcloud.cos.demo.FileOperatClass"); &fileLog.WriteLine("&serFilePath=" | &serFilePath); Local string &strReturn = &fileOperator.AppendObjectFromLocal(&strATTACHSYSFILENAME, &serFilePath); If Value(&strReturn) > 0 Then Local Record &recC_USER_FILE_TBL = CreateRecord(Record.C_USER_FILE_TBL); &recC_USER_FILE_TBL.ATTACHSYSFILENAME.Value = &strATTACHSYSFILENAME; &recC_USER_FILE_TBL.C_USER_FILENAME.Value = &strATTACHUSERFILE; &recC_USER_FILE_TBL.LASTUPDDTTM.Value = %Datetime; &recC_USER_FILE_TBL.LASTUPDOPRID.Value = %UserId; &recC_USER_FILE_TBL.Insert(); &retArrOfString.Push("1"); &retArrOfString.Push(&strATTACHSYSFILENAME); &retArrOfString.Push(&strATTACHUSERFILE); Local string &strATTACHSYSFILENAME1 = &strATTACHSYSFILENAME; delete_attachment("URL." | &FSTP_URL_ID, &strATTACHSYSFILENAME, &strATTACHUSERFILE, &MESSAGE_LVL, &RETCODE); &fileLog.WriteLine("cosKey=" | &strATTACHSYSFILENAME1 | ",上传成功 "); MessageBox(0, "", 20000, 51, "Message Not Found", "", "成功!"); Else &retArrOfString.Push("0"); &fileLog.WriteLine("Java返回&strReturn=" | &strReturn | ",cosKey=" | &strATTACHSYSFILENAME | ",上传失败!"); MessageBox(0, "", 20000, 51, "Message Not Found", "由于网络原因,", "失败,请重试!"); End-If; catch Exception &e &retArrOfString.Push("0"); &fileLog.WriteLine("cosKey=" | &strATTACHSYSFILENAME | ",上传失败,exception =" | &e.ToString()); MessageBox(0, "", 20000, 51, "Message Not Found", "由于网络原因,", "失败,请重试!"); end-try; End-If; If &RETCODE = 2 Or &RETCODE = 0 Then
If &RETCODE = 2 Then &retArrOfString.Push("2"); End-If; Else
&retArrOfString.Push("0"); &fileLog.WriteLine("PS返回&RETCODE=" | &RETCODE | ",cosKey=" | &strATTACHSYSFILENAME | ",上传失败!"); MessageBox(0, "", 20000, 51, "Message Not Found", "由于网络原因,", "失败,请重试!"); End-If; &fileLog.WriteLine("End ***** Datetime=" | %Datetime); &fileLog.WriteLine(" "); &fileLog.WriteLine(" "); &fileLog.close(); Return &retArrOfString; End-Function;
|