filedelete function OR filerename function

Discussions about CSEntry
Post Reply
khurshid.arshad
Posts: 572
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

filedelete function OR filerename function

Post by khurshid.arshad »

Dear Team
I want to use filedelete or filerename function in dropbox. Please advice.
Thanks.
a.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: filedelete function OR filerename function

Post by josh »

CSPro does not support those operations for Dropbox only for local files. Why do you need to do that?
khurshid.arshad
Posts: 572
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: filedelete function OR filerename function

Post by khurshid.arshad »

Dear Josh;
Thank you for your reply. Actually we are doing a panel survey.

We have trying to cover migrated households which have migrated from one EA to another EA. For Example.

The Household ID 5 is a migrated household and this household belongs to supervisor one. Supervisor one gets all the basic information and sends the data file in the dropbox and asks supervisor two to conduct the interview of this migrated household. Supervisor two will get the migrated data from the dropbox and conduct the interview.

Why i want to delete this file from the dropbox, maybe supervisor two by mistake gest this file again and replaces updated file.

I am using the fileexist function for the tablet but i want to see if there is any option to use filedelete.

My code is as follows:

Code: Select all

Function synmigratedhh();

	if HH_Type =0 then //Send Migrated data to the server
		If syncconnect (Dropbox )=1 then
			filesname=concat("HH1-",edit("9999", HM_CLUSTER), "-", edit("9999", HM_HOUSE_ID), "-",  edit("99", 0), ".csdb");

					syncfile(PUT, "..\Work\HH\"  + filesname, "Survey\MIG\");
				syncdisconnect();

				close(PSSN_HH1);
					filedelete( "..\Work\HH\" + filesname);
			stop(1);
		else
		endif;



	elseif HH_Type=4 then //Receive Migrated data from the server

{****CHECK FILE NAME EXIST IN TABLET OR NOT**************}
{********************************************************}
		Exists=fileexist (concat("..\WORK\HH\HH1-",edit("9999", HM_CLUSTER), "-", edit("9999", HM_HOUSE_ID), "-",edit("99", 0), ".csdb"));
				filesname=concat("HH1-",edit("9999", HM_CLUSTER), "-", edit("9999", HM_HOUSE_ID), "-",  edit("99", 0), ".csdb");

		if Exists >0 then //If file exist in Tablet 
			errmsg ("You have already [...%s...] in your Tablet.", filesname);
			sel1=accept(concat("You have already [ " ,  filesname ,   " ] in your Tablet"),
				"Error, Don't Download", 		{1}
				"Yes, Download This File"); 	{2}
			if sel1= 1 then
				reenter;
			else
				sel1=accept(concat("You will lost Previous [ ",filesname,   " ] from your Tablet"),

					"Don't Download From The DropBox",
					"Download From The DropBox");

				if sel1=1 then
					reenter;
				else
					if syncconnect(Dropbox)=1 then
						filesname=concat("HH1-",edit("9999", HM_CLUSTER), "-", edit("9999", HM_HOUSE_ID), "-",  edit("99", 0), ".csdb");
						syncfile(GET, "/SURVEY/MIG/" + filesname,"../Work/HH/" + filesname); //first path is dropbox and second path is from tablet
					filedelete("https:" + "//www.dropbox.com/SURVEY/MIG/HH1-0007-0135-00.csdb");
							syncdisconnect();
						stop(1);
					else
					endif;
				endif;
			endif;
		else //If file does not exist in Tablet
			if syncconnect(Dropbox)=1 then
				filesname=concat("HH1-",edit("9999", HM_CLUSTER), "-", edit("9999", HM_HOUSE_ID), "-",  edit("99", 0), ".csdb");
				syncfile(GET, "/SURVEY/MIG/" + filesname,"../Work/HH/" + filesname);
					execsystem("browse: https://www.dropbox.com");
					syncdisconnect();
				stop(1);
			else
			endif;

		endif;
	endif;
end;


	{ ***  MIGRATED DATA TRANSFER TO THE SERVER *** }
	{ ********************END********************** }




Thanks
a.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: filedelete function OR filerename function

Post by josh »

I see. One possibility would be instead of deleting the file to overwrite the file in the Dropbox with an empty file and then when the file is downloaded check if it is not empty before trying to use it.

If I was doing this though I would want to have a shared assignments file that controls which supervisor has access to which household. Then you would not allow a supervisor that was not assigned to that household to download or upload the file. The shared assignments would be a lookup file that you sync between the supervisors.
khurshid.arshad
Posts: 572
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: filedelete function OR filerename function

Post by khurshid.arshad »

Dear Josh;
Thank you for your reply and for guidance. I am using fileexist function instead empty but i will try this option as well. One more question, How we can track migrated member from one Enumeration Area to another Enumeration Area. if you can give me any guidance on this.

Thanks in advance.

a.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: filedelete function OR filerename function

Post by josh »

I'm not sure what you mean by tracking them. I guess you would need to tag the migrated record with a link back to the original record so maybe store the case id and line number of the person who migrated from the original data file.
khurshid.arshad
Posts: 572
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: filedelete function OR filerename function

Post by khurshid.arshad »

Dear Josh

For example:
Enumeration Area 1 and supervisor 1 is looking this area;
Enumeration Area 2 and supervisor 2 is looking this area;

Supervisors have their own households and no one can access other area households.

Now a household member who belongs to area 1 migrated into Area 2. Supervisor 1 conducts the interview of the rest of the members except the one who migrated from area 1 to area 2.

Now supervisor 1 will request the supervisor 2 to conduct the Interview of migrated member.

My question is when the supervisor 2 cannot access supervisor data, how he can conduct the interview of this migrated member.

Thanks.
Arshad
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: filedelete function OR filerename function

Post by josh »

I can't say I've ever done a survey like that. Maybe someone else on the forum has and give you some ideas.
Post Reply