Árvore de páginas

Versões comparadas

Chave

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

...

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 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): IBiometricDevice;
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: IDevice:

  • property Description: string read GetDescription write PutDescription;
  • property Manufacturer: string read GetManufacturer write PutManufacturer;
  • property Model: string read GetModel write PutModel;

São propriedades expostas pela implementação da interface IPersistentObject: IBiometricDevice:

  • property Mode: TBiometricMode read GetMode write PutMode;
  • property TemplateSize: Integer read GetTemplateSize write PutTemplateSize;
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:

dos componentes, segue-se uma hierarquia:
No exemplo a seguir, TBiometricDevice é uma implementação concreta que implementa IBiometricDevice, que deriva de IDevice;

Bloco de código
languagedelphi
titleExecução da ação de loginDispositivo biométrico
procedure TComponentDebugger.btnSendToBiometriesClick(Sender: TObject);
var
  Request: TWebRequest;
  Response: TWebResponse;
  Return: THTTPCode;
  ResponseJSON: TJSONObject;

  procedure SetAccessDataInINI;
  var
    URL : string;
    Path: string;
  TFormMain.ViewToModel;
begin
  FBiometricDevice  URL := string(cbxURL.Text).Replace('{personId}', edtPersonIdBiometries.Text, [rfReplaceAll])TBiometricDevice.Create;
    Path := URL.Delete('http://localhost/api');
    TIniReader.Instance.OpenFile(FBasePath + BIOMETRIES_INI_FILEFBiometricDevice.SetDescription(lbledObjtReference.Text)
                       .Section['Extra Headers']
  .SetManufacturer(lbledtManufacturer.Text)
                     .WriteString('Url', URLSetModel(lbledtModel.Text)
                  .SetMode(TBiometricMode(IfThen(cbbMode.ItemIndex < 0, 0,  .RootcbbMode.ItemIndex)))
                       .Section['CGI']
                       .WriteString('Logical Path', Path)
    .SetTemplateSize(StrToInt(lbledtTemplateSize.Text));
end;

TObjectType representa o cadastro de tipos de dispositivos/equipamentos, contendo sua descrição e um campo que conterá o schema de validação para objetos de seu tipo.

Bloco de código
languagedelphi
titleTipo de Objeto
procedure TFormMain.SaveData;
var
  Return: Cardinal;
begin
  TPersistenceType.Create(lbledtId.Text)
                   .WriteString('Physical Path', PathSetConnection(FConnection)
                       .UpdateFile;
  end;

  procedure SetRequestWithQueryParams;.SetReference(lbledtReference.Text)
  begin
    if chkWithParams.Checked then
    begin
      Request.QueryFields.Add(PAGE_PARAM.Format([edtPageBiometries.Text]));
.SetAttributes(TJSONObject(TJSONObject.ParseJSONValue(mmoAttributes.Text)))
       Request.QueryFields.Add(PAGE_SIZE_PARAM.Format([edtPageSizeBiometries.Text]));
    end;
  end;

  procedure SetRequest(const AIndex: Integer);
  begin
 .SetActive(chkActive.Checked)
     if AIndex = 0 then
    begin
      .Save(Return);
end;

TPersistenceObject é usado para salvar, recuperar, editar e excluir um objeto que representa um dispositivo, como um TBiometricDevice, e vincula com seu tipo, como um cadastro de TObjetcType para "Dispositivo biométrico".

Bloco de código
languagedelphi
titlePersistenceObject
procedure TFormMain.SaveData;
var
  Return: CardinalSetRequestWithQueryParams;
    end;
  end;
begin
  SetAccessDataInINIViewToModel;
  sedtResponseTPersistenceObject.Lines.Clear;Create(lbledtObjId.Text)
  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(FConnectionSetConnection(FConnection)
                    .SetReference(lbledObjtReference.Text)
                    .SetObjectType(TPersistenceType.Create
                                        , Request
          .SetConnection(FConnection)
                                                   .Load(FObjectTypeID[cbbObjTypeId.ItemIndex]))
                   , Response);
.SetObject(FBiometricDevice)
  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
SetActive(chkObjActive.Checked)
              ResponseJSON := Response.Content.ToJSON;
    sedtResponse.Text := ResponseJSON.PrettyFormat(2.Save(Return);
    ResponseJSON.Free;
  end;

  Request.Free;
end;

Resultado esperado:

Image Removed

Image Removed

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


04. DEMAIS INFORMAÇÕES

Por ser dependente do framework de desenvolvimento, os caminhos para os arquivos arquivos desta dependência devem estar presentes no projeto ao ser utilizado.

...