Jump to content

UniServerModule - Getting information from the form with the parameter in the server module.


SEGNA

Recommended Posts

Hi,


I want to connect the string FormName parameter that comes with the UniGUIServerModuleHTTPCommand procedure to a previously created form with that name and access the sql text of the FDqery in it.

 

procedure TUniServerModule.UniGUIServerModuleHTTPCommand(
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
  var Handled: Boolean);
var
prmFormName, s : string;
Form : TUniForm;

begin
  if ARequestInfo.Command = 'GET' then
      if ARequestInfo.URI = '/test' then 
	begin
		prm := ARequestInfo.Params.Values['FormName'];
		s := Form.FDQuery1.SQL.Text;

//        The example here is simplified. I tried to reach with Formclass but I get "Address Access Violation" warning.
//
//        The form I want to connect to was previously created in uniapliacation. This form can be a MainForm or an open form with a list of Customers.
//
//        I need the sql text of the FDquery in that form.
	end;

end;

 

Link to comment
Share on other sites

Hi,

As an example I am sending parameters by running GET method inside MainForm with htmlframe "http://localhost:8077/test?FormName=MainForm&Data=FDQuery1"

On the serverModule side, when I receive the incoming call in UniGUIServerModuleHTTPCommand, I need to connect to the form in the parameter and get the sql text of the dataset.

I cannot access MainForm or any other active form from within ServerModule. I need to make calculations on the sql side and send the result as text.

 

procedure TUniServerModule.UniGUIServerModuleHTTPCommand(
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
  var Handled: Boolean);
var
prmFormName, prmData, s : string;
Form : TUniForm;
FDQuery: TFDQuery;

begin


  if ARequestInfo.Command = 'GET' then
      if ARequestInfo.URI = '/test' then 
	begin
		prm := ARequestInfo.Params.Values['FormName'];
		prmDataSet := ARequestInfo.Params.Values['Data'];
		
		/// ConnectionCreate .....
		
		FDQuery := FDQuery.Create;
		FDQuery.Connection := ....;
		FDQuery.Sql.Text := TUniForm(UniApplication.FindComponent('MainForm') as TUniForm ).FindComponent( 'FDQuery1' )  as TFDQuery).SQL.Text;	
		FDQuery.Open;
		
		//I need to make calculations on the sql side and send the result. as text.
		
		AResponseInfo.ContentText := Result;
            AResponseInfo.WriteContent;		
	end;

end;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...