VFP开发的C/S模式的程序如何实现自动升级功能

最近用VFP开发了一个C/S模式的信息管理系统,由于公司有自己的VPN网路,系统的用户遍布国内外,所以急需要开发一个实现自动升级功能,这样我就可以随时发布信息的补丁包和新开发的功能了。

具体代码要结合程序。

一般这样:

程序A.EXE 和 程序B.EXE (为直正的程序)

1、由 程序A.EXE 连接数据库

2、由 程序A.EXE 取得数据库中 程序B.EXE 的版本(这个版本是在将最新的 程序B.EXE 写入数据库时一同写入的)

3、由 程序A.EXE 取得 程序B.EXE 的版本,如果本地 程序B.EXE 不存在,或版本低于 取得数据库中的版本,就将数据库的 程序B.EXE 读出并生成覆盖本地的 程序B.EXE

4、最后由 程序A.EXE 启动 本地的 程序B.EXE

 

下面是A.EXE的部分VFP代码:

*<-----Write a bat file----------------->*
lc_localPath = ALLTRIM(SYS(5)+SYS(2003))

*!*	copy \\sshc0000\Groups\Everyone_Full_Access\Watson_Xu(CDDLBackup)\Update\wec.exe d:\
*!*	copy \\sshc0000\Groups\Everyone_Full_Access\Watson_Xu(CDDLBackup)\Update\TemplateFiles d:\TemplateFiles
*<-------------local wec.exe path----------->*
*SUBSTR(STRTRAN(ALLTRIM(SYS(5)+SYS(2003)),"\",'"\"')+'"',1,2)+SUBSTR(STRTRAN(ALLTRIM(SYS(5)+SYS(2003)),"\",'"\"')+'"',4,LEN(STRTRAN(ALLTRIM(SYS(5)+SYS(2003)),"\",'"\"'))-1)

*<------------the path like:   c:"\"C:\Program Files"\"My Company Name------------>*
LcLocalWecExePath=STRTRAN(ALLTRIM(SYS(5)+SYS(2003)),"\",'"\"')
*<------------Change the path like: c:\"C:\Program Files"\"My Company Name"\------------>*
LcLocalWecExePath=SUBSTR(LcLocalWecExePath,1,2)+SUBSTR(LcLocalWecExePath,4)+'"\'
LcBatFile1="copy \\sshc0000\Groups\Everyone_Full_Access\Watson_Xu(CDDLBackup)\Update\wec.exe "+LcLocalWecExePath

LcLocalTemplateFilesPath=LcLocalWecExePath+"TemplateFiles\"
LcBatFile2="copy \\sshc0000\Groups\Everyone_Full_Access\Watson_Xu(CDDLBackup)\Update\TemplateFiles  "+LcLocalTemplateFilesPath
*<----------------end---------------------------->*

**Judge the path if existed
lcOtherPath=ALLTRIM(SYS(5)+SYS(2003))+"\Others"
IF !DIRECTORY(lcOtherPath)
    mkdir(lcOtherPath)
ENDIF 
LcLocalTemplateFilesPath=LcLocalWecExePath+"Others\"
LcBatFile3="copy \\sshc0000\Groups\Everyone_Full_Access\Watson_Xu(CDDLBackup)\Update\Others "+LcLocalTemplateFilesPath


IF !FILE(lc_localPath +"\UpdateSystem1.bat")
	lnfile = FCREATE(lc_localPath +"\UpdateSystem1.bat")
	= FWRITE(lnfile,LcBatFile1)
	= FCLOSE(lnfile)
ENDIF 

IF !FILE(lc_localPath +"\UpdateSystem2.bat")
	lnfile = FCREATE(lc_localPath +"\UpdateSystem2.bat")
	= FWRITE(lnfile,LcBatFile2)
	= FCLOSE(lnfile)
ENDIF 

IF !FILE(lc_localPath +"\UpdateSystem3.bat")
	lnfile = FCREATE(lc_localPath +"\UpdateSystem3.bat")
	= FWRITE(lnfile,LcBatFile3)
	= FCLOSE(lnfile)
ENDIF 
*<-----------end------------------------->*

IF USED("Cursor_SytemVersion")
	USE IN Cursor_SytemVersion
ENDIF 	
=SQLEXEC(gnconnhandle,"select * from systemparameter where ParaName='SystemVersion'","Cursor_SytemVersion") 
SELECT Cursor_SytemVersion
lcRemoteSystemVersion=ALLTRIM(Cursor_SytemVersion.ParaValue)

lc_value=""
lc_localPath = ALLTRIM(SYS(5)+SYS(2003))
IF !FILE(lc_localPath +"\SystemVersion.set")
	lnfile = FCREATE(lc_localPath +"\SystemVersion.set")
	= FWRITE(lnfile,"2011.12.12")
	= FCLOSE(lnfile)
ELSE
	lnfile = FOPEN(lc_localPath +"\SystemVersion.set")
	lc_value = FREAD(lnfile,16)
	= FCLOSE(lnfile)
ENDIF 


IF ALLTRIM(lc_Value)<lcRemoteSystemVersion  && Need to update client program
	*Copy remote file into locate directory
	TRY
		RUN UpdateSystem1.bat
		RUN UpdateSystem2.bat
		RUN UpdateSystem3.bat
	CATCH 
		
	ENDTRY 

	*Record new system version
	lnfile =  FOPEN(lc_localPath +"\SystemVersion.set",12)
	= FWRITE(lnfile,lcRemoteSystemVersion)
	= FCLOSE(lnfile)	
	WAIT "Updating Local System..." TIMEOUT 5
ENDIF 


 
*<---------------------------启动程序start----------------------->*
Declare Long WinExec In kernel32 String,Long
=WinExec("wec.exe",1)
*<---------------------------启动程序end----------------------->*


 

 

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值