Last sync time

Discussions about syncing data via Bluetooth, Dropbox, FTP, and using CSWeb
htuser
Posts: 382
Joined: December 19th, 2011, 6:26 pm
Location: HAITI

Last sync time

Postby htuser » February 26th, 2017, 8:30 pm

Hi Developer team,
I hope you're fine and hardly working for the next beta, mainly with password protected csdb.

I would like to know if there's a way to use the last time sync from Mysql inside cspro logic? This is very important because we would like that each enumerator to synchronize each day or at specific interval regarding last successful sync.
Thanks in advance,

josh
Posts: 1871
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Last sync time

Postby josh » February 27th, 2017, 8:22 am

This information is not available currently through CSPro logic. We would recommend that you use sysdate()/systime() to capture the time of the last synchronization and save that in settings (using savesetting).

htuser
Posts: 382
Joined: December 19th, 2011, 6:26 pm
Location: HAITI

Re: Last sync time

Postby htuser » March 5th, 2017, 11:48 am

Hi Josh,
Thanks for your precious support. However, this approach doesn't allow cspro logic to know if sync failed or no. Since i want to know the last succeded sync , ideas you give me isn't sufficient. I can do it only if i can retrieve server_revision, direction and timestamp infos from csdb in cspro logic.
Best regards,

josh
Posts: 1871
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Last sync time

Postby josh » March 5th, 2017, 12:41 pm

If sync failed then the sync_data function will return 0. If it succeeded then it will return 1. Only save the date to settings if sync_data returns 1.

htuser
Posts: 382
Joined: December 19th, 2011, 6:26 pm
Location: HAITI

Re: Last sync time

Postby htuser » March 5th, 2017, 12:44 pm

Thanks a lot Josh. This will work!

bhavesh.makwana
Posts: 5
Joined: May 2nd, 2019, 5:54 am

Re: Last sync time

Postby bhavesh.makwana » June 25th, 2019, 8:52 am

josh wrote:If sync failed then the sync_data function will return 0. If it succeeded then it will return 1. Only save the date to settings if sync_data returns 1.


Hi Josh,

It would be great help you share the small example of last sync time.


Thanks & Regards,
Bhavesh

aaronw
Posts: 171
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Last sync time

Postby aaronw » June 25th, 2019, 3:12 pm

Here's an example of what Josh was recommending.
numeric syncTimestamp;

// For brevity I have excluded connect/disconnect logic
if syncdata(PUT,SURVEY_DICT) then
    // Sync was successful
   
syncTimestamp = timestamp;
enddif;

// Use savesetting to make timestamp persistent
savesetting("LastSuccessfulSync", maketext("%d", syncTimestamp));


Now, what you do with the last successful sync is up to you.

bhavesh.makwana
Posts: 5
Joined: May 2nd, 2019, 5:54 am

Re: Last sync time

Postby bhavesh.makwana » June 26th, 2019, 5:43 am

Dear Aaronw,

if you have a small example of last sync application then please provide i am getting error in menu and main prog.

Before syncronization of the data how to get the current time into the database ? Pl. give us some small application which explain the logic.


Thanks & Regards,
Bhavesh

aaronw
Posts: 171
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Last sync time

Postby aaronw » June 26th, 2019, 3:17 pm

I don't have an example. However, I think I've demonstrated the key idea. As Josh stated we don't have the functionality to get the last sync time from the MySQL database through logic. In lieu of that we record the last sync time on the device when it happens.


Return to “Synchronization”