How to fix Bi-Directional Synchronization?
Asked Answered
H

0

0

I have a problem with the logic of my synchronization.

Client Database Table Column:
- LastSync (Datetime - This tracks when the last sync occurs)
- LastUpdated (Datetime - This tracks when the data is last updated regardless if its the client or server who updated the data)

Server Database Table Column:
- ServerUpdate (Datetime - This tracks when the server last updated the data)
- ClientUpdate (Datetime - This tracks when the client/user updated the data)

My problem:

To keep the client/user's data updated I get the data from the server whose ServerUpdate is greater than the ClientUpdate (Sample SQL: "Select ID FROM tblContacts WHERE ServerUpdate > ClientUpdate") then I update the client side (meaning I updated the data and the LastSync and LastUpdated).

The problem is when I sync the data of the client it always get the data whose ServerUpdate is greater than the ClientUpdate even though the data is already updated.

For example, the client sync the New Password (that the server changed) of my user that means the ServerUpdate is greater than the ClientUpdate. When you sync the data it will be updated in the client side. However, when you sync again the server is still passing the same data even though the data is already updated.

What can I do to get only the data that is not yet updated even if the ServerUpdate is greater than ClientUpdate?

Hospitable answered 2/12, 2018 at 15:4 Comment(3)
The mobile database adds a dirty flag, and the dirty flag indicates locally added or modified data that will be uploaded to the server on the next synchronization.Compotation
Did you examine your DateTime objects when you check for the last update, I have a feeling that your DateTime object is not getting updated to the latest last sync for some reason which is causing this issue.Amphioxus
@G.hakim it is updating the problem is the server keeps sending the data even though the data has been updatedHospitable

© 2022 - 2024 — McMap. All rights reserved.