AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Разработка
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 18.05.2009, 19:21   #1  
LisP is offline
LisP
Участник
 
9 / 11 (1) +
Регистрация: 17.05.2009
Адрес: Москва
Организация рассылки большому количеству контактов
Добрый день!

Столкнулся с непонятной проблемой, необходимо произвести рассылку по шаблону на 7000 контактов.

Вот этот код, взятый из SDK вполне рабочий и справляется с небольшими рассылками

Код:
 SendBulkMailRequest bulkMailRequest = new SendBulkMailRequest();

            // Create a query expression for the bulk operation to use to retrieve 
            // the contacts in our e-mail list.
            ConditionExpression condition = new ConditionExpression();
            condition.AttributeName = "contactid";
            condition.Operator = ConditionOperator.In;
            condition.Values = contactIds;

            FilterExpression filterExpression = new FilterExpression();
            filterExpression.Conditions = new ConditionExpression[] { condition };

            ColumnSet returnColumns = new ColumnSet();
            returnColumns.Attributes = new string[] { "contactid" };

            QueryExpression queryRequest = new QueryExpression();
            queryRequest.ColumnSet = returnColumns;
            queryRequest.EntityName = EntityName.contact.ToString();
            queryRequest.Criteria = filterExpression;

            // Attach the contact query to the bulk e-mail request.
            bulkMailRequest.Query = queryRequest;

            // Get a system user to use as the sender.
            bulkMailRequest.Sender = GetEmailSenderMoniker(service);

            // Set the RegardingId to the e-mail sender.
            bulkMailRequest.RegardingId = bulkMailRequest.Sender.Id;
            bulkMailRequest.RegardingType = EntityName.systemuser.ToString();

            // Use a built-in e-mail template.
            // NOTE: The e-mail template's 'template type' must match the type of customers
            // in the e-mail list. Our list contains contacts, so our template must be for contacts.
            bulkMailRequest.TemplateId = new Guid("07B94C1D-C85F-492F-B120-F0A743C540E6");

            // Create a tracking ID for the bulk operation to monitor its progress.
            RequestIdOptionalParameter trackingId = new RequestIdOptionalParameter();
            trackingId.Value = Guid.NewGuid();
            
            // Attach the tracking ID to the bulk e-mail request.
            bulkMailRequest.OptionalParameters = new OptionalParameter[] { trackingId };

            // Execute the async bulk e-mail request.
            service.Execute(bulkMailRequest);
            
            // Now that we have executed the bulk operation, we have to retrieve it using our tracking ID.
            ColumnSet asyncColumns = new ColumnSet();
            asyncColumns.Attributes = new string[] { "requestid", "statecode" };

            QueryByAttribute bulkQuery = new QueryByAttribute();
            bulkQuery.ColumnSet = asyncColumns;
            bulkQuery.EntityName = EntityName.asyncoperation.ToString();
            bulkQuery.Attributes = new string[] { "requestid" };
            bulkQuery.Values = new object[1];
            bulkQuery.Values[0] = trackingId.Value;

            // Retrieve the bulk e-mail async operation.
            BusinessEntityCollection aResponse = service.RetrieveMultiple(bulkQuery);

            // Monitor the async operation through polling.
            const int ARBITRARY_MAX_POLLING_TIME = 60;
            int secondsTicker = ARBITRARY_MAX_POLLING_TIME;

            asyncoperation createdBulkMailOperation = null;
            
            while (secondsTicker > 0)
            {
               // Make sure that the async operation was retrieved.
               if (aResponse.BusinessEntities.Length > 0)
               {
                  // Grab the one bulk operation that was created.
                  createdBulkMailOperation = (asyncoperation)aResponse.BusinessEntities[0];

                  // Check the operation's state.
                  if (createdBulkMailOperation.statecode.Value != AsyncOperationState.Completed)
                  {
                     // The operation has not yet completed.  Wait a second for the status to change.
                     System.Threading.Thread.Sleep(1000);
                     secondsTicker--;

                     // Retrieve a fresh version the bulk delete operation.
                     aResponse = service.RetrieveMultiple(bulkQuery);
                  }
                  else
                  {
                     // Stop polling because the operation's state is now completed.
                     secondsTicker = 0;
                  }
               }
               else
               {
                  // Wait a second for the async operation to become active.
                  System.Threading.Thread.Sleep(1000);
                  secondsTicker--;

                  // Retrieve the entity again.
                  aResponse = service.RetrieveMultiple(bulkQuery);
               }
            }
            
            // When the bulk e-mail operation has finished, all sent e-mail messages will have a status of "Pending Send" and 
            // will be picked up by your e-mail router. Or, you can then use BackgroundSendEmail to download
            // all the e-mail messages that were created by using the SendBulkEmail message. See the BackgroundSendEmail sample for an example.

            #region check success
            
            // Validate async operation succeeded.
            if (createdBulkMailOperation.statecode.Value == AsyncOperationState.Completed)
            {
               success = true;
            }
При отправить на 7000 контактов, не появляется никаких ошибок в логах (уровень отладки в конфиге EmailRouterа на 3 менял, ошибок нет), но и почта не уходит и даже соответствующие активности не создаются для контактов. Даже не знаю в чем проблема и как её решать. В хвосте функции объект createdBulkMailOperation.statecode приобретает значение Suspensed.
Пробовал увеличивать значение ARBITRARY_MAX_POLLING_TIME до 6000, не помогло, функция отрабатывает больше времени, но писем и активностей не появляется.
Старый 18.05.2009, 19:31   #2  
Артем Enot Грунин is offline
Артем Enot Грунин
Moderator
Аватар для Артем Enot Грунин
MCBMSS
Злыдни
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,912 / 623 (28) +++++++
Регистрация: 16.08.2007
Адрес: Пермь!
Записей в блоге: 151
Возможно недостаточно ресурсов сервера для такого объема корреспонденции. Насколько я понимаю, асинхронный сервис CRM приостанавливает задания до тех пор, пока не высвободятся ресурсы, чтобы не создавать ситуацию отказа в работе (deny of service). Может быть размер задания настолько велик, что ресурсов ему никогда не накопить... Попробуйте определить пороговое значение количества контактов в списке на которых он отрабатывает. Если оно не плавает, значит проблема в другом.
__________________
http://fixrm.wordpress.com, снятие/наведение порчи. Быстро, дорого, гарантия.

MS Certified Dirty Magic Professional
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Перенос данных из Диспетчера контактов в CRM dbd Dynamics CRM: Администрирование 1 27.10.2009 13:50
Проблема со слиянием контактов Camena Dynamics CRM: Прочие вопросы 1 23.03.2009 23:15
Отображение списка контактов на вкладке организации SLK Dynamics CRM: Разработка 39 19.03.2008 15:16
Служба рассылки по электронной почте Microsoft CRM не выполняется zhenek Dynamics CRM: Функционал 2 14.02.2008 00:37
Как присвоить большому кол-ву контактов одно значение stor Dynamics CRM: Администрирование 3 22.01.2007 19:59
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 10:43.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.