sync logic

Push data flow:

Step
client App
server
1

New Data can be captured in the following flows:

  • new Scan ticket
  • Answer Questions
  • Submit Additional Notes

Each flow will mark the entry in client side as "dirty". When each flow succeeds in the API call (which means server has been updated for individual entry, the "dirty" flag will be removed.

New Data = all entries with "dirty" flag.

Push new data to server. Include the device key (or device id).

 
2

 

Receive the new data.

3   Generate a timestamp (e.g. date time now) and stamp it to the data.
4   Save data to the DB together with the device key.

Pull data flow:


Step
client App
server
1

Pull new data from server.

Include the following parameters:

  • latest timestamp in local storage
  • device key (or device id)

 

 
2   Receive the client timestamp and client device key
3  

Query data from DB with this filter:

  • db timestamp > client timestamp
  • db device key != client device key

Send the resulting data back to client

4 Receive resulting data from server  
5

if record match (e.g. ticket id, customer id) with local storage

update the record locally.

Otherwise, add the new record locally.


你可能感兴趣的:(android)