我们目前正在改变后端系统的架构,我们发现我们需要使用OrganizationServiceProxy.EnableProxyTypes方法启用代码类型以在CodeActivities for Workflows中使用。
但是,每当我包含此方法调用时,它都会使Workflow在最终失败之前运行得非常慢。
以下是我们用来调用方法的代码:
var service = serviceFactory.CreateOrganizationService(context.UserId);
if (service is OrganizationService)
{
tracingService.Trace("Enabling proxy types");
((OrganizationServiceProxy)((OrganizationService)service).InnerService).EnableProxyTypes(assembly);
tracingService.Trace("Proxy types enabled");
}
有什么想法吗?
由于
答案 0 :(得分:0)
我从来没有必要将程序集作为参数传递给EnableProxyTypes。你没有通过组装就尝试了吗?
此外,还有另一种通过添加到Behaviors集合来启用代理类型的方法。这是一个例子:
public static IOrganizationService GetOrganizationService(Guid userId)
{
ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
Uri homeRealmUri = null;
using (OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(new Uri(GetOrganizationUri()),
homeRealmUri, credentials, null))
{
_serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
_serviceProxy.CallerId = userId;
IOrganizationService _service = (IOrganizationService)_serviceProxy;
return _service;
}
}