public static IOrganizationService GetCrmServiceByCrmAdmin(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
serviceFactory.GetType().GetProperty("ProxyTypesAssembly").SetValue(serviceFactory, typeof(XrmServiceContext).Assembly, null);
return serviceFactory.CreateOrganizationService(new Guid(_settingFactory.GetCrmAdminId));
}
Hiç yorum yok:
Yorum Gönder