Jump to content

brunotoira

Members
  • Posts

    43
  • Joined

  • Last visited

Posts posted by brunotoira

  1. Hello,

    If someone needs a freelancer, please talk to me. I Have many years of experience working with UniGui and +/- 10 years with Delphi and MS SQL, MySQL, Firebird and other RMDB

    Thanks from Portugal

  2. I have the same problem... ISAPI dont catch the URI for example.


     


    My website work's fine localhost:8077/api for example


    But when convert into ISAPI, i cant call "api" 


    give-me error


     

     

     

    My code:

     



    procedure TUniServerModule.UniGUIServerModuleHTTPCommand(
    ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
    var Handled: Boolean);
    var
    field_name,nomeDaColuna,valorDaColuna : String;
    I: Integer;
    Resultado:String;
    begin
    if (ARequestInfo.Params.Values['funcao']<>'sibsref-todos') and
    (ARequestInfo.Params.Values['funcao']<>'sibsref-lista') and
    (ARequestInfo.Params.Values['funcao']<>'sibsref-insere') then exit;


    if ARequestInfo.Params.Values['funcao']='sibsref-todos' then
    begin
    //showmessage('1');
    AResponseInfo.ContentType := 'text/html';

    if ARequestInfo.Params.Count<>3 then
    begin
    AResponseInfo.ContentText:='error 401';
    exit;
    end;

    ZQueryAPI.Close;
    ZQueryAPI.SQL.Clear;
    ZQueryAPI.SQL.Text :='select sibs_meps1_id as id,sibs_meps1_meps0id as meps0id, sibs_meps1_dthn as data '+
    ',sibs_meps1_ref as referencia, sibs_meps1_psc as valor'+
    ' from sibs_meps1 where dataficheiro>=:Data1 and dataficheiro<=:data2';
    ZQueryAPI.ParamByName('Data1').AsString:=copy(ARequestInfo.Params.Values['datainicio'],1,10);
    ZQueryAPI.ParamByName('Data2').AsString:=copy(ARequestInfo.Params.Values['datafim'],1,10);
    ZQueryAPI.Active := True;
    ZQueryAPI.First;
    end;

    if ARequestInfo.Params.ValueFromIndex[0]='sibsref-lista' then
    begin
    AResponseInfo.ContentType := 'text/html';
    if ARequestInfo.Params.Count<>2 then
    begin
    AResponseInfo.ContentText:='error 402';
    exit;
    end;

    ZQueryAPI.Close;
    ZQueryAPI.SQL.Clear;
    ZQueryAPI.SQL.Text :='select sibs_meps1_id as id,sibs_meps1_meps0id as meps0id, sibs_meps1_dthn as data '+
    ',sibs_meps1_ref as referencia, sibs_meps1_psc as valor'+
    ' from sibs_meps1 where sibs_meps1_ref=:Data1';
    ZQueryAPI.ParamByName('Data1').AsString:=copy(ARequestInfo.Params.Values['ref'],1,10);
    ZQueryAPI.Active := True;
    ZQueryAPI.First;
    end;

    if ARequestInfo.Params.ValueFromIndex[0]='sibsref-insere' then
    begin
    AResponseInfo.ContentType := 'text/html';
    //showmessage('3');
    if ARequestInfo.Params.Count<>8 then
    begin
    AResponseInfo.ContentText:='error 404';
    exit;
    end;

    ZQueryAPI.Close;
    ZQueryAPI.SQL.Clear;
    ZQueryAPI.SQL.Text :='DELETE FROM sibs_entidades WHERE CODIGO=:CODIGO';
    ZQueryAPI.ParamByName('CODIGO').AsString:=ARequestInfo.Params.Values['codigo'];
    ZQueryAPI.ExecSQL;

    ZQueryAPI.Close;
    ZQueryAPI.SQL.Clear;
    ZQueryAPI.SQL.Text :='INSERT INTO sibs_entidades (CODIGO,TELEMOVEL,EMAIL,NOME,APELIDO,ENTTRAB,CARTAO,REFERENCIA) '+
    'VALUES (:CODIGO,:TELEMOVEL,:EMAIL,:NOME,:APELIDO,:ENTTRAB,:CARTAO,:REFERENCIA)';
    ZQueryAPI.ParamByName('CODIGO').AsString:=ARequestInfo.Params.Values['codigo'];
    ZQueryAPI.ParamByName('TELEMOVEL').AsString:=ARequestInfo.Params.Values['telemovel'];
    ZQueryAPI.ParamByName('EMAIL').AsString:=ARequestInfo.Params.Values['email'];
    ZQueryAPI.ParamByName('NOME').AsString:=ARequestInfo.Params.Values['nome'];
    ZQueryAPI.ParamByName('APELIDO').AsString:=ARequestInfo.Params.Values['apelido'];
    ZQueryAPI.ParamByName('ENTTRAB').AsString:=ARequestInfo.Params.Values['EntTrab'];
    ZQueryAPI.ParamByName('CARTAO').AsString:=ARequestInfo.Params.Values['cartao'];
    ZQueryAPI.ParamByName('REFERENCIA').AsString:=ReferenciaMultibanco(ARequestInfo.Params.ValueFromIndex[1],15);
    ZQueryAPI.ExecSQL;

    ZQueryAPI.Close;
    ZQueryAPI.SQL.Clear;
    ZQueryAPI.SQL.Text :='select CODIGO,REFERENCIA from sibs_entidades where codigo=:codigo';
    ZQueryAPI.ParamByName('codigo').AsString:=ARequestInfo.Params.ValueFromIndex[1];
    ZQueryAPI.Active := True;
    ZQueryAPI.First;

    end;

    if ZQueryAPI.IsEmpty then exit;

    Resultado := '[';
    while (not ZQueryAPI.EOF) do
    begin

    Resultado := Resultado+'{';
    for I := 0 to ZQueryAPI.FieldDefs.Count-1 do
    begin
    nomeDaColuna := ZQueryAPI.FieldDefs[I].Name;
    valorDaColuna := ZQueryAPI.FieldByName(nomeDaColuna).AsString;
    Resultado := Resultado+'"'+nomeDaColuna+'":"'+valorDaColuna+'",';
    end;
    Delete(Resultado, Length(Resultado), 1);
    Resultado := Resultado+'},';

    ZQueryAPI.Next;
    end;
    ZQueryAPI.Refresh;

    Delete(Resultado, Length(Resultado), 1);
    Resultado := Resultado+']';

    AResponseInfo.ContentText:=Resultado;
    //AResponseInfo.WriteContent;

    Handled := true;

    //else
    // Handled := False;

    end;


  3. procedure TDropbox.Upload(const AFileName: String);
    const
    API_URL = 'https://api-content.dropbox.com/1/files_put/sandbox/';
    var
    URL: String;
    https: TIdHTTP;
    SslIoHandler: TIdSSLIOHandlerSocket;
    begin
    URL := API_URL+ExtractFileName(AFileName)
    + '?oauth_signature_method=PLAINTEXT&oauth_consumer_key=' + FAppKey
    + '&oauth_token=' + FOAuth.AccessToken
    + '&oauth_signature=' + FAppSecret + '%26' + FOAuth.AccessTokenSecret;

    https := TIdHTTP.Create(nil);
    try
    SslIoHandler := TIdSSLIOHandlerSocket.Create(https);
    SslIoHandler.SSLOptions.Method := sslvTLSv1;
    SslIoHandler.SSLOptions.Mode := sslmUnassigned;

    https.IOHandler := SslIoHandler;
    https.Post(URL, AFileName);
    finally
    FreeAndNil(https);
    end;
    end;
    • Like 1
    • Upvote 1
  4. Hello,

     

    I need to create an application to retrieve informations of Client Computer like:

     

    IP, Logon name, Computer Name and manufacturer of board...

     

    I was think to use Jedi JvComputerInfo... but i only retrieve server information.

     

     

    Anyone knows who do this?!

  5. Hello,

    I need to setup UniEdit to accept only chars:

     

    0..9 and "," Backspace and "-" to negative numbers.

     

    i create this function, but if i press "." (point) doesnt change to "," (comma)

     

     

    Anyway to do this?

    procedure TDataModule1.AllowedChars(Sender: TObject; var Key: Char);
    begin
      If sender is TUniEdit then
      Begin
        if charinset(Key,[backspace, '0'..'9'])=True then exit;
        if ((Key = '.')OR(Key = ',')) and (Pos(',', TUniEdit(sender).Text) = 0) {and (TUniEdit(sender).s <> 0)} then
        BEGIN
          KEY:=',';
          exit;
        END;
        if (Key = '-') {and (TUniEdit(sender).SelStart = 0)}
         and (pos('-',TUniEdit(sender).text)=0) then  exit;
        Key := #0;
      end;
    end;

     

×
×
  • Create New...