258 lines
9.3 KiB
C#
258 lines
9.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web;
|
|
using SteamWare;
|
|
|
|
namespace XPS_data
|
|
{
|
|
/// <summary>
|
|
/// modalità utente XPS Equa
|
|
/// </summary>
|
|
public enum modoXPS_Equa
|
|
{
|
|
magazzino,
|
|
spedizioni,
|
|
segreteria,
|
|
produzione,
|
|
direzione
|
|
}
|
|
|
|
/// <summary>
|
|
/// Summary description for XPS
|
|
/// </summary>
|
|
public class XPS
|
|
{
|
|
#region Public Fields
|
|
|
|
/// <summary>
|
|
/// singleton classe
|
|
/// </summary>
|
|
public static XPS obj = new XPS();
|
|
|
|
public DS_applicazioneTableAdapters.AnagClientiTableAdapter taAnCli;
|
|
|
|
public DS_applicazioneTableAdapters.AnagLavTableAdapter taAnLav;
|
|
|
|
public DS_applicazioneTableAdapters.v_commesseTableAdapter taComm;
|
|
|
|
public DS_applicazioneTableAdapters.sp_ddtTableAdapter taDdt;
|
|
|
|
public DS_XPSTableAdapters.NoteTableAdapter taNote;
|
|
|
|
public DS_applicazioneTableAdapters.IstObjTableAdapter taObj;
|
|
|
|
public DS_applicazioneTableAdapters.sp_rec4DayTableAdapter taRec4day;
|
|
|
|
public DS_applicazioneTableAdapters.sp_schedaIdentTableAdapter taSchedaIdent;
|
|
|
|
public DS_applicazioneTableAdapters.SP taSP;
|
|
|
|
#endregion Public Fields
|
|
|
|
#region Protected Constructors
|
|
|
|
/// <summary>
|
|
/// avvio classe
|
|
/// </summary>
|
|
protected XPS()
|
|
{
|
|
avvioTA();
|
|
setupConnectionStringBase();
|
|
}
|
|
|
|
#endregion Protected Constructors
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// avvia table adapters
|
|
/// </summary>
|
|
private void avvioTA()
|
|
{
|
|
// avvio i table adapters...
|
|
taObj = new DS_applicazioneTableAdapters.IstObjTableAdapter();
|
|
taSP = new DS_applicazioneTableAdapters.SP();
|
|
taSchedaIdent = new DS_applicazioneTableAdapters.sp_schedaIdentTableAdapter();
|
|
taDdt = new DS_applicazioneTableAdapters.sp_ddtTableAdapter();
|
|
taRec4day = new DS_applicazioneTableAdapters.sp_rec4DayTableAdapter();
|
|
taComm = new DS_applicazioneTableAdapters.v_commesseTableAdapter();
|
|
taAnCli = new DS_applicazioneTableAdapters.AnagClientiTableAdapter();
|
|
taAnLav = new DS_applicazioneTableAdapters.AnagLavTableAdapter();
|
|
taNote = new DS_XPSTableAdapters.NoteTableAdapter();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// effettua setup dei connection strings da web.config delal singola applicazione
|
|
/// </summary>
|
|
protected virtual void setupConnectionStringBase()
|
|
{
|
|
string connString = memLayer.ML.confReadString("XPSConnectionString");
|
|
// connections strings del db
|
|
taObj.Connection.ConnectionString = connString;
|
|
//taSP.Connection.ConnectionString = connString;
|
|
taSchedaIdent.Connection.ConnectionString = connString;
|
|
taDdt.Connection.ConnectionString = connString;
|
|
taRec4day.Connection.ConnectionString = connString;
|
|
taComm.Connection.ConnectionString = connString;
|
|
taAnCli.Connection.ConnectionString = connString;
|
|
taAnLav.Connection.ConnectionString = connString;
|
|
taNote.Connection.ConnectionString = connString;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Restituisce email dest da codCliente + check conf da web.config con forzatura a email interna
|
|
/// </summary>
|
|
/// <param name="CodCliente"></param>
|
|
/// <returns></returns>
|
|
public string getEmailDest(string CodCliente)
|
|
{
|
|
string answ = "";
|
|
if (memLayer.ML.CRS("_forcedDestEmail") != "")
|
|
{
|
|
answ = memLayer.ML.CRS("_forcedDestEmail");
|
|
}
|
|
else
|
|
{
|
|
answ = taAnCli.getByKey(CodCliente)[0].email;
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Invio email cliente x merce pronta
|
|
/// <paramref name="idxObj">Chiave Obj</paramref>
|
|
/// </summary>
|
|
public void sendEmailCliente(string idxObj)
|
|
{
|
|
// mi limito a mandare email e non segnalo altro... carico dati!
|
|
logger.lg.scriviLog("Richiesto invio email...");
|
|
int currState = 0;
|
|
bool emailReq = false;
|
|
string emailDest = "";
|
|
string CodCliente = "";
|
|
string ddt = "";
|
|
string dataRif = "";
|
|
string descr = "";
|
|
string peso = "";
|
|
DS_applicazione.IstObjRow rigaIstObj = null;
|
|
|
|
// calcolo lo stato dell'oggetto...
|
|
try
|
|
{
|
|
rigaIstObj = taObj.getByIdxObj(idxObj)[0];
|
|
currState = Convert.ToInt32(rigaIstObj.CodStato);
|
|
emailReq = rigaIstObj.emailReq;
|
|
CodCliente = rigaIstObj.CodCliente;
|
|
emailDest = getEmailDest(CodCliente);
|
|
logger.lg.scriviLog(string.Format("Recuperati dati per invio email: {0} | {1} | {2}", idxObj, CodCliente, emailDest));
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(String.Format("Eccezione in recupero dati commessa x email: {0}", exc), tipoLog.EXCEPTION);
|
|
}
|
|
try
|
|
{
|
|
rigaIstObj = taObj.getByIdxObj(idxObj)[0];
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(String.Format("Eccezione in invio email: {0}", exc), tipoLog.EXCEPTION);
|
|
}
|
|
try
|
|
{
|
|
ddt = string.IsNullOrEmpty(rigaIstObj.Nome) ? "N.A." : rigaIstObj.Nome;
|
|
descr = string.IsNullOrEmpty(rigaIstObj.Note) ? "N.A." : rigaIstObj.Note;
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
ddt = "n.d.";
|
|
descr = "n.d.";
|
|
logger.lg.scriviLog(String.Format("Eccezione in recupero dati x email: {0}", exc), tipoLog.EXCEPTION);
|
|
}
|
|
try
|
|
{
|
|
dataRif = rigaIstObj.DataRif.ToString("dd/MM/yy HH:mm");
|
|
peso = rigaIstObj.Peso.ToString();
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
dataRif = "n.d.";
|
|
peso = "n.d.";
|
|
logger.lg.scriviLog(String.Format("Eccezione in recupero dati x email: {0}", exc), tipoLog.EXCEPTION);
|
|
}
|
|
if (currState >= 5 && emailDest != "")
|
|
{
|
|
// invio email
|
|
|
|
// 'Notifica merce pronta'
|
|
string subject = user_std.UtSn.Traduci("emailSubject");
|
|
|
|
//'Attenzione, la merce relativa al DDT {0} del {1}, ({2}, peso {3} kg) è pronta per il ritiro presso EQUA s.p.a di Pedrengo'
|
|
string bodyMsg = string.Format(user_std.UtSn.Traduci("emailBody"), ddt, dataRif, descr, peso);
|
|
|
|
// se è forzato invio interno cambio subject e body...
|
|
if (memLayer.ML.CRS("_forcedDestEmail") != "")
|
|
{
|
|
DS_applicazione.v_commesseRow rigaComm = taComm.getByCod(idxObj)[0];
|
|
subject += string.Format(" | cliente: {0}", rigaComm.Cliente);
|
|
bodyMsg += string.Format("<br/><br/><a href=\"{0}detComm?CodDDT={1}\">Link diretto al DDT {2} - {3}</a>", memLayer.ML.CRS("mainSite"), rigaComm.Cod, rigaComm.DDT, rigaComm.descrizione);
|
|
}
|
|
// invio email!
|
|
bool fatto = gestEmail.geAuth.mandaEmail(memLayer.ML.confReadString("_emailUser"), emailDest, subject, bodyMsg);
|
|
if (fatto)
|
|
{
|
|
// aggiorno stato obj
|
|
taObj.updateEmailSent(idxObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// restituisce l'url formattato del report x stampare etichette e moduli con barcode
|
|
/// </summary>
|
|
/// <param name="Cod"></param>
|
|
/// <param name="tipoReport">tipo di report (label, module ...)</param>
|
|
/// <param name="outputRich">tipo di output richiesto (PDF / anteprima)</param>
|
|
/// <returns></returns>
|
|
public string urlReport(object Cod, string tipoReport, string outputRich)
|
|
{
|
|
string url, urlFormat, opzPdf, nomeRep;
|
|
try
|
|
{
|
|
urlFormat = SteamWare.memLayer.ML.confReadString("urlReporting");
|
|
if (outputRich == "PDF")
|
|
{
|
|
opzPdf = SteamWare.memLayer.ML.confReadString("reportOpzPdf");
|
|
}
|
|
else
|
|
{
|
|
opzPdf = "";
|
|
}
|
|
if (tipoReport == "label")
|
|
{
|
|
nomeRep = SteamWare.memLayer.ML.confReadString("reportName_lbl");
|
|
}
|
|
else // (tipoReport == "module")
|
|
{
|
|
nomeRep = SteamWare.memLayer.ML.confReadString("reportName_mod");
|
|
}
|
|
url = string.Format(urlFormat, SteamWare.memLayer.ML.confReadString("reportingServerAddress"), SteamWare.memLayer.ML.confReadString("reportDir"), nomeRep, Cod, opzPdf);
|
|
}
|
|
catch
|
|
{
|
|
url = "";
|
|
}
|
|
return url;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |