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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 22.05.2015, 15:52   #1  
-O_o- is offline
-O_o-
Еда - топливо, Одежда - н
Аватар для -O_o-
Лучший по профессии 2015
Лучший по профессии 2014
 
727 / 80 (4) ++++
Регистрация: 11.05.2012
Адрес: Киев
есть такое понятие как преобразование процесса в риалтайм. Кнопочка сверху.
По сути это синхронный плагин )
__________________
Все что вам нужно - это мозК
Еда - топливо... Одежда - необходимость...
Старый 22.05.2015, 16:26   #2  
GetLucky is offline
GetLucky
Участник
Лучший по профессии 2014
 
99 / 13 (1) ++
Регистрация: 03.09.2013
Цитата:
Сообщение от -O_o- Посмотреть сообщение
есть такое понятие как преобразование процесса в риалтайм. Кнопочка сверху.
По сути это синхронный плагин )
Я в курсе, я не вижу условие запуска
Цитата:
Условие запуска - Перед - Изменение статуса записи
Старый 22.05.2015, 16:53   #3  
-O_o- is offline
-O_o-
Еда - топливо, Одежда - н
Аватар для -O_o-
Лучший по профессии 2015
Лучший по профессии 2014
 
727 / 80 (4) ++++
Регистрация: 11.05.2012
Адрес: Киев
Цитата:
Сообщение от GetLucky Посмотреть сообщение
Я в курсе, я не вижу условие запуска
вот
Изображения
 
__________________
Все что вам нужно - это мозК
Еда - топливо... Одежда - необходимость...
Старый 22.05.2015, 21:50   #4  
GetLucky is offline
GetLucky
Участник
Лучший по профессии 2014
 
99 / 13 (1) ++
Регистрация: 03.09.2013
Цитата:
Сообщение от -O_o- Посмотреть сообщение
вот
На самом деле надо перевести БП в синхронный режим.
Старый 22.05.2015, 22:21   #5  
GetLucky is offline
GetLucky
Участник
Лучший по профессии 2014
 
99 / 13 (1) ++
Регистрация: 03.09.2013
Нашел более правильное решение, т.к. Case переводиться в состояния закрыто с использованием сущности IncidentResolution, то вполне логично повесить на создание этой сущности плагин, который на Post-operation будет апдейтить Кейс.

X++:
public class CaseResolution : IPlugin
    {
        public void Execute(IServiceProvider serviceProvider)
        {
            #region must to have
 
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
 
            IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
 
            // Create service with context of current user
            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
 
            //create tracing service
            ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
 
            #endregion
 
            #region Variable
 
            Entity targetCase = new Entity("incident");
            string strResolution = string.Empty;
            int intTotalTime = -1;
            int intTotalBillableTime = -1;
            string strRemarks = string.Empty;
 
            #endregion
 
            if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
            {
 
                //create entity context
                Entity entity = (Entity)context.InputParameters["Target"];
 
                if (entity.LogicalName != "incidentresolution")
                    return;
 
                try
                {
                    if (entity.Contains("incidentid"))
                    {
                        //get the related Case
                        targetCase.Id = ((EntityReference)entity["incidentid"]).Id;
                         
                        //capture the Case Resolution Fields                      
                        strResolution = entity.Contains("subject") ? entity["subject"].ToString() : string.Empty;
                        intTotalBillableTime = entity.Contains("timespent") ? (Int32)entity["timespent"] : 0;   
                        strRemarks = entity.Contains("description") ? 
                            (entity["description"] != null ? entity["description"].ToString() : string.Empty) : 
                            string.Empty;
 
                        //get the total time from Activities
                        intTotalTime = GetTotalTime(service, targetCase.Id);
                         
                        //update Case with the fields
                        targetCase["new_resolution"] = strResolution;
                        targetCase["new_totalbillabletime"] = intTotalBillableTime;
                        targetCase["new_totaltime"] = intTotalTime;
                        targetCase["new_remark"] = strRemarks;
                        service.Update(targetCase);
                    }
                }
                catch (Exception ex)
                {
                    throw new InvalidPluginExecutionException(ex.Message);
                }
 
            }
        }
 
        private int GetTotalTime(IOrganizationService service, Guid guidRelatedCaseId)
        {
            //count the Activity Actual Duration Minutes for this Case
            //need to sum time spent of each activity (cannot directly using the actualtdurationminutes) 
 
            int intSumTotalTime = 0;
 
            //Retrieve all related Activities by Case
            QueryExpression query = new QueryExpression("activitypointer");
            query.ColumnSet.AddColumns("actualdurationminutes");
 
            query.Criteria = new FilterExpression();
            query.Criteria.AddCondition("regardingobjectid", ConditionOperator.Equal, guidRelatedCaseId);
 
            // Execute the Query 
            EntityCollection results = service.RetrieveMultiple(query);
 
            foreach (Entity entity in results.Entities)
            {
                int intActivityTime = 0;
                intActivityTime = entity.Contains("actualdurationminutes") ? (Int32)entity["actualdurationminutes"] : 0;
                intSumTotalTime = intSumTotalTime + intActivityTime;
            }
 
            return intSumTotalTime;
        }
    }

Последний раз редактировалось GetLucky; 22.05.2015 в 22:55.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 15 Blog bot Dynamics CRM: Blogs 1 10.02.2016 10:26
Leon's CRM Musings: Book Review: Microsoft Dynamics CRM 2013 Unleashed Blog bot Dynamics CRM: Blogs 0 31.10.2014 10:11
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 17 Blog bot Dynamics CRM: Blogs 0 10.05.2014 06:30
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2013 Update Rollup 2 Blog bot Dynamics CRM: Blogs 0 15.04.2014 01:15
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 16 Blog bot Dynamics CRM: Blogs 0 23.01.2014 03:15
Опции темы Поиск в этой теме
Поиск в этой теме:

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

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 22:58.