123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- $PBExportHeader$u_report_imex.sru
- forward
- global type u_report_imex from nonvisualobject
- end type
- end forward
- global type u_report_imex from nonvisualobject
- end type
- global u_report_imex u_report_imex
- type variables
- public integer len_headinfo = 100
- end variables
- forward prototypes
- public function integer f_import_report (string arg_importfilename, boolean arg_ifupdate, long arg_rpid, long arg_billid, ref string arg_msg)
- public function integer f_export_report (s_rpt_imex arg_imexport, string arg_exportbfilename, ref string arg_msg)
- end prototypes
- public function integer f_import_report (string arg_importfilename, boolean arg_ifupdate, long arg_rpid, long arg_billid, ref string arg_msg);
- Integer rslt = 1
- Blob blob_rsyntax
- Blob blob_r_headinfo
- Blob blob_importfilename
- String bczh_headinfo
- String headinfo
- String ls_system_id
- String info[]
- Integer ls_k
- Integer ls_psc
- s_rpt_imex s_import_report
- Long ls_new_rpid
- IF f_getblobfromfile_rpt(blob_importfilename,arg_importfilename,arg_msg) = 0 THEN
- rslt = 0
- ELSE
- // bczh_headinfo = Left(String(blob_importfilename),len_headinfo * 3)
- bczh_headinfo = Lefta(String(blob_importfilename, EncodingANSI!),len_headinfo * 3)
- headinfo = f_psw_bczh_rpt(bczh_headinfo,1,sys_power_key)
- ls_k = 0
- ls_psc = 0
- ls_psc = Pos(headinfo,";")
-
- DO WHILE ls_psc > 0
-
- IF Left(headinfo,ls_psc - 1) <> "" THEN
- ls_k ++
- info[ls_k] = Left(headinfo,ls_psc - 1)
- ELSE
- ls_k ++
- info[ls_k] = ""
- END IF
-
- headinfo = Right(headinfo,Len(headinfo) - ls_psc)
- ls_psc = Pos(headinfo,";")
- LOOP
-
- IF ls_k <> 8 THEN
- arg_msg = "信息段检查失败,可能数据包已破坏"
- rslt = 0
- ELSE
- ls_system_id = info[1]
- s_import_report.rpid = Long(info[2])
- s_import_report.RpName = info[3]
- s_import_report.Flag = Long(info[4])
- s_import_report.Ifuse = Long(info[5])
- s_import_report.Billid = Long(info[6])
- s_import_report.auditprint = Long(info[7])
- s_import_report.descrp = info[8]
- // IF ls_system_id <> sys_system_id THEN
- // arg_msg = "导入的不是本系统的数据包,请检查"
- // rslt = 0
- // ELSE
- blob_rsyntax = BlobMid(blob_importfilename,Len(bczh_headinfo) + 1)
-
- IF arg_ifupdate THEN
-
- UPDATEBLOB u_report_list
- Set Rpsyntax = ''
- Where rpid = :arg_rpid
- USING sqlca;
-
- UPDATEBLOB u_report_list
- Set Rpsyntax = :blob_rsyntax
- Where rpid = :arg_rpid
- USING sqlca;
-
- IF sqlca.SQLCode = 0 THEN
- IF sqlca.SQLNRows = 0 THEN
- INSERT INTO u_report_list (
- rpid,
- RpName,
- Flag,
- Ifuse,
- Billid,
- auditprint,
- descrp
- ) VALUES (
- :s_import_report.rpid,
- :s_import_report.RpName,
- :s_import_report.Flag,
- :s_import_report.Ifuse,
- :arg_billid,
- :s_import_report.auditprint,
- :s_import_report.descrp) USING sqlca;
-
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = "加入单据格式基础资料失败" + sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- COMMIT USING sqlca;
-
- UPDATEBLOB u_report_list
- Set Rpsyntax = :blob_rsyntax
- Where rpid = :s_import_report.rpid USING sqlca;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = "更新单据格式数据失败" + sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ELSE
- UPDATE u_report_list
- SET
- RpName = :s_import_report.RpName,
- Flag = :s_import_report.Flag,
- Ifuse = :s_import_report.Ifuse,
- Billid = :arg_billid,
- auditprint = :s_import_report.auditprint,
- descrp = :s_import_report.descrp
- Where rpid = :arg_rpid USING sqlca;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = "更新打印格式基础资料失败" + sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- ELSE
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = "导入打印格式数据失败" + sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- ELSE
- ls_new_rpid = f_sys_scidentity_rpt(0,"u_report_list","rpid",arg_msg,TRUE,sqlca)
- IF ls_new_rpid <= 0 THEN
- arg_msg = "获取打印格式ID失败" + sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- INSERT INTO u_report_list (
- rpid,
- RpName,
- Flag,
- Ifuse,
- Billid,
- auditprint,
- descrp
- ) VALUES (
- :ls_new_rpid,
- :s_import_report.RpName,
- :s_import_report.Flag,
- :s_import_report.Ifuse,
- :arg_billid,
- :s_import_report.auditprint,
- :s_import_report.descrp
- ) USING sqlca;
-
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = "新加入打印格式基础资料失败" + sqlca.SQLErrText
- rslt = 0
- ELSE
- COMMIT USING sqlca;
- UPDATEBLOB u_report_list
- Set Rpsyntax = :blob_rsyntax
- Where rpid = :ls_new_rpid USING sqlca;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = "更新打印格式数据失败" + sqlca.SQLErrText
- rslt = 0
- END IF
- //END IF
- END IF
- END IF
- END IF
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING sqlca;
- ELSE
- COMMIT USING sqlca;
- END IF
- RETURN rslt
- end function
- public function integer f_export_report (s_rpt_imex arg_imexport, string arg_exportbfilename, ref string arg_msg);
- integer rslt = 1
- blob blob_zipfile
- blob blob_r_headinfo
- blob blob_exportfilename
- blob blob_rsyntax
- string headinfo
- string trailinfo
- string r_headinfo
- uo_yfimex uo_export_report
- if arg_imexport.flag = 0 then
- rslt = 0
- arg_msg ="格式/报表:" + arg_imexport.RpName + "没有数据,导出失败"
- goto ext
- end if
- if fileexists(arg_exportbfilename) then
- if not filedelete(arg_exportbfilename) then
- rslt = 0
- arg_msg = "删除临时文件失败(" + arg_exportbfilename + "),请先手动清除!"
- goto ext
- end if
- end if
- selectblob Rpsyntax
- into :blob_rsyntax
- from u_report_list
- where u_report_list.rpid = :arg_imexport.rpid using sqlca;
- if sqlca.sqlcode <> 0 then
- rslt = 0
- arg_msg = "查询格式/报表:" + arg_imexport.RpName + " 格式失败"
- goto ext
- else
- headinfo = headinfo + sys_system_id + ";"
- headinfo = headinfo + string(arg_imexport.rpid) + ";"
- headinfo = headinfo + arg_imexport.RpName + ";"
- headinfo = headinfo + string(arg_imexport.Flag) + ";"
- headinfo = headinfo + string(arg_imexport.Ifuse) + ";"
- headinfo = headinfo + string(arg_imexport.Billid) + ";"
- headinfo = headinfo + string(arg_imexport.auditprint) + ";"
- headinfo = headinfo + arg_imexport.descrp + ";"
- trailinfo = fill("*",len_headinfo - len(headinfo))
- r_headinfo = headinfo + trailinfo
- r_headinfo = f_psw_bczh(r_headinfo,0,sys_power_key)
- blob_r_headinfo = blob(r_headinfo, EncodingANSI!)
- blob_exportfilename = blob_r_headinfo + blob_rsyntax
- if f_saveblobtofile_rpt(blob_exportfilename,arg_exportbfilename,arg_msg) = 0 then
- rslt = 0
- end if
- end if
- ext:
- return rslt
- end function
- on u_report_imex.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on u_report_imex.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|