Ferramentas do usuário

Ferramentas do site


manual_usuario:studio:fluxo:designer:scripts

Diferenças

Aqui você vê as diferenças entre duas revisões dessa página.

Link para esta página de comparações

manual_usuario:studio:fluxo:designer:scripts [2016/01/19 15:09] – [StrToInt] administradormanual_usuario:studio:fluxo:designer:scripts [Data desconhecida] (atual) – edição externa (Data desconhecida) 127.0.0.1
Linha 176: Linha 176:
  
 ### ###
-Os procedimentos entre Repeat e until é executado na seqüência enquanto uma condição seja satisfeita.+Os procedimentos entre Repeat e until são executados na seqüência enquanto uma condição seja satisfeita.
 ### ###
  
Linha 342: Linha 342:
 Listagem das funções específicas do WFS. Listagem das funções específicas do WFS.
  
 +====ConectarDBSistema====
 +----
 +
 +###
 +A função estabelece uma conexão com um [[manual_usuario:studio:studio_objetivo_sistemas | sistema]] cadastrado e que possua uma conexão válida. O parâmetro passado deverá ser exatamente o nome do sistema.
 +###
 +
 +//Sintaxe//
 +
 +  ConectarDBSistema('RH3');
 +
 +//Exemplo//
 +
 +  conexao := ConectarDBSistema('RH3');
 =====Funções nativas===== =====Funções nativas=====
 ---- ----
Linha 2236: Linha 2250:
   var   var
     A, B, C, D, E, F : Integer;     A, B, C, D, E, F : Integer;
 +  
   begin   begin
     A := 32;     A := 32;
Linha 2244: Linha 2258:
     E := StrToIntDef('-0x1E', 0);     E := StrToIntDef('-0x1E', 0);
     F := A + B + C + D + E;     F := A + B + C + D + E;
 +  
     sMensagem := 'A : '+IntToStr(A);     sMensagem := 'A : '+IntToStr(A);
     sMensagem := 'B : '+IntToStr(B);     sMensagem := 'B : '+IntToStr(B);
Linha 2257: Linha 2271:
   var   var
     A : Integer;     A : Integer;
 +  
   begin   begin
     A := StrToIntDef('100 ', 55);     A := StrToIntDef('100 ', 55);
     sMensagem := 'Value = '+IntToStr(A);     sMensagem := 'Value = '+IntToStr(A);
 +  
     A := StrToIntDef('$FG' , 66);     A := StrToIntDef('$FG' , 66);
     sMensagem := 'Value = '+IntToStr(A);     sMensagem := 'Value = '+IntToStr(A);
Linha 2280: Linha 2294:
   var   var
     myTime : TDateTime;     myTime : TDateTime;
 +  
   begin   begin
     myTime := StrToTime('3PM');     myTime := StrToTime('3PM');
Linha 2325: Linha 2339:
   var   var
     myTime : TDateTime;     myTime : TDateTime;
 +  
   begin   begin
     myTime := StrToTime('15:22:35');     myTime := StrToTime('15:22:35');
Linha 2486: Linha 2500:
     text   : string;     text   : string;
     i      : Integer;     i      : Integer;
 +  
   begin   begin
     AssignFile(myFile, 'Test.txt');     AssignFile(myFile, 'Test.txt');
     ReWrite(myFile);     ReWrite(myFile);
 +  
     Write(myFile, 'Hello ');     Write(myFile, 'Hello ');
     Write(myFile, 'World');     Write(myFile, 'World');
 +  
     WriteLn(myFile);     WriteLn(myFile);
 +  
     for i := 2 to 4 do     for i := 2 to 4 do
       Write(myFile, i/2, '  ');       Write(myFile, i/2, '  ');
 +  
    WriteLn(myFile);    WriteLn(myFile);
 +  
     for i := 2 to 4 do     for i := 2 to 4 do
       Write(myFile, i/2:5:1);       Write(myFile, i/2:5:1);
 +  
     WriteLn(myFile);     WriteLn(myFile);
 +  
     CloseFile(myFile);     CloseFile(myFile);
 +  
     Reset(myFile);     Reset(myFile);
 +  
     while not Eof(myFile) do     while not Eof(myFile) do
     begin     begin
