first commit
This commit is contained in:
commit
cf97b64877
27585 changed files with 3281780 additions and 0 deletions
|
|
@ -0,0 +1,134 @@
|
|||
package com.ablia.newsletter;
|
||||
|
||||
import com.ablia.contab._ContabAdapter;
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.WcString;
|
||||
import com.ablia.util.StringTokenizer;
|
||||
import com.ablia.util.Vectumerator;
|
||||
import java.io.Serializable;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class AllegatoCodaMessaggi extends _ContabAdapter implements Serializable {
|
||||
private long id_allegatoCodaMessaggi;
|
||||
|
||||
private long id_codaMessaggi;
|
||||
|
||||
private String nomeFile;
|
||||
|
||||
private CodaMessaggi codaMessaggi;
|
||||
|
||||
public AllegatoCodaMessaggi(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public AllegatoCodaMessaggi() {}
|
||||
|
||||
public void setId_allegatoCodaMessaggi(long newId_allegatoCodaMessaggi) {
|
||||
this.id_allegatoCodaMessaggi = newId_allegatoCodaMessaggi;
|
||||
}
|
||||
|
||||
public void setId_codaMessaggi(long newId_codaMessaggi) {
|
||||
this.id_codaMessaggi = newId_codaMessaggi;
|
||||
setCodaMessaggi(null);
|
||||
}
|
||||
|
||||
public void setNomeFile(String newNomeFile) {
|
||||
this.nomeFile = newNomeFile;
|
||||
}
|
||||
|
||||
public long getId_allegatoCodaMessaggi() {
|
||||
return this.id_allegatoCodaMessaggi;
|
||||
}
|
||||
|
||||
public long getId_codaMessaggi() {
|
||||
return this.id_codaMessaggi;
|
||||
}
|
||||
|
||||
public String getNomeFile() {
|
||||
return (this.nomeFile == null) ? "" : this.nomeFile.trim();
|
||||
}
|
||||
|
||||
public void setCodaMessaggi(CodaMessaggi newCodaMessaggi) {
|
||||
this.codaMessaggi = newCodaMessaggi;
|
||||
}
|
||||
|
||||
public CodaMessaggi getCodaMessaggi() {
|
||||
this.codaMessaggi = (CodaMessaggi)getSecondaryObject(this.codaMessaggi,
|
||||
CodaMessaggi.class, getId_codaMessaggi());
|
||||
return this.codaMessaggi;
|
||||
}
|
||||
|
||||
protected void deleteCascade() {}
|
||||
|
||||
public Vectumerator findByCR(AllegatoCodaMessaggiCR CR, int pageNumber, int pageRows) {
|
||||
String s_Sql_Find = "select DISTINCT A.* from ALLEGATO_CODA_MESSAGGI AS A";
|
||||
String s_Sql_Order = "";
|
||||
WcString wc = new WcString();
|
||||
if (!CR.getSearchTxt().trim().isEmpty()) {
|
||||
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(),
|
||||
" ");
|
||||
StringBuffer txt = new StringBuffer("(");
|
||||
while (st.hasMoreTokens()) {
|
||||
String token = st.nextToken();
|
||||
txt.append("(A.Cognome like '%" + token +
|
||||
"%' or A.Nome like '%" + token + "%')");
|
||||
if (st.hasMoreTokens())
|
||||
txt.append(" and ");
|
||||
}
|
||||
txt.append(")");
|
||||
wc.addWc(txt.toString());
|
||||
}
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
return findRows(stmt, pageNumber, pageRows);
|
||||
} catch (SQLException e) {
|
||||
removeCPConnection();
|
||||
handleDebug(e);
|
||||
return AB_EMPTY_VECTUMERATOR;
|
||||
}
|
||||
}
|
||||
|
||||
public void findByCodaMessaggiNomeFile(long l_id_codaMessaggi, String l_id_nomeFile) {
|
||||
String s_Sql_Find = "select DISTINCT A.* from ALLEGATO_CODA_MESSAGGI AS A";
|
||||
String s_Sql_Order = "";
|
||||
WcString wc = new WcString();
|
||||
wc.addWc("A.id_codaMessaggi=" + l_id_codaMessaggi);
|
||||
wc.addWc("A.nomeFile='" + l_id_nomeFile + "'");
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
findFirstRecord(stmt);
|
||||
} catch (SQLException e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getNomeFileCompleto() {
|
||||
return getNomeFileCompleto(getCodaMessaggi().getPathAllegato());
|
||||
}
|
||||
|
||||
public String getNomeFileCompleto(String l_path) {
|
||||
return String.valueOf(l_path) + getId_codaMessaggi() + "_" + getNomeFile();
|
||||
}
|
||||
|
||||
public String getNomeFileSuDisco() {
|
||||
return String.valueOf(getId_codaMessaggi()) + "_" + getNomeFile();
|
||||
}
|
||||
|
||||
public Vectumerator findByCodaMessaggi(long l_id_codaMessaggi, int pageNumber, int pageRows) {
|
||||
String s_Sql_Find = "select DISTINCT A.* from ALLEGATO_CODA_MESSAGGI AS A";
|
||||
String s_Sql_Order = " order by A.nomeFile";
|
||||
WcString wc = new WcString();
|
||||
wc.addWc("A.id_codaMessaggi=" + l_id_codaMessaggi);
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
return findRows(stmt, pageNumber, pageRows);
|
||||
} catch (SQLException e) {
|
||||
handleDebug(e);
|
||||
return AB_EMPTY_VECTUMERATOR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.ablia.newsletter;
|
||||
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.CRAdapter;
|
||||
|
||||
public class AllegatoCodaMessaggiCR extends CRAdapter {
|
||||
private long id_allegatoCodaMessaggi;
|
||||
|
||||
private long id_codaMessaggi;
|
||||
|
||||
private String nomeFile;
|
||||
|
||||
private CodaMessaggi codaMessaggi;
|
||||
|
||||
public AllegatoCodaMessaggiCR(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public AllegatoCodaMessaggiCR() {}
|
||||
|
||||
public void setId_allegatoCodaMessaggi(long newId_allegatoCodaMessaggi) {
|
||||
this.id_allegatoCodaMessaggi = newId_allegatoCodaMessaggi;
|
||||
}
|
||||
|
||||
public void setId_codaMessaggi(long newId_codaMessaggi) {
|
||||
this.id_codaMessaggi = newId_codaMessaggi;
|
||||
setCodaMessaggi(null);
|
||||
}
|
||||
|
||||
public void setNomeFile(String newNomeFile) {
|
||||
this.nomeFile = newNomeFile;
|
||||
}
|
||||
|
||||
public long getId_allegatoCodaMessaggi() {
|
||||
return this.id_allegatoCodaMessaggi;
|
||||
}
|
||||
|
||||
public long getId_codaMessaggi() {
|
||||
return this.id_codaMessaggi;
|
||||
}
|
||||
|
||||
public String getNomeFile() {
|
||||
return (this.nomeFile == null) ? "" : this.nomeFile.trim();
|
||||
}
|
||||
|
||||
public void setCodaMessaggi(CodaMessaggi newCodaMessaggi) {
|
||||
this.codaMessaggi = newCodaMessaggi;
|
||||
}
|
||||
|
||||
public CodaMessaggi getCodaMessaggi() {
|
||||
this.codaMessaggi = (CodaMessaggi)getSecondaryObject(
|
||||
this.codaMessaggi,
|
||||
CodaMessaggi.class, getId_codaMessaggi());
|
||||
return this.codaMessaggi;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
package com.ablia.newsletter;
|
||||
|
||||
import com.ablia.contab._ContabAdapter;
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.WcString;
|
||||
import com.ablia.util.StringTokenizer;
|
||||
import com.ablia.util.Vectumerator;
|
||||
import java.io.Serializable;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class AllegatoTemplateMsg extends _ContabAdapter implements Serializable {
|
||||
private long id_allegatoTemplateMsg;
|
||||
|
||||
private long id_templateMsg;
|
||||
|
||||
private String nomeFile;
|
||||
|
||||
private TemplateMsg templateMsg;
|
||||
|
||||
public AllegatoTemplateMsg(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public AllegatoTemplateMsg() {}
|
||||
|
||||
public void setId_allegatoTemplateMsg(long newId_allegatoTemplateMsg) {
|
||||
this.id_allegatoTemplateMsg = newId_allegatoTemplateMsg;
|
||||
}
|
||||
|
||||
public void setId_templateMsg(long newId_templateMsg) {
|
||||
this.id_templateMsg = newId_templateMsg;
|
||||
setTemplateMsg(null);
|
||||
}
|
||||
|
||||
public void setNomeFile(String newNomeFile) {
|
||||
this.nomeFile = newNomeFile;
|
||||
}
|
||||
|
||||
public long getId_allegatoTemplateMsg() {
|
||||
return this.id_allegatoTemplateMsg;
|
||||
}
|
||||
|
||||
public long getId_templateMsg() {
|
||||
return this.id_templateMsg;
|
||||
}
|
||||
|
||||
public String getNomeFile() {
|
||||
return (this.nomeFile == null) ? "" : this.nomeFile.trim();
|
||||
}
|
||||
|
||||
public void setTemplateMsg(TemplateMsg newTemplateMsg) {
|
||||
this.templateMsg = newTemplateMsg;
|
||||
}
|
||||
|
||||
public TemplateMsg getTemplateMsg() {
|
||||
this.templateMsg = (TemplateMsg)getSecondaryObject(
|
||||
this.templateMsg,
|
||||
TemplateMsg.class, getId_templateMsg());
|
||||
return this.templateMsg;
|
||||
}
|
||||
|
||||
protected void deleteCascade() {}
|
||||
|
||||
public Vectumerator findByCR(AllegatoTemplateMsgCR CR, int pageNumber, int pageRows) {
|
||||
String s_Sql_Find = "select DISTINCT A.* from ALLEGATO_TEMPLATE_MSG AS A";
|
||||
String s_Sql_Order = "";
|
||||
WcString wc = new WcString();
|
||||
if (!CR.getSearchTxt().trim().isEmpty()) {
|
||||
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
|
||||
StringBuffer txt = new StringBuffer("(");
|
||||
while (st.hasMoreTokens()) {
|
||||
String token = st.nextToken();
|
||||
txt.append("(A.nomeFile like '%" + token + "%' )");
|
||||
if (st.hasMoreTokens())
|
||||
txt.append(" and ");
|
||||
}
|
||||
txt.append(")");
|
||||
wc.addWc(txt.toString());
|
||||
}
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
return findRows(stmt, pageNumber, pageRows);
|
||||
} catch (SQLException e) {
|
||||
removeCPConnection();
|
||||
handleDebug(e);
|
||||
return AB_EMPTY_VECTUMERATOR;
|
||||
}
|
||||
}
|
||||
|
||||
public String getNomeFileCompleto() {
|
||||
return getNomeFileCompleto(getTemplateMsg().getPathAllegato());
|
||||
}
|
||||
|
||||
public String getNomeFileCompleto(String l_path) {
|
||||
return String.valueOf(l_path) + getNomeFileSuDisco();
|
||||
}
|
||||
|
||||
public String getNomeFileSuDisco() {
|
||||
return String.valueOf(getId_templateMsg()) + "_" + getNomeFile();
|
||||
}
|
||||
|
||||
protected int getStringValueCase(String l_colomnName) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void findByTemplateMsgNomeFile(long l_id_templateMsg, String l_id_nomeFile) {
|
||||
String s_Sql_Find = "select DISTINCT A.* from ALLEGATO_TEMPLATE_MSG AS A";
|
||||
String s_Sql_Order = "";
|
||||
WcString wc = new WcString();
|
||||
wc.addWc("A.id_templateMsg=" + l_id_templateMsg);
|
||||
wc.addWc("A.nomeFile='" + l_id_nomeFile + "'");
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
findFirstRecord(stmt);
|
||||
} catch (SQLException e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Vectumerator findByTemplateMsg(long l_id_templateMsg, int pageNumber, int pageRows) {
|
||||
String s_Sql_Find = "select DISTINCT A.* from ALLEGATO_TEMPLATE_MSG AS A";
|
||||
String s_Sql_Order = " order by A.nomeFile";
|
||||
WcString wc = new WcString();
|
||||
wc.addWc("A.id_templateMsg=" + l_id_templateMsg);
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
return findRows(stmt, pageNumber, pageRows);
|
||||
} catch (SQLException e) {
|
||||
handleDebug(e);
|
||||
return AB_EMPTY_VECTUMERATOR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.ablia.newsletter;
|
||||
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.CRAdapter;
|
||||
|
||||
public class AllegatoTemplateMsgCR extends CRAdapter {
|
||||
private long id_allegatoTemplateMsg;
|
||||
|
||||
private long id_templateMsg;
|
||||
|
||||
private String nomeFile;
|
||||
|
||||
private TemplateMsg templateMsg;
|
||||
|
||||
public AllegatoTemplateMsgCR(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public AllegatoTemplateMsgCR() {}
|
||||
|
||||
public void setId_allegatoTemplateMsg(long newId_allegatoTemplateMsg) {
|
||||
this.id_allegatoTemplateMsg = newId_allegatoTemplateMsg;
|
||||
}
|
||||
|
||||
public void setId_templateMsg(long newId_templateMsg) {
|
||||
this.id_templateMsg = newId_templateMsg;
|
||||
setTemplateMsg(null);
|
||||
}
|
||||
|
||||
public void setNomeFile(String newNomeFile) {
|
||||
this.nomeFile = newNomeFile;
|
||||
}
|
||||
|
||||
public long getId_allegatoTemplateMsg() {
|
||||
return this.id_allegatoTemplateMsg;
|
||||
}
|
||||
|
||||
public long getId_templateMsg() {
|
||||
return this.id_templateMsg;
|
||||
}
|
||||
|
||||
public String getNomeFile() {
|
||||
return (this.nomeFile == null) ? "" : this.nomeFile.trim();
|
||||
}
|
||||
|
||||
public void setTemplateMsg(TemplateMsg newTemplateMsg) {
|
||||
this.templateMsg = newTemplateMsg;
|
||||
}
|
||||
|
||||
public TemplateMsg getTemplateMsg() {
|
||||
this.templateMsg = (TemplateMsg)getSecondaryObject(
|
||||
this.templateMsg,
|
||||
TemplateMsg.class, getId_templateMsg());
|
||||
return this.templateMsg;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,149 @@
|
|||
package com.ablia.newsletter;
|
||||
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.CRAdapter;
|
||||
import java.sql.Date;
|
||||
|
||||
public class CodaMessaggiCR extends CRAdapter {
|
||||
private long id_codaMessaggi;
|
||||
|
||||
private long flgTipo = -1L;
|
||||
|
||||
private long flgStatoInvio = 0L;
|
||||
|
||||
private Date dataCreazione;
|
||||
|
||||
private String messaggio;
|
||||
|
||||
private String cellulare;
|
||||
|
||||
private String mailTo;
|
||||
|
||||
private String mailCc;
|
||||
|
||||
private String mailBcc;
|
||||
|
||||
private String campagna;
|
||||
|
||||
private long id_codaMessaggiS;
|
||||
|
||||
private String destinatario;
|
||||
|
||||
public CodaMessaggiCR(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public CodaMessaggiCR() {}
|
||||
|
||||
public void setId_codaMessaggi(long newId_codaInvio) {
|
||||
this.id_codaMessaggi = newId_codaInvio;
|
||||
}
|
||||
|
||||
public void setFlgTipo(long newFlgTipo) {
|
||||
this.flgTipo = newFlgTipo;
|
||||
}
|
||||
|
||||
public void setFlgStatoInvio(long newFlgStatoInvio) {
|
||||
this.flgStatoInvio = newFlgStatoInvio;
|
||||
}
|
||||
|
||||
public void setDataCreazione(Date newDataCreazione) {
|
||||
this.dataCreazione = newDataCreazione;
|
||||
}
|
||||
|
||||
public void setMessaggio(String newMessaggio) {
|
||||
this.messaggio = newMessaggio;
|
||||
}
|
||||
|
||||
public void setCellulare(String newCellulare) {
|
||||
this.cellulare = newCellulare;
|
||||
}
|
||||
|
||||
public void setMailTo(String newMailTo) {
|
||||
this.mailTo = newMailTo;
|
||||
}
|
||||
|
||||
public void setMailCc(String newMailCc) {
|
||||
this.mailCc = newMailCc;
|
||||
}
|
||||
|
||||
public void setMailBcc(String newMailBcc) {
|
||||
this.mailBcc = newMailBcc;
|
||||
}
|
||||
|
||||
public long getId_codaMessaggi() {
|
||||
return this.id_codaMessaggi;
|
||||
}
|
||||
|
||||
public long getFlgTipo() {
|
||||
return this.flgTipo;
|
||||
}
|
||||
|
||||
public long getFlgStatoInvio() {
|
||||
return this.flgStatoInvio;
|
||||
}
|
||||
|
||||
public Date getDataCreazione() {
|
||||
return this.dataCreazione;
|
||||
}
|
||||
|
||||
public String getMessaggio() {
|
||||
return (this.messaggio == null) ? "" : this.messaggio.trim();
|
||||
}
|
||||
|
||||
public String getCellulare() {
|
||||
return (this.cellulare == null) ? "" : this.cellulare.trim();
|
||||
}
|
||||
|
||||
public String getMailTo() {
|
||||
return (this.mailTo == null) ? "" : this.mailTo.trim();
|
||||
}
|
||||
|
||||
public String getMailCc() {
|
||||
return (this.mailCc == null) ? "" : this.mailCc.trim();
|
||||
}
|
||||
|
||||
public String getMailBcc() {
|
||||
return (this.mailBcc == null) ? "" : this.mailBcc.trim();
|
||||
}
|
||||
|
||||
public static final String getStatoInvio(long l_flgStatoInvio) {
|
||||
return CodaMessaggi.getStatoInvio(l_flgStatoInvio);
|
||||
}
|
||||
|
||||
public String getStatoInvio() {
|
||||
return CodaMessaggi.getStatoInvio(getFlgStatoInvio());
|
||||
}
|
||||
|
||||
public static final String getTipo(long l_flgTipo) {
|
||||
return CodaMessaggi.getTipo(l_flgTipo);
|
||||
}
|
||||
|
||||
public String getTipo() {
|
||||
return CodaMessaggi.getTipo(getFlgTipo());
|
||||
}
|
||||
|
||||
public String getCampagna() {
|
||||
return (this.campagna == null) ? "" : this.campagna.trim();
|
||||
}
|
||||
|
||||
public void setCampagna(String campagna) {
|
||||
this.campagna = campagna;
|
||||
}
|
||||
|
||||
public long getId_codaMessaggiS() {
|
||||
return this.id_codaMessaggiS;
|
||||
}
|
||||
|
||||
public void setId_codaMessaggiS(long id_codaMessaggiS) {
|
||||
this.id_codaMessaggiS = id_codaMessaggiS;
|
||||
}
|
||||
|
||||
public String getDestinatario() {
|
||||
return (this.destinatario == null) ? "" : this.destinatario.trim();
|
||||
}
|
||||
|
||||
public void setDestinatario(String destinatario) {
|
||||
this.destinatario = destinatario;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,306 @@
|
|||
package com.ablia.newsletter;
|
||||
|
||||
import com.ablia.anag.Users;
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.DBAdapter;
|
||||
import com.ablia.db.ResParm;
|
||||
import com.ablia.db.WcString;
|
||||
import com.ablia.util.StringTokenizer;
|
||||
import com.ablia.util.Vectumerator;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Date;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class MailNewsletter extends DBAdapter implements Serializable {
|
||||
private static final long serialVersionUID = 2575790244816812859L;
|
||||
|
||||
private long id_mailNewsletter;
|
||||
|
||||
private String eMail;
|
||||
|
||||
private long id_templateMsg;
|
||||
|
||||
private TemplateMsg templateMsg;
|
||||
|
||||
private Date dataTemplate;
|
||||
|
||||
class addMailsFromFile extends Thread {
|
||||
private String filename;
|
||||
|
||||
private ApplParmFull ap;
|
||||
|
||||
public addMailsFromFile(String l_filename, ApplParmFull l_ap) {
|
||||
synchronized (this) {
|
||||
if (!CodaMessaggi.isThreadAttivo()) {
|
||||
MailNewsletter.threadAddMailsFromFile = true;
|
||||
this.filename = l_filename;
|
||||
this.ap = l_ap;
|
||||
start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
long togliDuplicatiOgni = 1000L;
|
||||
long numRecord = 0L, numDuplicati = 0L;
|
||||
Timestamp start = new Timestamp(Calendar.getInstance()
|
||||
.getTimeInMillis());
|
||||
System.out.println("##############\nMailNewsletter.addMailsFromFile\nSTART: " +
|
||||
start.toString());
|
||||
ResParm rp = new ResParm(true);
|
||||
MailNewsletter ml = new MailNewsletter(MailNewsletter.this.getApFull());
|
||||
try {
|
||||
FileReader fr = new FileReader(this.filename);
|
||||
BufferedReader br = new BufferedReader(fr);
|
||||
long i = 0L;
|
||||
String s;
|
||||
while ((s = br.readLine()) != null) {
|
||||
ml = new MailNewsletter(MailNewsletter.this.getApFull());
|
||||
ml.setEMail(s);
|
||||
rp = ml.save();
|
||||
if (!rp.getStatus())
|
||||
numDuplicati++;
|
||||
numRecord++;
|
||||
MailNewsletter.threadAddMailsFromFileMsg = "Attenzione! Thread importazione indirizzi da file in esecuzione!!! Record inseriti: " +
|
||||
numRecord +
|
||||
" - duplicati o errori: " +
|
||||
numDuplicati;
|
||||
i++;
|
||||
if (i % 100L == 0L)
|
||||
System.out.print(".");
|
||||
if (i % 1000L == 0L)
|
||||
System.out.println(i);
|
||||
if (i % togliDuplicatiOgni == 0L)
|
||||
System.out.println(" " + rp.getMsg());
|
||||
}
|
||||
fr.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
MailNewsletter.this.handleDebug(e);
|
||||
} catch (IOException e) {
|
||||
MailNewsletter.this.handleDebug(e);
|
||||
}
|
||||
rp = MailNewsletter.this.cancellaDoppioni();
|
||||
System.out.println(" " + rp.getMsg());
|
||||
MailNewsletter.this.handleDebug(
|
||||
"Aggiunte nuove mail a mailNewsletter. Tot nuovi record immessi: " +
|
||||
numRecord, 1);
|
||||
Timestamp stop = new Timestamp(Calendar.getInstance()
|
||||
.getTimeInMillis());
|
||||
System.out.println("STOP: " + start.toString());
|
||||
SimpleDateFormat dfMS = new SimpleDateFormat("HH:mm:ss ");
|
||||
System.out.println("DURATA: " +
|
||||
dfMS.format((java.util.Date)new Time(stop.getTime() - start.getTime() -
|
||||
3600000L)) +
|
||||
|
||||
"\nMailNewsletter.addMailsFromFile\n****************");
|
||||
MailNewsletter.threadAddMailsFromFile = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean threadAddMailsFromFile = false;
|
||||
|
||||
public static String threadAddMailsFromFileMsg = "";
|
||||
|
||||
public MailNewsletter(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public MailNewsletter() {}
|
||||
|
||||
public void setId_mailNewsletter(long id_mailNewsletter) {
|
||||
this.id_mailNewsletter = id_mailNewsletter;
|
||||
}
|
||||
|
||||
public long getId_mailNewsletter() {
|
||||
return this.id_mailNewsletter;
|
||||
}
|
||||
|
||||
protected ResParm checkDeleteCascade() {
|
||||
return new ResParm(true);
|
||||
}
|
||||
|
||||
protected void deleteCascade() {}
|
||||
|
||||
public Vectumerator findCodaByCR(MailNewsletterCR CR, long inizio, long fine) {
|
||||
String s_Sql_Find = "select A.* from MAIL_NEWSLETTER AS A";
|
||||
String s_Sql_Order = " ";
|
||||
WcString wc = new WcString();
|
||||
if (!CR.getEMailR().equals(""))
|
||||
wc.addWc(" A.eMail LIKE '%" + CR.getEMailR() + "%' ");
|
||||
try {
|
||||
long start = inizio - 1L;
|
||||
long stop = fine - start;
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order + " limit " +
|
||||
start + "," + stop);
|
||||
return findRows(stmt, 0, 0);
|
||||
} catch (SQLException e) {
|
||||
removeCPConnection();
|
||||
handleDebug(e);
|
||||
return AB_EMPTY_VECTUMERATOR;
|
||||
}
|
||||
}
|
||||
|
||||
public void findByIndirizzo(String indirizzo) {
|
||||
String s_Sql_Find = "select DISTINCT A.* from MAIL_NEWSLETTER AS A";
|
||||
String s_Sql_Order = "";
|
||||
WcString wc = new WcString();
|
||||
wc.addWc(" A.indirizzo = '" + indirizzo + "' ");
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
findFirstRecord(stmt);
|
||||
} catch (SQLException e) {
|
||||
removeCPConnection();
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getEMail() {
|
||||
return (this.eMail == null) ? "" : this.eMail;
|
||||
}
|
||||
|
||||
public void setEMail(String indirizzo) {
|
||||
this.eMail = indirizzo;
|
||||
}
|
||||
|
||||
public ResParm addIndirizzi(String fileName) {
|
||||
if (!CodaMessaggi.isThreadAttivo())
|
||||
return new ResParm(true, "TThread inserimento indirizzi avviato");
|
||||
return new ResParm(false, "ATTENZIONE!! Thread in esecuzione!!!");
|
||||
}
|
||||
|
||||
public ResParm delIndirizzi(String indirizzi) {
|
||||
ResParm rp = new ResParm(true);
|
||||
StringTokenizer st = null;
|
||||
if (indirizzi.indexOf(",") > 0) {
|
||||
st = new StringTokenizer(indirizzi, ",");
|
||||
} else if (indirizzi.indexOf(";") > 0) {
|
||||
st = new StringTokenizer(indirizzi, ";");
|
||||
} else {
|
||||
st = new StringTokenizer(indirizzi, "\r\n");
|
||||
}
|
||||
if (st != null)
|
||||
while (st.hasMoreTokens()) {
|
||||
String indirizzo = st.nextToken().trim();
|
||||
findByIndirizzo(indirizzo);
|
||||
if (getDBState() == 1)
|
||||
rp = delete();
|
||||
}
|
||||
return rp;
|
||||
}
|
||||
|
||||
public ResParm impUtenti() {
|
||||
ResParm rp = new ResParm(true);
|
||||
Users user = new Users(getApFull());
|
||||
Vectumerator<Users> vec = user.findUsersByFlgMailingList();
|
||||
while (vec.hasMoreElements()) {
|
||||
user = (Users)vec.nextElement();
|
||||
if (!user.getEMail().equals("")) {
|
||||
MailNewsletter ml = new MailNewsletter(getApFull());
|
||||
ml.setEMail(user.getEMail());
|
||||
ml.save();
|
||||
}
|
||||
}
|
||||
return rp;
|
||||
}
|
||||
|
||||
public long getId_templateMsg() {
|
||||
return this.id_templateMsg;
|
||||
}
|
||||
|
||||
public void setId_templateMsg(long id_templateMsg) {
|
||||
this.id_templateMsg = id_templateMsg;
|
||||
}
|
||||
|
||||
public Date getDataTemplate() {
|
||||
return this.dataTemplate;
|
||||
}
|
||||
|
||||
public void setDataTemplate(Date dataTemplate) {
|
||||
this.dataTemplate = dataTemplate;
|
||||
}
|
||||
|
||||
public TemplateMsg getTemplateMsg() {
|
||||
this.templateMsg = (TemplateMsg)getSecondaryObject(this.templateMsg,
|
||||
TemplateMsg.class, getId_templateMsg());
|
||||
return this.templateMsg;
|
||||
}
|
||||
|
||||
public void setTemplateMsg(TemplateMsg templateMsg) {
|
||||
this.templateMsg = templateMsg;
|
||||
}
|
||||
|
||||
public Vectumerator findByCR(MailNewsletterCR CR, int pageNumber, int pageRows) {
|
||||
boolean flgOttimizzo = true;
|
||||
if (pageNumber == 0 && pageRows == 0)
|
||||
flgOttimizzo = false;
|
||||
StringBuffer s_Sql_Find = new StringBuffer(
|
||||
"select DISTINCT A.* from MAIL_NEWSLETTER AS A");
|
||||
String s_Sql_Order = "";
|
||||
WcString wc = new WcString();
|
||||
findByCRCreateWC(CR, s_Sql_Find, wc);
|
||||
if (!CR.getEMailR().equals(""))
|
||||
wc.addWc(" A.eMail LIKE '%" + CR.getEMailR() + "%' ");
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
s_Sql_Find + wc.toString() + s_Sql_Order);
|
||||
return findRows(stmt, pageNumber, pageRows);
|
||||
} catch (SQLException e) {
|
||||
removeCPConnection();
|
||||
handleDebug(e);
|
||||
return AB_EMPTY_VECTUMERATOR;
|
||||
}
|
||||
}
|
||||
|
||||
protected void findByCRCreateWC(MailNewsletterCR CR, StringBuffer s_Sql_Find, WcString wc) {
|
||||
if (!CR.getEMailR().equals(""))
|
||||
wc.addWc(" A.eMail LIKE '%" + CR.getEMailR() + "%' ");
|
||||
}
|
||||
|
||||
protected int findByCRTotRecord(MailNewsletterCR CR) {
|
||||
StringBuffer s_Sql_Find = new StringBuffer(
|
||||
"select count (DISTINCT A.id_mailNewsletter) as tot from MAIL_NEWSLETTER AS A");
|
||||
WcString wc = new WcString();
|
||||
findByCRCreateWC(CR, s_Sql_Find, wc);
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
s_Sql_Find + wc.toString());
|
||||
return (int)getTots(stmt);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public ResParm cancellaDoppioni() {
|
||||
String sql = "select id_mailNewsletter from MAIL_NEWSLETTER group by indirizzo having count(*) >1 limit 1, 1000 ";
|
||||
try {
|
||||
Vectumerator vec;
|
||||
long i = 0L;
|
||||
do {
|
||||
PreparedStatement stmt = getConn().prepareStatement(sql);
|
||||
vec = findRows(stmt);
|
||||
while (vec.hasMoreElements()) {
|
||||
MailNewsletter row = (MailNewsletter)vec.nextElement();
|
||||
row.delete();
|
||||
i++;
|
||||
}
|
||||
} while (vec.getTotNumberOfRecords() > 0);
|
||||
return new ResParm(true, "Num. doppioni cancellati : " + i);
|
||||
} catch (SQLException e) {
|
||||
removeCPConnection();
|
||||
handleDebug(e);
|
||||
return new ResParm(false, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package com.ablia.newsletter;
|
||||
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.CRAdapter;
|
||||
|
||||
public class MailNewsletterCR extends CRAdapter {
|
||||
private static final long serialVersionUID = 2575790244816812859L;
|
||||
|
||||
private long id_mailNewsletter;
|
||||
|
||||
private String eMailR;
|
||||
|
||||
private long inizio;
|
||||
|
||||
private long fine;
|
||||
|
||||
public MailNewsletterCR(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public MailNewsletterCR() {}
|
||||
|
||||
public void setId_mailNewsletter(long id_mailNewsletter) {
|
||||
this.id_mailNewsletter = id_mailNewsletter;
|
||||
}
|
||||
|
||||
public long getId_mailNewsletter() {
|
||||
return this.id_mailNewsletter;
|
||||
}
|
||||
|
||||
public String getEMailR() {
|
||||
return (this.eMailR == null) ? "" : this.eMailR;
|
||||
}
|
||||
|
||||
public void setEMailR(String indirizzo) {
|
||||
this.eMailR = indirizzo;
|
||||
}
|
||||
|
||||
public long getInizio() {
|
||||
return this.inizio;
|
||||
}
|
||||
|
||||
public void setInizio(long inizio) {
|
||||
this.inizio = inizio;
|
||||
}
|
||||
|
||||
public long getFine() {
|
||||
return this.fine;
|
||||
}
|
||||
|
||||
public void setFine(long fine) {
|
||||
this.fine = fine;
|
||||
}
|
||||
}
|
||||
180
rus/WEB-INF/lib/abliaDbCom_src/com/ablia/newsletter/NoMlist.java
Normal file
180
rus/WEB-INF/lib/abliaDbCom_src/com/ablia/newsletter/NoMlist.java
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
package com.ablia.newsletter;
|
||||
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.DBAdapter;
|
||||
import com.ablia.db.ResParm;
|
||||
import com.ablia.db.WcString;
|
||||
import com.ablia.reg.EcDc;
|
||||
import com.ablia.util.FileWr;
|
||||
import com.ablia.util.StringTokenizer;
|
||||
import com.ablia.util.Vectumerator;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Serializable;
|
||||
import java.net.URLEncoder;
|
||||
import java.sql.Date;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Time;
|
||||
|
||||
public class NoMlist extends DBAdapter implements Serializable {
|
||||
private static final long serialVersionUID = 1486503250372L;
|
||||
|
||||
public static final String NO_MLIST_KEY1 = "Xg3Z5sFQ";
|
||||
|
||||
public static final String NO_MLIST_KEY2 = "Xg3Z22FQ";
|
||||
|
||||
public static final String OK_PAGE = "/mlistOk.jsp";
|
||||
|
||||
public static final String ATTR_EMAIL = "email";
|
||||
|
||||
private long id_noMlist;
|
||||
|
||||
private String email;
|
||||
|
||||
private Date dataCancellazione;
|
||||
|
||||
private Time oraCancellazione;
|
||||
|
||||
private String ipAddress;
|
||||
|
||||
public NoMlist(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public NoMlist() {}
|
||||
|
||||
public void setId_noMlist(long newId_noMlist) {
|
||||
this.id_noMlist = newId_noMlist;
|
||||
}
|
||||
|
||||
public void setEmail(String newEmail) {
|
||||
this.email = newEmail;
|
||||
}
|
||||
|
||||
public void setDataCancellazione(Date newDataCancellazione) {
|
||||
this.dataCancellazione = newDataCancellazione;
|
||||
}
|
||||
|
||||
public void setOraCancellazione(Time newOraCancellazione) {
|
||||
this.oraCancellazione = newOraCancellazione;
|
||||
}
|
||||
|
||||
public void setIpAddress(String newIpAddress) {
|
||||
this.ipAddress = newIpAddress;
|
||||
}
|
||||
|
||||
public long getId_noMlist() {
|
||||
return this.id_noMlist;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return (this.email == null) ? "" : this.email.trim();
|
||||
}
|
||||
|
||||
public Date getDataCancellazione() {
|
||||
return this.dataCancellazione;
|
||||
}
|
||||
|
||||
public Time getOraCancellazione() {
|
||||
return this.oraCancellazione;
|
||||
}
|
||||
|
||||
public String getIpAddress() {
|
||||
return (this.ipAddress == null) ? "" : this.ipAddress.trim();
|
||||
}
|
||||
|
||||
protected ResParm checkDeleteCascade() {
|
||||
return new ResParm(true);
|
||||
}
|
||||
|
||||
protected void deleteCascade() {}
|
||||
|
||||
public Vectumerator<NoMlist> findByCR(NoMlistCR CR, int pageNumber, int pageRows) {
|
||||
String s_Sql_Find = "select DISTINCT A.* from NO_MLIST AS A";
|
||||
String s_Sql_Order = "";
|
||||
WcString wc = new WcString();
|
||||
if (!CR.getSearchTxt().trim().isEmpty()) {
|
||||
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
|
||||
StringBuffer txt = new StringBuffer("(");
|
||||
while (st.hasMoreTokens()) {
|
||||
String token = st.nextToken();
|
||||
txt.append("(A.Cognome like '%" + token + "%' or A.Nome like '%" + token + "%')");
|
||||
if (st.hasMoreTokens())
|
||||
txt.append(" and ");
|
||||
}
|
||||
txt.append(")");
|
||||
wc.addWc(txt.toString());
|
||||
}
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
return findRows(stmt, pageNumber, pageRows);
|
||||
} catch (SQLException e) {
|
||||
removeCPConnection();
|
||||
handleDebug(e);
|
||||
return AB_EMPTY_VECTUMERATOR;
|
||||
}
|
||||
}
|
||||
|
||||
public void findByEmail(String l_email) {
|
||||
String s_Sql_Find = "select DISTINCT A.* from NO_MLIST AS A";
|
||||
String s_Sql_Order = "";
|
||||
WcString wc = new WcString();
|
||||
wc.addWc("A.email='" + l_email + "'");
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
findFirstRecord(stmt);
|
||||
} catch (SQLException e) {
|
||||
removeCPConnection();
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String elaboraEPulisci(String filename) {
|
||||
int idx = filename.lastIndexOf(".");
|
||||
String newFileName = String.valueOf(filename.substring(0, idx)) + "_elaborato.txt";
|
||||
try {
|
||||
FileWr fw = new FileWr(newFileName);
|
||||
NoMlist bean = new NoMlist(getApFull());
|
||||
FileInputStream fstream = new FileInputStream(filename);
|
||||
DataInputStream in = new DataInputStream(fstream);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||
String strLine;
|
||||
while ((strLine = br.readLine()) != null) {
|
||||
bean.findByEmail(strLine);
|
||||
if (bean.getDBState() == 0) {
|
||||
fw.writeLine(strLine);
|
||||
continue;
|
||||
}
|
||||
System.out.println("Trovato " + strLine);
|
||||
}
|
||||
in.close();
|
||||
br.close();
|
||||
fw.closeFile();
|
||||
} catch (Exception e) {}
|
||||
return newFileName;
|
||||
}
|
||||
|
||||
public static final String crittaEmail(String email) {
|
||||
try {
|
||||
String e1c = EcDc.encodeDizionario(email, "Xg3Z5sFQ");
|
||||
String e2c = EcDc.encodeDizionario(email, "Xg3Z22FQ");
|
||||
System.out.println(String.valueOf(e1c) + " " + e2c);
|
||||
String action = "?e1=" + URLEncoder.encode(e1c, "utf-8") + "&e2=" + URLEncoder.encode(e2c, "utf-8");
|
||||
System.out.println(action);
|
||||
return action;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static final String decrittaEmail(String emailC1, String emailC2) {
|
||||
String email1 = EcDc.decodeDizionario(emailC1, "Xg3Z5sFQ");
|
||||
String email2 = EcDc.decodeDizionario(emailC2, "Xg3Z22FQ");
|
||||
if (email1.equals(email2))
|
||||
return email1;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package com.ablia.newsletter;
|
||||
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.CRAdapter;
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
|
||||
public class NoMlistCR extends CRAdapter {
|
||||
private String email;
|
||||
|
||||
private Date dataCancellazione;
|
||||
|
||||
private Time oraCancellazione;
|
||||
|
||||
private String ipAddress;
|
||||
|
||||
private long id_noMlist;
|
||||
|
||||
public NoMlistCR(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public NoMlistCR() {}
|
||||
|
||||
public void setEmail(String newEmail) {
|
||||
this.email = newEmail;
|
||||
}
|
||||
|
||||
public void setDataCancellazione(Date newDataCancellazione) {
|
||||
this.dataCancellazione = newDataCancellazione;
|
||||
}
|
||||
|
||||
public void setOraCancellazione(Time newOraCancellazione) {
|
||||
this.oraCancellazione = newOraCancellazione;
|
||||
}
|
||||
|
||||
public void setIpAddress(String newIpAddress) {
|
||||
this.ipAddress = newIpAddress;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return (this.email == null) ? "" : this.email.trim();
|
||||
}
|
||||
|
||||
public Date getDataCancellazione() {
|
||||
return this.dataCancellazione;
|
||||
}
|
||||
|
||||
public Time getOraCancellazione() {
|
||||
return this.oraCancellazione;
|
||||
}
|
||||
|
||||
public String getIpAddress() {
|
||||
return (this.ipAddress == null) ? "" : this.ipAddress.trim();
|
||||
}
|
||||
|
||||
public long getId_noMlist() {
|
||||
return this.id_noMlist;
|
||||
}
|
||||
|
||||
public void setId_noMlist(long newId_noMlist) {
|
||||
this.id_noMlist = newId_noMlist;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
package com.ablia.newsletter;
|
||||
|
||||
import com.ablia.contab._ContabAdapter;
|
||||
import com.ablia.db.AddImgInterface;
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.DBAdapter;
|
||||
import com.ablia.db.ResParm;
|
||||
import com.ablia.db.WcString;
|
||||
import com.ablia.util.StringTokenizer;
|
||||
import com.ablia.util.Vectumerator;
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class TemplateMsg extends _ContabAdapter implements Serializable, AddImgInterface {
|
||||
private long id_templateMsg;
|
||||
|
||||
private String descrizione;
|
||||
|
||||
private long flgTipo;
|
||||
|
||||
private String testoMessaggio;
|
||||
|
||||
private String imgTmst;
|
||||
|
||||
private String oggettoEmail;
|
||||
|
||||
public TemplateMsg(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public TemplateMsg() {}
|
||||
|
||||
public void setId_templateMsg(long newId_templateMsg) {
|
||||
this.id_templateMsg = newId_templateMsg;
|
||||
}
|
||||
|
||||
public void setDescrizione(String newDescrizione) {
|
||||
this.descrizione = newDescrizione;
|
||||
}
|
||||
|
||||
public void setFlgTipo(long newFlgTipo) {
|
||||
this.flgTipo = newFlgTipo;
|
||||
}
|
||||
|
||||
public void setTestoMessaggio(String newMessaggio) {
|
||||
this.testoMessaggio = newMessaggio;
|
||||
}
|
||||
|
||||
public long getId_templateMsg() {
|
||||
return this.id_templateMsg;
|
||||
}
|
||||
|
||||
public String getDescrizione() {
|
||||
return (this.descrizione == null) ? "" : this.descrizione.trim();
|
||||
}
|
||||
|
||||
public long getFlgTipo() {
|
||||
return this.flgTipo;
|
||||
}
|
||||
|
||||
public String getTestoMessaggio() {
|
||||
return (this.testoMessaggio == null) ? "" : this.testoMessaggio.trim();
|
||||
}
|
||||
|
||||
protected void deleteCascade() {
|
||||
for (int i = 1; i <= 4; i++)
|
||||
new File(String.valueOf(getDocBase()) + getPathAttach() + getImgFileName(i)).delete();
|
||||
}
|
||||
|
||||
public Vectumerator findByCR(TemplateMsgCR CR, int pageNumber, int pageRows) {
|
||||
String s_Sql_Find = "select A.* from TEMPLATE_MSG AS A";
|
||||
String s_Sql_Order = " order by A.descrizione desc";
|
||||
WcString wc = new WcString();
|
||||
if (!CR.getSearchTxt().trim().isEmpty()) {
|
||||
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
|
||||
StringBuffer txt = new StringBuffer("(");
|
||||
while (st.hasMoreTokens()) {
|
||||
String token = st.nextToken();
|
||||
txt.append("(A.descrizione like '%" + token + "%')");
|
||||
if (st.hasMoreTokens())
|
||||
txt.append(" and ");
|
||||
}
|
||||
txt.append(")");
|
||||
wc.addWc(txt.toString());
|
||||
}
|
||||
if (CR.getFlgTipo() != 0L)
|
||||
wc.addWc(" A.flgTipo = " + CR.getFlgTipo());
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
return findRows(stmt, pageNumber, pageRows);
|
||||
} catch (SQLException e) {
|
||||
removeCPConnection();
|
||||
handleDebug(e);
|
||||
return AB_EMPTY_VECTUMERATOR;
|
||||
}
|
||||
}
|
||||
|
||||
public static final String getTipo(long l_flgTipo) {
|
||||
return CodaMessaggi.getTipo(l_flgTipo);
|
||||
}
|
||||
|
||||
public String getTipo() {
|
||||
return CodaMessaggi.getTipo(getFlgTipo());
|
||||
}
|
||||
|
||||
protected int getStringValueCase(String l_colomnName) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getImgFileName(int imgNumber) {
|
||||
return getImgFileName(imgNumber, getImgTmst());
|
||||
}
|
||||
|
||||
public String getImgFileName(int imgNumber, String oldTmst) {
|
||||
return String.valueOf(getId_templateMsg()) + "_" + oldTmst + "_" + imgNumber + ".jpg";
|
||||
}
|
||||
|
||||
public String getImgTmst() {
|
||||
return (this.imgTmst == null) ? "" : this.imgTmst.trim();
|
||||
}
|
||||
|
||||
public void setImgTmst(String imgTmst) {
|
||||
this.imgTmst = imgTmst;
|
||||
}
|
||||
|
||||
public String getPathAttach() {
|
||||
return getParm("CODA_MESSAGGI_PATH_IMG_MSG").getTesto();
|
||||
}
|
||||
|
||||
public Vectumerator findAll(long l_flgTipo) {
|
||||
String s_Sql_Find = "select A.* from TEMPLATE_MSG AS A";
|
||||
String s_Sql_Order = " order by A.descrizione";
|
||||
WcString wc = new WcString();
|
||||
wc.addWc("A.flgTipo=" + l_flgTipo);
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
return findRows(stmt);
|
||||
} catch (SQLException e) {
|
||||
removeCPConnection();
|
||||
handleDebug(e);
|
||||
return AB_EMPTY_VECTUMERATOR;
|
||||
}
|
||||
}
|
||||
|
||||
public String getOggettoEmail() {
|
||||
return (this.oggettoEmail == null) ? "" : this.oggettoEmail.trim();
|
||||
}
|
||||
|
||||
public void setOggettoEmail(String oggettoEmail) {
|
||||
this.oggettoEmail = oggettoEmail;
|
||||
}
|
||||
|
||||
public String getDescrizioneCompleta() {
|
||||
return String.valueOf(getTipo()) + "-" + getDescrizione();
|
||||
}
|
||||
|
||||
public ResParm addAllegato(AllegatoTemplateMsg row) {
|
||||
AllegatoTemplateMsg bean = new AllegatoTemplateMsg(getApFull());
|
||||
bean.findByTemplateMsgNomeFile(row.getId_templateMsg(), row.getNomeFile());
|
||||
if (bean.getDBState() == 1)
|
||||
return new ResParm(false, "Nome File Duplicato");
|
||||
row.setDBState(0);
|
||||
ResParm rp = row.save();
|
||||
return rp;
|
||||
}
|
||||
|
||||
public ResParm delAllegato(AllegatoTemplateMsg row) {
|
||||
AllegatoTemplateMsg bean = new AllegatoTemplateMsg(getApFull());
|
||||
bean.findByPrimaryKey(row.getId_allegatoTemplateMsg());
|
||||
return bean.delete();
|
||||
}
|
||||
|
||||
public String getPathAllegato() {
|
||||
return String.valueOf(getDocBase()) + getParm("TMPL_MSG_ATTACH_PATH").getTesto();
|
||||
}
|
||||
|
||||
public Vectumerator getAllegati() {
|
||||
return new AllegatoTemplateMsg(getApFull()).findByTemplateMsg(getId_templateMsg(), 0, 0);
|
||||
}
|
||||
|
||||
public String getMessaggioLinkAssoluti() {
|
||||
String l_urlImg = getParm("CODA_MESSAGGI_IMG_URL_BASE").getTesto();
|
||||
String l_msg = getTestoMessaggio();
|
||||
int idx;
|
||||
while ((idx = l_msg.indexOf("../")) >= 0)
|
||||
l_msg = String.valueOf(l_msg.substring(0, idx)) + l_msg.substring(idx + 3);
|
||||
l_msg = l_msg.replaceAll("\"_img/_imgMsg", "\"" + l_urlImg + "_img/_imgMsg");
|
||||
l_msg = l_msg.replaceAll("\"/_img/_imgMsg", "\"" + l_urlImg + "_img/_imgMsg");
|
||||
l_msg = l_msg.replaceAll("href=\"/", "href=\"" + l_urlImg);
|
||||
return l_msg;
|
||||
}
|
||||
|
||||
public String getTestoMessaggioScript() {
|
||||
return DBAdapter.prepareScriptString(getTestoMessaggio(), true, false);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.ablia.newsletter;
|
||||
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.CRAdapter;
|
||||
|
||||
public class TemplateMsgCR extends CRAdapter {
|
||||
private long id_templateMsg;
|
||||
|
||||
private String descrizione;
|
||||
|
||||
private long flgTipo;
|
||||
|
||||
private String messaggio;
|
||||
|
||||
public TemplateMsgCR(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public TemplateMsgCR() {}
|
||||
|
||||
public void setId_templateMsg(long newId_templateMsg) {
|
||||
this.id_templateMsg = newId_templateMsg;
|
||||
}
|
||||
|
||||
public void setDescrizione(String newDescrizione) {
|
||||
this.descrizione = newDescrizione;
|
||||
}
|
||||
|
||||
public void setFlgTipo(long newFlgTipo) {
|
||||
this.flgTipo = newFlgTipo;
|
||||
}
|
||||
|
||||
public void setMessaggio(String newMessaggio) {
|
||||
this.messaggio = newMessaggio;
|
||||
}
|
||||
|
||||
public long getId_templateMsg() {
|
||||
return this.id_templateMsg;
|
||||
}
|
||||
|
||||
public String getDescrizione() {
|
||||
return (this.descrizione == null) ? "" : this.descrizione.trim();
|
||||
}
|
||||
|
||||
public long getFlgTipo() {
|
||||
return this.flgTipo;
|
||||
}
|
||||
|
||||
public String getMessaggio() {
|
||||
return (this.messaggio == null) ? "" : this.messaggio.trim();
|
||||
}
|
||||
|
||||
public static final String getTipo(long l_flgTipo) {
|
||||
return CodaMessaggi.getTipo(l_flgTipo);
|
||||
}
|
||||
|
||||
public String getTipo() {
|
||||
return CodaMessaggi.getTipo(getFlgTipo());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.ablia.newsletter.servlet;
|
||||
|
||||
import com.ablia.newsletter.CodaMessaggi;
|
||||
import com.ablia.servlet.GetFileSvlt;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet(urlPatterns = {"/_imgMsg/logo/*"})
|
||||
public class CodaMessaggiOpenMailSvlt extends GetFileSvlt {
|
||||
protected String getFileName(HttpServletRequest req, HttpServletResponse res) {
|
||||
String temp = req.getRequestURI();
|
||||
int idx1 = temp.lastIndexOf("_") + 1;
|
||||
int idx2 = temp.lastIndexOf(".png");
|
||||
try {
|
||||
long l_id = Long.parseLong(temp.substring(idx1, idx2));
|
||||
if (l_id > 0L) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
if (bean.getDBState() == 1)
|
||||
CodaMessaggi.addLettura(bean, req.getRemoteAddr());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return String.valueOf(getDocBase()) + "_img/_imgMsg" +
|
||||
"/logo/logoMsg.png";
|
||||
}
|
||||
|
||||
protected boolean checkProfile(HttpServletRequest req, HttpServletResponse res) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean isSecureServlet(HttpServletRequest req) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.ablia.newsletter.servlet;
|
||||
|
||||
import com.ablia.db.CRAdapter;
|
||||
import com.ablia.db.DBAdapter;
|
||||
import com.ablia.newsletter.MailNewsletter;
|
||||
import com.ablia.servlet.AblServletSvlt;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class MailNewsletterSvlt extends AblServletSvlt {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected boolean isSecureServlet(HttpServletRequest req) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
if (getCmd(req).equals("delNewsletter")) {
|
||||
String indirizzo = getRequestParameter(req, "ind");
|
||||
try {
|
||||
MailNewsletter ml = new MailNewsletter(getApFull(req));
|
||||
ml.delIndirizzi(indirizzo);
|
||||
RequestDispatcher rd = getServletContext()
|
||||
.getRequestDispatcher("/mailNewsletter.jsp");
|
||||
rd.forward((ServletRequest)req, (ServletResponse)res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void search(HttpServletRequest req, HttpServletResponse res) {
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
protected void sqlActions(HttpServletRequest req, HttpServletResponse res) {
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
package com.ablia.newsletter.servlet;
|
||||
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.CRAdapter;
|
||||
import com.ablia.db.DBAdapter;
|
||||
import com.ablia.db.ResParm;
|
||||
import com.ablia.newsletter.NoMlist;
|
||||
import com.ablia.newsletter.NoMlistCR;
|
||||
import com.ablia.servlet.AblServletSvlt;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet(urlPatterns = {"/NoMlist.abl"})
|
||||
public class NoMlistSvlt extends AblServletSvlt {
|
||||
protected boolean isSecureServlet(HttpServletRequest req) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CRA, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new NoMlist(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new NoMlistCR(getApFull(req));
|
||||
}
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
NoMlist.crittaEmail("acolzi@ablia.com");
|
||||
String e1 = getRequestParameter(req, "e1");
|
||||
String e2 = getRequestParameter(req, "e2");
|
||||
String email = NoMlist.decrittaEmail(e1, e2);
|
||||
try {
|
||||
if (email == null) {
|
||||
req.setAttribute("email", email);
|
||||
sendMessage(req, "Errore!");
|
||||
RequestDispatcher rd = getServletContext().getRequestDispatcher("/mlistOk.jsp");
|
||||
rd.forward((ServletRequest)req, (ServletResponse)res);
|
||||
} else {
|
||||
NoMlist bean = new NoMlist(getApFull(req));
|
||||
bean.findByEmail(email);
|
||||
if (bean.getId_noMlist() > 0L) {
|
||||
sendMessage(req, "Email " + email + " già esclusa dalle mailing list!");
|
||||
} else {
|
||||
bean.setEmail(email);
|
||||
bean.setDataCancellazione(DBAdapter.getToday());
|
||||
bean.setOraCancellazione(DBAdapter.getNow());
|
||||
bean.setIpAddress(req.getRemoteAddr());
|
||||
ResParm rp = bean.save();
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Email " + email + " esclusa correttamente dalle mailing list!");
|
||||
} else {
|
||||
sendMessage(req, "Errore! Impossibile salvare. Email " + email + " " + rp.getMsg());
|
||||
}
|
||||
}
|
||||
RequestDispatcher rd = getServletContext().getRequestDispatcher("/mlistOk.jsp");
|
||||
rd.forward((ServletRequest)req, (ServletResponse)res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void _cancellaMail(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
String email = getRequestParameter(req, "email");
|
||||
try {
|
||||
if (email.isEmpty()) {
|
||||
req.setAttribute("email", email);
|
||||
sendMessage(req, "Errore!");
|
||||
RequestDispatcher rd = getServletContext().getRequestDispatcher("/mlistOk.jsp");
|
||||
rd.forward((ServletRequest)req, (ServletResponse)res);
|
||||
} else {
|
||||
NoMlist bean = new NoMlist(apFull);
|
||||
bean.findByEmail(email);
|
||||
if (bean.getId_noMlist() > 0L) {
|
||||
sendMessage(req, "Email " + email + " già esclusa dalle mailing list!");
|
||||
} else {
|
||||
bean.setEmail(email);
|
||||
bean.setDataCancellazione(DBAdapter.getToday());
|
||||
bean.setOraCancellazione(DBAdapter.getNow());
|
||||
bean.setIpAddress(req.getRemoteAddr());
|
||||
ResParm rp = bean.save();
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Email " + email + " esclusa correttamente dalle mailing list!");
|
||||
} else {
|
||||
sendMessage(req, "Errore! Impossibile salvare. Email " + email + " " + rp.getMsg());
|
||||
}
|
||||
}
|
||||
RequestDispatcher rd = getServletContext().getRequestDispatcher("/mlistOk.jsp");
|
||||
rd.forward((ServletRequest)req, (ServletResponse)res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.ablia.newsletter.servlet;
|
||||
|
||||
import com.ablia.db.CRAdapter;
|
||||
import com.ablia.db.DBAdapter;
|
||||
import com.ablia.newsletter.TemplateMsg;
|
||||
import com.ablia.newsletter.TemplateMsgCR;
|
||||
import com.ablia.servlet.AblServletSvlt;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet(urlPatterns = {"/ShowTemplateMsgWww.abl"})
|
||||
public class ShowTemplateMsgWwwSvlt extends AblServletSvlt {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new TemplateMsg(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new TemplateMsgCR(getApFull(req));
|
||||
}
|
||||
|
||||
protected void search(HttpServletRequest req, HttpServletResponse res) {
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
protected void sqlActions(HttpServletRequest req, HttpServletResponse res) {
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
protected boolean isSecureServlet(HttpServletRequest req) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,429 @@
|
|||
package com.ablia.newsletter.servlet.admin;
|
||||
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.CRAdapter;
|
||||
import com.ablia.db.DBAdapter;
|
||||
import com.ablia.db.ResParm;
|
||||
import com.ablia.newsletter.AllegatoCodaMessaggi;
|
||||
import com.ablia.newsletter.CodaMessaggi;
|
||||
import com.ablia.newsletter.CodaMessaggiCR;
|
||||
import com.ablia.newsletter.TemplateMsg;
|
||||
import com.ablia.servlet.AblServletSvlt;
|
||||
import com.ablia.util.AbMessages;
|
||||
import com.ablia.util.Vectumerator;
|
||||
import java.io.File;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet(urlPatterns = {"/admin/newsletter/CodaMessaggi.abl"})
|
||||
public class CodaMessaggiSvlt extends AblServletSvlt {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = (CodaMessaggi)beanA;
|
||||
req.setAttribute("listaTemplateMsg",
|
||||
new TemplateMsg(getApFull(req)).findAll(bean.getFlgTipo()));
|
||||
if (bean.getId_templateMsg() > 0L)
|
||||
req.setAttribute("listaAllegatiTemplateMsg", bean.getTemplateMsg()
|
||||
.getAllegati());
|
||||
req.setAttribute("listaAllegati", bean.getAllegati());
|
||||
}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new CodaMessaggi(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new CodaMessaggiCR(getApFull(req));
|
||||
}
|
||||
|
||||
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
req.setAttribute("bean", bean);
|
||||
req.setAttribute("listaTemplateMsg",
|
||||
new TemplateMsg(getApFull(req)).findAll(bean.getFlgTipo()));
|
||||
}
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
System.out.println(getCmd(req));
|
||||
super.otherCommands(req, res);
|
||||
}
|
||||
|
||||
protected String getAttachPath(HttpServletRequest req) {
|
||||
return ((CodaMessaggi)getBean(req)).getPathAttach();
|
||||
}
|
||||
|
||||
protected boolean isLoadImageServlet() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected ResParm afterImgFileSave(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = (CodaMessaggi)beanA;
|
||||
String oldImgTmst = bean.getImgTmst();
|
||||
ResParm rp = super.afterImgFileSave(bean, req, res);
|
||||
String temp = bean.getTestoMessaggio();
|
||||
long l_totImgNumber = getRequestLongParameter(req, "totImgNumber");
|
||||
if (l_totImgNumber == 0L)
|
||||
l_totImgNumber = 4L;
|
||||
for (int i = 1; (long)i <= l_totImgNumber; i++)
|
||||
temp = temp.replaceAll(bean.getImgFileName(i, oldImgTmst),
|
||||
bean.getImgFileName(i));
|
||||
bean.setTestoMessaggio(temp);
|
||||
rp.append(bean.save());
|
||||
return rp;
|
||||
}
|
||||
|
||||
protected ResParm creaFileAllegato(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
synchronized (this) {
|
||||
ResParm rp = new ResParm(true, "");
|
||||
CodaMessaggi bean = (CodaMessaggi)beanA;
|
||||
String targetDir = bean.getPathAllegato();
|
||||
File pathDir = new File(targetDir);
|
||||
if (!pathDir.exists())
|
||||
pathDir.mkdirs();
|
||||
String targetFile = String.valueOf(targetDir) + "/" + bean.getId_codaMessaggi() +
|
||||
"_";
|
||||
Vectumerator completeFileNames = (Vectumerator)
|
||||
req.getAttribute("completeAttachName");
|
||||
Vectumerator fileNames = (Vectumerator)
|
||||
req.getAttribute("attachName");
|
||||
if (completeFileNames.hasMoreElements()) {
|
||||
String sourceFile = (String)completeFileNames.nextElement();
|
||||
String fileName = (String)fileNames.elementAt(0);
|
||||
targetFile = String.valueOf(targetFile) + fileName;
|
||||
if (isFileExist(sourceFile)) {
|
||||
new File(targetFile).delete();
|
||||
new File(sourceFile).renameTo(new File(targetFile));
|
||||
}
|
||||
}
|
||||
return rp;
|
||||
}
|
||||
}
|
||||
|
||||
public void _inviaMsg(HttpServletRequest req, HttpServletResponse res) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
ResParm rp = new ResParm(true);
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
if (bean.getDBState() == 1) {
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
CR.setId_codaMessaggiS(bean.getId_codaMessaggi());
|
||||
rp = bean.inviaMessaggiAll(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Errore!. Impossibile inviare messaggio nullo");
|
||||
}
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Invio messaggio avvenuto con successo");
|
||||
} else {
|
||||
sendMessage(req, rp.getMsg());
|
||||
}
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
protected void addRows(HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = null;
|
||||
ResParm rp = new ResParm(true, "");
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
bean = new CodaMessaggi(getApFull(req));
|
||||
try {
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
rp = bean.save();
|
||||
l_id = bean.getId_codaMessaggi();
|
||||
req.setAttribute("id_codaMessaggi", String.valueOf(l_id));
|
||||
req.setAttribute("bean", bean);
|
||||
if (rp.getStatus()) {
|
||||
if (getAct(req).equals("addAllegato")) {
|
||||
AllegatoCodaMessaggi row = new AllegatoCodaMessaggi(
|
||||
getApFull(req));
|
||||
fillObject(req, row);
|
||||
rp = bean.addAllegato(row);
|
||||
rp.append(creaFileAllegato(bean, req, res));
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
} else if (getAct(req).equals("delAllegato")) {
|
||||
AllegatoCodaMessaggi row = new AllegatoCodaMessaggi(
|
||||
getApFull(req));
|
||||
fillObject(req, row);
|
||||
rp = bean.delAllegato(row);
|
||||
sendMessage(
|
||||
req,
|
||||
String.valueOf(AbMessages.getMessage(getLocale(req),
|
||||
"SAVE_OK")) +
|
||||
": Allegato Cancellato");
|
||||
showBean(req, res);
|
||||
}
|
||||
} else {
|
||||
req.setAttribute("bean", bean);
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
forceMessage(req,
|
||||
AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void _inviaMsgAll(HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
fillObject(req, CR);
|
||||
ResParm rp = new ResParm(true);
|
||||
rp = bean.inviaMessaggiAll(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
if (getCmd(req).equals("inviaMsgD")) {
|
||||
showBean(req, res);
|
||||
} else {
|
||||
search(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void _delMsgInviati(HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
CR.setFlgStatoInvio(1L);
|
||||
ResParm rp = bean.cancellazioneMassiva(CR);
|
||||
forceMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _delMsgCR(HttpServletRequest req, HttpServletResponse res) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
fillObject(req, CR);
|
||||
ResParm rp = bean.cancellazioneMassiva(CR);
|
||||
forceMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _useTemplate(HttpServletRequest req, HttpServletResponse res) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
long l_id_templateMsg = getRequestLongParameter(req, "id_templateMsg");
|
||||
TemplateMsg ts = new TemplateMsg(getApFull(req));
|
||||
ts.findByPrimaryKey(l_id_templateMsg);
|
||||
ResParm rp = bean.useTemplate(ts);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Template Messaggio associato correttamente.");
|
||||
} else {
|
||||
sendMessage(req,
|
||||
"ERRORE!. Impossibile associare template: " + rp.getMsg());
|
||||
}
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
req.setAttribute("lastUpdTmst", bean.getLastUpdTmst()
|
||||
.toString());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _msgInCoda(HttpServletRequest req, HttpServletResponse res) {
|
||||
if (getCmd(req).equals("inviaMsgD") || getCmd(req).equals("inviaMsg")) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
ResParm rp = new ResParm(true);
|
||||
if (getCmd(req).equals("inviaMsgD")) {
|
||||
fillObject(req, bean);
|
||||
bean.save();
|
||||
}
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
if (bean.getDBState() == 1) {
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
CR.setId_codaMessaggiS(bean.getId_codaMessaggi());
|
||||
rp = bean.inviaMessaggiAll(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Errore!. Impossibile inviare messaggio nullo");
|
||||
}
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Invio messaggio avvenuto con successo");
|
||||
} else {
|
||||
sendMessage(req, rp.getMsg());
|
||||
}
|
||||
if (getCmd(req).equals("inviaMsgD")) {
|
||||
showBean(req, res);
|
||||
} else {
|
||||
search(req, res);
|
||||
}
|
||||
} else if (getCmd(req).equals("inviaMsgAll")) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
fillObject(req, CR);
|
||||
ResParm rp = new ResParm(true);
|
||||
rp = bean.inviaMessaggiAll(CR);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Messaggi in invio.......... ");
|
||||
} else {
|
||||
sendMessage(req, rp.getMsg());
|
||||
}
|
||||
if (getCmd(req).equals("inviaMsgD")) {
|
||||
showBean(req, res);
|
||||
} else {
|
||||
search(req, res);
|
||||
}
|
||||
} else if (getCmd(req).equals("delMsgInviati")) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
CR.setFlgStatoInvio(1L);
|
||||
ResParm rp = bean.cancellazioneMassiva(CR);
|
||||
forceMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
} else if (getCmd(req).equals("delMsgCR")) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
fillObject(req, CR);
|
||||
ResParm rp = bean.cancellazioneMassiva(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
} else if (getCmd(req).equals("useTemplate")) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
long l_id_templateMsg = getRequestLongParameter(req,
|
||||
"id_templateMsg");
|
||||
TemplateMsg ts = new TemplateMsg(getApFull(req));
|
||||
ts.findByPrimaryKey(l_id_templateMsg);
|
||||
ResParm rp = bean.useTemplate(ts);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Template Messaggio associato correttamente.");
|
||||
} else {
|
||||
sendMessage(req, "ERRORE!. Impossibile associare template: " +
|
||||
rp.getMsg());
|
||||
}
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
req.setAttribute("lastUpdTmst", bean.getLastUpdTmst()
|
||||
.toString());
|
||||
showBean(req, res);
|
||||
} else if (getCmd(req).equals("detachTemplate")) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
long imgNum = getRequestLongParameter(req, "imgNum");
|
||||
if (imgNum == 0L)
|
||||
imgNum = 4L;
|
||||
ResParm rp = bean.detachTemplate((int)imgNum);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req,
|
||||
"Template Messaggio disassociato correttamente.");
|
||||
} else {
|
||||
sendMessage(req, "ERRORE!. Impossibile disassociare template: " +
|
||||
rp.getMsg());
|
||||
}
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
showBean(req, res);
|
||||
} else if (getCmd(req).equals("msgInCoda")) {
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
ResParm rp = bean.updateStatoMessaggi(
|
||||
2L,
|
||||
0L);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Stati aggiornati correttamente.");
|
||||
} else {
|
||||
sendMessage(req,
|
||||
"ERRORE!. Impossibile aggiornare stato del messaggio: " +
|
||||
rp.getMsg());
|
||||
}
|
||||
search(req, res);
|
||||
} else {
|
||||
super.otherCommands(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void _detachTemplate(HttpServletRequest req, HttpServletResponse res) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
long imgNum = getRequestLongParameter(req, "imgNum");
|
||||
if (imgNum == 0L)
|
||||
imgNum = 4L;
|
||||
ResParm rp = bean.detachTemplate((int)imgNum);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Template Messaggio disassociato correttamente.");
|
||||
} else {
|
||||
sendMessage(req, "ERRORE!. Impossibile disassociare template: " +
|
||||
rp.getMsg());
|
||||
}
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _inviaMsgD(HttpServletRequest req, HttpServletResponse res) {
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
CodaMessaggi bean = new CodaMessaggi(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
ResParm rp = new ResParm(true);
|
||||
fillObject(req, bean);
|
||||
bean.save();
|
||||
req.setAttribute("id_codaMessaggi",
|
||||
String.valueOf(bean.getId_codaMessaggi()));
|
||||
if (bean.getDBState() == 1) {
|
||||
CodaMessaggiCR CR = new CodaMessaggiCR(getApFull(req));
|
||||
CR.setId_codaMessaggiS(bean.getId_codaMessaggi());
|
||||
rp = bean.inviaMessaggiAll(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Errore!. Impossibile inviare messaggio nullo");
|
||||
}
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Invio messaggio avvenuto con successo");
|
||||
} else {
|
||||
sendMessage(req, rp.getMsg());
|
||||
}
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _addAllegato(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
CodaMessaggi bean = new CodaMessaggi(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
bean.findByPrimaryKey(l_id);
|
||||
String fileName = getRequestParameter(req, "fileNameOnServer_1");
|
||||
String targetDir = bean.getPathAllegato();
|
||||
File pathDir = new File(targetDir);
|
||||
if (!pathDir.exists())
|
||||
pathDir.mkdirs();
|
||||
String targetFile = String.valueOf(targetDir) + "/" + bean.getId_codaMessaggi() + "_" + fileName;
|
||||
String sourceFile = String.valueOf(getDocBase()) + getPathTmp() + fileName;
|
||||
if (isFileExist(sourceFile)) {
|
||||
new File(targetFile).delete();
|
||||
new File(sourceFile).renameTo(new File(targetFile));
|
||||
}
|
||||
AllegatoCodaMessaggi row = new AllegatoCodaMessaggi(apFull);
|
||||
fillObject(req, row);
|
||||
row.setNomeFile(fileName);
|
||||
ResParm rp = bean.addAllegato(row);
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _delAllegato(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
CodaMessaggi bean = new CodaMessaggi(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_codaMessaggi");
|
||||
bean.findByPrimaryKey(l_id);
|
||||
AllegatoCodaMessaggi row = new AllegatoCodaMessaggi(apFull);
|
||||
fillObject(req, row);
|
||||
bean.delAllegato(row);
|
||||
sendMessage(req, String.valueOf(AbMessages.getMessage(getLocale(req), "SAVE_OK")) + ": Allegato Cancellato");
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
package com.ablia.newsletter.servlet.admin;
|
||||
|
||||
import com.ablia.db.CRAdapter;
|
||||
import com.ablia.db.DBAdapter;
|
||||
import com.ablia.db.ResParm;
|
||||
import com.ablia.newsletter.CodaMessaggi;
|
||||
import com.ablia.newsletter.MailNewsletter;
|
||||
import com.ablia.newsletter.MailNewsletterCR;
|
||||
import com.ablia.newsletter.TemplateMsg;
|
||||
import com.ablia.servlet.AblServletSvlt;
|
||||
import com.ablia.util.AbMessages;
|
||||
import com.ablia.util.Vectumerator;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet(urlPatterns = {"/admin/newsletter/MailNewsletter.abl"})
|
||||
public class MailNewsletterSvlt extends AblServletSvlt {
|
||||
private static final long serialVersionUID = -7017882231079147417L;
|
||||
|
||||
public void _cancGo(HttpServletRequest req, HttpServletResponse res) {
|
||||
MailNewsletter ml = new MailNewsletter(getApFull(req));
|
||||
String indirizzi = getRequestParameter(req, "indirizzi");
|
||||
ml.delIndirizzi(indirizzi);
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter bean, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {
|
||||
req.setAttribute("listaTemplateMsg", new TemplateMsg(getApFull(req))
|
||||
.findAll(1L));
|
||||
}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new MailNewsletter(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new MailNewsletterCR(getApFull(req));
|
||||
}
|
||||
|
||||
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected boolean isSimpleServlet(HttpServletRequest req) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
protected void manageMultipartRequest(HttpServletRequest req, HttpServletResponse res) {
|
||||
int LIMIT = 148000;
|
||||
String[] fileNameTypes = {
|
||||
"txt", "xls", "ods", "mdb", "xml", "pdf",
|
||||
"odt", "doc", "html", "zip",
|
||||
"csv" };
|
||||
String targetDir = String.valueOf(getDocBase()) + getPathTmp();
|
||||
String[] fileNameParameters = { "fileName" };
|
||||
try {
|
||||
if (manageMultipartRequestParameters(req, LIMIT,
|
||||
fileNameParameters, null, fileNameTypes, targetDir)) {
|
||||
processNoEncTypeRequest(req, res);
|
||||
} else {
|
||||
sendGrantMessage(req, AbMessages.getMessage(getLocale(req),
|
||||
"MR_FILE_ERROR"));
|
||||
search(req, res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addRows(HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
public void _delNewsletter(HttpServletRequest req, HttpServletResponse res) {
|
||||
MailNewsletter ml = new MailNewsletter(getApFull(req));
|
||||
String indirizzo = getRequestParameter(req, "ind");
|
||||
ml.delIndirizzi(indirizzo);
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _impUtenti(HttpServletRequest req, HttpServletResponse res) {
|
||||
MailNewsletter ml = new MailNewsletter(getApFull(req));
|
||||
ml.impUtenti();
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _impGo(HttpServletRequest req, HttpServletResponse res) {
|
||||
if (!MailNewsletter.threadAddMailsFromFile) {
|
||||
MailNewsletter ml = new MailNewsletter(getApFull(req));
|
||||
Vectumerator fn = (Vectumerator)
|
||||
req.getAttribute("completeAttachName");
|
||||
String fileName = (String)fn.nextElement();
|
||||
ResParm rp = ml.addIndirizzi(fileName);
|
||||
forceMessage(req, rp.getMsg());
|
||||
} else {
|
||||
forceMessage(req,
|
||||
"ATTENZIONE!! Thread inserimento indirizzi ancora in esecuzione!!!");
|
||||
}
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _creaCodaMail(HttpServletRequest req, HttpServletResponse res) {
|
||||
MailNewsletter ml = new MailNewsletter(getApFull(req));
|
||||
MailNewsletterCR CR = new MailNewsletterCR(getApFull(req));
|
||||
fillObject(req, CR);
|
||||
ResParm rp = new CodaMessaggi(getApFull(req)).creaCodaMessaggi(CR,
|
||||
getRequestLongParameter(req, "id_templateMsg"));
|
||||
forceMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
package com.ablia.newsletter.servlet.admin;
|
||||
|
||||
import com.ablia.common.JsonUploadFileResponse;
|
||||
import com.ablia.common.Users;
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.CRAdapter;
|
||||
import com.ablia.db.DBAdapter;
|
||||
import com.ablia.jsp.Ab;
|
||||
import com.ablia.newsletter.NoMlist;
|
||||
import com.ablia.newsletter.NoMlistCR;
|
||||
import com.ablia.servlet.AblServletSvlt;
|
||||
import com.google.gson.Gson;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet(urlPatterns = {"/admin/newsletter//NoMlist.abl"})
|
||||
public class NoMlistSvlt extends AblServletSvlt {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new NoMlist(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new NoMlistCR(getApFull(req));
|
||||
}
|
||||
|
||||
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
super.otherCommands(req, res);
|
||||
}
|
||||
|
||||
public String getPathAttach(HttpServletRequest req) {
|
||||
return "_tmp/";
|
||||
}
|
||||
|
||||
public void _saveFile(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Users utente = new Users(apFull);
|
||||
long l_id_users = getLoginUserId(req);
|
||||
utente.findByPrimaryKey(l_id_users);
|
||||
if (utente.getId_users() > 0L) {
|
||||
HashMap<String, String> uploadedImages = (HashMap<String, String>)req.getAttribute("_UFN");
|
||||
String currentFullFileName = "", currentFileName = "";
|
||||
if (!uploadedImages.isEmpty()) {
|
||||
Iterator<Map.Entry<String, String>> iterator = uploadedImages.entrySet().iterator();
|
||||
if (iterator.hasNext()) {
|
||||
Map.Entry<String, String> entry = iterator.next();
|
||||
currentFullFileName = entry.getValue();
|
||||
currentFileName = entry.getKey();
|
||||
}
|
||||
}
|
||||
if (!currentFullFileName.isEmpty())
|
||||
synchronized (this) {
|
||||
String targetDir = String.valueOf(getDocBase()) + getPathAttach(req);
|
||||
String newFileName = String.valueOf(utente.getId_users()) + "_" + getTimeNameForFileUpload() + "_" + currentFileName;
|
||||
File cfn = new File(currentFullFileName);
|
||||
File newFile = new File(String.valueOf(targetDir) + newFileName);
|
||||
cfn.renameTo(newFile);
|
||||
cfn = null;
|
||||
newFile = null;
|
||||
Gson gson = new Gson();
|
||||
if (newFileName.endsWith(".txt")) {
|
||||
String fileElaborato = new NoMlist(apFull).elaboraEPulisci(String.valueOf(targetDir) + newFileName);
|
||||
String fileElaboratoName = fileElaborato.replace(targetDir, "");
|
||||
sendHtmlMsgResponse(req, res,
|
||||
"[" + gson.toJson(new JsonUploadFileResponse(true,
|
||||
Ab.formatBeanMsg("File " + currentFileName + " Elaborato correttamente", ""),
|
||||
fileElaboratoName, "../../" + getPathAttach(req) + fileElaboratoName)) + "]");
|
||||
} else {
|
||||
sendHtmlMsgResponse(req, res, "[" + gson.toJson(new JsonUploadFileResponse(true,
|
||||
Ab.formatBeanMsg("Mandami un txt bischero", ""), "", "to")) + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void search(HttpServletRequest req, HttpServletResponse res) {
|
||||
callJsp(req, res);
|
||||
}
|
||||
|
||||
public void _elaboraMlist(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
long id_clifor = getRequestLongParameter(req, "id_clifor");
|
||||
if (id_clifor == 0L)
|
||||
sendMessage(req, "ERRORE! Cliente non impostato");
|
||||
search(req, res);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,207 @@
|
|||
package com.ablia.newsletter.servlet.admin;
|
||||
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.CRAdapter;
|
||||
import com.ablia.db.DBAdapter;
|
||||
import com.ablia.db.ResParm;
|
||||
import com.ablia.newsletter.AllegatoTemplateMsg;
|
||||
import com.ablia.newsletter.CodaMessaggi;
|
||||
import com.ablia.newsletter.TemplateMsg;
|
||||
import com.ablia.newsletter.TemplateMsgCR;
|
||||
import com.ablia.servlet.AblServletSvlt;
|
||||
import com.ablia.util.AbMessages;
|
||||
import com.ablia.util.Vectumerator;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet(urlPatterns = {"/admin/newsletter/TemplateMsg.abl"})
|
||||
public class TemplateMsgSvlt extends AblServletSvlt {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected void addRows(HttpServletRequest req, HttpServletResponse res) {
|
||||
TemplateMsg bean = null;
|
||||
ResParm rp = new ResParm(true, "");
|
||||
long l_id = getRequestLongParameter(req, "id_templateMsg");
|
||||
bean = new TemplateMsg(getApFull(req));
|
||||
try {
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
rp = bean.save();
|
||||
l_id = bean.getId_templateMsg();
|
||||
req.setAttribute("id_templateMsg", String.valueOf(l_id));
|
||||
req.setAttribute("bean", bean);
|
||||
if (rp.getStatus()) {
|
||||
if (getAct(req).equals("addAllegato")) {
|
||||
AllegatoTemplateMsg row = new AllegatoTemplateMsg(getApFull(req));
|
||||
fillObject(req, row);
|
||||
rp = bean.addAllegato(row);
|
||||
rp.append(creaFileAllegato(bean, req, res));
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
} else if (getAct(req).equals("delAllegato")) {
|
||||
AllegatoTemplateMsg row = new AllegatoTemplateMsg(getApFull(req));
|
||||
fillObject(req, row);
|
||||
rp = bean.delAllegato(row);
|
||||
sendMessage(req, String.valueOf(AbMessages.getMessage(getLocale(req), "SAVE_OK")) + ": Allegato Cancellato");
|
||||
showBean(req, res);
|
||||
}
|
||||
} else {
|
||||
req.setAttribute("bean", bean);
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
TemplateMsg bean = (TemplateMsg)beanA;
|
||||
req.setAttribute("listaAllegati", bean.getAllegati());
|
||||
}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new TemplateMsg(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new TemplateMsgCR(getApFull(req));
|
||||
}
|
||||
|
||||
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {
|
||||
TemplateMsg bean = new TemplateMsg(getApFull(req));
|
||||
bean.setFlgTipo(1L);
|
||||
req.setAttribute("bean", bean);
|
||||
}
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
super.otherCommands(req, res);
|
||||
}
|
||||
|
||||
protected boolean isLoadImageServlet() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected String getAttachPath(HttpServletRequest req) {
|
||||
return ((TemplateMsg)getBean(req)).getPathAttach();
|
||||
}
|
||||
|
||||
protected ResParm afterImgFileSave(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
TemplateMsg bean = (TemplateMsg)beanA;
|
||||
String oldImgTmst = bean.getImgTmst();
|
||||
ResParm rp = super.afterImgFileSave(bean, req, res);
|
||||
String temp = bean.getTestoMessaggio();
|
||||
long l_totImgNumber = getRequestLongParameter(req, "totImgNumber");
|
||||
if (l_totImgNumber == 0L)
|
||||
l_totImgNumber = 4L;
|
||||
for (int i = 1; (long)i <= l_totImgNumber; i++)
|
||||
temp = temp.replaceAll(bean.getImgFileName(i, oldImgTmst), bean.getImgFileName(i));
|
||||
bean.setTestoMessaggio(temp);
|
||||
rp.append(bean.save());
|
||||
return rp;
|
||||
}
|
||||
|
||||
public void _creaCodaMsg(HttpServletRequest req, HttpServletResponse res) {
|
||||
long l_id_templateMsg = getRequestLongParameter(req, "id_templateMsg");
|
||||
TemplateMsg ts = new TemplateMsg(getApFull(req));
|
||||
ts.findByPrimaryKey(l_id_templateMsg);
|
||||
String targetDir = String.valueOf(getDocBase()) + getPathTmp();
|
||||
String targetFile = String.valueOf(targetDir) + "creaCodaMsg_" + getTimeNameForFileUpload() + "_" + ts.getId_templateMsg() + ".txt";
|
||||
HashMap<String, String> uploadedFiles = (HashMap<String, String>)req.getAttribute("_UFN");
|
||||
if (!uploadedFiles.isEmpty()) {
|
||||
Iterator<Map.Entry<String, String>> iterator = uploadedFiles.entrySet().iterator();
|
||||
if (iterator.hasNext()) {
|
||||
Map.Entry<String, String> entry = iterator.next();
|
||||
String sourceFile = entry.getValue();
|
||||
if (isFileExist(sourceFile)) {
|
||||
new File(targetFile).delete();
|
||||
new File(sourceFile).renameTo(new File(targetFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
CodaMessaggi cm = new CodaMessaggi(getApFull(req));
|
||||
ResParm rp = cm.creaCodaMessaggi(ts, targetFile);
|
||||
forceMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
protected ResParm creaFileAllegato(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
synchronized (this) {
|
||||
ResParm rp = new ResParm(true, "");
|
||||
TemplateMsg bean = (TemplateMsg)beanA;
|
||||
String targetDir = bean.getPathAllegato();
|
||||
File pathDir = new File(targetDir);
|
||||
if (!pathDir.exists())
|
||||
pathDir.mkdirs();
|
||||
String targetFile = String.valueOf(targetDir) + "/" + bean.getId_templateMsg() + "_";
|
||||
Vectumerator completeFileNames = (Vectumerator)req.getAttribute("completeAttachName");
|
||||
Vectumerator fileNames = (Vectumerator)req.getAttribute("attachName");
|
||||
if (completeFileNames.hasMoreElements()) {
|
||||
String sourceFile = (String)completeFileNames.nextElement();
|
||||
String fileName = (String)fileNames.elementAt(0);
|
||||
targetFile = String.valueOf(targetFile) + fileName;
|
||||
if (isFileExist(sourceFile)) {
|
||||
new File(targetFile).delete();
|
||||
new File(sourceFile).renameTo(new File(targetFile));
|
||||
}
|
||||
}
|
||||
return rp;
|
||||
}
|
||||
}
|
||||
|
||||
public void _addAllegato(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
TemplateMsg bean = new TemplateMsg(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_templateMsg");
|
||||
bean.findByPrimaryKey(l_id);
|
||||
String fileName = getRequestParameter(req, "fileNameOnServer_1");
|
||||
String targetDir = bean.getPathAllegato();
|
||||
File pathDir = new File(targetDir);
|
||||
if (!pathDir.exists())
|
||||
pathDir.mkdirs();
|
||||
String targetFile = String.valueOf(targetDir) + "/" + bean.getId_templateMsg() + "_" + fileName;
|
||||
String sourceFile = String.valueOf(getDocBase()) + getPathTmp() + fileName;
|
||||
if (isFileExist(sourceFile)) {
|
||||
new File(targetFile).delete();
|
||||
new File(sourceFile).renameTo(new File(targetFile));
|
||||
}
|
||||
AllegatoTemplateMsg row = new AllegatoTemplateMsg(apFull);
|
||||
fillObject(req, row);
|
||||
row.setNomeFile(fileName);
|
||||
ResParm rp = bean.addAllegato(row);
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _delAllegato(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
TemplateMsg bean = new TemplateMsg(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_templateMsg");
|
||||
bean.findByPrimaryKey(l_id);
|
||||
AllegatoTemplateMsg row = new AllegatoTemplateMsg(apFull);
|
||||
fillObject(req, row);
|
||||
bean.delAllegato(row);
|
||||
sendMessage(req, String.valueOf(AbMessages.getMessage(getLocale(req), "SAVE_OK")) + ": Allegato Cancellato");
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _creaCodaMsgLte(HttpServletRequest req, HttpServletResponse res) {
|
||||
long l_id_templateMsg = getRequestLongParameter(req, "id_templateMsg");
|
||||
TemplateMsg ts = new TemplateMsg(getApFull(req));
|
||||
ts.findByPrimaryKey(l_id_templateMsg);
|
||||
String fileName = getRequestParameter(req, "fileNameOnServer_99");
|
||||
String fullMlFIle = String.valueOf(getDocBase()) + getPathTmp() + fileName;
|
||||
CodaMessaggi cm = new CodaMessaggi(getApFull(req));
|
||||
ResParm rp = cm.creaCodaMessaggi(ts, fullMlFIle);
|
||||
forceMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue