Dropbox Sync

Discussions about syncing data via Bluetooth, Dropbox, FTP, and using CSWeb
Forum rules
New release: CSPro 8.0
Anysia
Posts: 28
Joined: March 12th, 2016, 6:54 am

Dropbox Sync

Post 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
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Dropbox Sync

Post 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)
Anysia
Posts: 28
Joined: March 12th, 2016, 6:54 am

Re: Dropbox Sync

Post 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
Attachments
errorDropbox.png
errorDropbox.png (8.55 KiB) Viewed 9781 times
savy
Posts: 159
Joined: December 27th, 2012, 1:36 pm

Re: Dropbox Sync

Post 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.
Anysia
Posts: 28
Joined: March 12th, 2016, 6:54 am

Re: Dropbox Sync

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

Re: Dropbox Sync

Post 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,
G.VOLNY, a CSProuser from Haiti, since 2004
savy
Posts: 159
Joined: December 27th, 2012, 1:36 pm

Re: Dropbox Sync

Post 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
Anysia
Posts: 28
Joined: March 12th, 2016, 6:54 am

Re: Dropbox Sync

Post by Anysia »

Thanks htuser and Savy
Vicmar
Posts: 1
Joined: June 13th, 2017, 4:29 pm

Re: Dropbox Sync

Post 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.
Anysia
Posts: 28
Joined: March 12th, 2016, 6:54 am

Re: Dropbox Sync

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