How to Work with FIVEWIN and Web Side by Side - An Easy Way

How to Work with FIVEWIN and Web Side by Side - An Easy Way

Postby Otto » Tue Aug 27, 2024 9:15 am

How to Work with FIVEWIN and Web Side by Side - An Easy Way
Hello friends,

I have conducted many tests and have concluded that if you want to combine a DBF desktop application with a web application, the simplest solution is to exchange data via JSON files. I have also implemented a heartbeat function, which means the online application periodically checks if the heartbeat of FIVEWIN.EXE is present, indicating that it is running and functioning properly. The desktop application regularly creates a file, and the online application checks how old this file is. If it is older than a certain time, an error is displayed.

The next step is to implement authentication so that only authorized JSON files can be passed to the FIVEWIN.EXE; otherwise, they will simply be deleted.

The file-based system takes 200 ms, which I think is a good value. It also has the advantage of not requiring changes to the existing program. I believe that if one were to release this, it would be the best path to take. Also, adding or updating data is rare in this case. Here, you can see all CRUD actions with data exchange via files and the FIVEWIN.EXE.

I have now created a test with data deletion and a FIVEWIN EXE with a timer. It is a very simple program, as you can see from the attached screenshot.

The PHP program writes a file. In this case, I read from the filename what needs to be done and the record number. The PHP program itself also has a timer (JavaScript interval) that checks and updates the view. The big advantage here, even if you might lose some speed, is that you pass the data to FIVEWIN and are sure that it arrives.


Even when there is a lot of work, you should take some time for a little fun. I have now added a heartbeat. If the FIVEWIN.EXE is active and functioning, so that it can receive and process the JSON files, then you will see the heartbeat. A nice little gimmick.

Best regards,
Otto



Image

Image

Image

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to Work with FIVEWIN and Web Side by Side - An Easy Way

Postby chiaiese » Fri Aug 30, 2024 10:37 am

Hi Otto,
my simple solution is to call the fivewin.exe from php simply passing the parameters I receive from Apache server.
The environment is a Windows VPS server with Apache + Php installed but I think it would run on Linux also
this is a very simplified code for index.php just to send the idea:

Code: Select all  Expand view

switch ($_SERVER['SERVER_NAME']) {
    case "siteone.com":
        $exename =  'folderOne\FWsiteOne.exe';
        break;
    case "www.siteTwo.it":
    case "siteTwo.it":
        $exename =  'folderTwo\FWSiteTwo.exe';
        break;
    case "www.site3.net":
        $exename =  'folder3\FWSite3.exe';
        break;
}
$runexe = $exename.' '.$user.' '.$pswd.' '.$func.' '.$gets.' '.$posts ;     // passing parameters managed before
$htmlOut = shell_exec( $runexe );                               // the exe program produces html code
echo($htmlOut);                                         // display the page
 
Roberto Chiaiese
R&C Informatica S.n.c.
http://www.recinformatica.it
info@recinformatica.it
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Re: How to Work with FIVEWIN and Web Side by Side - An Easy Way

Postby Otto » Fri Aug 30, 2024 1:37 pm

Hello Roberto,

Thank you. In your case, if I understand the code correctly, you would have a PHP endpoint that receives the response and then calls an executable with parameter passing.

I will run a test to see how fast the execution is here.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to Work with FIVEWIN and Web Side by Side - An Easy Way

Postby chiaiese » Fri Aug 30, 2024 2:28 pm

Otto,
if you want to test the execution speed you can visit these sites:
https://www.recinformatica.it (our site)
https://www.to-build.it (one of the last done, multilingual)
https://www.autoricambischicchi.it
https://www.sicuriallestero.it
https://www.boscomarshop.it (an e-commerce under construction)

all sites (and others) on the same webserver, some of them from several years,
all sites entirely written in harbour, data-driven, dbf files, my custom harbour CMS,
some sites share data with customer's databases via synchronization (orders, invoices and other documents)
some customers can manage site contents by their Fivewin accounting software (product description, prices, images and so on)

Roberto
Roberto Chiaiese
R&C Informatica S.n.c.
http://www.recinformatica.it
info@recinformatica.it
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Re: How to Work with FIVEWIN and Web Side by Side - An Easy Way

