Пример #1
0
        public void GenerateList(ListSettings settings)
        {
            settings.Job.JobStatus = JobStatus.Running;
            settings.Job.Started   = DateTime.Now;
            settings.Job.JobName   = $"Generating new list '{settings.Name}' with '{settings.Recipients}' recipients";

            try
            {
                settings.Job.Status = $"Creating {settings.Recipients} Contacts";
                var contactRepository = new ContactRepository();
                var contacts          = contactRepository.CreateContacts(settings.Job, settings.Recipients);

                var contactListRepository = new ContactListRepository();
                contactListRepository.CreateList(settings.Job, settings.Name, contacts);

                IndexService.RebuildListIndexes(settings.Job);

                settings.Job.JobStatus = JobStatus.Complete;
                settings.Job.Status    = "DONE!";
                Log.Info($"EXMGenerator completed: {settings.Job.CompletedContacts}", this);
            }
            catch
            {
                settings.Job.Status    = "Failed!";
                settings.Job.JobStatus = JobStatus.Failed;
            }
            finally
            {
                settings.Job.Ended = DateTime.Now;
            }
        }
Пример #2
0
        public void GenerateList(ListSettings settings)
        {
            settings.Job.JobStatus = JobStatus.Running;
            settings.Job.Started   = DateTime.Now;
            settings.Job.JobName   = $"Generating new list '{settings.Name}' with '{settings.Recipients}' recipients";

            try
            {
                settings.Job.Status = $"Creating {settings.Recipients} Contacts";
                var contactRepository = new ContactRepository();
                var contacts          = contactRepository.CreateContacts(settings.Job, settings.Recipients);

                var contactListRepository = new ContactListRepository();

                using (new SecurityDisabler())
                {
                    contactListRepository.CreateList(settings.Job, settings.Name, contacts);
                }

                settings.Job.JobStatus = JobStatus.Complete;
                settings.Job.Status    = "DONE!";
                Log.Info($"EXMGenerator completed: {settings.Job.CompletedContacts}", this);
            }
            catch (Exception ex)
            {
                settings.Job.Status    = "Failed!";
                settings.Job.JobStatus = JobStatus.Failed;
                Log.Error(string.Format("EXMGenerator failed: {0}", ex.Message), ex, this);
            }
            finally
            {
                settings.Job.Ended = DateTime.Now;
            }
        }