Page 1 of 5

Dropbox Sync

Posted: May 29th, 2017, 6:19 pm
by Anysia
in GLOBAL PROC (MENU APP)
if syncconnect(Dropbox) then

// get the latest versions of the application files from Dropbox
syncfile(GET,"/prog/Menu/Menu.pff");
syncfile(GET,"/prog/Menu/Menu.pen");
syncfile(GET,"/prog/progA/progA.pen");
syncfile(GET,"/prog/progB/progB.pen");
syncfile(GET,"/prog/progB/progGPS.pen");




// send the latest cases to Dropbox
syncdata(PUT,Menu.dcf);
syncdata(PUT,procA.dcf);
syncdata(PUT,progB.dcf);
syncdata(PUT,progGPS.dcf);


syncdisconnect();

endif;

pls i want to use dropbox to sync three apps that use one menu to sync, progA , progB and proGPS are lunched by a common menu. the above code is not working. pls can the forum help

Re: Dropbox Sync

Posted: May 30th, 2017, 2:50 am
by josh
To download the files into separate directories supply the "to" path as the third argument to syncfile. Note that the from path should be relative the directory of the currently running application. So if you have the following directory structure on your tablet:

Code: Select all

CSEntry/
    Menu/
        Menu.pff
        Menu.pen
    progA/
        progA.pen
    progB/
        progB.pen
and you are running the logic from in Menu.pen then your to paths should be relative the directory CSEntry/Menu. So the directory for the menu would be the current directory but progA it would be ../progA/ and for progB it would be ../progB. Using ".." means "up one level" so it takes you from the Menu directory up to the CSEntry directory. Putting it together you would have:
syncfile(GET,"/prog/Menu/Menu.pff"); // Menu gets put in current directory so no need for "to" path
syncfile(GET,"/prog/Menu/Menu.pen");
syncfile(GET,
"/prog/progA/progA.pen", "../progA/"); // ProgA goes in progA directory so use ".." to go up one level
syncfile(GET,"/prog/progB/progB.pen", "../progB/"); // ProgB goes in progB directory so use ".." to go up one level

syncdata() takes the dictionary name not the file name. You can see the dictionary name in the dictionary editor or in the dictionary tree on the left side of the screen in CSPro designer. It will usually be something like SIMPLE_CAPI_DICT so you would use:
syncdata(PUT, SIMPLE_CAPI_DICT)

Re: Dropbox Sync

Posted: May 30th, 2017, 8:55 am
by Anysia
Thanks Josh ... let more help it an error with the sync function

if syncconnect(Dropbox) then ....
i get an error ...

Can you please explain to me why and

Re: Dropbox Sync

Posted: May 31st, 2017, 6:14 pm
by savy
You cannot use syncconnect in proc global. You can either use it in any of the data entry events like preproc, postproc etc . Or Use syncconnect in a user-defined function and call the user-defined function from any of the data entry events.

Re: Dropbox Sync

Posted: June 1st, 2017, 6:40 pm
by Anysia
Hi Savvy thanks,
Based on the above sync script can you help me with an example function on sync with dropbox.
Am confused with which proc i should use the syncconnect.... pls an not advance user.

thanks

Re: Dropbox Sync

Posted: June 1st, 2017, 6:59 pm
by htuser
Hi Anysia,
Please follow this logic for having a user defined function (for syncrhonisation purpose using dropbox)

Code: Select all

function syncusingdropbox ()
if syncconnect(Dropbox) then

    // get the latest versions of the application files from Dropbox
    syncfile(GET,"/MyApp/MyApp.pff");
    syncfile(GET,"/MyApp/MyApp.pen");

    // send the latest cases to Dropbox
    syncdata(PUT,SURVEY_DICT);

    syncdisconnect();

endif;
end;
after, you can call this function :

Code: Select all

syncusingdropbox ()
when you want to sync.
You can find more information in the help part of Cspro.
Hope this will help you!
Htuser,

Re: Dropbox Sync

Posted: June 1st, 2017, 7:06 pm
by savy
In the CSPro examples folder under "1 - Data Entry\Synchronization In Logic" you can see how sync is done using CSWeb.
You can easily change syncWithHeadquarters function to use Dropbox instead of CSWeb as shown below to sync to dropbox
Your dropbox sync code will look something like this
if syncconnect(Dropbox) then
 syncdata(PUT, HOUSEHOLDQUESTIONNAIRE_DICT);
 syncdisconnect();
endif;
Hope this helps

Re: Dropbox Sync

Posted: June 2nd, 2017, 3:38 am
by Anysia
Thanks htuser and Savy

Re: Dropbox Sync

Posted: June 13th, 2017, 5:08 pm
by Vicmar
Dear All
Please can you help me understand how to distribute .pen and .pff files to tablets without making use of synchronization using .pnc script. The synchronization should be done in Dropbox. Interviewers are in various cities, some at considerable distances. Thank you in advance for the help.

Re: Dropbox Sync

Posted: June 19th, 2017, 12:32 pm
by Anysia
Based on the example synchronization i am able to sync multiple applications but the challenge is the .csdb file can not be sync.
I am not able to find out where the problem is:

if syncconnect(Dropbox) then
syncdata(PUT,PTA_DICT);

The .pen files sync successfully