david600320@hotmail.com Posted February 17, 2020 Share Posted February 17, 2020 (edited) Is it not Possible UniSession.BrowserWindow in UniGUIServerModuleHTTPCommand ? - Version 1.90.0.1514 , XE2 In the ServerModule , I made a pdf file from FastReport ( makePdf()) and saved on the /files folder successed . What i want to show the pdf file on the new browser . but failed . What am i wrong ? procedure TUniServerModule.UniGUIServerModuleHTTPCommand( ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean); var r : string ; params : TStrings ; cHost : String ; cHostUrlPortPdfRepoPathFilename : String ; begin ARequestInfo.ContentType := 'application/json;charset=utf-8;' ; //success AResponseInfo.CustomHeaders.AddValue('Access-Control-Allow-Origin', '*'); //CORS AResponseInfo.CustomHeaders.AddValue('Access-Control-Allow-Credentials', 'true'); //CORS params := ARequestInfo.Params ; // 109-2. FastReport -> pdfFile -> show pdfFile on the New BrowserWindow if UpperCase(ARequestInfo.URI) = UpperCase( '/report' ) then begin Handled := true; r := ''; r := MakePDF() ; // (success getting pdf filename as files/Repo_200217184615048.pdf ) cHostUrlPortPdfRepoPathFilename := ARequestInfo.Host + '/' + r ; cHostUrlPortPdfRepoPathFilename := StringReplace( cHostUrlPortPdfRepoPathFilename , '\' , '/' , [rfReplaceAll, rfIgnoreCase] ) ; // failed below all . Read of address 00000017 ) // (Errors both ) ( Access violation at address 007212DA in module 'fastReport_test.exe' ) UniSession.UrlRedirect( cHostUrlPortPdfRepoPathFilename ); UniSession.BrowserWindow( cHostUrlPortPdfRepoPathFilename , 0, 0, '_blank'); //AResponseInfo.ContentText := cHostUrlPortPdfRepoPathFilename ; end; end; thanks , Edited February 17, 2020 by david600320@hotmail.com show error Quote Link to comment Share on other sites More sharing options...
Oliver Morsch Posted February 17, 2020 Share Posted February 17, 2020 There is no Unissession in UniGUIServerModuleHTTPCommand. Quote Link to comment Share on other sites More sharing options...
david600320@hotmail.com Posted February 17, 2020 Author Share Posted February 17, 2020 @Oliver thanks, btw, Is there a way for this to solve this ? How to open a new Browser in UniGUIServerModuleHTTPCommand ? Quote Link to comment Share on other sites More sharing options...
david600320@hotmail.com Posted February 18, 2020 Author Share Posted February 18, 2020 in UniGUIServerModuleHTTPCommand. [Solved] pdfUrl := 'http://127.0.0.1:8077/files/Repo_200218085047701.pdf' ShellExecute(0, 'OPEN', PChar(pdfUrl), '', '', SW_SHOWNORMAL); Q. Is this only way to solve ? Quote Link to comment Share on other sites More sharing options...
Oliver Morsch Posted February 18, 2020 Share Posted February 18, 2020 You open a browser on the Server... Quote Link to comment Share on other sites More sharing options...
david600320@hotmail.com Posted February 19, 2020 Author Share Posted February 19, 2020 @Oliver , Thank you for your help . Quote You open a browser on the Server... By the way , I am not clear that solved was a good way or not. ( The Server is for only as Reporting-server independent of any Front-end ) Could you give me a better Idea ? Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 19, 2020 Share Posted February 19, 2020 8 hours ago, david600320@hotmail.com said: @Oliver , Thank you for your help . By the way , I am not clear that solved was a good way or not. ( The Server is for only as Reporting-server independent of any Front-end ) Could you give me a better Idea ? ShellExecute not work on application as Service (HyperServer) Use instead something like this (RunApp) : function WTSQueryUserToken(SessionId: ULONG; var phToken: THandle): BOOL; stdcall; external 'Wtsapi32.dll'; procedure TBackUp.RunApp(Ma_cmdLine, Dossier: String); var hToken: THandle; StartupInfo: TStartupInfo; ProcessInfo: TProcessInformation; res: boolean; begin //============ // RunApp fonctionne uniquement en Service (HyperServer) pas en debugMode // RunApp remplace le ShellExecute (pour Desktop version) //============ GetStartupInfo(StartupInfo); if WTSQueryUserToken(WtsGetActiveConsoleSessionID, hToken) then begin res := CreateProcessAsUser(hToken, Nil, PChar('cmd.exe /C ' + Ma_cmdLine), nil, nil, True, CREATE_NO_WINDOW, nil, PChar(Dossier), StartupInfo, ProcessInfo); if res then WaitForSingleObject(ProcessInfo.hProcess,INFINITE); end; end; Quote Link to comment Share on other sites More sharing options...
david600320@hotmail.com Posted February 20, 2020 Author Share Posted February 20, 2020 @AbakSoft , Thanks for your kind explanation !! // calling .... pdfUrl := 'http://127.0.0.1:8077/files/Repo_200218085047701.pdf' RunApp( ' chrome ' , pdfURL); // function RunApp( Ma_cmdLine, Dossier : String ) ChromeBrowserPath := 'cmd.exe /C ' + Ma_cmdLine + ' ' + Dossier ; res := CreateProcessAsUser(hToken, nil, PChar(ChromeBrowserPath), nil, nil, False, CREATE_NEW_CONSOLE, nil, nil, // PChar(WorkDir), StartupInfo, ProcessInfo); As I mentioned above, I wanted to show a pdf file on the new google browser but still Failed. ( In Command line , ' chrome http://127.0.0.1:8077/files/Repo_....pdf is OK - successed !! ) As Result - just 200 ok - , Not showing !! What am i wrong ? Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 20, 2020 Share Posted February 20, 2020 Sorry, Not sure we are talking about the same thing. i wante to advise only if you will use after hyperserver (what is highly recommanded) then forget SHELLEXECUTE. Use instead RunApp (showed above). Now about showing a pdf file, it's quit simple : seesee FastReport Demo (mega unigui Demo). Regards. Quote Link to comment Share on other sites More sharing options...
david600320@hotmail.com Posted February 20, 2020 Author Share Posted February 20, 2020 Ok Thanks @AbakSoft !! Have a good day !! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.