Exemplo n.º 1
0
        public ActionResult Index(long eventId, long customerId)
        {
            var appointmentConfirmationViewModel =
                _emailNotificationModelsFactory.GetAppointmentConfirmationModel(eventId, customerId);

            return(View(appointmentConfirmationViewModel));
        }
Exemplo n.º 2
0
        public void PollforSendingScondScreeningReminders()
        {
            try
            {
                var value = _configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.ScreeningReminderNotification);

                if (value.ToLower() != bool.TrueString.ToLower())
                {
                    return;
                }

                var eventCustomers = _eventCustomerRepository.GetEventCustomersForSecondScreeingReminderNotification(_hoursBeforeAppointment, _interval);
                if (eventCustomers != null && eventCustomers.Any())
                {
                    foreach (var eventCustomer in eventCustomers)
                    {
                        try
                        {
                            var account = _corporateAccountRepository.GetbyEventId(eventCustomer.EventId);
                            if (account != null && !(account.SendAppointmentMail && account.AppointmentReminderMailTemplateId > 0))
                            {
                                continue;
                            }

                            _logger.Info(string.Format("Sending second screening reminder for Customer [Id:{0}] and Event[Id:{1}]  ", eventCustomer.CustomerId, eventCustomer.EventId));

                            var customer = _customerRepository.GetCustomer(eventCustomer.CustomerId);

                            var appointmentConfirmationViewModel = _emailNotificationModelsFactory.GetAppointmentConfirmationModel(eventCustomer.EventId, eventCustomer.CustomerId);

                            string emailTemplateAlias = EmailTemplateAlias.ScreeningReminderMail;

                            if (account != null && account.AppointmentReminderMailTemplateId > 0)
                            {
                                var emailTemplate = _emailTemplateRepository.GetById(account.AppointmentReminderMailTemplateId);
                                emailTemplateAlias = emailTemplate.Alias;
                            }

                            _notifier.NotifySubscribersViaEmail(NotificationTypeAlias.TwoHoursBeforeAppointment, emailTemplateAlias, appointmentConfirmationViewModel, customer.Id, eventCustomer.CustomerId, "Second Automated Reminder Notification");
                        }
                        catch (Exception ex)
                        {
                            _logger.Error(string.Format("Message:{0} \nStackTrace: {1}", ex.Message, ex.StackTrace));
                        }
                    }
                }
                else
                {
                    _logger.Info("No Customers Found for Second screening reminder!");
                }
            }
            catch (Exception exception)
            {
                _logger.Error("Exception occurred while Poll for Sending Second Screening Reminders");
                _logger.Error("Exception:  " + exception.Message);
                _logger.Error("Exception:  " + exception.StackTrace);
            }
        }
Exemplo n.º 3
0
        public void AppointmentConfirmationTester()
        {
            //var validUserId = 1;

            //where areyou invoking it?
            var appointmentConfirmationViewModel = _emailNotificationModelsFactory.GetAppointmentConfirmationModel(2, 7);

            _notifier.NotifySubscribersViaEmail(NotificationTypeAlias.AppointmentConfirmationWithEventDetails, "AppointmentConfirmationWithEventDetails", appointmentConfirmationViewModel, 1, 1, "integration test", useAlternateEmail: true);
        }
Exemplo n.º 4
0
        public void PollforSendingScreeningReminders()
        {
            var value = _configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.ScreeningReminderNotification);

            if (value.ToLower() != bool.TrueString.ToLower())
            {
                return;
            }

            const int pageSize   = 50;
            int       pageNumber = 1;

            _logger.Info("\n");
            _logger.Info(string.Format("Screening Reminder Queuing. Date: {0:MM/dd/yyyy} ", DateTime.Now));
            _logger.Info("\n");

            var filter = new EventBasicInfoViewModelFilter
            {
                DateFrom = DateTime.Now.Date.AddDays(_daysIntervalBeforeEvent),
                DateTo   = DateTime.Now.Date.AddDays(_daysIntervalBeforeEvent)
            };

            while (true)
            {
                int totalRecords;

                var events = _eventRepository.GetEventsbyFilters(filter, pageNumber, pageSize, out totalRecords);

                events = events.Where(e => e.Status == EventStatus.Active || (e.Status == EventStatus.Suspended && e.IsLocked));

                if (events == null || !events.Any())
                {
                    _logger.Info("No Events Found!");
                    break;
                }

                foreach (var theEvent in events)
                {
                    CorporateAccount account = null;
                    if (theEvent.EventType == EventType.Corporate)
                    {
                        var sendNotification = false;

                        if (theEvent.AccountId.HasValue && theEvent.AccountId.Value > 0)
                        {
                            account          = ((IUniqueItemRepository <CorporateAccount>)_corporateAccountRepository).GetById(theEvent.AccountId.Value);
                            sendNotification = account.SendAppointmentMail && account.AppointmentReminderMailTemplateId > 0;
                        }
                        if (!sendNotification)
                        {
                            continue;
                        }
                    }

                    _logger.Info(string.Format("Queuing Event [Id:{0}] [Name:{1}]  [Date:{2:MM/dd/yyyy}] ", theEvent.Id, theEvent.Name, theEvent.EventDate));
                    _logger.Info("\n");

                    var eventCustomers = _eventCustomerRepository.GetbyEventId(theEvent.Id);

                    var customerIds = eventCustomers.Where(ec => ec.AppointmentId.HasValue && !ec.NoShow && !ec.LeftWithoutScreeningReasonId.HasValue).Select(ec => ec.CustomerId).Distinct().ToArray();
                    if (!customerIds.Any())
                    {
                        _logger.Info("No Customers Found!");
                        continue;
                    }

                    var customers = _customerRepository.GetCustomers(customerIds);

                    foreach (var customer in customers)
                    {
                        _logger.Info(string.Format("Queuing Customer [Id:{0}] [Name:{1}]  ", customer.CustomerId, customer.NameAsString));
                        try
                        {
                            var appointmentConfirmationViewModel = _emailNotificationModelsFactory.GetAppointmentConfirmationModel(theEvent.Id, customer.CustomerId);

                            string emailTemplateAlias = EmailTemplateAlias.ScreeningReminderMail;

                            if (account != null && account.AppointmentReminderMailTemplateId > 0)
                            {
                                var emailTemplate = _emailTemplateRepository.GetById(account.AppointmentReminderMailTemplateId);
                                emailTemplateAlias = emailTemplate.Alias;
                            }

                            _notifier.NotifySubscribersViaEmail(NotificationTypeAlias.ScreeningReminderMail, emailTemplateAlias, appointmentConfirmationViewModel, customer.Id, customer.CustomerId, "Automated Reminder Notification", useAlternateEmail: true);
                        }
                        catch (Exception ex)
                        {
                            _logger.Error(string.Format("Message:{0} \nStackTrace: {1}", ex.Message, ex.StackTrace));
                        }
                    }
                }

                if ((pageNumber * pageSize) >= totalRecords)
                {
                    break;
                }

                pageNumber++;
            }
        }
