Commit inicial: fuentes MBS ERP (Genero 6) + .gitignore + docs/SETUP_PC_MBS.md
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
|
||||
IMPORT util
|
||||
IMPORT com
|
||||
IMPORT os
|
||||
|
||||
|
||||
FUNCTION envia_encuesta(email_cliente,xcotizacion,nombre,xventas, vieneDe)
|
||||
DEFINE email_cliente,nombre VARCHAR(100),
|
||||
xcotizacion INT,
|
||||
xventas VARCHAR(1),
|
||||
url,strcuerpo,strusername,xsmtphost,strpassword,strport,srtsubject,urlk,cotiza,resp STRING,
|
||||
data RECORD
|
||||
token STRING
|
||||
END RECORD,
|
||||
esValido, vieneDe STRING
|
||||
|
||||
# CALL apiclient(email_cliente) RETURNING esValido,resp
|
||||
# DISPLAY "estado: ",esValido," respuesta: ",resp
|
||||
# IF esValido = 'VALIDO' THEN
|
||||
LET url = "https://encuesta-final.vercel.app/api/encrypt"
|
||||
LET cotiza = xcotizacion USING "<<<<<<<<"
|
||||
DISPLAY "cotizacion: ",cotiza
|
||||
CALL jewt(url,cotiza) RETURNING urlk
|
||||
|
||||
TRY
|
||||
CALL util.JSON.parse(urlk,data)
|
||||
CATCH
|
||||
DISPLAY "EMITIO UN ERROR EL JSON"
|
||||
RETURN
|
||||
END TRY
|
||||
DISPLAY "token ",data.token
|
||||
DISPLAY "urlk ",urlk
|
||||
IF xventas = '1' OR xventas='3' THEN
|
||||
LET url = "https://encuesta-final.vercel.app/orden/encuesta1/",data.token
|
||||
LET strcuerpo = "<p><a href='",url CLIPPED,"'>",
|
||||
"<img border='0' alt='Encuesta' src='https://ws.marmotech.com.do/imagenes/principal/2.png' width='600' height='400'>",
|
||||
"</a></p>"
|
||||
|
||||
END IF
|
||||
IF xventas = '2' THEN
|
||||
LET url = "https://encuesta-final.vercel.app/orden/encuesta2/",data.token
|
||||
LET strcuerpo = "<p><a href='",url CLIPPED,"'>",
|
||||
"<img border='0' alt='Encuesta' src='https://ws.marmotech.com.do/imagenes/principal/encuestaingles.png' width='600' height='400'>",
|
||||
"</a></p>"
|
||||
|
||||
END IF
|
||||
#-------------------------------------------------------------------------
|
||||
# LET strcuerpo = "<html><body><h1>ESTA ES LA ENCUESTA</h1><input type='button' value='ENVIAR ENCUESTA'/></body></html>"
|
||||
|
||||
SELECT a.from_address,a.puerto,a.nombre_servidor,a.clave
|
||||
INTO strusername,strport,xsmtphost,strpassword
|
||||
FROM tbperfil_mail a WHERE cod_perfil =2
|
||||
|
||||
# LET strusername ='notificacion@marmotech.com.do'
|
||||
# LET xsmtphost ='smtp.office365.com'
|
||||
# LET xsmtpport = '587'
|
||||
# LET xpassword = 'Lmmjvsd2020'
|
||||
# LET vendedoremail = 'jsoto@marmotech.com.do'
|
||||
IF xventas = '1' OR xventas = '3' THEN
|
||||
LET srtsubject = 'ENCUESTA MARMOTECH'
|
||||
END IF
|
||||
IF xventas = '2' THEN
|
||||
LET srtsubject = 'SURVEY MARMOTECH'
|
||||
END IF
|
||||
CALL enviaemail(email_cliente,srtsubject,strcuerpo,NULL,strusername,xsmtphost,strport,strpassword) #RETURNING retorne
|
||||
INSERT INTO encuestas_log (fecha,referencia,observacion,email,nombre_usuario,estado,mensaje_respuesta,ventas,idencuesta, programa)
|
||||
VALUES (getdate(),cotiza,'ENVIO ENCUESTA CLIENTE EXTERNO',email_cliente,nombre,'VALIDO',resp,xventas,'3', vieneDe)
|
||||
# ELSE
|
||||
# INSERT INTO encuestas_log (fecha,referencia,observacion,email,nombre_usuario,estado,mensaje_respuesta)
|
||||
# VALUES (getdate(),cotiza,'ENVIO ENCUESTA CLIENTE EXTERNO LOCAL',email_cliente,nombre,'INVALIDO',resp)
|
||||
# END if
|
||||
END FUNCTION
|
||||
FUNCTION jewt(url,dato)
|
||||
DEFINE jwtk,ret,res,url,s,dato STRING
|
||||
|
||||
LET s = dato CLIPPED
|
||||
CALL sync_send_command(url, s) RETURNING ret, res
|
||||
LET jwtk = res
|
||||
RETURN jwtk
|
||||
END FUNCTION
|
||||
|
||||
|
||||
#
|
||||
## Communications library using com (http or https)
|
||||
#
|
||||
|
||||
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","dbsync/json")
|
||||
DISPLAY "request ",cmd
|
||||
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