...
03. SOLUÇÃO
A implementação da interface depende das interfaces estão nas seguintes units:
- IPersistentObject em Framework.Classes.InteropObject;
- IPersistenceBase, IPersistenceType e IPersistenceObject em Framework.Classes.Persistence;
- IDevice e IBiometricDevice em Framework.Classes.Device;
Que dependem dos seguintes elementos do framework de desenvolvimento:
- Framework.Classes.BusinessProperty;
- Framework.Classes.DBInteropObject.Connections.Database;
- Framework.ConstsClasses.HTTPCodesInteropObject;
- Framework.ConstsConnections.ServerDefinitionsDatabase;
- Framework.Types.ContentTypeJSON;
- Framework.ConstsHelpers.HTTPCodesDateTime;
- Framework.Helpers.JSON e;
- Framework.Helpers.Rtti;
- Framework.Helpers.Str.;
| Totvs custom tabs box |
|---|
| tabs | Métodos expostos,Propriedades expostas,Exemplos de uso |
|---|
| ids | metodos,propriedades,exemplos |
|---|
|
| Totvs custom tabs box items |
|---|
| default | yes |
|---|
| referencia | metodos |
|---|
| São métodos expostos pela implementação da interface IPersistentObject: - function SetId(const Value: string): IPersistentObject;
São métodos expostos pela implementação da interface IPersistenceBase: - function SetId(const Value: string): IPersistenceBase; reintroduce;
- function SetReference(const Value: string): IPersistenceBase;
- function SetAttributes(const Value: TJSONObject): IPersistenceBase;
- function SetActive(const Value: Boolean): IPersistenceBase;
- function Load(const AId: string): IPersistenceBase; reintroduce; virtual; abstract;
- function Save(out AReturn: Cardinal): IPersistenceBase; reintroduce; virtual; abstract;
São métodos expostos pela implementação da interface ICATRACABase: IPersistenceType: - function SetId(const Value: string): IPersistenceType; reintroduce;
- function SetReference(const Value: string): IPersistenceType; reintroduce;
- function SetAttributes(const Value: TJSONObject): IPersistenceType; reintroduce;
- function SetActive(const Value: Boolean): IPersistenceType; reintroduce;
- function Load(const AId: string): IPersistenceType; reintroduce;
- function Save(out AReturn: Cardinal): IPersistenceType; reintroduce;
- function SetConnection(const AConnection: IDBFullConfigConnection): IPersistenceType; reintroduce;
São métodos expostos pela implementação da interface IPersistenceObject: - function IsValid: Boolean;
- function SetId(const Value: string): IPersistenceObject; reintroduce;
- function SetObjectType(const Value: IPersistenceType): IPersistenceObject;
- function SetReference(const Value: string): IPersistenceObject; reintroduce;
- function Load(const AId: string): IPersistenceObject; reintroduce;
- function Save(out AReturn: Cardinal): IPersistenceObject; reintroduce;
- function SetConnection(const AConnection: IDBFullConfigConnection): IPersistenceObject; reintroduce;
- function SetActive(const Value: Boolean): IPersistenceObject; reintroduce;
- function SetObject(const AObject: IPersistentObject): IPersistenceObject;
São métodos expostos pela implementação da interface IDevice: - function SetId(const Value: string): IDevice; reintroduce;
- function SetDescription(const Value: string): IDevice;
- function SetManufacturer(const Value: string): IDevice;
- function SetModel(const Value: string): IDevice;
São métodos expostos pela implementação da interface IBiometricDevice: - function SetId(const Value: string): IBiometricDevice; reintroduce;
- function SetDescription(const Value: string): IBiometricDevice; reintroduce;
- function SetManufacturer(const Value: string): IBiometricDevice; reintroduce;
- function SetModel(const Value: string): IBiometricDevice; reintroduce;
- function SetMode(const Value: TBiometricMode): IBiometricDevice;
- function SetTemplateSize(const Value: Integer): IBiometricDevicefunction TreatRequest(const AConnection: IDBFullConfigConnection; const ARequest: TWebRequest; const AResponse: TWebResponse): THTTPCode;
|
| Totvs custom tabs box items |
|---|
| default | no |
|---|
| referencia | propriedades |
|---|
| São propriedades expostas pela implementação da interface IPersistentObject: - property Id: string read GetId write PutId;
São propriedades expostas pela implementação da interface IPersistenceBase: - property Reference: string read GetReference write PutReference;
- property Attributes: TJSONObject read GetAttributes write PutAttributes;
- property Active: Boolean read GetActive write PutActive;
São propriedades expostas pela implementação da interface IPersistenceType: - property Reference: string read GetReference write PutReference;
- property Attributes: TJSONObject read GetAttributes write PutAttributes;
- property Active: Boolean read GetActive write PutActive;
São propriedades expostas pela implementação da interface IPersistenceObject: São propriedades expostas pela implementação da interface IPersistentObject: São propriedades expostas pela implementação da interface IPersistentObject:Não há propriedades expostas pela interface ICATRACABase. |
| Totvs custom tabs box items |
|---|
| default | no |
|---|
| referencia | exemplos |
|---|
| Para utilização da implementação da interface ICATRACABase em aplicações Delphi, segue o exemplo de uso deste componente.
Execução da ação de login: | Bloco de código |
|---|
| language | delphi |
|---|
| title | Execução da ação de login |
|---|
| 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; |
Resultado esperado: 

Os demais métodos retornam uma mensagem 204 - No content -, não possuindo retorno visível. |
|
...