2017-01-22 3 views
2

Мы разрабатываем систему, которая подключается к Microsoft Dynamics CRM с помощью XRM SDK, это на стороне сервера построена на .NET MVC, Front End Side построен на AngularjsМедленность в динамике CRM с использованием XRM SDK?

Мы столкнулись с проблемой задержки в ответах API, напр. Для входа в API API требуется как минимум 1,8 секунды для получения успеха или ложного ответа, и этот API является самым быстрым.

Другие API еще медленнее, мы попытались поймать источник этой медлительности, чтобы исправить это, но не повезло. это XRM SDK, API или CRM.

Если вы можете помочь.

var cols = new ColumnSet("exdyn_employeecontractid", "exdyn_contractstatus"); 
      var secondEntityCols = new ColumnSet("exdyn_companyagreementid", "exdyn_agreementstatus"); 

      var filter = new FilterExpression 
      { 
       Conditions = 
       { 
        new ConditionExpression 
        { 
         AttributeName = "exdyn_employeeid", 
         Operator = ConditionOperator.Equal, 
         Values = {model.EmployeeId} 
        }, 
        new ConditionExpression 
        { 
         AttributeName = "exdyn_contractstatus", 
         Operator = ConditionOperator.Equal, 
         Values = { 3 } // approved {2} signed 
        }, 

       }, 

       FilterOperator = LogicalOperator.And 
      }; 
      var secondFilter = new FilterExpression 
      { 
       Conditions = 
       { 
        new ConditionExpression 
        { 
         AttributeName = "exdyn_agreementstatus", 
         Operator = ConditionOperator.Equal, 
         Values = { 2 } // active {2} 
        } 
       } 
      }; 

      var entity = _organizationService.GetEntityCollectionWithJoin 
       ("exdyn_employeecontract", "exdyn_companyagreement", 
       "exdyn_companyagreementid", "exdyn_companyagreementid", JoinOperator.Inner, 
       cols, secondEntityCols, filter, secondFilter).Entities.FirstOrDefault(); 

==============

код Используется для подключения:

public class WebModule : Module 
    { 
     protected override void Load(ContainerBuilder builder) 
     { 
      // Register your Web API controllers. 
      builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); 
      // Register your MVC controllers. 
      builder.RegisterControllers(Assembly.GetExecutingAssembly()); 
      // OPTIONAL: Register web abstractions like HttpContextBase. 
      builder.RegisterModule<AutofacWebTypesModule>(); 
      builder.RegisterFilterProvider(); 
      builder.Register(c => new WebConfigurationSettings()).As<IWebSettings>().SingleInstance(); 
      builder.Register(GetOrganizationServiceManagement).SingleInstance(); 
      builder.Register(GetOrganizationProxy).InstancePerRequest(); 
      builder.Register(c => new ExceptionHandler()).SingleInstance(); 

      builder.Register(c => new EmployeeService(c.Resolve<IOrganizationService>())) 
       .As<IEmployeeService>() 
       .EnableInterfaceInterceptors() 
       .InterceptedBy(typeof(ExceptionHandler)) 
       .InstancePerRequest(); 
      builder.Register(c => new AttendanceService(c.Resolve<IOrganizationService>())) 
       .As<IAttendanceService>().EnableInterfaceInterceptors() 
       .InterceptedBy(typeof(ExceptionHandler)) 
       .InstancePerRequest(); 

      builder.Register(c => new ContractService(c.Resolve<IOrganizationService>())) 
       .As<IContractService>().EnableInterfaceInterceptors() 
       .InterceptedBy(typeof(ExceptionHandler)) 
       .InstancePerRequest(); 

      builder.Register(c => new InquiryService(c.Resolve<IOrganizationService>(), c.Resolve<ILookupService>())) 
       .As<IInquiryService>().EnableInterfaceInterceptors() 
       .InterceptedBy(typeof(ExceptionHandler)) 
       .InstancePerRequest(); 

      builder.Register(c => new LookupService(c.Resolve<IOrganizationService>())) 
       .As<ILookupService>().EnableInterfaceInterceptors() 
       .InterceptedBy(typeof(ExceptionHandler)) 
       .InstancePerRequest(); 

      builder.Register(c => new LeaveRequestService(c.Resolve<IOrganizationService>(), 
       c.Resolve<IContractService>(), c.Resolve<ILookupService>())) 
       .As<ILeaveRequestService>().EnableInterfaceInterceptors() 
       .InterceptedBy(typeof(ExceptionHandler)) 
       .InstancePerRequest(); 


      builder.Register(c => new PurchaseRequestService(c.Resolve<IOrganizationService>(), c.Resolve<ILookupService>())) 
       .As<IPurchaseRequestService>().EnableInterfaceInterceptors() 
       .InterceptedBy(typeof(ExceptionHandler)) 
       .InstancePerRequest(); 

      builder.Register(c => new NotificationService(c.Resolve<IOrganizationService>())) 
       .As<INotificationService>().EnableInterfaceInterceptors() 
       .InterceptedBy(typeof(ExceptionHandler)) 
       .InstancePerRequest(); 
      builder.Register(c => new CacheClient()) 
       .As<ICacheClient>() 
       .SingleInstance(); 
     } 

     private static IServiceManagement<IOrganizationService> GetOrganizationServiceManagement(IComponentContext ctx) 
     { 
      var settings = ctx.Resolve<IWebSettings>(); 

      return ServiceConfigurationFactory.CreateManagement<IOrganizationService>(
         new Uri(settings.OrganizationUrl)); 
     } 

     private static IOrganizationService GetOrganizationProxy(IComponentContext ctx) 
     { 
      var svcMgmt = ctx.Resolve<IServiceManagement<IOrganizationService>>(); 
      var settings = ctx.Resolve<IWebSettings>(); 
      var credentials = new AuthenticationCredentials(); 
      credentials.ClientCredentials.UserName.UserName = settings.SystemUserName; 
      credentials.ClientCredentials.UserName.Password = settings.SystemUserPassword; 
      var authCredentials = svcMgmt.Authenticate(credentials); 
      //return new OrganizationServiceProxy(svcMgmt, authCredentials.SecurityTokenResponse); 
      return new OrganizationServiceProxy(svcMgmt, authCredentials.ClientCredentials); 
     } 

    } 
