campo-sirio/src/include/spotlite.cpp
mtollari eb45e8eded Patch level : 12.0 484
Files correlati     : 
Commento            : Modificato invio email, se la powershell è attivata chiama la funzione specifica


git-svn-id: svn://10.65.10.50/branches/R_10_00@24222 c028cbd2-c16b-5b4b-a496-9718f37d4682
2017-11-30 15:50:13 +00:00

120 lines
3.0 KiB
C++
Executable File

#include <applicat.h>
#include <dongle.h>
#include <mask.h>
#include <modaut.h>
#include <spotlite.h>
#include <defmask.h>
#include <bagn003.h>
// Funzione per generare il nome di un file da archiviare
bool spotlite_generate_name(const char* codnum, TFilename& pdf)
{
bool ok = main_app().get_next_pdf(0, -1, codnum, 0, 0, pdf);
if (ok && pdf.exist())
{
TString msg;
msg = TR("Il documento risulta essere gia' archiviato: sovrascrivere");
msg << '\n' << pdf.name();
ok = yesno_box(msg);
}
return ok;
}
KEY spotlite_ask_name(TFilename& pdf, int & size)
{
TMask msk("bagn009");
TApplication& a = main_app();
const bool can_arc = a.has_module(RSAUT);
const bool can_sign = can_arc && a.has_module(FDAUT);
msk.enable(DLG_EXPORT, can_arc);
msk.enable(DLG_PDF, can_arc);
msk.enable(DLG_SIGNPDF, can_sign);
TFilename export_name;
const bool gnp = a.get_next_pdf(0, 0, NULL, 1, 0, pdf);
if (gnp)
{
pdf.ext("");
export_name = pdf.name();
}
if (export_name.blank())
export_name = "export";
msk.enable(DLG_ARCHIVE, can_arc && gnp);
msk.enable(DLG_SIGNARC, can_sign && gnp);
msk.enable(DLG_EMAIL, can_arc);
msk.enable(DLG_SIGNMAIL, can_sign);
pdf.tempdir();
msk.set(F_PRINTER, pdf); // Cartella dei file da esportare
msk.set(F_FORM, export_name); // Nome standard del file da esportare
KEY key = msk.run();
if (key != K_ESC && key != K_QUIT)
{
pdf = msk.get(F_PRINTER);
if (!pdf.exist())
pdf.tempdir();
if (!msk.field(F_FORM).empty())
export_name = msk.get(F_FORM);
if (msk.id2pos(F_SIZE) >= 0 && !msk.field(F_SIZE).empty())
size = msk.get_int(F_SIZE);
else
size = 0;
pdf.add(export_name);
pdf.ext("pdf");
switch (key)
{
case 'A':
case 'a':
if (!spotlite_generate_name(msk.get(F_FORM), pdf))
key = K_QUIT;
break;
case 'E':
case 'e':
pdf.ext("txt");
break;
case 'X':
case 'x':
pdf.ext("xls");
break;
default : break;
}
}
return key;
}
// Funzione per notificare al sistema l'avvenuta archiviazione
bool spotlite_notify(const TFilename& pdf)
{
bool ok = pdf.exist();
if (ok)
{
TFilename sentinel = pdf.path();
sentinel.add("sentinel.ini");
ofstream s(sentinel, ios::app);
s << pdf.name() << endl;
}
return ok;
}
// Funzione per spedire un pdf via mail
bool spotlite_send_mail(const TFilename& pdf)
{
TToken_string to(15, ';'), cc(15, ';'), ccn(15, ';'), attach(pdf, ';');
TString subj, text;
short flags = 0x1; // UI
bool ok = main_app().get_next_mail(to, cc, ccn, subj, text, attach, flags);
if (subj.blank())
subj.cut(0) << TR("Invio di ") << pdf.name();
if (!(flags & 0x1) && to.empty_items() && cc.empty_items() && ccn.empty_items())
flags |= 0x1; // Forza UI in assenza di destinatari
static bool usePower = ini_get_bool(CONFIG_USER, "Mail", "Powershell");
ok = (usePower ? xvt_powermail_send(to, cc, ccn, subj, text, attach, flags, user()) :
xvt_mail_send(to, cc, ccn, subj, text, attach, flags)) != 0;
return ok;
}