Android Question Data server advice please

JesseW

Active Member
Licensed User
Longtime User
I have developed and deployed my first cross platform B4X project, Farm Finder, a small utility app for accounts of agricultural truck drivers so see at a glance how far a farm is, how much the trip pays, gps coordinates, and an old farm name if it's changed names recently. It also launches the appropriate maps app and drops a pin on the driveway if requested by the driver. Since it can be used by multiple accounts at multiple companies, it comes with no data installed. It must be entered by the account management, then distributed to the drivers via data update package in an email.

These update packages are sent by placing base-64 encoded csv data on the clipboard and instructing the manager to paste it into the body of an email and send it. The driver reads the instructions at the top of the email which instructs them to touch and hold on the email till the cut n paste menu comes up, touch Select All then Copy and start the app. The app then detects the update and asks to install it. This process must be repeated every time a farm is added or removed or changes names, or pay rates change. This all works very well. but... Some of the drivers are not techies, and someone else must install the update for them.

I'm thinking a better way to do all this would be to have the data on a server on the internet, and each time any data is altered, a complete data package sent to the server as soon as it is entered. Then, each time a driver brings up the app, ie. B4XPages_Appear, it would transparently look to the server and download and install any new updates.

My question is this. I'm not sure if I should use https get, or ftp, or a raw socket connection, or maybe something else I haven't considered. I could use https and have an ASP script on the backend for the processing. But I'm steering towards ftp I think, and wanted to ask you all if there were any better ideas.

Sorry for rambling, and thank you for listening and for any input you have.
 

FrostCodes

Active Member
Licensed User
Longtime User
I have developed and deployed my first cross platform B4X project, Farm Finder, a small utility app for accounts of agricultural truck drivers so see at a glance how far a farm is, how much the trip pays, gps coordinates, and an old farm name if it's changed names recently. It also launches the appropriate maps app and drops a pin on the driveway if requested by the driver. Since it can be used by multiple accounts at multiple companies, it comes with no data installed. It must be entered by the account management, then distributed to the drivers via data update package in an email.

These update packages are sent by placing base-64 encoded csv data on the clipboard and instructing the manager to paste it into the body of an email and send it. The driver reads the instructions at the top of the email which instructs them to touch and hold on the email till the cut n paste menu comes up, touch Select All then Copy and start the app. The app then detects the update and asks to install it. This process must be repeated every time a farm is added or removed or changes names, or pay rates change. This all works very well. but... Some of the drivers are not techies, and someone else must install the update for them.

I'm thinking a better way to do all this would be to have the data on a server on the internet, and each time any data is altered, a complete data package sent to the server as soon as it is entered. Then, each time a driver brings up the app, ie. B4XPages_Appear, it would transparently look to the server and download and install any new updates.

My question is this. I'm not sure if I should use https get, or ftp, or a raw socket connection, or maybe something else I haven't considered. I could use https and have an ASP script on the backend for the processing. But I'm steering towards ftp I think, and wanted to ask you all if there were any better ideas.

Sorry for rambling, and thank you for listening and for any input you have.
I believe you can use https get, this would also make it easy to scale also. If the data is heavy maybe about 1MB+, you can consider splitting the updates into multiple updates or you can write it into a file and download it using Huge file downloader.

This is just my opinion, I might be wrong based on your use case.
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
I may be over simplifying here but why download the entire file to each device?

Set up a database on a VPS and use jrdc2 to allow your app to get just the information it needs.
 
Upvote 0

JesseW

Active Member
Licensed User
Longtime User
I believe you can use https get, this would also make it easy to scale also.
Thanks. Our original 100 farm file is 8.5k. But I was thinking ftp because I could get a files list and compare the filename, which would be stamped with a timestamp from the Now keyword when it was created and uploaded, to the timestamp in settings to see if it's the same file. I could write a small ASP routine to return the current db version, and another to actually get the data. I will think about this. Thanks for the input

