首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > PB >

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

2012-04-03 
pb 上传下载更新的问题?用以下脚本添加文件 cb_tj.clickedInteger li_retString ls_filepath,ls_filenamed

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
  ifmessagebox('提示','要添加的文件已经在服务器上而且修改时间一样,确定要继续?',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 


  else
loops =ld_filesize/32765 + 1
  end if 
  else
loops =1
  end if 
lb_file=blob("")
FOR i =1 TO Loops step 1
ll_readfile=fileread(ll_filenum,b)  
if ll_readfile =-1 then messagebox('','读取文件错误')
lb_file =lb_file + b
  Next
FileClose(ll_filenum)

ib_total =lb_file

上传cb_sc.click中
long ret,loops,ll_filenum,ll_readfile ,ll_id
String ls_filepath,ls_filename
Integer li_row,i
String ls_version
Decimal ld_filesize
Datetime ldt_create,ldt_modify
string ls_memo ,ls_exp //说明,扩展名
BLOB lb_file,b
Integer li_pos
Integer li_count //统计是否有相同版本号的程序
String ls_modfiydate 

SQLCA.AutoCommit = true


//有一个文件上传并且这个文件已经在列表中时不上传的标志
string ls_bz ='0'
if dw_upload.rowcount() = 0 then 
messagebox("提示",'请添加需上传的文件!') 
return
end if

//打开提示区
openwithparm(w_ts_show,"正在上传文件,请稍后.....")
li_row =1
//一次传一个
ls_version =trim(dw_upload.getitemstring( li_row,"version"))
ls_filename =trim(dw_upload.getitemstring(li_row,"filename"))
ls_filepath =dw_upload.getitemstring( li_row,"path")
ls_memo =dw_upload.getitemstring( li_row,"memo")
ldt_create =dw_upload.getitemdatetime( li_row,"createdate")
ldt_modify =dw_upload.getitemdatetime( li_row,"modifydate")
UPDATEBLOB UPDATE_PROGRAMDATA SET SZ =:ib_total WHERE MC =:ls_filename and NBBB =:ls_version USING SQLCA;
close(w_ts_show)
if ls_bz <>'1' then
COMMIT USING SQLCA;
Messagebox('提示','文件上传成功')
else
return
end if 
SQLCA.AutoCommit = False










[解决办法]

探讨
后来查到是什么错误,都不知道如何解决。
就是
SELECTBLOB SZ INTO :bl_file From UPDATE_PROGRAMDATA WHERE BH = :ll_lstid USING sqlca;
取出来的len(bl_file) 就是比UPDATEBLOB UPDATE_PROGRAMDATA SET SZ =:ib_total WHERE MC =:ls_filena……

热点排行