FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Update FWH programs via SQL-database?
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Update FWH programs via SQL-database?
Posted: Wed Aug 15, 2018 08:39 AM

Hello,

I have SQL-programmas installed on servers or NAS.
The exe-files are installed on a shared directory on de server. So each time I do an update, all users have the new version.

The only problem is when someone use the database remotly, I have to installed the programm to that PC localy.
The programm is installed on that PC, and via the correct IP-adres and PORT-forwarding, it connect to the database.

I can olso use a VPN-connection, but only to use that, I don't want to do this.

Now I had an idea to read the exe-file in a blob-field of a table in the database, and when the user is connected, the program check's if this is a new version, and write it to the PC.
I only hve to install it one time on the pc, then the updates are automaticly.
Is this a goed idea? Does anyone allready try this?

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Update FWH programs via SQL-database?
Posted: Wed Aug 15, 2018 12:15 PM

Interesting approuch...

This link seems to save exe to blob.

https://osandamalith.com/2016/06/24/sto ... ide-mysql/

viewtopic.php?f=6t=30337hilit=blob+data

viewtopic.php?f=3t=30715hilit=blob+data

Maybe it is a help.

Groetjes,
Marc

&&&&
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Re: Update FWH programs via SQL-database?
Posted: Thu Aug 16, 2018 03:46 AM

Since 2012 I work this way.
My programs connect to my server database and check for new versions. If it does, the program downloads the package from a BLOB / BINARY field '
I use the ADS for this.

Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: Update FWH programs via SQL-database?
Posted: Fri Aug 17, 2018 11:24 AM
Dear Giovany,

Giovany Vecchi wrote:Since 2012 I work this way.
My programs connect to my server database and check for new versions. If it does, the program downloads the package from a BLOB / BINARY field '
I use the ADS for this.

How can you download the program? Because you will know the new version, when you run the program. How do you download to override the opening program?

Thanks for any idea.
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: Update FWH programs via SQL-database?
Posted: Mon Aug 20, 2018 10:12 AM

Hi Dutch,

Let's start with your outdated exe, and let's call it Current.Exe. At start, via ftp/sql or whatever you want to use, find a new version and download that file as NewVersion.exe. At this point we need to call a third program, Updater.exe that will do:
- First, check that NewVersion.exe Exists. If posible, do a checksum validation if possible.
- Rename Current.exe to something else like OldExe+CurDate()
- Rename NewVersion.exe to Current.exe
- Launch Current.exe and finish

You should add extra steps to revert the situation in case sth fails.
KR,

Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: Update FWH programs via SQL-database?
Posted: Mon Aug 20, 2018 11:33 AM

Dear Carlos,

It means, we must have 2 exe files (1 program/ 1 check update) to check new version.

Thanks so much,

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Re: Update FWH programs via SQL-database?
Posted: Mon Aug 20, 2018 02:15 PM
It uses the same executable, downloads a zip file, unzipped into a folder and the program itself creates a .BAT file, and closes the program after it executes the .BAT file.

.BAT
Code (fw): Select all Collapse
@ECHO OFF
cls
ECHO AGUARDE A ATUALIZAÇÃO DO PROGRAMA
:APAGA
CHOICE /T 1 /C y /CS /D y
ATTRIB -R -S -H CARTORIO.EXE
DEL CARTORIO.EXE
IF EXIST CARTORIO.EXE GOTO APAGA
COPY C:\SISTEMAS\PROTWIN\TEMP\UPDATE\CARTORIO.EXE
ECHO ARQUIVO DE ATUALIZACAO PROCESSADO
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: Update FWH programs via SQL-database?
Posted: Tue Aug 21, 2018 03:09 AM

Dear Giovany,

Thank you, I got it.

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: Update FWH programs via SQL-database?
Posted: Tue Aug 21, 2018 06:25 AM

Hi Giovany,

I don't delete the former exe because sth can fail and i don't want to leave the user without the app. And renaming is allowed in case the exe is being executed, but deleting is not always an option.

If possible, add some kind of binary validation to the download, like checking the md5 on the new file. Security is never enough!

