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

上面完成了本地端的数据库同步,现在开始实现目标的数据库同步层.这样才能实现真正的同步.

Iteration 1
同步分为本地目标同步 / 远程目标同步
.本地同步实际上就是数据的本地转移,如果是本程序内的同步,就是同一个数据库里面的转移.不同程序的同步就是数据库之间转移.性质一样.
.网站同步则是把目标的CVC放在了远程,实现机制有差别.


Iteration 2
.本地目标同步
就是读取写入另外一个数据库.因此数据操作层只需要把操作对象换到目标就行了.
Download:
.read all the CVCdata under the same projectname. (really? slowly...)
. compare the CVCdata with local database.
.List the New data, (insert directly.)
.List the Conflict data, (do nothing. display it.)
.Neglect the same data, Neglect the old data. (for target)
.Return the new data List to Target database. Then withdraw the data from it.
.Insert the database throw CVCLayer according to the new data list.
.Display the conflict data according to the conflict list.

Upload
.Read the CVCdata with true Mark under the same projectname.
.Process it by CVCLayer, then throw it to target database.
.Target CVCLayer get the CVCData, compare with the target DB. List the Conflict data(Local Version <= TVersion), List the Accept Data (No same data is existed because it is filtered by Mark.)
.return the Lists to local CVCLayer. CVCLayer transmit the data to target. Target get the data. and insert  / update it.

Iteration 3
.远程目标同步
逻辑和上面的一样,唯一就是通讯方式.本地通过直接调用本地的类实现,远程需要调用Web Service.因此要保证接口一致

Iteration 4
.Sync Module _ Download
ASyncController: Responsible for Insert / Delete / update data to Local Database
public void Download(string ProjectName) // call Acync to download
private void BeginDownload() // call CVC Controller to download and set the InsertTable, UpdateTable, ConflictList
private void EndDownload(AcyncCallBack)

.CVC Module : Responsible for concurrency control.
public void Download(ICVCFetcher)
{
//get Target CVC data  as DataTable
//Compare the data one by one from local DB.
//Set the InsertList(LV = null), UpdateList(TV > LV), ConflictList(TV < LV)
//get Target DataTable according to the list above
}

posted @ 2006-11-10 19:25    阅读(312)  评论(0编辑  收藏  举报
IT民工