Example #1
0
        private void SendEmailToContact(Job job, Contact contact, MessageItem messageItem)
        {
            if (contact == null || !contact.Id.HasValue)
            {
                return;
            }

            var dispatchArgs = new DispatchNewsletterArgs(messageItem, new SendingProcessData(messageItem.MessageId.ToID()));

            _dispatchManager.AddRecipientToDispatchQueue(dispatchArgs, contact.Identifiers.FirstOrDefault(x => x.Source.Equals("ExperienceGenerator")));

            GenerateEventService.GenerateSent(messageItem.ManagerRoot.Settings.BaseURL, contact.Id.Value, messageItem, messageItem.StartTime);
            job.CompletedEmails++;
        }
        private void SendEmailToContact(Job job, ContactData contact, MessageItem messageItem)
        {
            var customValues = new ExmCustomValues
            {
                DispatchType    = DispatchType.Normal,
                Email           = contact.PreferredEmail,
                MessageLanguage = messageItem.TargetLanguage.ToString(),
                ManagerRootId   = messageItem.ManagerRoot.InnerItem.ID.ToGuid(),
                MessageId       = messageItem.InnerItem.ID.ToGuid()
            };

            EcmFactory.GetDefaultFactory().Bl.DispatchManager.EnrollOrUpdateContact(contact.ContactId, new DispatchQueueItem(), messageItem.PlanId.ToGuid(), Constants.SendCompletedStateName, customValues);

            GenerateEventService.GenerateSent(messageItem.ManagerRoot.Settings.BaseURL, contact.ContactId, messageItem, messageItem.StartTime);
            job.CompletedEmails++;
        }
Example #3
0
        private void GenerateEvents(Job job, MessageItem email, Funnel funnelDefinition, IReadOnlyCollection <Contact> contactsForThisEmail)
        {
            if (funnelDefinition == null)
            {
                return;
            }

            try
            {
                var contactIndex = 1;
                foreach (var contactData in contactsForThisEmail)
                {
                    if (job.JobStatus == JobStatus.Cancelling)
                    {
                        return;
                    }

                    job.Status = $"Generating events for contact {contactIndex++} of {contactsForThisEmail.Count}";

                    var events = _randomContactMessageEventsFactory.CreateRandomContactMessageEvents(contactData, funnelDefinition, email);

                    GenerateEventService.GenerateContactMessageEvents(job, events);

                    if (events.Events.Any(e => e.EventType == EventType.UnsubscribeFromAll))
                    {
                        _unsubscribeFromAllContacts.Add(events.ContactId);
                    }

                    job.CompletedEvents++;
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to generate events", ex);
                throw;
            }
        }