Commit inicial: fuentes MBS ERP (Genero 6) + .gitignore + docs/SETUP_PC_MBS.md
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
IMPORT com
|
||||
IMPORT util
|
||||
|
||||
TYPE t_sync_cmd RECORD
|
||||
oper STRING,
|
||||
data STRING
|
||||
END RECORD
|
||||
|
||||
|
||||
DEFINE url STRING
|
||||
MAIN
|
||||
|
||||
|
||||
|
||||
CALL productoclienterest()
|
||||
|
||||
END MAIN
|
||||
FUNCTION productoclienterest()
|
||||
DEFINE s STRING,
|
||||
r_cmd t_sync_cmd
|
||||
DEFINE data RECORD
|
||||
usuario VARCHAR(50),
|
||||
clave VARCHAR(50),
|
||||
codigo VARCHAR(25)
|
||||
END RECORD,
|
||||
ret INTEGER,
|
||||
res STRING
|
||||
LET url = "https://ws.marmotech.com.do/gas/ws/r/restserver"
|
||||
|
||||
LET data.usuario='jsoto'
|
||||
LET data.clave = 'lmmjvsd2014'
|
||||
LET data.codigo='196681781079'
|
||||
|
||||
LET r_cmd.oper = 'productos_display'
|
||||
LET r_cmd.data = util.JSON.stringify(data)
|
||||
|
||||
LET s = util.JSON.stringify(r_cmd)
|
||||
|
||||
#LET s='{
|
||||
#"oper": "productos_display",
|
||||
#"data": {
|
||||
# "usuario": "CRM_user",
|
||||
# "clave": "XMarmotech2019",
|
||||
# "codigo": "196681781079"
|
||||
#}
|
||||
#}'
|
||||
|
||||
DISPLAY "s-",s
|
||||
CALL sync_send_command(url, s) RETURNING ret, res
|
||||
DISPLAY "DATOS ",res," ret ",ret
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION sync_send_command(url, cmd)
|
||||
|
||||
DEFINE url, cmd STRING
|
||||
DEFINE result, tmp STRING
|
||||
DEFINE http_req com.HTTPRequest
|
||||
DEFINE http_resp com.HTTPResponse
|
||||
|
||||
|
||||
TRY
|
||||
LET http_req = com.HTTPRequest.Create(url)
|
||||
CALL http_req.setConnectionTimeout(40)
|
||||
CALL http_req.setTimeout(40)
|
||||
CALL http_req.setMethod("POST")
|
||||
CALL http_req.setCharset("UTF-8")
|
||||
CALL http_req.setHeader("DBSync-Client","mbs")
|
||||
CALL http_req.setHeader("Content-Type","application/json")
|
||||
|
||||
CALL http_req.doTextRequest(cmd)
|
||||
LET http_resp=http_req.getResponse()
|
||||
IF http_resp.getStatusCode() != 200 THEN
|
||||
RETURN http_resp.getStatusCode(), http_resp.getStatusDescription()
|
||||
END IF
|
||||
LET tmp = http_resp.getStatusDescription()
|
||||
IF (tmp == "OK" || tmp == "no error" ) THEN
|
||||
RETURN -1, SFMT("HTTP request status description: %1 ",tmp)
|
||||
END IF
|
||||
LET result = http_resp.getTextResponse()
|
||||
CATCH
|
||||
RETURN -2, SFMT("HTTP request error: STATUS=%1 (%2)",STATUS,SQLCA.SQLERRM)
|
||||
END TRY
|
||||
|
||||
RETURN 0, result
|
||||
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION show_sync_err(msg)
|
||||
DEFINE msg STRING
|
||||
CALL fgl_winmessage(%"ERROR", msg, "exclamation")
|
||||
END FUNCTION
|
||||
Reference in New Issue
Block a user