个人网站www.pixysoft.net设计系列: 数据库同步的实现

个人网站www.pixysoft.net设计系列: 数据库同步的实现

Iteration 1
.对于本地新增的数据,版本号全部为0
.上传成功后,版本自动加1
.上传失败则直接返回(Web V <= Local V)
.下载成功后,修改本地版本号
.下载失败,直接返回(Web V >= Local V)

Interation 2
.CVCL放在本地端.
.本地直接操作数据库的时候不修改版本(新增的数据自动设0)
.当确定同步的时候,本地数据版本+1,然后上传.如果成功则保存两地版本
.如果失败,则返回失败信息通知处理

Interation 3
.在数据库字段里面添加mark字段,表示是否被修改.
.上传的时候读取mark字段,作为上传内容.
.上传/下载成功后,mark字段自动被设置为false。
.本地数据Insert/update的之后自动设置Mark = true

Interation 4
。在WebDatabase数据库操作类里面增加对mark的控制
。写一个CVController: 放在Database上面.里面提供了与Database一样的接口,通知增加了额外的操作

//Database Method
public Insert / change the mark for the data.
public Update / change the mark for the data.

private ActivateMark
private DeActivateMark

private InitVersion / When create a new data, it should initiate the version for that data.

//Net work method
public Download / download the data from Web: get local data according to the download data, compare the version, insert / update the correct data and list the error data.
public Upload / upload the data to the Web: select all the markTrue data, increate the version and upload.

private IncreateVersion / When upload, the data should pass this method to increate version.
private CompareVersion / When download, the data should be compared with those in local database, and list the conflict ones.


Interation 5 数据删除
。当本地删除了数据,如果是Download,则直接插入/ 如果是Upload,则提示是否删除目标数据
。目标删除了数据(默认为没添加数据),Download 则提示是否删除本地数据.Upload则直接插入

to be continued ...

posted @ 2006-11-09 15:10    阅读(534)  评论(0编辑  收藏  举报
IT民工