Page 1 of 1

Last sync time

Posted: February 26th, 2017, 8:30 pm
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,

Re: Last sync time

Posted: February 27th, 2017, 8:22 am
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).

Re: Last sync time

Posted: March 5th, 2017, 11:48 am
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,

Re: Last sync time

Posted: March 5th, 2017, 12:41 pm
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.

Re: Last sync time

Posted: March 5th, 2017, 12:44 pm
by htuser
Thanks a lot Josh. This will work!

Re: Last sync time

Posted: June 25th, 2019, 8:52 am
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

Re: Last sync time

Posted: June 25th, 2019, 3:12 pm
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.

Re: Last sync time

Posted: June 26th, 2019, 5:43 am
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

Re: Last sync time

Posted: June 26th, 2019, 3:17 pm
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.