Jump to content

irigsoft

uniGUI Subscriber
  • Posts

    1370
  • Joined

  • Last visited

  • Days Won

    22

Everything posted by irigsoft

  1. If You made this by security reason, this is not real secure method. For more info check here:
  2. Hello, I add here how to replace url on browser (from here: ) procedure TMainForm.UniFormActivate(Sender: TObject); var EnableAutoLog : Boolean; begin If (TRIM (TUniGUISession(UniSession).UniApplication.Parameters.Values ['login']) <> '') and (EnableAutoLog) then begin //replace URL UniSession.AddJS( // Current URL: UniSession.ARequest.Referer 'const nextURL = ''' + StringReplace (UniSession.ARequest.Referer,'login=' + TUniGUISession(UniSession).UniApplication.Parameters.Values ['login'],'',[rfReplaceAll,rfIgnoreCase]) + ''';' + 'const nextTitle = ''' + UniServerModule.Title + ''';' + 'const nextState = { additionalInformation: ''Updated the URL with JS'' };' // This will create a new entry in the browser's history, without reloading + 'window.history.pushState(nextState, nextTitle, nextURL);' // This will replace the current entry in the browser's history, without reloading + 'window.history.replaceState(nextState, nextTitle, nextURL);' ); end;
  3. Hello, try this. https://www.30secondsofcode.org/articles/s/javascript-modify-url-without-reload procedure TMainForm.UniFormActivate(Sender: TObject); var EnableAutoLog : Boolean; begin If (TRIM (TUniGUISession(UniSession).UniApplication.Parameters.Values ['login']) <> '') and (EnableAutoLog) then begin //replace URL UniSession.AddJS( // Current URL: UniSession.ARequest.Referer 'const nextURL = ''' + StringReplace (UniSession.ARequest.Referer,'login=' + TUniGUISession(UniSession).UniApplication.Parameters.Values ['login'],'',[rfReplaceAll,rfIgnoreCase]) + ''';' + 'const nextTitle = ''' + UniServerModule.Title + ''';' + 'const nextState = { additionalInformation: ''Updated the URL with JS'' };' // This will create a new entry in the browser's history, without reloading + 'window.history.pushState(nextState, nextTitle, nextURL);' // This will replace the current entry in the browser's history, without reloading + 'window.history.replaceState(nextState, nextTitle, nextURL);' ); end; But, You must know this will replace only URL, on Google Console will be seen all history as clear text !!!
  4. Hi, you may want to consider an API model. One uniGui application to send a request to other uniGui application (database server) using JSON, XML or other methods to obtain data from the database.
  5. Hello, can You try to : 1. create QRCode 2. Save to local File with name (QRDateTimeMiliseconds) 3. Load from file into image to show on end User
  6. @Sherzod Yes, I suggest for test purposes only to download image with QR code. I suggested using a different application to generate a QR code image and just drawing to check the problem. If the problem still exists, then the drawing procedure is a problem.
  7. can you try using qr code generated via goolge, and just download and load image ? "https://chart.apis.google.com/chart?chs=400x400&cht=qr&chld=M&chl=YOURQRSTRINGHERE"
  8. So, if you ignore the automatically generated code (just use static), do you get the same problem ? in witch part of string is differens in QR code, on sUserId or sTransferRef ?
  9. How do you set values for sUserId and sTransRef, is this an automatic generating function?
  10. In this option you can try to show / hide the buttons on two identical toolbars. Not good at all, but another option
  11. hello, i am not sure by maybe problem is in openssl.dll versions. try to search in web
  12. Using Promise with asynchronous = false, do whatever it takes.
  13. Enabling CORS is possible in server side. Maybe this will help, from here: https://portswigger.net/web-security/cors/access-control-allow-origin or here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin , https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS procedure TUniServerModule.UniGUIServerModuleHTTPCommand //enable CORS (XMLHttpRequest) AResponseInfo.CustomHeaders.AddValue('Access-Control-Allow-Origin', 'Server_URL'); AResponseInfo.CustomHeaders.AddValue('Access-Control-Expose-Headers', '"Location, Warning, Etag"'); AResponseInfo.CustomHeaders.AddValue('Access-Control-Allow-Origin-Headers', '"Accept, Content-Type, If-None-Match, X-If-None-Match"'); AResponseInfo.CustomHeaders.AddValue('Access-Control-Allow-Headers', '"Content-Type, If-None-Match, X-If-None-Match, Authorization"'); AResponseInfo.CustomHeaders.AddValue('Access-Control-Allow-Credentials', 'true'); AResponseInfo.CustomHeaders.AddValue('Access-Control-Allow-Methods', 'GET');//,POST, DELETE, HEAD, OPTIONS AResponseInfo.CustomHeaders.AddValue('Access-Control-Max-Age', '86400'); not tested !!!
  14. I did a few tests with the suggestions from here, but I think the example expects user interaction, maybe I'm wrong. In my case I start a cycle from the server, which has 5 steps, on each a function is started by the user addJS, without interaction with the user (the Mask is visible) the server expects a response in the variable "print", and the response from the finished function I catch in "onajaxevent". I would like not to run step 2 of the cycle until I get the answer from step 1. Now I'm experimenting with a combo box. I start server procedure with onbuttonClick. There are 5 values in it, for each of them I perform the function on the part of the user, which must return the third value in the list and the server to stop the cycle. In this situation visually I get: The last value is loaded in the list and in one memo field I see how the results of the function are scrolled for all steps for I := 0 to Combobox.Count - 1 do begin Combobox.ItemIndex := I; //start my clientside procedure - uniMemo.onajaxevent if ResultofClient = 3 then break; end; Solution : UniMainModule.EnableSynchronousOperations must be true, to refresh combox on client Side.
  15. @Sherzod I am sorry, is there a functionallity like Synchronize(Wait : boolean) and Synchronize(Delay : integer), but Synchronize(Wait : boolean) - wait for some variable value? I see on documentation that Synchronize(Wait : boolean) for user interaction.
  16. I posted all the features and logic, I hope that's enough
  17. Here is the situation in real life: 1. uniGui StandAllone server 2. Android device (android WebView with uniGui application started on it) or on mobile browser 3. Android third party server (application server to comunicate to device) instaled on Android device (same as pont 2) 4. UniGui Application send commands to point 3 with XHttpRequest url: http://localhost:4444/settings (com=deviceID,tcp=0); - no answer from point 3 send next commmand: url http://localhost:4444/getDeviceinfo(); - must WAIT answer from point 3 when answer comming on ajaxevent, send next command http://localhost:4444/PaperFeed(); - must WAIT answer from point 3
  18. on ajavaevent in myuniMemo on MainForm if EventName = 'FiscalAnswer' then begin TRY FiscalCMD := params.values['_cmd']; TuniMemo(Sender).Text := 'ANSWER=' + params.values['_value']; if TRIM (TuniMemo(Sender).Text) <> '' then begin UniMainModule.onError := (POS ('<Err Source=',TuniMemo(Sender).Text) > 0); //if return error If (UniMainModule.onError) then begin UniMainModule.FiscalErrorTxt := TuniMemo(Sender).Text; //UniSession.AddJS('alert (' + params.values['_value'] + ')') end; RetAnswer; //procedure work on aswer UniMainModule.onprint := False; end; EXCEPT //on e:Exception do Dialogs.ShowMessage (EventName + ' - ' + e.message); END; //go to execute next command in list If (UniMainModule.URLCommands.Count > 0) //and (not UniMainModule.onError) then begin uniMainModule.SendtoFiscalDevice_DirectAPI (TuniMemo(Sender),UniMainModule.URLCommands [0]); end; end; EXCEPT //on e:Exception do Dialogs.ShowMessage (EventName + ' - ' + e.message); END;
  19. procedure on client side declared in uniMainModule: UniMainModule.SendtoFiscalDevice_DirectAPI (uniMemo_Fisc,UniMainModule.URLCommands [0]); //procedure on client side var sCMD, fURL : string; begin If (TRIM (cmd) <> '') //AND (not uniMainModule.onprint) //OR (not uniMainModule.onError) then begin TRY sCMD := StringReplace (COPY (cmd,2,POS ('(',cmd)-2),'"','',[rfReplaceAll]); fURL := UniServerModule.SistemSettingsList.Values ['PrintServer_URL']; UniMainModule.onprint := True; myMemo.Clear; //jQuery // UniSession.addJS ('$.get(''' + fURL + TRIM (cmd) + ''', function(responseText) {' // + ' var sRes = responseText;' // //+ ' alert ("HAVE responce:" + sRes);' // + ' ajaxRequest (' + myMemo.JSName // + ' , "FiscalAnswer", ["_value=" + sRes,"_cmd=" + "' + sCMD + '"]);' // + '});' // ); //execute XMLHttpRequest UniSession.AddJS (' new Promise(function(resolve, reject) {' + ' let xhttp = new XMLHttpRequest();' + ' xhttp.timeout = 2000;' // time in milliseconds + ' xhttp.onreadystatechange = function() {' + ' if (this.readyState == 4 ) { ' + ' if (this.status == 200) {' //must wait this to return onajaxevent + ' var sRes = this.responseText;' + ' ajaxRequest (' + myMemo.JSName + ' , "FiscalAnswer", ["_value=" + sRes,"_cmd=" + "' + sCMD + '"]);' + ' } else {' + ' ajaxRequest (' + myMemo.JSName + ' , "NoFiscalAnswer", ["_value=" + "OK","_cmd=" + "' + sCMD + '"]);' + ' };' + ' resolve(this.responseText);' + ' };' + ' };' + ' xhttp.open("GET", ''' + fURL + TRIM (cmd) + ''', false);' //set to false to make server wait util client finish + ' xhttp.send(null);' + '});'//end Promise ); EXCEPT //on E: Exception do Dialogs.ShowMessage ('SendtoFiscalDevice ERROR: ' + e.Message);//uniMainModule.onprint := False; END; If (UniMainModule.URLCommands.Count > 0) AND (not UniMainModule.onError) then begin UniMainModule.URLCommands.Delete (0); cmd := ''; end; end;
  20. just function will post here. uniMainModule - public UniMainModule.URLCommands : TStringList; on btnclik to start loop: procedure TUniForm_FiscalSettings.UniButton1Click(Sender: TObject); var sList : Integer; begin sList := 0; FiskalDevice.ID := ''; FiskalDevice.MFP := ''; UniMainModule.onPrint := False; UniMainModule.onError := False; repeat Inc (sList); if UniCheckBox_CheckIfConnected.Checked then begin UniComboBox_FiscalID.ItemIndex := sList; end; //1 step - send settings to device UniMainModule.URLCommands.Clear; UniMainModule.URLCommands.Add ('/settings(com="' + UniComboBox_FiscalID.Text + '",tcp=0)'); UniMainModule.SendtoFiscalDevice_DirectAPI (uniMemo_Fisc,UniMainModule.URLCommands [0]);//procedure on client side //2 step - if result from 1 step then get device ID UniMainModule.URLCommands.Clear; UniMainModule.URLCommands.Add ('/ReadSerialAndFiscalNums()'); UniMainModule.SendtoFiscalDevice_DirectAPI (uniMemo_Fisc,UniMainModule.URLCommands [0]);//procedure on client side //send next command to device UniMainModule.URLCommands.Clear; UniMainModule.URLCommands.Add ('/PaperFeed()'); UniMainModule.SendtoFiscalDevice_DirectAPI (uniMemo_Fisc,UniMainModule.URLCommands [0]); //procedure on client side //if have result from 2 step showmessage - just for test ! if FiskalDevice.ID > '' then begin ShowMessage ('Fisc ID: ' + FiskalDevice.ID); break; end; if FiskalDevice.ID <> '' then begin end; until (sList > UniComboBox_FiscalID.Count-1) OR (FiskalDevice.ID <> ''); end;
  21. Thank You, this is for Showmodal. Buf if I want to wait until onajaxevent ocure (or exact Eventname in ajaxevent) to proceed with loop ?
  22. Hello, @Sherzod I'm sorry, but I still have a problem getting information from the client. The procedure works, but the server executes code and does not block. So, I have this logic: 1. For a loop in a server 2. JSCode (Send url to device). I use Promises and XhttpRequest 3. in ajaxevent waiting for a response from the client 4. if the answer is true, go to the next one in the cycle from point 1. This loop has a ShowMessage (intToStr (I)) for each step of the loop, but I get it once with the last value of the loop. I even use ShowMask on ButtonClick.
  23. Hello, did You succeed with this problem ?
×
×
  • Create New...