71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Data
|
|
{
|
|
public class utils
|
|
{
|
|
/// <summary>
|
|
/// Effettua invio notifica (email e quando disponibile tramite notifica browser)
|
|
/// </summary>
|
|
/// <param name="mittente"></param>
|
|
/// <param name="destinatario"></param>
|
|
/// <param name="oggetto"></param>
|
|
/// <param name="corpo"></param>
|
|
/// <param name="tipoNotifica">1 = email | 2 = webPush | 3 = email + webPush</param>
|
|
/// <returns></returns>
|
|
public static bool inviaEmail(string mittente, string destinatario, string oggetto, string corpo, int tipoNotifica)
|
|
{
|
|
bool answ = false;
|
|
// se in modalità debug --> email solo a destinatario _debugEmail
|
|
#if DEBUG
|
|
string newEmail = memLayer.ML.CRS("_debugEmail");
|
|
//loggo sostituzione...
|
|
logger.lg.scriviLog(string.Format("Applicazione in DEBUG: sostituzione email destinatario {0} --> {1} prima dell'invio", destinatario, newEmail), tipoLog.INFO);
|
|
destinatario = memLayer.ML.CRS("_debugEmail");
|
|
#endif
|
|
// se richeisto webPush...
|
|
if (tipoNotifica == 2 || tipoNotifica == 3)
|
|
{
|
|
sendPushNotification();
|
|
answ = true;
|
|
}
|
|
if (tipoNotifica == 1 || tipoNotifica == 3)
|
|
{
|
|
gestEmail.geAuth.mandaEmail(mittente, destinatario, oggetto, corpo);
|
|
answ = true;
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Gestione invio push notifications
|
|
/// </summary>
|
|
private static void sendPushNotification()
|
|
{
|
|
// da fare... sottoscrizione canale?!?
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ripulisce le note per display
|
|
/// </summary>
|
|
/// <param name="original"></param>
|
|
/// <returns></returns>
|
|
public static string parseNote(object original)
|
|
{
|
|
string answ = original.ToString();
|
|
// fix a capo..
|
|
answ = answ.Replace("\n", @"<br/>");
|
|
// fix linee...
|
|
answ = answ.Replace("---", @"<hr/>");
|
|
// fix bold...
|
|
answ = answ.Replace("[[", @"<b>").Replace("]]", @"</b>");
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
}
|