f_rpt_import.srf 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. $PBExportHeader$f_rpt_import.srf
  2. $PBExportComments$引入所有报表-- 函数
  3. global type f_rpt_import from function_object
  4. end type
  5. forward prototypes
  6. global function long f_rpt_import (transaction f_t)
  7. end prototypes
  8. global function long f_rpt_import (transaction f_t);datastore lds
  9. long ll,lls,llc,lll
  10. string ls_id,ls_dw,ls_dws
  11. BLOB lblob
  12. if MESSAGEBOX('提示','此操作将会先删除现有的全部报表!~n~n是否继续?',QUESTION!,YESNO!,2)=2 then
  13. return 0
  14. end if
  15. lds=create datastore
  16. lds.dataobject='dw_rpts'
  17. lds.settransobject(f_t)
  18. if not fileexists('reports.txt') then
  19. messagebox('提示','reports.txt文件不存在,不能引入!')
  20. return 0
  21. end if
  22. openwithparm(w_rpt_message,'正在进行,请等候......')
  23. lll=FileLength('reports.txt')
  24. llc=Ceiling(lll/32765)
  25. lll=FileOpen('reports.txt',StreamMode!,Read!,Shared!)
  26. for ll=1 to llc
  27. FileRead(lll,ls_dw)
  28. ls_dws=ls_dws+ls_dw
  29. next
  30. FileClose(lll)
  31. lll=pos(ls_dws,'$$&')
  32. ls_dw=left(ls_dws,lll -1)
  33. ls_dws=mid(ls_dws,lll)
  34. lds.ImportString(ls_dw)
  35. delete from reports using f_t;
  36. commit using f_t;
  37. lds.update()
  38. commit using f_t;
  39. lls=lds.rowcount()
  40. for ll=1 to lls
  41. w_rpt_message.event ue_percent(ll*100/lls)
  42. ls_id=lds.getitemstring(ll,'rid')
  43. llc=pos(ls_dws,'$$&'+ls_id+'$')
  44. lll=pos(ls_dws,'&&$'+ls_id+'&')
  45. ls_dw=mid(ls_dws,llc+len(ls_id)+4,lll -llc -len(ls_id) -4)
  46. ls_dws=mid(ls_dws,lll)
  47. lblob=blob(ls_dw, EncodingANSI!)
  48. updateblob reports set rsyntax=:lblob where rid=:ls_id using f_t;
  49. commit using f_t;
  50. next
  51. close(w_rpt_message)
  52. messagebox('提示','共引入'+string(lls)+'个报表!')
  53. destroy lds
  54. return lls
  55. end function