if (not (group exist "0001_folder1_folder2_folder3")) { group add "0001_folder1_folder2_folder3"; }; script merge "folder1.folder2.folder3.step_1_source_connect.exe" true 5 (param ) "Connect to the source" { # CONFIGURATION ; -> "[CONF_NAME_OF_THE_FLOW]" "name_of_the_flow"; # INITIALIZATION ; -> "[FLOW_PID]" [PID]; # HANDLE ; try { # Flow initialization; stack flow_init [FLOW_PID] [CONF_NAME_OF_THE_FLOW] "{}"; stack flow_step [FLOW_PID] 1 "source_connect..."; # Local connection: don't use step 1; log write "Source: Local connection" OK null null; #Step 1 is valid; stack flow_step [FLOW_PID] 1 "source_connect_ok"; include "folder1.folder2.folder3.step_2_extract.exe"; } { #Step 1 is not valid; stack flow_step [FLOW_PID] 1 "source_connect_KO"; # Give the error to the stack and stop the process; exception (1) ([global_err]); } "[global_err]"; } "Return nothing"; if (not (group is granted script "folder1.folder2.folder3.step_1_source_connect.exe" "0001_folder1_folder2_folder3")) { group grant script "folder1.folder2.folder3.step_1_source_connect.exe" "0001_folder1_folder2_folder3"; }; script merge "folder1.folder2.folder3.step_2_extract.exe" true 1 (param ) "Extract files from the source" { # HANDLE ; try { # Mark the flow as step 2; stack flow_step [FLOW_PID] 2 "extract..."; # Create the local directory PID; file mkdir (concat "home/" [FLOW_PID]); #Step 2 is valid; stack flow_step [FLOW_PID] 2 "extract_ok"; stack (date now) "folder1.folder2.folder3.step_3_transform.exe" "[FLOW_PID]" [FLOW_PID] "[filename]" ""; } { #Step 2 is not valid; stack flow_step [FLOW_PID] 2 "extract_KO"; # Give the error to the stack and stop the process; exception (1) ([global_err]); } "[global_err]"; } "Return nothing"; if (not (group is granted script "folder1.folder2.folder3.step_2_extract.exe" "0001_folder1_folder2_folder3")) { group grant script "folder1.folder2.folder3.step_2_extract.exe" "0001_folder1_folder2_folder3"; }; script merge "folder1.folder2.folder3.step_3_transform.exe" true 1 (param (var "[FLOW_PID]" {true} "The flow PID" is_null:true is_empty:true "1") (var "[filename]" {true} "The filename" is_null:true is_empty:true "file.xxx") ) "Transform the file" { # HANDLE ; try { # Mark the flow as step 3; stack flow_step [FLOW_PID] 3 "transform..."; # EMAIL: don't use step 3; log write "EMAIL: don't use step 3" OK null null; #Step 3 is valid; stack flow_step [FLOW_PID] 3 "transform_ok"; stack (date now) "folder1.folder2.folder3.step_4_destination_connect.exe" "[FLOW_PID]" [FLOW_PID] "[filename]" [filename]; } { #Step 3 is not valid; stack flow_step [FLOW_PID] 3 "transform_KO"; # Give the error to the stack and stop the process; exception (1) ([global_err]); } "[global_err]"; } "Return nothing"; if (not (group is granted script "folder1.folder2.folder3.step_3_transform.exe" "0001_folder1_folder2_folder3")) { group grant script "folder1.folder2.folder3.step_3_transform.exe" "0001_folder1_folder2_folder3"; }; script merge "folder1.folder2.folder3.step_4_destination_connect.exe" true 5 (param (var "[FLOW_PID]" {true} "The flow PID" is_null:true is_empty:true "1") (var "[filename]" {true} "The filename" is_null:true is_empty:true "file.xxx") ) "Connect to the destination" { # HANDLE ; try { # Flow initialization; stack flow_step [FLOW_PID] 4 "destination_connect..."; # EMAIL: don't use step 4; log write "EMAIL: don't use step 4" OK null null; #Step 4 is valid; stack flow_step [FLOW_PID] 4 "destination_connect_ok"; include "folder1.folder2.folder3.step_5_load.exe"; } { #Step 4 is not valid; stack flow_step [FLOW_PID] 4 "destination_connect_KO"; # Give the error to the stack and stop the process; exception (1) ([global_err]); } "[global_err]"; } "Return nothing"; if (not (group is granted script "folder1.folder2.folder3.step_4_destination_connect.exe" "0001_folder1_folder2_folder3")) { group grant script "folder1.folder2.folder3.step_4_destination_connect.exe" "0001_folder1_folder2_folder3"; }; script merge "folder1.folder2.folder3.step_5_load.exe" true 1 (param ) "Load file to the destination" { # CONFIGURATION ; -> "[CONF_DESTINATION_CM_SMTP]" "demo_cm_smtp"; -> "[CONF_DESTINATION_EMAIL_TO]" "jim@innov-ai.com;dan@innov-ai.com"; -> "[CONF_DESTINATION_EMAIL_CC]" "contact@innov-ai.com"; -> "[CONF_DESTINATION_EMAIL_BCC]" "contact@innov-ai.com"; -> "[CONF_DESTINATION_EMAIL_SUBJECT]" (concat "Hello '" [filename] "'!"); # HANDLE ; try { # Mark the flow as step 5; stack flow_step [FLOW_PID] 5 "load..."; -> "[BODY]" "Hi, here information :"; log write (concat "Send data from SOAP API by email...") OK null null; xml load "flow_source" (soap https "https://www.dneonline.com/calculator.asmx" "{}" "" "text/xml; charset=utf-8" (concat "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:tem=\"http://tempuri.org/\"> <soap:Header/> <soap:Body> <tem:Add> <tem:intA>3</tem:intA> <tem:intB>4</tem:intB> </tem:Add> </soap:Body> </soap:Envelope>")); # BEGIN METHOD 1; -> "[T_A]" (xml select text "flow_source" "/data/A"); -> "[T_B]" (xml select text "flow_source" "/data/B"); -> "[T_C]" (xml select text "flow_source" "/data/C"); concat_var "[BODY]" [_n_] [T_A] ", " [T_B] ", " [T_C]; concat_var "[BODY]" [_n_] [_n_] "END."; json load "files" "[]"; json iarray "files" / (concat "home/" [FLOW_PID] "/" [filename]) STR; mail send [CONF_DESTINATION_CM_SMTP] [CONF_DESTINATION_EMAIL_TO] [CONF_DESTINATION_EMAIL_CC] [CONF_DESTINATION_EMAIL_BCC] [CONF_DESTINATION_EMAIL_SUBJECT] [BODY] (json doc "files"); # END METHOD 1; # BEGIN METHOD 2; -> "[nb_rows]" (xml count "flow_source" "/data/rows/item"); for (-> "[i_xml]" 1) (<= [i_xml] [nb_rows]) (++ "[i_xml]") { -> "[T_A]" (xml select text "flow_source" (concat "/data/rows/item[" [i_xml] "]/A")); -> "[T_B]" (xml select text "flow_source" (concat "/data/rows/item[" [i_xml] "]/B")); -> "[T_C]" (xml select text "flow_source" (concat "/data/rows/item[" [i_xml] "]/C")); mail send [CONF_DESTINATION_CM_SMTP] [CONF_DESTINATION_EMAIL_TO] [CONF_DESTINATION_EMAIL_CC] [CONF_DESTINATION_EMAIL_BCC] [CONF_DESTINATION_EMAIL_SUBJECT] (concat [T_A] ", " [T_B] ", " [T_C]) "[]"; }; log write (concat "Sended.") OK null null; #Step 5 is valid; stack flow_step [FLOW_PID] 5 "load_ok"; } { #Step 5 is not valid; stack flow_step [FLOW_PID] 5 "load_KO"; # Give the error to the stack and stop the process; exception (1) ([global_err]); } "[global_err]"; } "Return nothing"; if (not (group is granted script "folder1.folder2.folder3.step_5_load.exe" "0001_folder1_folder2_folder3")) { group grant script "folder1.folder2.folder3.step_5_load.exe" "0001_folder1_folder2_folder3"; };