123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- $PBExportHeader$f_pbd_update.srf
- $PBExportComments$自动更新PBD-- 函数
- global type f_pbd_update from function_object
- end type
- forward prototypes
- global subroutine f_pbd_update (string f_dwname, transaction f_tran)
- end prototypes
- global subroutine f_pbd_update (string f_dwname, transaction f_tran);//f_pbd_update('all',sqlca)//强行更新PBD中所有的数据窗口
- //f_pbd_update('',sqlca)//比较日期和时间,更新PBD中所有跟后台的时间不一致的数据窗口
- //f_pbd_update('dw_xxx',sqlca)//更新PBD中指定的dw_xxx数据窗口
- string ls_con,ls[4],ls_dwsave,ls_datetime,ls_rid,ls_dw,ls_pbd,ls_err
- long li,li_rows,ll1,ll2,ll3,ll4
- BLOB lblob
- ls_pbd="exportdw.pbd"
- datastore lds,lds2
- lds=create datastore
- lds.dataobject='dw_rpts'
- lds2=create datastore
- lds2.dataobject='dw_rpt_cysx'
- lds.settransobject(f_tran)
- if f_dwname='' or f_dwname='all' then
- ls_con="rfilt='database' and rdname>'0'"//为了减轻此功能更新时间,前台打印dw语法从数据库取
- // ls_con="rdname>'0'"//此语句将把所有dw语法更新
- else
- ls_con="rdname='"+f_dwname+"'"
- end if
- f_myretrieve2(lds,ls_con)
- li_rows=lds.rowcount()
- ls[1]=LibraryDirectory(ls_pbd,Dirall!)
- lds2.ImportString(ls[1])
- lds2.setfilter("pos(#3,'<time:')>0")
- lds2.filter()
- for li=1 to li_rows
- ls_dwsave=lds.getitemstring(li,'rdname')
- ls_datetime=lds.getitemstring(li,'rdatetime')
- ll1=lds2.find("#1='"+ls_dwsave+"'",1,9999)
- if ll1>0 then
- ls[2]=f_rsx2(lds2.getitemstring(ll1,3),'<time:','>')
- else
- ls[2]=''
- end if
- //PBD中dw时间<>报表最后修改时间,要重新产生dw1
- if ls_datetime<>ls[2] or f_dwname='all' then//f_dwname='all'不管日期比较
- openwithparm(w_rpt_message,'%正在生成'+ls_dwsave+',请等候......')
- ls_rid=lds.getitemstring(li,'rid')
- selectblob rsyntax into :lblob from reports where rid=:ls_rid using f_tran;
- if f_tran.sqlcode=0 THEN
- ls_dw=string(lblob)
- if isnull(ls_dw) or ls_dw='' then continue
- ls[4]=lds.getitemstring(li,'rcname')+' <time:'+ls_datetime+'>'
- if LibraryImport(ls_pbd,ls_dwsave,ImportDataWindow!,ls_dw,ls[3],ls[4])=1 then
- else
- ls_err=ls_err+char(13)+'创建'+ls_dwsave+'时的错误:'+ls[3]
- end if
- end if
- close(w_rpt_message)
- end if
- next
- destroy lds
- destroy lds2
- if ls_err>'' then messagebox('提示',ls_err)
- return
- end subroutine
|