Postby Otto » Fri Aug 30, 2024 2:44 pm

Roberto,
thank you very much for your examples.
Very professional and beautiful.
You should post more about how you do it.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to Work with FIVEWIN and Web Side by Side - An Easy Way

Postby chiaiese » Tue Sep 03, 2024 12:57 am

hello Otto,
here is a brief description:
the CMS module is a standard fw desktop application, it is the place where all informations about the sites are stored: sites, pages, contents, menus, documents, html templates, css files and so on.
It is multi-site so a single customer can have multiple sites sharing the same dbf's. As an example: the official site, landing pages, reserved areas with login, etc.
It is multi-language, contents can be active or not or scheduled. Every folder/customer has its own repository

The cgimodule.exe is the app that is called by php with the parameters received from Apache server. this app recognizes the user by the 'session id', interprets the parameters ('gets' and 'posts' as the pageId), reads contents from the repository, builds the pages and returns the html code to php. Every customer can have one or more cgi-modules, one per site/domain.
It uses classes to generate html pages, contents, menus, browses, forms, carousels, grids and image galleries from repository

Harbour power: in the repository we can define as 'content' a function or codeblock that is executed at runtime, the result is macro-substituted inside the html template via $KEYWORDS to create real-time contents.
We can also define nested templates (virtual pages) so can create very complex pages built by 'sections' .or. share sections across multiple pages (as an example page header and footer are 'sections')
Don't update pages, update sections!

There is still a lot of work to do but we can already create complex real web applications
If you have any question feel free to ask
kind regards
Roberto
Last edited by chiaiese on Tue Sep 03, 2024 9:35 am, edited 1 time in total.
Roberto Chiaiese
R&C Informatica S.n.c.
http://www.recinformatica.it
info@recinformatica.it
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Re: How to Work with FIVEWIN and Web Side by Side - An Easy Way

Postby Antonio Linares » Tue Sep 03, 2024 6:04 am

Dear Roberto,

It would be great if you could share some simple example so it can help Harbour users as a guide

many thanks!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to Work with FIVEWIN and Web Side by Side - An Easy Way

Postby chiaiese » Wed Sep 04, 2024 5:35 pm

hi Antonio,
here is a simplified sample code I use:

Code: Select all  Expand view

function main()
parameters User,Password,cFunction,cGets,cPosts
... here some settings
*  Start application      **********************
public oApp     := CApp():New(" Gestione CGI Web  ",INI_FILE)
oApp:cParms     := cParms                   // parametri da Setup
oApp:cGets      := cGets                        // parametri GET  (dai link/bottoni)
oApp:cPosts     := cPosts                   // parametri POST (dai FORM)
oApp:lPost      := .t.                      // passaggio parametri con metodo POST - 14/03/2014
oApp:lUtf8      := .t.                      // conversione stringhe UTF8 - 27/06/2018
oApp:Start(User,Password)                       // user = Sessid
if empty(cFunction)                                 // se non è un passaggio
    cFunction := getPar(cPosts,"function")          // predefinito ctrl se c'e
endif                                                   // una funzione chiamata da POST

cFunction := lower(cFunction)
nLang := val(alltrim(getPar(,"L")))             // language
nLang := if(range(nLang,0,4),nLang,0)               // add: 18/03/2019
cSub := lower(getPar(,"cSub"))                      // sub-function

if cFunction=="nil"                         // carattere
    cFunction := lower(getpar(,"id"))
    if empty(cFunction)
        cFunction := "homepage"    // default PageId
    endif
endif

// pageId, idSito, ..., Tabella contenuti sito
oPage := CWebPage():New(cFunction,"MYSITE",,,{|oPage,cHead|setHeader(oPage,cHead)},,TABVAR):Exec()        // here we build Page object and output the Html code

release all
exit()
// end program
 


and here is the definition of the main Class CWebPage()

Code: Select all  Expand view

