New sync to Dropbox

Discussions about CSEntry
cspronatasha
Posts: 8
Joined: July 11th, 2017, 2:46 pm

New sync to Dropbox

Post by cspronatasha »

Hi,

I am having trouble getting around the new synchronization of data to Dropbox from Android tablets. I have two external dictionaries. I have only synced .dat files in the past and understand that the new sync only works with .csdb. I have updated my .pff to read:

[Run Information]
Version=CSPro 7.0
AppType=Entry

[DataEntryInit]
Interactive=Ask

[Files]
Application=.\followup_ghana.ent
InputData=.\followup_ghana.csdb

[ExternalFiles]
BL_INPUT_DATA_DICT=.\lookup1_followup.dat
BL_INPUT_ROST_DICT=.\lookup_roster_followup.dat

[Parameters]

My logic code is below:

Code: Select all

function syncdropbox ()
if syncconnect(Dropbox) then

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

	// get the latest lookup file from Dropbox
    syncdata(GET,BL_INPUT_DATA_DICT);
    syncdata(GET,BL_INPUT_ROST_DICT);
    
    // send the latest survey data to Dropbox
    syncdata(PUT,FOLLOWUP_GHANA_DICT);

    syncdisconnect();

endif;
end;
I am getting an error on line 13( syncdata(PUT,FOLLOWUP_GHANA_DICT);) stating "ERROR: Invalid function call (external dictionary name expected) near line 15 in GLOBAL procedure". When I try and use the simpler synchronization option, through the menu for the designer, I am getting un-readable files in the Data Viewer without using the filename I specified in the .pff (followup_ghana).

