$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