$PBExportHeader$uo_oa_flow_fj_downsave.sru forward global type uo_oa_flow_fj_downsave from nonvisualobject end type end forward global type uo_oa_flow_fj_downsave from nonvisualobject end type global uo_oa_flow_fj_downsave uo_oa_flow_fj_downsave type variables transaction ins_tran //数据commit事务 end variables forward prototypes public function integer f_down_fj (long arg_fjid, string arg_fjname, ref blob arg_fjdata, ref string arg_msg) public function integer f_del_fj (long arg_fjid, string arg_fjname, ref string arg_msg) public function integer f_update_fj (long arg_flowid, long arg_fjid, long arg_annextype, string arg_fjname, blob arg_fjbody, long arg_fjtype, long arg_ifdownfj, long arg_iflookfj, decimal arg_filesize, ref string arg_msg, boolean arg_ifcommit) public function integer f_update_blob_fj (long arg_fjid, string arg_fjname, blob arg_fjbody, ref string arg_msg, boolean arg_ifcommit) public function integer f_save_fj (long arg_flowid, long arg_annextype, string arg_fjname, blob arg_fjbody, long arg_fjtype, long arg_ifdownfj, long arg_iflookfj, ref string arg_msg, boolean arg_ifcommit, decimal arg_filesize, integer arg_ifmain) public function integer getflowannex (long arg_flowid, ref s_oa_doc_annex arg_s_oda[]) end prototypes public function integer f_down_fj (long arg_fjid, string arg_fjname, ref blob arg_fjdata, ref string arg_msg);Long rslt = 1,cnt Blob ls_filedata IF arg_fjid <= 0 THEN rslt = 0 arg_msg = '下载附件失败(错误附件ID)' GOTO ext END IF IF arg_fjname = '' THEN rslt = 0 arg_msg = '下载附件失败(错误附件名)' GOTO ext END IF SELECT count(*) INTO :cnt FROM oa_flow_annex WHERE (oa_flow_annex.AnnexNO = :arg_fjid) AND (oa_flow_annex.Filename = :arg_fjname) USING ins_tran; IF ins_tran.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询附件信息失败>>'+ins_tran.SQLErrText GOTO ext END IF SELECTBLOB Fileblob INTO :ls_filedata FROM oa_flow_annex Where (oa_flow_annex.AnnexNO = :arg_fjid) AND (oa_flow_annex.Filename = :arg_fjname) USING ins_tran; IF ins_tran.SQLCode <> 0 THEN rslt = 0 arg_msg = '下载附件失败>>'+ins_tran.SQLErrText GOTO ext END IF arg_fjdata = ls_filedata ext: RETURN rslt end function public function integer f_del_fj (long arg_fjid, string arg_fjname, ref string arg_msg);Long rslt = 1,cnt IF arg_fjid <= 0 THEN rslt = 0 arg_msg = '删除附件失败(错误附件ID)' GOTO ext END IF IF arg_fjname = '' THEN rslt = 0 arg_msg = '删除附件失败(错误附件名)' GOTO ext END IF //SELECT count(*) // INTO :cnt // FROM oa_flow_annex // WHERE (oa_flow_annex.AnnexNO = :arg_fjid) AND // (oa_flow_annex.Filename = :arg_fjname) // USING ins_tran; //IF ins_tran.SQLCode <> 0 THEN // rslt = 0 // arg_msg = '查询附件信息失败>>'+ins_tran.SQLErrText // GOTO ext //END IF delete FROM oa_flow_annex Where (oa_flow_annex.AnnexNO = :arg_fjid) AND (oa_flow_annex.Filename = :arg_fjname) USING ins_tran; IF ins_tran.SQLCode <> 0 THEN rslt = 0 arg_msg = '删除附件失败>>'+ins_tran.SQLErrText GOTO ext END IF ext: RETURN rslt end function public function integer f_update_fj (long arg_flowid, long arg_fjid, long arg_annextype, string arg_fjname, blob arg_fjbody, long arg_fjtype, long arg_ifdownfj, long arg_iflookfj, decimal arg_filesize, ref string arg_msg, boolean arg_ifcommit);//保存附件 Long rslt = 1, cnt Long ls_newid IF arg_flowid <= 0 THEN rslt = 0 arg_msg = '保存附件失败(公文模板ID)' GOTO ext END IF IF IsNull(arg_fjname) Or arg_fjname = '' THEN rslt = 0 arg_msg = '保存附件失败(附件名)' GOTO ext END IF SELECT count(*) INTO :cnt FROM oa_flow_annex WHERE (oa_flow_annex.AnnexNO = :arg_fjid) AND (oa_flow_annex.Filename = :arg_fjname) Using ins_tran; IF ins_tran.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询附件信息失败>>'+ins_tran.SQLErrText GOTO ext END IF UPDATE oa_flow_annex SET annextype = :arg_annextype, Filename = :arg_fjname, Opdate = getdate(), Opemp = :publ_operator, Filetype = :arg_fjtype, IFDOWNFJ = :ARG_IFDOWNFJ, IFLOOKFJ = :ARG_IFLOOKFJ, filesize = :arg_filesize WHERE (AnnexNO = :arg_fjid) Using ins_tran; IF ins_tran.SQLCode <> 0 THEN rslt = 0 arg_msg = '因网络或其它原因保存附件失败>>'+ins_tran.SQLErrText GOTO ext END IF UpdateBlob oa_flow_annex Set Fileblob = :arg_fjbody Where AnnexNO = :arg_fjid Using ins_tran; IF ins_tran.SQLCode <> 0 THEN rslt = 0 arg_msg = '因网络或其它原因保存附件失败>>'+ins_tran.SQLErrText GOTO ext END IF ext: IF rslt = 0 THEN ROLLBACK Using ins_tran; ELSEIF arg_ifcommit THEN COMMIT Using ins_tran; END IF RETURN rslt end function public function integer f_update_blob_fj (long arg_fjid, string arg_fjname, blob arg_fjbody, ref string arg_msg, boolean arg_ifcommit);//保存附件 Long rslt = 1, cnt Long ls_newid //IF arg_flowid <= 0 THEN // rslt = 0 // arg_msg = '保存附件失败(公文模板ID)' // GOTO ext //END IF IF IsNull(arg_fjname) Or arg_fjname = '' THEN rslt = 0 arg_msg = '保存附件失败(附件名)' GOTO ext END IF SELECT count(*) INTO :cnt FROM oa_flow_annex WHERE (oa_flow_annex.AnnexNO = :arg_fjid) AND (oa_flow_annex.Filename = :arg_fjname) Using ins_tran; IF ins_tran.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询附件信息失败>>'+ins_tran.SQLErrText GOTO ext END IF UpdateBlob oa_flow_annex Set Fileblob = :arg_fjbody Where AnnexNO = :arg_fjid Using ins_tran; IF ins_tran.SQLCode <> 0 THEN rslt = 0 arg_msg = '因网络或其它原因保存附件失败>>'+ins_tran.SQLErrText GOTO ext END IF ext: IF rslt = 0 THEN ROLLBACK Using ins_tran; ELSEIF arg_ifcommit THEN COMMIT Using ins_tran; END IF RETURN rslt end function public function integer f_save_fj (long arg_flowid, long arg_annextype, string arg_fjname, blob arg_fjbody, long arg_fjtype, long arg_ifdownfj, long arg_iflookfj, ref string arg_msg, boolean arg_ifcommit, decimal arg_filesize, integer arg_ifmain);//保存附件 Long rslt = 1 Long ls_newid,cnt If arg_flowid <= 0 Then rslt = 0 arg_msg = '保存附件失败(公文模板ID)' Goto ext End If If IsNull(arg_fjname) Or arg_fjname = '' Then rslt = 0 arg_msg = '保存附件失败(附件名)' Goto ext End If //检查流程是否已存在主附件 If arg_ifmain = 1 Then Select count(*) Into :cnt From oa_flow_annex Where FlowID = :arg_flowid And ifmain = 1; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = '查询是否已存在主附件失败,'+sqlca.SQLErrText Goto ext End If If cnt > 0 Then rslt = 0 arg_msg = '本流程已存在主附件,不能重复上传' Goto ext End If End If ls_newid = f_sys_scidentity(0,"oa_flow_annex","AnnexNO",arg_msg,True,id_sqlca) If ls_newid <= 0 Then rslt = 0 Goto ext End If Insert Into oa_flow_annex ( FlowID, annextype, AnnexNO, Filename, Opdate, Opemp, Filetype, IFDOWNFJ, IFLOOKFJ, filesize, ifmain) Values ( :arg_flowid, :arg_annextype, :ls_newid, :arg_fjname, getdate(), :publ_operator, :arg_fjtype, :ARG_IFDOWNFJ, :ARG_IFLOOKFJ, :arg_filesize, :arg_ifmain) Using ins_tran; If ins_tran.SQLCode <> 0 Then rslt = 0 arg_msg = '因网络或其它原因保存附件失败>>'+ins_tran.SQLErrText Goto ext Else Commit Using ins_tran; End If UpdateBlob oa_flow_annex Set Fileblob = :arg_fjbody Where AnnexNO = :ls_newid Using ins_tran; If ins_tran.SQLCode <> 0 Then rslt = 0 arg_msg = '因网络或其它原因保存附件失败>>'+ins_tran.SQLErrText Goto ext End If Commit Using ins_tran; ext: Return rslt end function public function integer getflowannex (long arg_flowid, ref s_oa_doc_annex arg_s_oda[]);//GetFlowAnnex Integer rslt = 1 String arg_msg Long i,ll_i,ll_row Blob lb_FileData s_oa_doc_annex s_oda[] i = 1 Declare cur_mx Cursor For Select AnnexNo, Filename, Filetype, annextype, IFDOWNFJ, IFLOOKFJ, Filesize, ifmain From oa_flow_annex Where flowid = :arg_flowid; Open cur_mx; Fetch cur_mx Into :s_oda[i].AnnexNo, :s_oda[i].FileName, :s_oda[i].Filetype, :s_oda[i].annextype, :s_oda[i].IFDOWNFJ, :s_oda[i].IFLOOKFJ, :s_oda[i].Filesize, :s_oda[i].ifmain; Do While sqlca.SQLCode = 0 If f_down_fj( s_oda[i].AnnexNo, s_oda[i].Filename, lb_FileData, arg_msg) = 0 Then rslt = 0 Goto ext End If s_oda[i].FileBlob = lb_FileData i++ Fetch cur_mx Into :s_oda[i].AnnexNo, :s_oda[i].FileName, :s_oda[i].FileType, :s_oda[i].annextype, :s_oda[i].IFDOWNFJ, :s_oda[i].IFLOOKFJ, :s_oda[i].Filesize, :s_oda[i].ifmain; Loop Close cur_mx; For i = 1 To UpperBound(s_oda) - 1 arg_s_oda[i] = s_oda[i] Next ext: Return rslt end function on uo_oa_flow_fj_downsave.create call super::create TriggerEvent( this, "constructor" ) end on on uo_oa_flow_fj_downsave.destroy TriggerEvent( this, "destructor" ) call super::destroy end on