Any help would be much appreciated. What I would ideally want is for the data to be saved to a different folder from the .pff and .pen file on Dropbox with each tablet getting its own folder and uploading data by date? Something like the below code (except it doesn't work for me)

Code: Select all

   //string Date=edit("999999",sysdate("DDMMYY"));
    //syncfile(PUT,"*.csdb",concat("ifpri_mnutrition_ghana/Data/followup_field","/", getusername(), "/",Date,"/")) ;

    //syncdisconnect();
Many thanks in advance.
josh
Posts: 2401
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: New sync to Dropbox

Post by josh »

If you want to emulate the behavior of the old PNC based sync then use text (.dat) files and use syncfile instead of syncdata. csdb files are bigger that text files to save bandwidth use text. The code you pasted below:

Code: Select all

syncfile(PUT,"*.csdb",concat("ifpri_mnutrition_ghana/Data/followup_field","/", getusername(), "/",Date,"/")) ;
Seems like that could work although without the whole application it is not possible to test. The data files would need to be in the same directory as the application since you are not using an absolute path. If they are in a different folder the above would not find them.

If you want to use syncdata and the new csdb format then the error that you are seeing is because one of the dictionaries you are using (FOLLOWUP_GHANA_DICT) is not a valid external dictionary name in your application. Hard to tell without the whole application but it could be that you forgot to add it as an external dictionary, could be spelled wrong or it could be that it is the main dictionary for the application and not an external dictionary. From your pff file it seems that the latter could be the case here. You would need to use a menu program to do the synchronization so that the main data file is not open. See the "Synchronization from Logic" example in the examples folder.
cspronatasha
Posts: 8
Joined: July 11th, 2017, 2:46 pm

Re: New sync to Dropbox

Post by cspronatasha »

Many thanks, Josh. That is very helpful. I went ahead and used the code below but run into the problem of the folders being created and a text file followup_ghana.dat included in the sub-folder but the file is empty. The same file on the tablet's memory is about 600 KB. Could this be because of what you wrote on the data files needing to be in the same directory as the application? Could you help me a bit more with that part of it - I have deployed the .pff .pen and my external dictionary look up files through a USB in the csentry folder of the tablet. The sync is putting it on Dropbox - I am unsure how to line those two up and confused about why one data file is empty and one is not.

Many thanks in advance for you help.

Code: Select all

function syncdropbox () 
if syncconnect(Dropbox) then
    
    string Date=edit("999999",sysdate("DDMMYY"));
    syncfile(PUT,"followup_ghana.dat",concat("ifpri_mnutrition_ghana/Data/followup_field","/", getusername(), "/",Date,"/")) ;

    syncdisconnect();

endif;
end;
josh
Posts: 2401
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: New sync to Dropbox

Post by josh »

Can you post your application? It is hard to figure these things without something to test. Zip up the application (without data files) and post it here. You can use the pack application to do this.
josh
Posts: 2401
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: New sync to Dropbox

Post by josh »

Thanks for posting the application. That makes it much easier. The problem is that you are trying to sync the main data file but that file is currently being edited so it is locked by the application and can't be read. We should have an error message in such a case to tell you that this cannot be done. We will add that in the future.

In the meantime you have two options. You can create a separate application to do the sync. I've attached an example. You can also use the sync options dialog to do the sync but this will use the new smart sync so you will need to use csdb and you will need to download using DataViewer to get a single csdb file instead of having a bunch of files in the Dropbox.
cspronatasha
Posts: 8
Joined: July 11th, 2017, 2:46 pm

Re: New sync to Dropbox

Post by cspronatasha »

Many thanks with your help with the sync issue - this helps a lot. I look forward to seeing the updated sync in version 7.1.

I have a favor to ask: The application I posted contains identifiers for some of our study participants. In my hurry to solve the problem, I did not think about the implications of putting those online and then came back to delete it this morning and realised that I needed a moderator to do so. Are you a moderator or administrator who can delete that post of mine? I much appreciate all your help.
zerfu1534
Posts: 10
Joined: March 8th, 2023, 3:08 am

sycronization problem through logic

Post by zerfu1534 »

I am novice to CSPRO. I have a simple menu calling the other two application. It works fine offline on laptop. But when synced through the dialog box, the menu misses the other application when run on android. On the other hand, I found it difficult write the logic from the start. Example, the dictionary name is not recognized from SyncData(PUT, ETC_ENT_DICT);
Attachments
CSPro.rar
(130.55 KiB) Downloaded 321 times
justinlakier
Posts: 218
Joined: November 21st, 2022, 4:41 pm

Re: New sync to Dropbox

Post by justinlakier »

Hi Zerfu,

The .pen files you provided can run the application, but can't be read in the CSPro designer. If you want us to be able to test the code and read the logic, we require the .ENT files as well, in a zip file with the entire application. This can be posted here or, if you'd rather it not be posted publicly, you can send it to us at cspro@lists.census.gov.

In the future, please don't add to a thread that has been inactive for over a year. If existing threads on similar topics haven't helped, create a new thread, linking to the old thread if applicable.

Thank you,
Justin
Last edited by justinlakier on March 9th, 2023, 1:49 pm, edited 1 time in total.
zerfu1534
Posts: 10
Joined: March 8th, 2023, 3:08 am

Re: New sync to Dropbox

Post by zerfu1534 »

Many thanks Justin for your response. I will take your comments in the future. Here is the entire file for your review,
Attachments
ethiotelecom.rar
(806.96 KiB) Downloaded 319 times
justinlakier
Posts: 218
Joined: November 21st, 2022, 4:41 pm

Re: synchronization problem through logic

Post by justinlakier »

Hi Zerfu,

Looking through your logic, the lines in Menu's PROC NAME that you use to execpff use your computer's full path to these files. This won't work anywhere the full path doesn't match your own computer. I used a relative path instead, and changed the section to read

if INTERVIIEWER_MENU=1 or SUPERVISOR_MENU=1 then
execpff("..\Residential\Residential.pff", stop);
elseif INTERVIIEWER_MENU=2 or SUPERVISOR_MENU=2 then
execpff("..\Enterprise\Enterprise.pff", stop);
endif;

Then I deployed the ethiotelecom folder and the geocode csdbs to android, and was able to go from the menu application to the residential and enterprise applications with no problem. If you use absolute paths for navigation anywhere else in your code, I recommend making them relative paths.

Hope that helps,
Justin
Post Reply