KR

Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Re: Update FWH programs via SQL-database?
Posted: Wed Aug 22, 2018 01:48 AM

The running program will check the downloaded files first. After unpacking, the package in addition to the main executable can contain sql script, another executable to run before the upgrade, or perform processes for database actuation when finalizing the program in exclusive mode. All this is you who have to plan to avoid problems.

Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Update FWH programs via SQL-database?
Posted: Wed Aug 22, 2018 08:08 AM

Hi,

I also check for the new version in the exe-file.
Than save it with an temporary name to the PC.
Than create a bat-file that delete de original file, rename the new file and call the program again.
The bat-file is called when exiting the exe-file.
Until now I download the file from a website.
Now I wanted to save in in the SQL-database.
The only problem is that the exe-file is to large (8Mb) to save in the blob-file. Do I do some settings in the server?

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: Update FWH programs via SQL-database?
Posted: Wed Aug 22, 2018 08:59 AM
Dear Marc,

I use upx to compress the EXE file. It works well for many years.
viewtopic.php?f=3&t=35841&hilit=upx#p213562

Marc Vanzegbroeck wrote:Hi,

I also check for the new version in the exe-file.
Than save it with an temporary name to the PC.
Than create a bat-file that delete de original file, rename the new file and call the program again.
The bat-file is called when exiting the exe-file.
Until now I download the file from a website.
Now I wanted to save in in the SQL-database.
The only problem is that the exe-file is to large (8Mb) to save in the blob-file. Do I do some settings in the server?
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Update FWH programs via SQL-database?
Posted: Wed Aug 22, 2018 09:03 AM
Dutch,

I'm also using upx to compress the exe-files, but than I'm also getting the message that the file is too big.


dutch wrote:Dear Marc,

I use upx to compress the EXE file. It works well for many years.
viewtopic.php?f=3&t=35841&hilit=upx#p213562

Marc Vanzegbroeck wrote:Hi,

I also check for the new version in the exe-file.
Than save it with an temporary name to the PC.
Than create a bat-file that delete de original file, rename the new file and call the program again.
The bat-file is called when exiting the exe-file.
Until now I download the file from a website.
Now I wanted to save in in the SQL-database.
The only problem is that the exe-file is to large (8Mb) to save in the blob-file. Do I do some settings in the server?
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: Update FWH programs via SQL-database?
Posted: Wed Aug 22, 2018 11:08 AM
Marc,

Can you try Mediumblob columns instead of Blob?
Marc Vanzegbroeck wrote:Dutch,

I'm also using upx to compress the exe-files, but than I'm also getting the message that the file is too big.


dutch wrote:Dear Marc,

I use upx to compress the EXE file. It works well for many years.
viewtopic.php?f=3&t=35841&hilit=upx#p213562

Marc Vanzegbroeck wrote:Hi,

I also check for the new version in the exe-file.
Than save it with an temporary name to the PC.
Than create a bat-file that delete de original file, rename the new file and call the program again.
The bat-file is called when exiting the exe-file.
Until now I download the file from a website.
Now I wanted to save in in the SQL-database.
The only problem is that the exe-file is to large (8Mb) to save in the blob-file. Do I do some settings in the server?
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: Update FWH programs via SQL-database?
Posted: Thu Jan 24, 2019 12:00 PM
Hi Giovany,

How do you call BATCH file from the main program and keep it still run after the main program end?

I try ShellExecute() but it doesn't run.

Giovany Vecchi wrote:It uses the same executable, downloads a zip file, unzipped into a folder and the program itself creates a .BAT file, and closes the program after it executes the .BAT file.

.BAT
Code (fw): Select all Collapse
@ECHO OFF
cls
ECHO AGUARDE A ATUALIZAÇÃO DO PROGRAMA
:APAGA
CHOICE /T 1 /C y /CS /D y
ATTRIB -R -S -H CARTORIO.EXE
DEL CARTORIO.EXE
IF EXIST CARTORIO.EXE GOTO APAGA
COPY C:\SISTEMAS\PROTWIN\TEMP\UPDATE\CARTORIO.EXE
ECHO ARQUIVO DE ATUALIZACAO PROCESSADO
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)