Last sync time

Discussions about syncing data via Bluetooth, Dropbox, FTP, and using CSWeb
Forum rules
New release: CSPro 8.0
Post Reply
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Last sync time

Post by htuser »

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,
G.VOLNY, a CSProuser from Haiti, since 2004
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Last sync time

Post by josh »

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: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Last sync time

Post by htuser »

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,
G.VOLNY, a CSProuser from Haiti, since 2004
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Last sync time

Post by josh »

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: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Last sync time

Post by htuser »

Thanks a lot Josh. This will work!
G.VOLNY, a CSProuser from Haiti, since 2004
bhavesh.makwana
Posts: 6
Joined: May 2nd, 2019, 5:54 am

Re: Last sync time

Post by bhavesh.makwana »

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: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Last sync time

Post by aaronw »

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: 6
Joined: May 2nd, 2019, 5:54 am

Re: Last sync time

Post by bhavesh.makwana »

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: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Last sync time

Post by aaronw »

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.
Post Reply