当前位置: 代码迷 >> PB >> pb 上传下载更新的有关问题
  详细解决方案

pb 上传下载更新的有关问题

热度:101   发布时间:2016-04-29 08:28:35.0
pb 上传下载更新的问题?
用以下脚本添加文件 cb_tj.clicked
Integer li_ret
String ls_filepath,ls_filename
decimal ld_filesize
DateTime ldt_xtsj //系统时间
DateTime ldt_create,ldt_modify //创建时间,修改时间
String ls_bbh , ls_explain //版本号 ,说明
Integer li_i,i
integer li_jc,li_jcrow //检测
string ls_memo ,ls_exp //说明,扩展名
Blob lb_abc
integer li_count
datastore lds_filelist
lds_filelist =create datastore
lds_filelist.dataobject ="dw_gxfile_list"
lds_filelist.settransobject( sqlca)

//string 
li_ret =GetFileOpenName("选择文件",ls_filepath,ls_filename,"","PBD文件(pbd),*.pbd,程序文件(exe),*.exe,dll文件(dll),*.dll,所有文件,*.*")
//取消选择了
if li_ret <> 1 then
return
end if 
ld_filesize =FileLength(ls_filepath)


decimal ld_filesize_new
datetime ldt_create_new,ldt_modify_new

//文件创建,修改时间
ldt_create =gu_pub_func.uf_file_getdatetime( ls_filepath, 0)
ldt_modify =gu_pub_func.uf_file_getdatetime(ls_filepath,2)

//检测是否选择了同一样的文件,并且是同修改时间同大小,等
if dw_upload.rowcount() > 0 then
dw_upload.accepttext( )
li_jcrow =dw_upload.find( "filename ='"+ls_filename+"'", 1,dw_upload.rowcount())
if li_jcrow > 0 then
ldt_create_new =dw_upload.object.CreateDate[li_jcrow]
ldt_modify_new =dw_upload.object.modifydate[li_jcrow]
ld_filesize_new =dw_upload.object.filesize[li_jcrow]
//messagebox(string(ldt_create_new),string(ldt_modify_new)+'|'+string(ld_filesize_new))
IF (li_jcrow > 0 and ld_filesize =ld_filesize_new) then
string ls_1,ls_2,ls_3,ls_4
ls_1 =string(ldt_create,'yyyymmdd hh:mm:ss')
ls_2 =string(ldt_create_new,'yyyymmdd hh:mm:ss')
ls_3 =string(ldt_modify,'yyyymmdd hh:mm:ss')
ls_4 =string(ldt_modify_new,'yyyymmdd hh:mm:ss')

if trim(ls_1)=trim(ls_2) and trim(ls_3)=trim(ls_4) then
messagebox('提示','你选择了完全一样的文件')
return
end if 
end if 
end if 
end if 
//判断在服务器上是否有一样的文件
li_count =lds_filelist.retrieve(trim(ls_filename),ldt_modify)
destroy lds_filelist;
IF li_count > 0 then
  if messagebox('提示','要添加的文件已经在服务器上而且修改时间一样,确定要继续?',QUESTION!,YesNO!,2) =1 then
  else

return
  end if 
end if 

//开启一行准备数据
li_i =dw_upload.insertrow( 0)
Select Count(NBBB) INTO:i FROM UPDATE_PROGRAMDATA WHERE MC=:ls_filename USING SQLCA;
IF i=0 OR isnull(i) then 
i =1 
else
i=i+1
end if 
if li_i > 0 then
  ldt_xtsj =gf_get_xtsj()
  ls_bbh =String(ldt_xtsj,"yyyymmdd")+string(i)
else
return
end if 

dw_upload.setitem( li_i,"version",ls_bbh)
dw_upload.setitem( li_i,"filename",ls_filename)
dw_upload.setitem( li_i,"filesize",ld_filesize)
dw_upload.setitem( li_i,"createdate",ldt_create)
dw_upload.setitem( li_i,"modifydate",ldt_modify)
dw_upload.setitem( li_i,"memo",ls_explain)
dw_upload.setitem( li_i,"path",ls_filepath)
ls_exp =Right(ls_filename,len(ls_filename) - Pos(ls_filename,'.'))

lb_abc = blob("abc") //往filedata字段赋初值
INSERT INTO UPDATE_PROGRAMDATA(MC,EXT,BZ,SZ,DOWN,CREATEDATE,MODIFYDATE,FILESIZE,NBBB)
VALUES(:ls_filename,:ls_exp,:ls_memo,:lb_abc,'Y',:ldt_create,:ldt_modify,:ld_filesize,:ls_bbh) USING SQLCA;

if sqlca.sqlcode = 0 then 
commit using sqlca;
else
messagebox('提示','添加失败,请与管理员联系'+sqlca.sqlerrtext)
rollback using sqlca;
end if 

long ll_filenum
Integer loops,ll_readfile
Blob lb_file,b
//读取数据
ll_filenum =FileOpen(ls_filepath,streammode!,read!,lockread!)
 
if ld_filesize > 32765 then
if mod(ld_filesize,32765) =0 then
loops =ld_filesize/32765