+0

Это On-Premise или Online? Вы используете конечную точку мыла или остальную конечную точку? – Sxntk

+0

Вы должны отправить какой-то код. Как используется SDK? Как создается соединение? Формат строки подключения? – dynamicallyCRM

+0

Звучит о праве на меня.По моему опыту Dynamics CRM Online отстой: не масштабируется, если он опускается вниз - ничего не поделаешь, нет доступа к подчеркиванию SQL Server, низкой производительности и т. Д. –

ответ

1

Это, скорее всего, CRM/API-интерфейсы. Вы должны быть в состоянии проверить это с чем-то вроде Fiddler, чтобы посмотреть на сделанные запросы и определить, где происходит медлительность. Например, следующий будет запрашивая CRM онлайн песочницу, используя старую версию SDK:

var connection = CrmConnection.Parse(@"Url=https://ORG.crm.dynamics.com;Username=USERNAME;Password=PASSWORD"); 
_orgService = new OrganizationService(connection); 

_orgService.RetrieveMultiple(new FetchExpression(@"<fetch><entity name='account'><attribute name='accountid'/></entity></fetch>")); 

Проверка скрипача вы увидите следующее:

enter image description here

  1. Есть ~ 4 индивидуальный HTTP-запросы от клиента, чтобы выполнить проверку подлинности за 1,5 секунды (в данном случае это исключительно пользователь O365, ADFS не используется)
  2. Последний HTTP-запрос - это фактический запрос, возвращающий 5k Идентификаторы учетной записи. Требуется ~ 5 секунд, чтобы вернуться.

Если вы используете свой код и сравниваете его с фактическими HTTP-запросами, вы можете увидеть, где тратится время, но я бы сказал, что это будут запросы, а не SDK.

Есть несколько вещей, которые вы можете сделать, чтобы попытаться оптимизировать запросы:

  1. возвращают только данные, необходимые
  2. Предельное количество присоединяется
  3. Убедитесь, что плагины не работают на RetrieveMultiple объекта, который вы запрашиваете.
  4. Подтвердите подлинность и повторное использование «соединения». (В зависимости от того, какую версию SDK вы используете, и какие части этого SDK это можно сделать разными способами. CrmServiceClient кэши по умолчанию в настоящее время, у других строк подключения были такие параметры, как Service Configuration Instance Mode).
Смежные вопросы