Exemplo n.º 5
0
        public void SendAppointmentConfirmationMail(Customer customer, Event eventData, long createdByOrgRoleUserId, string source, CorporateAccount account)
        {
            var sendNotification = false;

            if (eventData.EventType == EventType.Retail)
            {
                sendNotification = true;
            }
            else if (eventData.AccountId.HasValue && eventData.AccountId.Value > 0 && account != null)
            {
                // account = ((IUniqueItemRepository<CorporateAccount>)_corporateAccountRepository).GetById(eventData.AccountId.Value);
                sendNotification = account.SendAppointmentMail && account.AppointmentConfirmationMailTemplateId > 0;
            }

            if (sendNotification)
            {
                var appointmentConfirmationViewModel = _emailNotificationModelsFactory.GetAppointmentConfirmationModel(eventData.Id, customer.CustomerId);

                string emailTemplateAlias = EmailTemplateAlias.AppointmentConfirmationWithEventDetails;
                if (account != null && account.AppointmentConfirmationMailTemplateId > 0)
                {
                    var emailTemplate = _emailTemplateRepository.GetById(account.AppointmentConfirmationMailTemplateId);
                    emailTemplateAlias = emailTemplate.Alias;
                }

                _notifier.NotifySubscribersViaEmail(NotificationTypeAlias.AppointmentConfirmationWithEventDetails, emailTemplateAlias, appointmentConfirmationViewModel, customer.Id, createdByOrgRoleUserId, source, useAlternateEmail: true);
            }

            var eventCustomer = _eventCustomerRepository.Get(eventData.Id, customer.CustomerId);

            if (customer.IsSubscribed == null || customer.IsSubscribed.Value == false)
            {
                _logger.Info("Customer has not subscribed for SMS " + customer.CustomerId);
                return;
            }

            if (account != null && !account.EnableSms)
            {
                _logger.Info("SMS feature has been disabled by corporate account: " + account.Tag + " EventId: " + eventData.Id);
                return;
            }

            var messageAlreadySentList = _eventCustomerNotificationRepository.GetAllByEventCustomerId(eventCustomer.Id, NotificationTypeAlias.AppointmentConfirmation);

            var messageCount = (messageAlreadySentList != null && messageAlreadySentList.Any()) ? messageAlreadySentList.Count() : 0;

            if (account != null && messageCount >= account.MaximumSms)
            {
                _logger.Info(string.Format("Maximum Number of reminder message sms has been sent for this event. eventId {0} Customer Id: {1}", eventCustomer.EventId, eventCustomer.Id));
                return;
            }

            var smsTemplateAlias = EmailTemplateAlias.AppointmentConfirmation;

            if (account != null && account.ConfirmationSmsTemplateId.HasValue && account.ConfirmationSmsTemplateId.Value > 0)
            {
                var smsTemplate = _emailTemplateRepository.GetById(account.ConfirmationSmsTemplateId.Value);
                smsTemplateAlias = smsTemplate.Alias;
            }

            if (eventCustomer.EnableTexting)
            {
                var smsAppointmentConfirmation = _smsNotificationModelsFactory.GetScreeningReminderSmsNotificationModel(customer, eventData);
                var notification = _notifier.NotifyViaSms(NotificationTypeAlias.AppointmentConfirmation, smsTemplateAlias, smsAppointmentConfirmation, customer.Id, createdByOrgRoleUserId, source);

                if (notification != null)
                {
                    var eventCustomerNotification = new EventCustomerNotification {
                        EventCustomerId = eventCustomer.Id, NotificationId = notification.Id, NotificationTypeId = notification.NotificationType.Id
                    };
                    _eventCustomerNotificationRepository.Save(eventCustomerNotification);
                }
            }
        }