我以前试过沿着这条路走,但我没有找到一个干脆的解决方案。
因此,我开始了一个项目,但放弃了,而是要求我的设备直接与 SQL Server 通信。
如果您无法选择直接与服务器通信,那么您的一个数据库(设备上的本地数据库或主服务器上的中央数据库)将需要一个字段来表示某种形式的日期戳和您的设备将需要跟踪此日期戳。
DateTime dateStamp; // on Windows Mobile
private void MockUp() {
ReadDataFromServer();
dateStamp = ReadDateFromServer();
DoStuffInYourProgram();
UpdateAnythingNewerThan(dateStamp);
}
private void ReadDataFromServer() {
// read data from your central server
// and store that data into a DataSet or DataTable
}
private DateTime ReadDateFromServer() {
// this would be better in the ReadDataFromServer() method,
// but it is shown here for clarity
}
private void DoStuffInYourProgram() {
// This isn't a real routine, but rather what you are going
// to have your device doing
}
private void UpdateAnythingNewerThan(DateTime value) {
// read records from your server that are newer than the value
// passed in, then update those values with the new data your
// device has collected.
}
我希望我可以不那么模糊,但这应该会给你一个大致的想法。