New Sync using dropbox

Discussions about syncing data via Bluetooth, Dropbox, FTP, and using CSWeb
Forum rules
New release: CSPro 8.0
Post Reply
RERII
Posts: 56
Joined: March 4th, 2015, 11:34 am

New Sync using dropbox

Post by RERII »

I know you can copy this example below. Please help

How do I get the sync sign to appear above the case listing in the csentry?
line 5 is suppose to get the .pff file from a folder on dropbox called MyApp right?
line 6 is suppose to get the .pen file from a folder on dropbox called MyApp right?
Line 9 gives me a error in cspro that says "ERROR: Invalid character expression near line 11 in TESTING_FF procedure" anytime I compile. so I can't even create the .pen
I tried using syncfile to send the .dat using PUT but that doesnt work for me either. using this
"syncfile(PUT,"*.dat", "/test/%DEVICEID%/*.dat");"
It is suppose to put any dat file into the deviceid folder within the test folder. It compiles but in csentry it says
CSEntry Error (100113) Invalid file specification:/test/*.dat"
and when I go to the test folder on dropbox it shows a file that says %DEVICEID%, I would think it would create the folder that matches the device ID
and put the dat file in there but nope.

I am at a lost. I definitely do not want to go back to ODK.

1) // connect to Dropbox
2) if syncconnect(Dropbox) = 1 then
3)
4) // get the latest versions of the application files from Dropbox
5) syncfile(GET,"/MyApp/MyApp.pff");
6) syncfile(GET,"/MyApp/MyApp.pen");
7)
8) // send the latest cases to Dropbox
9) syncdata(PUT,TESTING_DICT);
10)
11) syncdisconnect();
12)
13) endif;
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: New Sync using dropbox

Post by josh »

How do I get the sync sign to appear above the case listing in the csentry?
There are two different ways to do sync:

1) use the synchronization options dialog
2) use the sync functions (synconnect, syncdata...) in your application logic.

The sync sign only shows up in the case listing if you use the synchronization options (option 1). Synchronization from logic (option 2) is meant only for advanced situations where you would initiate the synchronization from a menu program. Based on the logic you have, there is no need for you to use the sync functions in logic. If all you want to do is sync a single data file and optionally update the .pen and .pff files then just use the synchronization options. You only need to use the logic functions if you want to sync multiple dictionaries or use Bluetooth.

For details on how to use the synchronization options dialog look in "Synchronization Options" in the help in CSPro. You can also a copy of that help page here: http://csprousers.org/help/CSPro/synchr ... imple.html

If you want to use the logic functions, take a look at the Synchronization in logic example in the CSPro examples folder.

If you go with the synchronization options (which I would recommend), then you can ignore the rest of this post.
line 5 is suppose to get the .pff file from a folder on dropbox called MyApp right?
line 6 is suppose to get the .pen file from a folder on dropbox called MyApp right?
That is correct.
Line 9 gives me a error in cspro that says "ERROR: Invalid character expression near line 11 in TESTING_FF procedure" anytime I compile. so I can't even create the .pen
The code looks ok to me but it is hard to know the issue just looking at a code snippet. Would need you to post the whole application to figure out the problem for sure. If TESTING_DICT has not been added to the application as an external dictionary that could be the problem. Also, to use syncdata, you need the data file to be in csdb format. syncdata does not work with text (.dat) files.
I tried using syncfile to send the .dat using PUT but that doesnt work for me either. using this
"syncfile(PUT,"*.dat", "/test/%DEVICEID%/*.dat");"
It is suppose to put any dat file into the deviceid folder within the test folder. It compiles but in csentry it says
CSEntry Error (100113) Invalid file specification:/test/*.dat"
and when I go to the test folder on dropbox it shows a file that says %DEVICEID%, I would think it would create the folder that matches the device ID and put the dat file in there but nope.
I don't recommend using syncfile with data files. You lose out on all the "smarts" of sync. The entire data file is sent up to the server every time and it will overwrite the existing data on the server. This means you have to name each data file differently which makes the whole sync process quite complex. If you use syncdata() the system takes care of all that for you. It only uploads cases that have changed since the last sync and you don't delete the cases that were already synced.

%DEVICEID% does not work with syncfile. That was used in the old PNC file based sync from version 6. We do not recommend using that for new projects. If you wanted to do the equivalent you could do:
syncfile(PUT,"*.dat", "/test/" + getdeviceid() + "/");
Note that when using synchronization options or using the syncdata() function, you won't see a single data file in the Dropbox. The data is uploaded to a bunch of different files and is not directly readable by CSPro. To retrieve the data from the Dropbox use the DataViewer tool. This will combine all the data that was synced to the Dropbox into a single data file.

http://csprousers.org/help/DataViewer/d ... _data.html
RERII
Posts: 56
Joined: March 4th, 2015, 11:34 am

Re: New Sync using dropbox

Post by RERII »

Josh
Thanks a Mil. I realized the syncdata option was with a menu only after I posted.

With using the synchronization option in the menu, could you guys develop a way to insert the dropbox


I have to start training people within the various counties on the use of mobile devices for our census sometime within the next six months, if the gov can get themselves straightened out. We'll possibly end up using about 8000 tablets. Is there anyway I can load all of those devices with the .pen and .pff files without having to do it manually?
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: New Sync using dropbox

Post by josh »

We are working on a way to make it easier to deploy applications to tablets via sync for version 7.1. That should help.

Another option is since you are ordering a large enough number of tablets you should be able to negotiate with the supplier to install to install CSEntry and your applications for you at the factory. We know of a number of countries that have done that for their censuses although they are larger countries that ordered more than 8000 tablets. Still it would be worth exploring with the suppliers as it will save you quite a bit of time.
RERII
Posts: 56
Joined: March 4th, 2015, 11:34 am

Re: New Sync using dropbox

Post by RERII »

Regarding the ordering of the tablets the GIS director and I had a meeting Sunday and he brought up the same Idea. I've been looking for devices that might be durable for the Census. I wanted to know if I am just using the flat program without the menu application, and I set the synchronization up form the menu, should I load the the dictionary in the same folder as the pen and pff files on dropbox?
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: New Sync using dropbox

Post by josh »

No need to put the dictionary in the Dropbox. It gets uploaded automatically the first time you sync.

Based on our experience with other census applications you will probably eventually need a menu program. In most censuses we see at least two applications: one for listing and one for the household questionnaire. In some cases there is another application for collective quarters or other household types. You then end up with a menu program to tie everything together as well to handle assignments and reports. Once you have the menu program it makes sense to just add sync there so you can sync all the apps at once. We did a training last year focused on Census applications. You might take a look at the notes and examples from that: http://teleyah.com/cspro/SouthAfricaOct2016/ In particular check out out session 8 on menu programs. If you have contacts at the statistics offices in Malawi, Ethiopia or Cameroon you could reach out them as well as they are doing tablet censuses using CSPro and might be willing to share their applications and experience. Lesotho also did a tablet Census using CSPro although they used CSPro 6.3 so the sync logic was quite different.
RERII
Posts: 56
Joined: March 4th, 2015, 11:34 am

Re: New Sync using dropbox

Post by RERII »

Josh

Sorry I phrased the question wrong. Okay Most of the work I do I don't use a menu but I know now from what you are saying I'll need a menu for the Census. I just design the application without a menu usually that is what i meant by flat program. For my current program I created my PEN and PFF files, and added them to Dropbox, also added them to the device. Now the problem is, when I update the dictionary, make changes in the skip pattern, change value labels, or something like that, I run the .PEN and put the file on drop box, when I synchronize it it doesn't update the changes in the device. I expect the PEN i added to the drop box to add the changes when I synchronize.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: New Sync using dropbox

Post by josh »

That works slightly differently depending on how you are doing the sync. If you set it up with the sync options dialog then you need to check the box "Download application files" and then make sure that the path in "Path to application on server" matches the folder that you put your pen and pff files in the Dropbox. So for example if you put your pen and pff files in Dropbox/MyApp then you would put "/MyApp" as "Path to application on server" since the path starts at the Dropbox folder.

If you are using sync from logic then you would add two calls to syncfile() to get the pen and pff:

syncfile(GET, "MyApp/MyApp.pen", "MyApp.pen");
syncfile(GET, "MyApp/MyApp.pff", "MyApp.pff");

The only trick here is making sure you get the paths correct. The first argument is path to the file in the Dropbox. So in the above I'm assuming the files are Dropbox/MyApp. The second argument is the local path which will be relative to the application that is currently running.

In both cases, you do exactly as you said. Each time you modify your application you publish a new pen file and copy it to the Dropbox.

If the app is not getting updated on the devices then it is most likely a problem with the path. Looking at the sync.log file on the device can help debug path problems as it will show the full path on the device that gets used.
Post Reply