一种基于.net实现CS架构药店系统自动更新的方法与流程

文档序号:20162924发布日期:2020-03-24 21:12阅读:506来源:国知局
一种基于.net实现CS架构药店系统自动更新的方法与流程

本发明涉及.net技术领域,特别涉及一种基于cs实现药店系统自动更新的方法。



背景技术:

client/server(客户机/服务器)结构,是大家熟知的软件系统体系结构,通过将任务合理分配到client端和server端,降低了系统的通讯开销,需要安装客户端才可进行管理操作。

客户端和服务器端的程序不同,用户的程序主要在客户端,服务器端主要提供数据管理、数据共享、数据及系统维护和并发控制等,客户端程序主要完成用户的具体的业务。

开发比较容易,操作简便,但应用程序的升级和客户端程序的维护较为困难。



技术实现要素:

本发明解决的技术问题在于提供一种基于cs实现药店系统自动更新的方法;本发明解决了传统客户端应用更新麻烦,不能及时更新的问题。

本发明解决上述技术问题的技术方案是:

步骤一、获取服务器上的版本号和当前系统的版本号,判断当前系统版本是否需要更新;

步骤二、读取配置文件获取需要更新的文件列表;

步骤三、根据更新列表从服务器上下载更新文件;

步骤四、循环遍历新文件并替换当前版本的旧文件;

步骤五、更新成功重启系统。

本发明的有益效果:通过对比系统版本号,获取服务器上最新的文件,并通过循环遍历更新文件替换当前系统的旧文件,从而做到当前版本的升级与更新。本发明有效的解决了传统客户端应用更新麻烦,不能及时更新的问题。

附图说明

下面结合附图对本发明进一步说明:

图1为本发明的流程图。

具体实施方式

如图1所示,本发明采用如下步骤:

步骤一、获取服务器上的版本号和当前系统的版本号,判断当前系统版本是否需要更新;如:

doubleservicever=double.parse(xmlcontent_service.selectsinglenode("filever").innertext);

doublelocalver=double.parse(xmlcontent_local.selectsinglenode("filever").innertext);

if(servicever>localver){

//更新处理

}

步骤二、读取配置文件获取需要更新的文件列表;如:

privatelist<su_file>m_serverfilelist=newlist<su_file>();

for(inti=0;i<node.childnodes.count;i++){

m_serverfilelist.add(newsu_file(node.childnodes[i].attributes["name"].value,node.childnodes[i].attributes["date"].value));

}

步骤三、根据更新列表从服务器上下载更新文件;如:

if(file.exists(strupdatefile+"tmp"))file.delete(strupdatefile+"tmp");

file.move(strupdatefile,strupdatefile+"tmp");

//下载更新

setupdatelab(string.format("更新自身"),

enum.updatestate.downloading);

using(webclientwcdown=newwebclient()){

try{

wcdown.encoding=system.text.encoding.getencoding("utf-8");

wcdown.downloadfile(_downloadurl+m_serverfilelist[i].name,strupdatefile);

}

catch(exceptionex){

messagebox.show(ex.message.tostring());

returnfalse;}

}

步骤四、循环遍历新文件并替换当前版本的旧文件;如:

for(inti=0;i<updatefilecount;i++){

setupdatelab(string.format("正在更新第{0}个文件:{1}",(i+1).tostring(),_updatefilelist[i]),enum.updatestate.downloading);

using(webclientwcdown=newwebclient()){

stringstrtmppath=_downloadsavetemppath;

try{

string[]arrupdatepath=_updatefilelist[i].split(newchar[]{'/'});

//如果没有这个目录,那么建立目录

if(arrupdatepath.length>1){

for(intj=0;j<arrupdatepath.length-1;j++){

strtmppath+="\\"+arrupdatepath[j];

if(!directory.exists(strtmppath)){

directory.createdirectory(strtmppath);}

}

}

strtmppath+="\\"+arrupdatepath[arrupdatepath.length-1];

wcdown.downloadfile(_downloadurl+_updatefilelist[i],strtmppath);

}

catch(exceptionex){

messagebox.show(ex.message.tostring());

messagebox.show(_downloadurl+_updatefilelist[i]+"\n"+strtmppath);

returnfalse;}

}

setupdateprobar(100,false);

thread.sleep(100);

}

步骤五、更新成功重启系统;如:

system.diagnostics.process.start("update.exe");

system.diagnostics.process[]ps=system.diagnostics.process.getprocesses();

foreach(system.diagnostics.processpinps){

processprocesses=process.getcurrentprocess();

stringname=processes.processname;

if(p.processname.toupper()==name.toupper()){

p.kill();

//break;//防止存在多个进程,即主程序打开了多次

}

}。

当前第1页1 2 3 
网友询问留言 已有0条留言
  • 还没有人留言评论。精彩留言会获得点赞!
1