Beispiel #1
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;
            }
        }