Linha 2515: Linha 2529:
       sMensagem := text;       sMensagem := text;
     end;     end;
 +  
     CloseFile(myFile);     CloseFile(myFile);
   end;   end;
Linha 2527: Linha 2541:
       male : Boolean;       male : Boolean;
     end;     end;
 +  
   var   var
     myFile   : File of TCustomer;     myFile   : File of TCustomer;
     customer : TCustomer;     customer : TCustomer;
 +  
   begin   begin
     AssignFile(myFile, 'Test.cus');     AssignFile(myFile, 'Test.cus');
     ReWrite(myFile);     ReWrite(myFile);
 +  
     customer.name := 'Fred Bloggs';     customer.name := 'Fred Bloggs';
     customer.age  := 21;     customer.age  := 21;
     customer.male := true;     customer.male := true;
     Write(myFile, customer);     Write(myFile, customer);
 +  
     customer.name := 'Jane Turner';     customer.name := 'Jane Turner';
     customer.age  := 45;     customer.age  := 45;
     customer.male := false;     customer.male := false;
     Write(myFile, customer);     Write(myFile, customer);
 +  
     CloseFile(myFile);     CloseFile(myFile);
 +  
     FileMode := fmOpenRead;     FileMode := fmOpenRead;
     Reset(myFile);     Reset(myFile);
 +  
     while not Eof(myFile) do     while not Eof(myFile) do
     begin     begin
Linha 2560: Linha 2574:
                         ' is '+IntToStr(customer.age);                         ' is '+IntToStr(customer.age);
     end;     end;
 +  
     CloseFile(myFile);     CloseFile(myFile);
   end;   end;
Linha 2569: Linha 2583:
     myWord, myWord1, myWord2 : Word;     myWord, myWord1, myWord2 : Word;
     myFile : File of Word;     myFile : File of Word;
 +  
   begin   begin
     AssignFile(myFile, 'Test.bin');     AssignFile(myFile, 'Test.bin');
     ReWrite(myFile);     ReWrite(myFile);
 +  
     myWord1 := 234;     myWord1 := 234;
     myWord2 := 567;     myWord2 := 567;
     Write(myFile, myWord1, myWord2);     Write(myFile, myWord1, myWord2);
 +  
     CloseFile(myFile);     CloseFile(myFile);
 +  
     FileMode := fmOpenRead;     FileMode := fmOpenRead;
     Reset(myFile);     Reset(myFile);
 +  
     while not Eof(myFile) do     while not Eof(myFile) do
     begin     begin
Linha 2588: Linha 2602:
       sMensagem := IntToStr(myWord);       sMensagem := IntToStr(myWord);
     end;     end;
 +  
     CloseFile(myFile);     CloseFile(myFile);
   end;   end;
Linha 2607: Linha 2621:
     myFile : TextFile;     myFile : TextFile;
     text   : string;     text   : string;
 +  
   begin   begin
     AssignFile(myFile, 'Test.txt');     AssignFile(myFile, 'Test.txt');
     ReWrite(myFile);     ReWrite(myFile);
 +  
     WriteLn(myFile, 'Hello World');     WriteLn(myFile, 'Hello World');
 +  
     WriteLn(myFile);     WriteLn(myFile);
 +  
     WriteLn(myFile, '22/7 = ' , 22/7);     WriteLn(myFile, '22/7 = ' , 22/7);
 +  
     WriteLn(myFile, '22/7 = ' , 22/7:12:6);     WriteLn(myFile, '22/7 = ' , 22/7:12:6);
 +  
     CloseFile(myFile);     CloseFile(myFile);
 +  
     Reset(myFile);     Reset(myFile);
 +  
     while not Eof(myFile) do     while not Eof(myFile) do
     begin     begin
