IMPORT util DEFINE url STRING TYPE t_sync_cmd RECORD oper STRING, data STRING END RECORD MAIN CALL startlog("err_client_test.log") LET url="http://localhost:8097" IF test_connection()==0 THEN DISPLAY "CONNECTION OK" CALL envia_foto("../prueba.jpg") END IF END MAIN FUNCTION test_connection() DEFINE msg STRING DEFINE ret INTEGER DEFINE cmd STRING DEFINE r_cmd t_sync_cmd LET r_cmd.oper = "get_status" LET r_cmd.data = "" LET cmd = util.JSON.stringify(r_cmd) CALL sync_send_command(url, cmd) RETURNING ret, msg IF ret == 0 THEN CALL fgl_winmessage("Respuesta",msg,"information") ELSE LET msg=SFMT(%"Connection %1 failed",r_cmd.oper),"\n",url,"\n",msg CALL show_sync_err(msg) LET ret=-3 END IF RETURN ret END FUNCTION FUNCTION envia_foto(imagen) DEFINE imagen STRING DEFINE t RECORD poportunidades RECORD tema varchar(100) , direccion varchar(100) , telefono varchar(20) , # email VARCHAR(50), email_usuario varchar(50) , email_asignada varchar(50), lat float , long float # crm varchar(2) END RECORD, imagenes RECORD imagen BYTE END RECORD END RECORD DEFINE cmd, res, msg STRING DEFINE ret INTEGER DEFINE r_cmd t_sync_cmd -- preparacion de datos para enviar al sever LOCATE t.imagenes.imagen IN MEMORY CALL t.imagenes.imagen.readFile(imagen) LET t.poportunidades.tema="PRUEBA" LET t.poportunidades.direccion="" LET t.poportunidades.email_usuario="" LET t.poportunidades.email_asignada="" LET t.poportunidades.lat = 0 LET t.poportunidades.long= 0 -- envio de datos al sever LET r_cmd.oper = "envia_info" LET r_cmd.data = util.JSON.stringify(t) -- aca se convierte a string los datos de la operacion LET cmd = util.JSON.stringify(r_cmd) -- aca se convierte a string el comando/operacion a enviar al server CALL sync_send_command(url, cmd) RETURNING ret, res IF ret == 0 THEN CALL fgl_Winmessage("Respuesta",res,"information") --TRY --CALL util.JSON.parse(res,t) --CALL fgl_Winmessage("INFO","ENVIO EXITOSO","information") --CATCH --CALL show_sync_err(SFMT("JSON parse error: %1", STATUS)) --END TRY ELSE LET msg=SFMT(%"Connection '%1' failed",r_cmd.oper),"\n",url,"\n",res CALL show_sync_err(msg) END IF END FUNCTION