procedure TComponentDebugger.btnSendToBiometriesClick(Sender: TObject);
var
Request: TWebRequest;
Response: TWebResponse;
Return: THTTPCode;
ResponseJSON: TJSONObject;
procedure SetAccessDataInINI;
var
URL : string;
Path: string;
begin
URL := string(cbxURL.Text).Replace('{personId}', edtPersonIdBiometries.Text, [rfReplaceAll]);
Path := URL.Delete('http://localhost/api');
TIniReader.Instance.OpenFile(FBasePath + BIOMETRIES_INI_FILE)
.Section['Extra Headers']
.WriteString('Url', URL)
.Root
.Section['CGI']
.WriteString('Logical Path', Path)
.WriteString('Physical Path', Path)
.UpdateFile;
end;
procedure SetRequestWithQueryParams;
begin
if chkWithParams.Checked then
begin
Request.QueryFields.Add(PAGE_PARAM.Format([edtPageBiometries.Text]));
Request.QueryFields.Add(PAGE_SIZE_PARAM.Format([edtPageSizeBiometries.Text]));
end;
end;
procedure SetRequest(const AIndex: Integer);
begin
if AIndex = 0 then
begin
SetRequestWithQueryParams;
end;
end;
begin
SetAccessDataInINI;
sedtResponse.Lines.Clear;
Request := TWinCGIRequest.Create(FBasePath + BIOMETRIES_INI_FILE, FBasePath + CONTENT_FILE, FBasePath + OUTPUT_FILE);
Response := TCGIResponse.Create(Request);
SetRequest(cbxURL.ItemIndex);
Return := TCATRACAFactory.Instance.GetObject(BIOMETRIES_CLASS_KEY).TreatRequest(FConnection
, Request
, Response);
case Return.IsOkResult of
True : Application.MessageBox(PWideChar(RESPONSE_MESSAGE.Format([Return.Code, Return.Message])), 'Informação', MB_OK or MB_ICONINFORMATION);
False: Application.MessageBox(PWideChar(RESPONSE_MESSAGE.Format([Return.Code, Return.Message])), 'Erro', MB_OK or MB_ICONERROR);
end;
if Return <> hcNoContent then
begin
ResponseJSON := Response.Content.ToJSON;
sedtResponse.Text := ResponseJSON.PrettyFormat(2);
ResponseJSON.Free;
end;
Request.Free;
end; |