示例#1
0
        private static void SendAndLogLABReminderMail(List<Data.Model.CustomerProspect> customers)
        {
            var clientGroupbyAdvisor = new Dictionary<Guid, List<Data.Model.CustomerProspect>>();
            foreach (var customer in customers)
            {
                if (!clientGroupbyAdvisor.ContainsKey(customer.idUserCreated))
                    clientGroupbyAdvisor.Add(customer.idUserCreated, new List<Data.Model.CustomerProspect> { customer });
                else
                    clientGroupbyAdvisor[customer.idUserCreated].Add(customer);
            }
            try
            {
                var customerToReminder = CustomerProspectBL.SendAlertEmailToUpdate_LAB(clientGroupbyAdvisor);
                foreach (var customer in customerToReminder)
                {
                    ReportLABReminderLog reminder = new ReportLABReminderLog()
                    {
                        DateCreated = DateTime.Now,
                        Email = customer.User1.UserEmail,
                        idCustomer = customer.idCustomer,
                        IsAlertRecipientClient = false,
                        IsAutomatic = true,
                        DocumentType = CustomerProspectBL.TypeRelanceLAB
                    };

                    Upsilab.Business.ReportLABReminderLog.ReportLABReminderLogBL.AddReminder(reminder);
                }
                 //Creation log de la relance
            }
            catch (Exception ex)
            {
                Business.Log.Log.AppendException(ex);
            }
        }
示例#2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="customer"></param>
        /// <param name="typeReminder"></param>
        private static void SendAndLogReminderMail(Data.Model.CustomerProspect customer, string typeReminder)
        {
            try
            {
                bool isSent = false;

                System.Console.WriteLine("\nRelance du client '{0} - {1} {2}'.", customer.User.UserEmail, customer.User.UserFirstName, customer.User.UserName);

                if (typeReminder == CustomerProspectBL.TypeRelanceLAB || typeReminder == CustomerProspectBL.TypeRelanceCNI || typeReminder == CustomerProspectBL.TypeRelancePASSEPORT)
                {
                    isSent = CustomerProspectBL.SendAlertEmailToUpdate_LAB_CNI_Passport(customer, typeReminder, true);
                    System.Console.WriteLine(@"Envoi email à l'utilisateur '{0} - {1} {2}' : {3}", customer.User1.UserEmail, customer.User1.UserFirstName, customer.User1.UserName, (isSent) ? "OK" : "KO");
                }
                else if (typeReminder == CustomerProspectBL.TypeRelanceRECUEIL)
                {
                    isSent = CustomerProspectBL.SendAlertEmailToUpdateReport(customer, false, true);
                    if (customer.IsAlertRecipientClient)
                    {
                        System.Console.WriteLine(@"Envoi email au client : {0}", (isSent) ? "OK" : "KO");
                    }
                    else
                    {
                        System.Console.WriteLine(@"Envoi email à l'utilisateur '{0} - {1} {2}' : {3}", customer.User1.UserEmail, customer.User1.UserFirstName, customer.User1.UserName, (isSent) ? "OK" : "KO");
                    }
                }

                //Creation log de la relance
                if (isSent)
                {
                    bool sendToCustomer = typeReminder == CustomerProspectBL.TypeRelanceLAB || typeReminder == CustomerProspectBL.TypeRelanceCNI || typeReminder == CustomerProspectBL.TypeRelancePASSEPORT ? false : customer.IsAlertRecipientClient;
                    ReportLABReminderLog reminder = new ReportLABReminderLog()
                    {
                        DateCreated = DateTime.Now,
                        Email = (sendToCustomer) ? customer.User.UserEmail : customer.User1.UserEmail,
                        idCustomer = customer.idCustomer,
                        IsAlertRecipientClient = sendToCustomer,
                        IsAutomatic = true, //service auto
                        DocumentType = typeReminder,
                        //IsEmailSent = isSent
                    };

                    Upsilab.Business.ReportLABReminderLog.ReportLABReminderLogBL.AddReminder(reminder);
                }
            }
            catch (Exception ex)
            {
                Business.Log.Log.AppendException(ex);
            }

        }
        public string RelancerMAJ(Guid id)
        {
            string state = "Ok";

            try
            {
                // Envoi mail 
                CustomerProspect customer = CustomerProspectBL.GetCustomerProspectById(id);
                //Si relance manuelle, c'est toujours le client qui est le destinataire
                bool forceCustomerAsRecipient = true;
                bool isSent = CustomerProspectBL.SendAlertEmailToUpdateReport(customer, forceCustomerAsRecipient, false);

                string docType = Upsilab.Business.Souscription.SouscriptionBL.ReportApplication;
                if (SessionManager.Exists(CONFIG_RELANCE))
                {
                    SessionManager.Get<string>(CONFIG_RELANCE, out docType);

                    switch (docType)
                    {
                        case CustomerProspectBL.RECUEIL: { docType = Upsilab.Business.Souscription.SouscriptionBL.ReportApplication; break; }
                        case CustomerProspectBL.LAB: { docType = Upsilab.Business.Souscription.SouscriptionBL.LabApplication; break; }
                        case CustomerProspectBL.CNI: { docType = Upsilab.Business.Souscription.SouscriptionBL.CNIApplication; break; }
                        case CustomerProspectBL.PASSEPORT: { docType = Upsilab.Business.Souscription.SouscriptionBL.PasseportApplication; break; }
                    }
                }

                //Creation log de la relance
                ReportLABReminderLog reminder = new ReportLABReminderLog()
                 {
                     DateCreated = DateTime.Now,
                     Email = customer.User.UserEmail,
                     idCustomer = id,
                     IsAlertRecipientClient = true, //Relance manuelle, toujours client
                     IsAutomatic = false,
                     DocumentType = docType
                     //IsLAB = false,
                     //IsEmailSent = isSent
                 };

                Upsilab.Business.ReportLABReminderLog.ReportLABReminderLogBL.AddReminder(reminder);

                state = (isSent) ? "Ok" : "Ko";
            }
            catch (Exception ex)
            {
                state = "Ko";
                Business.Log.Log.AppendException(ex);
            }

            return state;
        }