Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

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
tabsMétodos expostos,Propriedades expostas,Exemplos de uso
idsmetodos,propriedades,exemplos
Totvs custom tabs box items
defaultyes
referenciametodos

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
defaultno
referenciapropriedades

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
defaultno
referenciaexemplos

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
languagedelphi
titleExecuçã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 204No content -, não possuindo retorno visível.

...