Beispiel #1
0
 private static void GenerateOrderPdfAndSendEmail(ProducerBill bill)
 {
     try
     {
         if (bill.BillEntries.Count == 0)
         {
             AuthMessageSender.SendEmail(bill.AdherentStolon.Stolon.Label,
                                         bill.AdherentStolon.Adherent.Email,
                                         bill.AdherentStolon.Adherent.CompanyName,
                                         "Aucune commande chez " + bill.AdherentStolon.Stolon.Label + " cette semaine.",
                                         "<h3>Aucune commande chez  " + bill.AdherentStolon.Stolon.Label + " cette semaine.");
         }
         else
         {
             //Generate pdf file
             bool hasFile = GenerateOrderPDF(bill);
             //Send mail to producer
             try
             {
                 string message = bill.HtmlOrderContent;
                 if (hasFile)
                 {
                     message += "<h3>En pièce jointe votre bon de commande de la semaine chez " + bill.AdherentStolon.Stolon.Label + " (Bon de commande " + bill.BillNumber + ")</h3>";
                 }
                 AuthMessageSender.SendEmail(bill.AdherentStolon.Stolon.Label,
                                             bill.AdherentStolon.Adherent.Email,
                                             bill.AdherentStolon.Adherent.CompanyName,
                                             "Votre bon de commande de la semaine chez " + bill.AdherentStolon.Stolon.Label + " (Bon de commande " + bill.BillNumber + ")",
                                             message,
                                             hasFile ? File.ReadAllBytes(bill.GetOrderFilePath()) : null,
                                             "Bon de commande " + bill.GetOrderFileName());
             }
             catch (Exception exept)
             {
                 Logger.LogError("Error on sending mail " + exept);
             }
         }
     }
     catch (Exception exept)
     {
         AuthMessageSender.SendEmail(bill.AdherentStolon.Stolon.Label,
                                     Configurations.Application.ContactMailAddress,
                                     "Stolons",
                                     "Erreur lors de la génération de la facture " + bill.BillNumber + " à " + bill.AdherentStolon.Adherent.Email,
                                     "Message d'erreur : " + exept.Message);
     }
 }
Beispiel #2
0
 public static bool GenerateOrderPDF(ProducerBill bill)
 {
     return(GeneratePDF(bill.HtmlOrderContent, bill.GetOrderFilePath()));
 }