Linha 2629: Linha 2643:
       sMensagem := text;       sMensagem := text;
     end;     end;
 +  
     CloseFile(myFile);     CloseFile(myFile);
   end;   end;
 +
 +======Biblioteca de Classes======
 +----
 +
 +Este tópico descreve e exemplifica o uso de classes utilizadas pelo WFS.
 +
 +=====HTTP/REST via script=====
 +----
 +
 +**Exemplo 1: ** Testes de envio (SLACK) para uma pessoa especifica passando o nome de outras pessoa no username;
 +
 +  var
 +    http: TWHTTP;
 +    response: THTTResponse;
 +    jsonObject: TJsonObject; 
 +    token, channel, text, username: String;
 +    
 +  begin
 +             
 +    try
 +      try
 +        // Criando a conexão 
 +        http := TWHTTP.create();
 +        // Parâmetros necessários para o método GET.
 +        token := http.encodeParameter( 'xoxb-179556611860-ZhO1pl49DXlJOmbDp6nKU9jd' );
 +        channel := http.encodeParameter( '@juliano.rafael' );
 +        text := http.encodeParameter( 'Teste de *integração*' );
 +        username := http.encodeParameter( '@juliano.rafael' ); 
 +        // Precisa de SSL.
 +        http.setSSL( true );
 +        response :=  http.doGet( 'https://slack.com/api/chat.postMessage?token=' + token + '&channel=' + channel + '&text=' + text + '&username=' + username );
 +        jsonObject := response.GetResponseJson(response.GetResponseString());
 +      except
 +        showMessage( 'ocorreu erro' );  
 +      end;  
 +    finally
 +      http.Free();
 +      response.Free();
 +    end;
 +                            
 +  end;                       
 +
 +**Exemplo 2: ** Teste de envio para um canal se passando por um usuário;
 +
 +  var
 +    http: TWHTTP;
 +    response: THTTResponse;
 +    jsonObject: TJsonObject; 
 +    token, channel, text, username: String;
 +    
 +  begin
 +             
 +    try
 +      try
 +        // Criando a conexão 
 +        http := TWHTTP.create();
 +        // Parâmetros necessários para o método GET.
 +        token := http.encodeParameter( 'xoxb-179556611860-ZhO1pl49DXlJOmbDp6nKU9jd' );
 +        channel := http.encodeParameter( 'channel' );
 +        text := http.encodeParameter( 'Teste de *integração*' );
 +        username := http.encodeParameter( '@juliano.rafael' ); 
 +        // Precisa de SSL.
 +        http.setSSL( true );
 +        response :=  http.doGet( 'https://slack.com/api/chat.postMessage?token=' + token + '&channel=' + channel + '&text=' + text + '&username=' + username );
 +        // Convertendo o retorno em JsonObject.
 +        jsonObject := response.GetResponseJson(response.GetResponseString());
 +      except
 +        showMessage( 'ocorreu erro' );  
 +      end;  
 +    finally
 +      http.Free();
 +      response.Free();
 +    end;
 +                            
 +  end;                       
 +
 +**Exemplo 3: ** Carregando lista de usuários do Slack;
 +
 +  var
 +    http: TWHTTP;
 +    response: THTTResponse;
 +    jsonObject: TJsonObject; 
 +    jsonPair: TJSonPair;
 +    jsonArray: TJsonArray;
 +    token, url: String;
 +    i: Integer;     
 +    
 +  begin              
 +             
 +    try
 +      try
 +        // Criando a conexão 
 +        http := TWHTTP.create();
 +        // Parâmetros necessários para o método GET.
 +        token := http.encodeParameter( 'xoxb-179556611860-ZhO1pl49DXlJOmbDp6nKU9jd' );
 +        // Precisa de SSL.
 +        http.setSSL( true );   
 +        url := 'https://slack.com/api/users.list?token=' + token; 
 +        response :=  http.doGet( url );
 +        // Convertendo o retorno em JsonObject.
 +        jsonObject := response.GetResponseJson(response.GetResponseString());
 +        jsonPair := response.getByName( jsonObject, 'members' );
 +        jsonArray := jsonPair.jsonValue;
 +        for i := 0 to jsonArray.size - 1 do
 +        begin 
 +          showMessage( TJsonObject( jsonArray.get(i) ).get(2).jsonValue.value );
 +        end;                            
 +        
 +      except
 +        showMessage( 'ocorreu erro' );  
 +      end;  
 +    finally
 +      http.Free();
 +      response.Free();
 +    end;
 +                            
 +  end;   
 +
 +**Exemplo 4: ** Inserindo Issue no Jira via basic authentication;
 +
 +  var
 +    http: TWHTTP;
 +    response: THTTResponse;
 +    jsonObject: TJsonObject; 
 +    url, paramJson: String;
 +    
 +  begin              
 +             
 +    try
 +      try
 +        // Criando a conexão 
 +        http := TWHTTP.create();
 +        // Neste caso necessario autenticação básica
 +        http.setBasicAuthentication( true );
 +        http.setUser( 'board-jira@rh3software.com' );
 +        http.setPassWord( 'Rh3@1593576482' );
 +        // Será passado um Json.
 +        http.setContentType( 'application/json' );
 +        // Default charset.
 +        http.setCharset( 'utf-8' );
 +        // Precisa de SSL.
 +        http.setSSL( true );
 +        // Json em forma de string para ser passado como data para o doPost.
 +        paramJson := '{
 +                      "fields": {
 +                      "project":                                     
 +                               
 +                                "key": "RH3"
 +                             },
 +                      "summary": "Segundo testes da API.",
 +                      "description": "Creating of an issue using project keys and issue type names using the REST API",
 +                      "issuetype": {      
 +                          "name": "Bug"                 
 +                                           
 +                     }
 +                  }';                  
 +        // URL 
 +        url := 'https://rh3software.atlassian.net/rest/api/2/issue'; 
 +        // Response do doPost
 +        response :=  http.doPost( url, paramJson );                        
 +        // Convertendo o retorno em JsonObject.
 +        jsonObject := response.GetResponseJson(response.GetResponseString()); 
 +        // Pegando o objeto retornado para mostrar a chave que foi incluída.
 +        showMessage( response.getByName( jsonObject, 'key' ).jsonValue.value );
 +        
 +       except
 +          showMessage( 'ocorreu erro' );  
 +       end;  
 +    finally
 +      http.Free();
 +      response.Free();
 +    end;
 +                    
 +  end;                                                                   
 +
 +**Exemplo 5: ** Retornando um statuscode >= 400 da api.
 +
 +  var
 +    http: TWHTTP;
 +    response: THTTResponse;
 +    jsonObject: TJsonObject; 
 +    url, paramJson: String;
 +    
 +  begin              
 +             
 +    try
 +      try
 +        // Criando a conexão 
 +        http := TWHTTP.create();
 +        // Neste caso necessario autenticação básica
 +        http.setBasicAuthentication( true );
 +        http.setUser( 'board-jira@rh3software.com' );
 +        http.setPassWord( 'Rh3@1593576482' );
 +        // Será passado um Json.
 +        http.setContentType( 'application/json' );
 +        // Default charset.                                         
 +        http.setCharset( 'utf-8' );        
 +        // Precisa de SSL.
 +        http.setSSL( true );
 +        // Json em forma de string para ser passado como data para o doPost.
 +        paramJson := '{
 +                      "fields": {
 +                      "project":                                     
 +                               
 +                                "key": "fdsafdas"
 +                             },
 +                      "summary": "REST ye merry gentlemen.",
 +                      "description": "Creating of an issue using project keys and issue type names using the REST API",
 +                      "issuetype": {                 
 +                          "name": "Bug"                 
 +                                           
 +                     }
 +                  }';                  
 +        // URL 
 +        url := 'https://rh3software.atlassian.net/rest/api/2/issue'; 
 +        // Response do doPost
 +        response :=  http.doPost( url, paramJson );                        
 +        // Convertendo o retorno em JsonObject.
 +        jsonObject := response.GetResponseJson(response.GetResponseString()); 
 +        // Pegando o objeto retornado porem o statuscode > 400
 +        if response.getStatusCode() >= 400 then
 +          showMessage( TJsonObject( response.getByName( jsonObject, 'errors' ).jsonValue ).get(0).jsonValue.value );
 +        
 +       except
 +          showMessage( 'ocorreu erro' );  
 +       end;  
 +    finally
 +      http.Free();
 +      response.Free();
 +    end;
 +                    
 +  end;
 +
manual_usuario/studio/fluxo/designer/scripts.1453216193.txt.gz · Última modificação: (edição externa)