Class CWebPage              // 03/11/2017
    var aFiles as array     // files procedura da aprire

    var cSiteId             // id sito (cod. in tabella generale)
    var cPageId             // id pagina (Nome)
    var cKeyPag             // Chiave pagina x Seek (cSiteId+cPageId)   add: 22/06/2018
    var cAllpages               // codice pagina 'invisibile' per i contenuti validi per tutte le pagine (no stdout)
                                // es. menu, logo, footer, ecc.
    var cHeadTpl                // header template
    var cFootTpl                // footer template
    var cCssFile                // file css
    var cFavicon                // favicon
    var cLogo                   // logo
    var cTagDescription     // meta tag description
    var cKeyWords               // meta tag keywords
    var cHtml                   // html generato
    var cTabVar             // tabella contenuti vari di default - può essere modificata
    var cFileOpen               // elenco dei files da aprire per questa pagina (comma separated)

    var bSetHeader          // codebock to set header
    var bSetFooter          // codebock to set footer
    var bFor                    // filtro sui contenuti

    var lUtf8 init .t.      // se output in utf-8 (solo contenuti non-stdout)
    var lStdOut init .t.        // se output su stdOut
    var lContentOnly init .f.   // .t. non visualizza header e footer

    var nLang                   // indice lingua [1-5]          // 19/06/2023
    var cLang                   // sigla lingua [ITA,ENG,SPA,FRA,DEU(ROM)]          // 19/06/2023

    var nAreaTab                // area Tabelle                 // 11/04/2019
    var nAreaAll                // area Allegati x sito         // 11/04/2019
    var oContent                // contenitore principale

    Method New( cPageId, cSiteId, aFiles, cAllPag, bSetHeader, bSetFooter, cTab, nAreaTab, nAreaAll ) Constructor
    Method exec()                                           // eseguo motore pagina
    Method allegati(cIdContent,cPage)                                       // visualizzo allegati (contenuto)
    Method carousel(oCnt,aCarousel,lCaption)                                       // creo carousel
    Method content(cIdContent,cPage)                // visualizzo un content-object
    Method edit(cIdContent,cPage)                          // visualizzo oggetto Edit (contenuto)
    Method genContent()                                        // genero e visualizzo i contenuti
    Method genMenu(cIdContent,cPage)              // visualizzo menu (contenuto)
    Method genSlides(cIdContent,cPage)                                         // visualizzo slides/carousel
    Method genBlock( obj, cTipo, cIdContent )           // genera 'bData' per il contenuto
    Method griglia(cIdContent,cPage)                     // visualizzo una griglia (contenuto)
    Method loadAllega(cPage,cIdContent,cType,cTag)                                // carica allegati per una griglia
    Method readContent(cSite,cPage)                      // carico singolo contenuto
    Method template(cIdContent,cPage)                   // visualizzo template (pagina in pagina)
   
    Method loadMenu(nMenu,cIdContent,cPage) hidden                       // carica il menu
    Method buildMenu(aM,nIdx) hidden                    // genera il menu (html)
    Method lSito(cTab) inline (cTab $ TABSITE+"-"+TABTEMP+"-"+TABVAR )      // come pr_tabel - 29/10/2022
EndClass
 


Obviously other classes helps to manage Contents and Content elements
Roberto Chiaiese
R&C Informatica S.n.c.
http://www.recinformatica.it
info@recinformatica.it
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Re: How to Work with FIVEWIN and Web Side by Side - An Easy Way

Postby Otto » Fri Sep 06, 2024 9:17 am

Dear Roberto,
Thank you very much.
I will take a close look at the code and will surely have more questions about it.

I was not online last week because I was at a TikTok Tourism Marketing Meeting at the new TikTok HQ in Dublin.
An amazing success story and a very exciting product.

May I ask where in Italy you are from? I live just 4 km from the Italian border. Maybe we can meet sometime.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to Work with FIVEWIN and Web Side by Side - An Easy Way

Postby chiaiese » Fri Sep 06, 2024 10:48 am

Hi Otto,
I'm from Napoli but I live in Roma from over 30 years.
Often people who lives at borders are bilingual..so do you also speak Italian? :-)

If you have more questions I will be happy to answer
Regards
Roberto Chiaiese
R&C Informatica S.n.c.
http://www.recinformatica.it
info@recinformatica.it
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 50 guests