Set up a database on a VPS and use jrdc2 to allow your app to get just the information it needs.
I've never even heard of VPS or jrdc2, but I will check them out. One reason not to implement something like this, is some of the agricultural farms are far away from civilized areas and don't always have cell phone service. Thanks tho...
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
I have developed and deployed my first cross platform B4X project, Farm Finder, a small utility app for accounts of agricultural truck drivers so see at a glance how far a farm is, how much the trip pays, gps coordinates, and an old farm name if it's changed names recently. It also launches the appropriate maps app and drops a pin on the driveway if requested by the driver. Since it can be used by multiple accounts at multiple companies, it comes with no data installed. It must be entered by the account management, then distributed to the drivers via data update package in an email.

These update packages are sent by placing base-64 encoded csv data on the clipboard and instructing the manager to paste it into the body of an email and send it. The driver reads the instructions at the top of the email which instructs them to touch and hold on the email till the cut n paste menu comes up, touch Select All then Copy and start the app. The app then detects the update and asks to install it. This process must be repeated every time a farm is added or removed or changes names, or pay rates change. This all works very well. but... Some of the drivers are not techies, and someone else must install the update for them.

I'm thinking a better way to do all this would be to have the data on a server on the internet, and each time any data is altered, a complete data package sent to the server as soon as it is entered. Then, each time a driver brings up the app, ie. B4XPages_Appear, it would transparently look to the server and download and install any new updates.

My question is this. I'm not sure if I should use https get, or ftp, or a raw socket connection, or maybe something else I haven't considered. I could use https and have an ASP script on the backend for the processing. But I'm steering towards ftp I think, and wanted to ask you all if there were any better ideas.

Sorry for rambling, and thank you for listening and for any input you have.
My app is for nurses working for clients in ther home and uses https with asp.net backend to commun icate with the server - works perectly. I'm sing a JSON string generated on the server written by myself. The database on the server is MS SQL and in the app SQLite. You can send a device ID back to the server and each driver will get only a fraction of the info related to him, not a whole database or a huge file.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
Thanks. Our original 100 farm file is 8.5k. But I was thinking ftp because I could get a files list and compare the filename, which would be stamped with a timestamp from the Now keyword when it was created and uploaded, to the timestamp in settings to see if it's the same file. I could write a small ASP routine to return the current db version, and another to actually get the data. I will think about this. Thanks for the input


I've never even heard of VPS or jrdc2, but I will check them out. One reason not to implement something like this, is some of the agricultural farms are far away from civilized areas and don't always have cell phone service. Thanks tho...
In this case you can use Wi-Fi (do they have Internet?) or wait for Ilan Mask
 
Upvote 0

JesseW

Active Member
Licensed User
Longtime User
In this case you can use Wi-Fi (do they have Internet?) or wait for Ilan Mask
??? We don't always have that long to wait. Since the data files are so small, and can transfer almost instantaneously, I think using the entire file is the right way. And there isn't usually WIFI at the farms. Not for the drivers anyway. But that's no issue. If the app tries an update and it errors out, it can just ignore it and use the list it has and update next time.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
I am a fan of FTP and have used it many times to download small update files in exactly the way that you describe. It works perfectly.

However, FTP is unfashionable and most web programmers these days have probably never used it and will suggest something more up-to-date. Nothing wrong with that, but it does not mean that there is anything bad about FTP in the application that you describe.

If you want to learn about jrdc2 then maybe now is your chance. But, as one of my old managers used to say, "There is nothing wrong with 'adequate'. Once you have found an adequate solution don't waste time looking further.".
 
Last edited:
Upvote 0

JesseW

Active Member
Licensed User
Longtime User
Example of saving the downloaded file:
B4X:
Sub DownloadAndSaveFile (Link As String)
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Link)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
    Dim out As OutputStream = File.OpenOutput(File.DirInternal, "filename.dat", False)
    File.Copy2(j.GetInputStream, out)
    out.Close '<------ very important
End If
j.Release
End Sub

Could this be written like this for a text file?
B4X:
Sub DownloadAndSaveFile (Link As String)
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Link)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then File.WriteString(File.DirInternal, "filename.dat", j.GetString)
j.Release
End Sub
 
Upvote 0
Top