Jump to content
uniGUI Discussion Forums


uniGUI Subscriber
  • Content Count

  • Joined

  • Last visited

  • Days Won


Ron last won the day on September 24 2019

Ron had the most liked content!

Community Reputation

72 Excellent

About Ron

  • Rank
    Advanced Member

Profile Information

  • Gender
  • Location

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. mairdi


  2. Ron

    save and load File in Database: Has someone a Demo??

    //insert into myfiletable values(0, :date, :filename, :file); with SaveFileQuery do begin paramByName('date').AsDateTime:=now; paramByName('filename').AsInteger:=uniFileUpload1.fileName; try blob := TMemoryStream.Create; blob.Seek(0, soFromBeginning); try blob.loadFromFile(myFileName); //if you have the file on disc myFastReport.SaveToStream(blob, true, true, false); //if you need to save a PDF report finally end; finally paramByName('file').LoadFromStream(blob, ftBlob); //if you use any of the above options paramByName('file').LoadFromStream(uniFileUpload1.stream, ftBlob); //if you have not saved the file yet ExecSQL; blob.Free end; end;
  3. Ron

    How to send http request from UniGui

    If you are making an http request from the client (which you do when you use JS, as all JS runs in the browser client) then you can only communicate with the local computer through CORS, and the local webserver must be configured to accept such requests. If you want to communicate to the outside world, you have to do it from the server side, and that is straightforward using e.g. idHTTP and doing a simple http get request. Example of JS call to local webserver using CORS UniSession.AddJS('$.get("'+uniMainModule.corsPort+'?event='+inttostr(EventID)+'&op='+uniMainModule.operator+'", function( data ){' + ' ajaxRequest(TransactionForm.form, ["cashRegisterEvent"], { response : data }); '+ ' }); '); Apache set up for CORS in httpd.conf <VirtualHost *:80> DocumentRoot "c:\program files (x86)\cashreg\apache22\htdocs" Header set Access-Control-Allow-Origin "*" </VirtualHost> IndyHTTPServer set up for CORS if sameText('', ARequestInfo.RemoteIP) and (ARequestInfo.CommandType=hcGet) and (length(aRequestInfo.Params.text)>0) then begin AResponseInfo.CustomHeaders.AddValue('Access-Control-Allow-Origin', '*'); EventIDStr:=aRequestInfo.Params[0];
  4. Ron

    Delphi and Linux

    andy - I only have a couple of the regular Spooky2 generators, never tried the Scalar thing
  5. Ron

    Delphi and Linux

    I created a couple of apps in Lazarus some years ago, it actually works. http://microhertz.org/
  6. Ron

    isapi server error 500 in apache

    Can you please post the lines you added to the httpd.conf ?
  7. Ron

    how check internet connection unigui

    You have to check a server which is usually online, or a list of servers if you cannot be certain of a single server. In principle you can never rely fully on a single server, as hardware/technology by nature cannot be trusted 100%. If you have a list of ten servers, and half of them reply correctly, you can probably assume that you are connected. If none of them reply at all, chances are that you may not be connected. You can check DNS servers, but even they go down at times, but usually not for long. Google's DNS's are at and
  8. Ron

    how to open url to another tab?

    I don't think you can choose which browser to open. The default browser will be called, just as when you double-click an .htm file in File Explorer.
  9. Ron

    how check internet connection unigui

    Please realize that InetIsOffline function is not reliable, as this is what signals the tray internet status icon, and I guess we've all experienced times when the status claimed we had internet access while we did not have it. There is potentially much lag in that function, in my experience. The point of checking for internet connection is to be sure you have it, or sure you don't have it. To know this you actually have to try to get some data from an outside server, or preferrably several servers as the one server you check may be down. You can use a list of servers. Internet is a living thing where devices come in and drop out all the time, so "internet access" is a rather vague term. Define the internet? Even Google has been down for a little while, several times...
  10. Ron

    how check internet connection unigui

    The only "reliable" way is to try get some data from a server of your choice: function TMainF.isInternetConnection: Boolean; begin try IdHTTP.Get('http://www.svtech.cz'); except on E: Exception do begin if not (E is EIdHTTPProtocolException) then begin Result := False; Exit; end; end; end; Result := True; end;
  11. I fully agree, and it is the great integration with Delphi and its visual tools, and the server-centric approach that makes it so powerful and almost priceless.
  12. Ron

    Handle Stateless Requests

    You want to respond to http requests for doing simple tasks, and you can use Unigui for this. The benefit is to have all the code in one place. The best way to do this is to use URL parameters for those tasks, with an ID for identifying the user, and picking this up in the MainForm, and there choosing which subform to display. Normally a user would have to log in to your app, but in the MainModule you also check for the presence of a URL parameter and do an automatic login based on the URL ID, which you check against a table with an expiry date. So for the task you direct the user to your special form and let him do whatever it is, and then afterwards either log him out or direct him to his account page, e.g. The HTTPCommand function is presently not working in ISAPI mode, so I would not go that way. Besides, it is not necessary at all when you can use URL parameters as explained above. The only reason you would actually use HTTPCommand would be if you did not want to engage any forms but just do some simple HTTP response - but for that kind of job I would rather create a VCL service app using the Indy HTTP Server. It would give me much more freedom to configure the server, as it would not be running under Apache or IIS and restricted to their port.
  13. Ron

    Redirect from HTTP to HTTPS [SOLVED]

    On Apache I use the rewrite engine, set up in httpd.conf: RewriteEngine On RewriteCond %{THE_REQUEST} !\.php [NC] RewriteCond %{HTTPS} off RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
  14. Ron

    StateFull or StateLess

    Only the simplest webapps are completely stateless, as far as I know. There are two basic ways to store state: 1) on the server, using session control with session data stored on the server 2) on the client, as a session identifier passed in the URL back and forth The second option is what they call stateless, as state is not stored on the server but on the client, so it is really not stateless per se. Please correct me if I am wrong. With Unigui you can do both, but since every form takes an initial loading of a MainModule, it may not be as efficient as with e.g. TMSWebCore, where you only have a bunch of html, css and js files to load. With good webserver preloading and caching you may come close, though.
  15. Ron

    unload unigui dll on apache with another unigui.dll?

    I made an update system with client and server update modules as regular VLC apps. The client UPX-packs and zips the update file and sends it using FTP to my update server, which unzips and copies the .dep file to the correct deploy folders for all instances on the webserver. When the update server notices an incoming file, it creates a simple text file in the unigui app root dir, which the unigui app then discovers (timer checking) and shows an update message, warning that the app will restart in about 30 seconds and then deletes this text file. I guess you could instead copy the .dep file to another folder and give the user the chance to select when to update, i.e. when to copy the file to the deploy folder, if you like.