Commit inicial: fuentes MBS ERP (Genero 6) + .gitignore + docs/SETUP_PC_MBS.md
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
all:: javax.mail.jar
|
||||
|
||||
javax.mail.jar:
|
||||
curl -L -c cookie.txt http://java.net/projects/javamail/downloads/download/javax.mail.jar > javax.mail.jar
|
||||
rm -f cookie.txt
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<ManagedForm fileVersion="31400" gstVersion="3140a" name="managedform" uid="{f627faad-2077-4941-8fc6-e136014908c7}">
|
||||
<AGSettings>
|
||||
<DynamicProperties version="2"/>
|
||||
</AGSettings>
|
||||
<Record name="record1" uid="{8afc488a-b676-4ec5-bd84-8bf46d5cdf71}">
|
||||
<RecordField fieldIdRef="6" name="ruta_orig" uid="{9d420b6f-dc4e-496c-88af-6f5607acd085}"/>
|
||||
<RecordField fieldIdRef="7" name="nombre_cliente" uid="{5ee67cac-cc05-443b-88fb-aa19777efde4}"/>
|
||||
<RecordField fieldIdRef="1" name="num_doc" uid="{81d47546-a2eb-4419-b286-59ff6331d8be}"/>
|
||||
</Record>
|
||||
<Record name="Drecord" uid="{7e63bda9-8d4f-4203-bbbe-fe6300d34910}">
|
||||
<RecordField fieldIdRef="4" name="ruta_orig1" uid="{eda10cb5-e2cc-4611-8cb8-c73fb9bf94f5}"/>
|
||||
<RecordField fieldIdRef="3" name="ruta_fis1" uid="{7db55299-70af-458f-9d29-019f4ecb9e24}"/>
|
||||
<RecordField fieldIdRef="5" name="nombreFileOriginal1" uid="{057f6011-e85d-4acb-b2ab-6746ccc77cc3}"/>
|
||||
<RecordField fieldIdRef="2" name="nombreFile1" uid="{5e2d864f-5766-4e53-bbe6-e3458f6ac795}"/>
|
||||
</Record>
|
||||
<Form gridHeight="25" gridWidth="80" name="form" text="Form">
|
||||
<Grid gridHeight="18" gridWidth="73" name="grid1" posX="6" posY="2">
|
||||
<Group gridHeight="7" gridWidth="70" name="group1" posX="1" posY="1" text="">
|
||||
<Label gridHeight="1" gridWidth="6" name="label1" posX="1" posY="1" text="CLIENTE:"/>
|
||||
<FFLabel fieldId="7" gridHeight="1" gridWidth="23" name="nombre_cliente" posX="9" posY="1" title="fflabel1" widget="FFLabel"/>
|
||||
<Label gridHeight="1" gridWidth="9" name="label2" posX="1" posY="2" text="NO. DOCUMENTO"/>
|
||||
<FFLabel fieldId="1" gridHeight="1" gridWidth="13" justify="left" name="num_doc" posX="11" posY="2" title="fflabel1" widget="FFLabel"/>
|
||||
<Button gridHeight="1" gridWidth="9" image="fa-upload" name="UploadBttn" posX="1" posY="5" tabIndex="-1" text=""/>
|
||||
<Edit fieldId="6" gridHeight="1" gridWidth="58" name="ruta_orig" posX="11" posY="5" scroll="true" tabIndex="-1" title="edit6" widget="Edit"/>
|
||||
</Group>
|
||||
<Group gridHeight="8" gridWidth="69" name="group2" posX="2" posY="9" text="DOCUMENTOS">
|
||||
<Table gridHeight="6" gridWidth="48" name="table1" posX="1" posY="1" totalRows="5">
|
||||
<Edit fieldId="4" gridHeight="1" gridWidth="10" name="ruta_orig1" posX="0" posY="0" scroll="true" tabIndex="-1" title="RUTA ORIGINAL" widget="Edit"/>
|
||||
<Edit fieldId="3" gridHeight="1" gridWidth="8" name="ruta_fis1" posX="10" posY="0" scroll="true" tabIndex="-1" title="RUTA FISICA" widget="Edit"/>
|
||||
<Edit fieldId="5" gridHeight="1" gridWidth="14" name="nombreFileOriginal1" posX="18" posY="0" scroll="true" tabIndex="-1" title="NOMBRE FILE ORIGINAL" widget="Edit"/>
|
||||
<Edit fieldId="2" gridHeight="1" gridWidth="8" name="nombreFile1" posX="32" posY="0" scroll="true" tabIndex="-1" title="NOMBRE FILE" widget="Edit"/>
|
||||
</Table>
|
||||
<Button gridHeight="2" gridWidth="5" image="fa-folder-open-o" name="OpenBttn" posX="50" posY="3" tabIndex="-1" text=""/>
|
||||
</Group>
|
||||
</Grid>
|
||||
</Form>
|
||||
<DiagramLayout>
|
||||
<![CDATA[AAAAAgAAAEwAewA4AGEAZgBjADQAOAA4AGEALQBiADYANwA2AC0ANABlAGMANQAtAGIAZAA4ADQALQA4AGIAZgA0ADYAZAA1AGMAZABmADcAMQB9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAEwAewA3AGUANgAzAGIAZABhADkALQA4AGQANABmAC0ANAAyADAAMwAtAGIAYgBiAGUALQBmAGUANgAzADAAMABkADMANAA5ADEAMAB9QCqqqu1VVZhAKqqq7VVVmD9gYk3S8an8AQ==]]>
|
||||
</DiagramLayout>
|
||||
</ManagedForm>
|
||||
@@ -0,0 +1,4 @@
|
||||
# Netscape HTTP Cookie File
|
||||
# https://curl.se/docs/http-cookies.html
|
||||
# This file was generated by libcurl! Edit at your own risk.
|
||||
|
||||
@@ -0,0 +1,275 @@
|
||||
IMPORT os
|
||||
IMPORT JAVA java.lang.System
|
||||
IMPORT JAVA java.lang.Object
|
||||
IMPORT JAVA java.io.ByteArrayOutputStream
|
||||
IMPORT JAVA java.io.PrintStream
|
||||
IMPORT JAVA java.util.Properties
|
||||
IMPORT JAVA javax.mail.Session
|
||||
IMPORT JAVA javax.mail.Transport
|
||||
IMPORT JAVA javax.mail.Authenticator
|
||||
IMPORT JAVA javax.mail.Message
|
||||
IMPORT JAVA javax.mail.Message.RecipientType
|
||||
IMPORT JAVA javax.mail.internet.InternetAddress
|
||||
#IMPORT JAVA javax.mail.internet.MimeMessage
|
||||
IMPORT JAVA javax.mail.internet.MimeMultipart
|
||||
#IMPORT JAVA javax.mail.internet.MimeBodyPart
|
||||
IMPORT JAVA com.sun.mail.smtp.SMTPTransport
|
||||
IMPORT security
|
||||
|
||||
CONSTANT debug_level = 1
|
||||
|
||||
DEFINE logtext,rcpt_to,subject,body STRING
|
||||
DEFINE out_stream ByteArrayOutputStream
|
||||
DEFINE buf base.StringBuffer
|
||||
|
||||
TYPE cnf_t RECORD
|
||||
hostname STRING,
|
||||
smtphost STRING,
|
||||
smtpport INTEGER,
|
||||
senderemail STRING,
|
||||
smtpauth SMALLINT, -- 1: uses SMTP AUTH, 0: doesn't use AUTH
|
||||
username STRING,
|
||||
password STRING,
|
||||
use_ssl SMALLINT, -- 1: uses SSL, 0: doesn't use SSL
|
||||
use_tls SMALLINT, -- 1: uses TLS, 0: doesn't use TLS
|
||||
cnxtimeout INTEGER
|
||||
END RECORD
|
||||
DEFINE cnf cnf_t
|
||||
|
||||
|
||||
DEFINE xpassword STRING
|
||||
|
||||
DEFINE sesion Session,
|
||||
propuesta Properties,
|
||||
password,s_protocol,m_charset STRING
|
||||
# DEFINE msg MimeMessage
|
||||
# DEFINE mbodyp MimeBodyPart
|
||||
DEFINE multip MimeMultipart
|
||||
DEFINE trans SMTPTransport
|
||||
|
||||
|
||||
FUNCTION enviaemail(rcpt_to,subject,body,attachment,xusername,xsmtphost,xsmtpport,xpassword)
|
||||
|
||||
DEFINE mensaje,rcpt_to,subject,body,attachment,xusername,xsmtphost,xsmtpport,xpassword STRING
|
||||
|
||||
|
||||
|
||||
|
||||
END FUNCTION
|
||||
|
||||
PRIVATE FUNCTION create_cxion_session()
|
||||
DEFINE s_proto, s_password STRING
|
||||
DEFINE x_timeout INTEGER
|
||||
DEFINE sess Session
|
||||
DEFINE props Properties
|
||||
DEFINE custom_ps PrintStream
|
||||
|
||||
# Connection parameters preparation
|
||||
|
||||
CALL show_debug_msg(1,"Preparing connection parameters ...")
|
||||
# LET cnf.password = 'Lmmjvsd2020'
|
||||
CALL string_to_base64(cnf.password) RETURNING cnf.password
|
||||
|
||||
LET s_password=base64_to_string(cnf.password)
|
||||
|
||||
IF cnf.cnxtimeout>0 THEN
|
||||
LET x_timeout=cnf.cnxtimeout*1000 # convert to miliseconds
|
||||
ELSE
|
||||
LET x_timeout=0
|
||||
END IF
|
||||
|
||||
LET cnf.use_tls = TRUE
|
||||
LET cnf.use_ssl = FALSE
|
||||
|
||||
IF cnf.use_ssl THEN
|
||||
LET s_proto="smtps"
|
||||
ELSE
|
||||
LET s_proto="smtp"
|
||||
END IF
|
||||
|
||||
|
||||
CALL show_debug_msg(2,SFMT("Host: %1",cnf.smtphost))
|
||||
CALL show_debug_msg(2,SFMT("Port: %1",cnf.smtpport))
|
||||
CALL show_debug_msg(2,SFMT("User: %1",cnf.username))
|
||||
CALL show_debug_msg(4,SFMT("Password: %1",cnf.password)) # this is the base64 password
|
||||
CALL show_debug_msg(5,SFMT("Pswd txt: %1",s_password)) # this is the plain-text password
|
||||
CALL show_debug_msg(2,SFMT("Prot: %1",s_proto))
|
||||
CALL show_debug_msg(2,SFMT("TLS: %1",cnf.use_tls))
|
||||
CALL show_debug_msg(2,SFMT("Timeout: %1",x_timeout))
|
||||
|
||||
# Session properties preparation
|
||||
|
||||
CALL show_debug_msg(1,"Preparing Session properties ...")
|
||||
|
||||
LET props=System.getProperties()
|
||||
|
||||
IF cnf.use_ssl THEN
|
||||
CALL setMailProperties(props,"smtp","ssl.enable","true")
|
||||
ELSE
|
||||
CALL setMailProperties(props,"smtp","ssl.enable","false")
|
||||
END IF
|
||||
|
||||
IF cnf.smtpauth THEN
|
||||
CALL setMailProperties(props,s_proto,"auth","true")
|
||||
ELSE
|
||||
CALL setMailProperties(props,s_proto,"auth","false")
|
||||
END IF
|
||||
|
||||
CALL setMailProperties(props,s_proto,"port",cnf.smtpport)
|
||||
|
||||
CALL setMailProperties(props,s_proto,"connectiontimeout",x_timeout)
|
||||
|
||||
IF cnf.use_tls THEN
|
||||
CALL setMailProperties(props,s_proto,"starttls.enable","true")
|
||||
# the following 2 parameters are needed for FourJs mail server
|
||||
# but also work fine with Gmail servers when TLS option is selected
|
||||
# both servers were tested on 2016-06-02
|
||||
CALL setMailProperties(props,s_proto,"ssl.checkserveridentity","false")
|
||||
CALL setMailProperties(props,s_proto,"ssl.trust","*")
|
||||
ELSE
|
||||
CALL setMailProperties(props,s_proto,"starttls.enable","false")
|
||||
END IF
|
||||
|
||||
# Session creation
|
||||
|
||||
CALL show_debug_msg(1,"Creating Session ...")
|
||||
|
||||
LET sess=Session.getInstance(props)
|
||||
LET out_stream = ByteArrayOutputStream.create()
|
||||
LET custom_ps = PrintStream.create(out_stream)
|
||||
CALL sess.setDebugOut(custom_ps)
|
||||
CALL sess.setDebug(TRUE)
|
||||
|
||||
RETURN sess,s_password,s_proto
|
||||
|
||||
END FUNCTION
|
||||
|
||||
|
||||
FUNCTION base64_to_string(str_b64)
|
||||
|
||||
DEFINE str_out,str_b64,str_aux STRING
|
||||
|
||||
TRY
|
||||
CALL security.Base64.ToString(str_b64) RETURNING str_out
|
||||
CATCH
|
||||
LET str_aux="Unable to convert the Base64 string into plain-text:",STATUS
|
||||
CALL mbox_ok("Error", str_aux, "stop")
|
||||
LET str_out=NULL
|
||||
END TRY
|
||||
|
||||
RETURN str_out
|
||||
|
||||
END FUNCTION
|
||||
|
||||
PRIVATE FUNCTION show_debug_msg(lev,msg)
|
||||
DEFINE lev SMALLINT
|
||||
DEFINE msg STRING
|
||||
IF lev>=debug_level THEN
|
||||
DISPLAY msg
|
||||
END IF
|
||||
END FUNCTION
|
||||
|
||||
PRIVATE FUNCTION setMailProperties(props,prot,prop,val)
|
||||
DEFINE props Properties
|
||||
DEFINE auxi,prot,prop,val STRING
|
||||
|
||||
LET auxi=SFMT("mail.%1.%2",prot,prop)
|
||||
|
||||
CALL props.put(auxi,val)
|
||||
|
||||
CALL show_debug_msg(1,SFMT("Property '%1' set to value '%2'", auxi, val))
|
||||
|
||||
END FUNCTION
|
||||
FUNCTION mbox_ok(t, m, i)
|
||||
DEFINE t,m,i STRING
|
||||
MENU t ATTRIBUTES(STYLE="dialog",COMMENT=m,IMAGE=i)
|
||||
COMMAND "Ok" EXIT MENU
|
||||
END MENU
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION string_to_base64(str_ent)
|
||||
|
||||
DEFINE str_ent,str_b64,str_aux STRING
|
||||
|
||||
TRY
|
||||
CALL security.Base64.FromString(str_ent) RETURNING str_b64
|
||||
CATCH
|
||||
LET str_aux="Unable to convert the input string into Base64:",STATUS
|
||||
CALL mbox_ok("Error", str_aux, "stop")
|
||||
LET str_b64=NULL
|
||||
END TRY
|
||||
|
||||
RETURN str_b64
|
||||
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION validate_param_smpt_auth()
|
||||
|
||||
DEFINE flag_ok BOOLEAN
|
||||
|
||||
LET flag_ok=TRUE
|
||||
|
||||
IF xpassword=cnf.password THEN
|
||||
-- if password didn't change we don't encrypt as it is already encrypted
|
||||
ELSE
|
||||
IF LENGTH(cnf.password)>0 THEN
|
||||
CALL string_to_base64(cnf.password) RETURNING cnf.password
|
||||
END IF
|
||||
LET xpassword=cnf.password -- store new encrypted value
|
||||
END IF
|
||||
|
||||
IF cnf.smtpauth THEN
|
||||
IF LENGTH(cnf.username) == 0 THEN
|
||||
LET flag_ok=FALSE
|
||||
CALL mbox_ok("Error", "The username is mandatory when using Smtp Auth", "stop")
|
||||
ELSE
|
||||
IF LENGTH(cnf.password) == 0 THEN
|
||||
LET flag_ok=FALSE
|
||||
CALL mbox_ok("Error", "The password is mandatory when using Smtp Auth", "stop")
|
||||
END IF
|
||||
END IF
|
||||
END IF
|
||||
|
||||
RETURN flag_ok
|
||||
|
||||
END FUNCTION
|
||||
|
||||
# Retrieve the current charset
|
||||
FUNCTION getCharset()
|
||||
DEFINE l STRING
|
||||
DEFINE c base.Channel
|
||||
|
||||
LET c = base.Channel.create()
|
||||
CALL c.openPipe("fglrun -i mbcs 2>&1", "r")
|
||||
LET l = c.readLine()
|
||||
WHILE l IS NOT NULL
|
||||
IF l MATCHES "Charmap : *" THEN
|
||||
RETURN l.subString(16,length(l))
|
||||
EXIT WHILE
|
||||
END IF
|
||||
LET l = c.readLine()
|
||||
END WHILE
|
||||
RETURN "ISO-8859-1" -- default value
|
||||
END FUNCTION
|
||||
|
||||
PRIVATE FUNCTION show_output_dialog(s_stat)
|
||||
DEFINE s_stat,s_msg,s_color STRING
|
||||
DEFINE strbuf base.StringBuffer
|
||||
|
||||
IF s_stat="OK" THEN
|
||||
LET s_color="green"
|
||||
LET s_msg="The SMTP connection ended OK."
|
||||
ELSE
|
||||
LET s_color="red"
|
||||
LET s_msg="The SMTP connection ended with Error."
|
||||
END IF
|
||||
|
||||
# separates the Session debug message into html lines
|
||||
LET strbuf = base.StringBuffer.create()
|
||||
CALL strbuf.append(out_stream.toString())
|
||||
CALL strbuf.replace("\n","<BR>",0)
|
||||
|
||||
LET logtext=strbuf.toString(),"<BR>", # first adds the debug lines without additional format
|
||||
SFMT("<font color='%1'>",s_color),s_msg,"</font>" # then adds the result message in color
|
||||
|
||||
END FUNCTION
|
||||
@@ -0,0 +1,170 @@
|
||||
DEFINE
|
||||
i INT,
|
||||
client_data DYNAMIC ARRAY OF RECORD
|
||||
flag BOOLEAN,
|
||||
contactos STRING,
|
||||
nombre STRING,
|
||||
puesto STRING
|
||||
END RECORD
|
||||
|
||||
DEFINE MailStruct RECORD
|
||||
contactos STRING,
|
||||
subject STRING,
|
||||
body STRING
|
||||
END RECORD
|
||||
|
||||
DEFINE xusername, xsmtphost, xsmtpport, xpassword STRING
|
||||
DEFINE
|
||||
documentName STRING,
|
||||
conduce BYTE
|
||||
|
||||
FUNCTION envio_email(
|
||||
tip_cliente INT,
|
||||
sec_client INT,
|
||||
nombre STRING,
|
||||
num_orden INT,
|
||||
usuario STRING)
|
||||
|
||||
OPEN WINDOW w2 WITH FORM "envio_email"
|
||||
CALL fgl_settitle("Envio factura a cliente")
|
||||
|
||||
INITIALIZE client_data TO NULL
|
||||
INITIALIZE mailStruct TO NULL
|
||||
|
||||
CALL buscarData(tip_cliente, sec_client, num_orden)
|
||||
|
||||
DISPLAY nombre TO nombre_cliente
|
||||
|
||||
INPUT ARRAY client_Data
|
||||
FROM record1.*
|
||||
ATTRIBUTES(UNBUFFERED, WITHOUT DEFAULTS)
|
||||
|
||||
ON ACTION CANCEL
|
||||
EXIT INPUT
|
||||
CLOSE WINDOW w2
|
||||
|
||||
AFTER INPUT
|
||||
|
||||
INPUT BY NAME MailStruct.* ATTRIBUTES(UNBUFFERED, WITHOUT DEFAULTS)
|
||||
BEFORE INPUT
|
||||
DISPLAY documentName TO documentName
|
||||
CALL BuildMail()
|
||||
|
||||
ON ACTION CANCEL
|
||||
EXIT INPUT
|
||||
CLOSE WINDOW w2
|
||||
|
||||
AFTER INPUT
|
||||
CALL SendMail(num_orden, usuario)
|
||||
|
||||
END INPUT
|
||||
END INPUT
|
||||
CLOSE WINDOW w2
|
||||
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION buscarData(tip_cliente INT, sec_client INT, orden INT)
|
||||
|
||||
SET CONNECTION "MARMOTECH"
|
||||
|
||||
SELECT 0, patente, nombre
|
||||
INTO client_data[1].flag,
|
||||
client_data[1].contactos,
|
||||
client_data[1].nombre
|
||||
FROM vetb00004
|
||||
WHERE tipo_cliente = tip_cliente AND sec_cliente = sec_client
|
||||
|
||||
IF client_data[1].contactos IS NOT NULL THEN
|
||||
LET client_data[1].puesto = "PRINCIPAL"
|
||||
END IF
|
||||
|
||||
SELECT 0, email, 'Elvis', 'PRUEBA'
|
||||
INTO client_data[2].flag,
|
||||
client_data[2].contactos,
|
||||
client_data[2].nombre,
|
||||
client_data[2].puesto
|
||||
FROM seg0001
|
||||
WHERE usuario = 'egarcia'
|
||||
|
||||
DECLARE buscar CURSOR FOR
|
||||
SELECT 0, a.email, a.contacto, a.puesto
|
||||
FROM vetb00087 a
|
||||
WHERE a.tipo_cliente = tip_cliente AND a.sec_cliente = sec_client
|
||||
|
||||
LET i = 3
|
||||
FOREACH buscar INTO client_data[i].*
|
||||
LET i = i + 1
|
||||
END FOREACH
|
||||
|
||||
LOCATE conduce IN MEMORY
|
||||
|
||||
SELECT TOP(1) nombre_file, documento
|
||||
INTO documentName, conduce
|
||||
FROM prtb00029
|
||||
WHERE num_oc = orden AND tipo_file = 'CO'
|
||||
|
||||
SET CONNECTION "EXTERIOR"
|
||||
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION BuildMail()
|
||||
|
||||
INITIALIZE mailstruct.* TO NULL
|
||||
|
||||
FOR i = 1 TO client_data.getLength()
|
||||
|
||||
IF client_data[i].flag == 1 THEN
|
||||
|
||||
IF mailstruct.contactos IS NULL THEN
|
||||
LET mailstruct.contactos = client_data[i].contactos
|
||||
|
||||
ELSE
|
||||
|
||||
LET mailstruct.contactos =
|
||||
mailstruct.contactos || ", " || client_data[i].contactos
|
||||
END IF
|
||||
END IF
|
||||
|
||||
END FOR
|
||||
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION SendMail(orden INT, usuario STRING)
|
||||
|
||||
DEFINE attachment STRING
|
||||
|
||||
SET CONNECTION "MARMOTECH"
|
||||
|
||||
SELECT from_address, nombre_Servidor, puerto, clave
|
||||
INTO xusername, xsmtphost, xsmtpport, xpassword
|
||||
FROM tbperfil_mail
|
||||
WHERE cod_perfil = 2
|
||||
|
||||
SET CONNECTION "EXTERIOR"
|
||||
|
||||
LET attachment = "archivos\\", usuario CLIPPED, documentName
|
||||
CALL conduce.writeFile(attachment)
|
||||
|
||||
LET mailstruct.body = "<table><tr><td>",MAILSTRUCT.body CLIPPED,"</td></tr></table>"
|
||||
|
||||
TRY
|
||||
|
||||
CALL enviaemail(
|
||||
mailstruct.contactos,
|
||||
mailstruct.subject,
|
||||
mailstruct.body,
|
||||
attachment,
|
||||
xusername,
|
||||
xsmtphost,
|
||||
xsmtpport,
|
||||
xpassword)
|
||||
CATCH
|
||||
|
||||
CALL fgl_winmessage(
|
||||
"ESTADO DEL EMAIL",
|
||||
"Ha ocurrido un error al mandar el email",
|
||||
"INFO")
|
||||
|
||||
END TRY
|
||||
|
||||
END FUNCTION
|
||||
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
all:: javax.mail.jar
|
||||
|
||||
javax.mail.jar:
|
||||
curl -L -c cookie.txt http://java.net/projects/javamail/downloads/download/javax.mail.jar > javax.mail.jar
|
||||
rm -f cookie.txt
|
||||
Reference in New Issue
Block a user