123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406 |
- $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
|