C# 多个执行调用

C# 多个执行调用,c#,.net,dynamics-crm,dynamics-crm-4,crm,C#,.net,Dynamics Crm,Dynamics Crm 4,Crm,我正在尝试更新电话实体上的字段,然后将其关闭。据我所知,目前做这件事需要两个电话。但这是痛苦的缓慢,因为它需要30分钟来处理60个电话,我有大约20万要做。有没有一种方法可以将两者合并到一个通话中 这是我目前的密码- foreach (phonecall phonepointer in _businessEntityCollection.BusinessEntities.Cast<phonecall>() .Where(phonepointer => phonepoi

我正在尝试更新电话实体上的字段,然后将其关闭。据我所知,目前做这件事需要两个电话。但这是痛苦的缓慢,因为它需要30分钟来处理60个电话,我有大约20万要做。有没有一种方法可以将两者合并到一个通话中

这是我目前的密码-

foreach (phonecall phonepointer in _businessEntityCollection.BusinessEntities.Cast<phonecall>()
     .Where(phonepointer => phonepointer.statecode.Value == PhoneCallState.Open))
{
  //Update fiserv_contactstatus value
  phonepointer.fiserv_contactstatus = Picklist;
  crmService.Update(phonepointer);

  //Cancel activity
  setStatePhoneCallRequest.PhoneCallState = PhoneCallState.Canceled;
  setStatePhoneCallRequest.PhoneCallStatus = 200011;
  setStatePhoneCallRequest.EntityId = phonepointer.activityid.Value;

  crmService.Execute(setStatePhoneCallRequest);
}
foreach(businessEntityCollection.BusinessEntities.Cast()中的phonecall phonepointer)
.Where(phonepointer=>phonepointer.statecode.Value==PhoneCallState.Open))
{
//更新fiserv\u触点状态值
phonepointer.fiserv\u contactstatus=选取列表;
crmService.Update(phonepointer);
//取消活动
setStatePhoneCallRequest.PhoneCallState=PhoneCallState.Cancelled;
setStatePhoneCallRequest.PhoneCallStatus=200011;
setStatePhoneCallRequest.EntityId=phonepointer.activityid.Value;
crmService.Execute(setStatePhoneCallRequest);
}

不幸的是,你无能为力

您可以尝试使用新的SDK和XRM上下文(强类型类)批量更新电话呼叫实体(这应该更快),但仍然需要使用老式的
CrmService
逐个实际更改每个实体的状态

编辑: 您也可以直接更改数据库中实体的状态,但这应该是您最后的选择,因为手动更改CRM DB是不受支持的,而且是危险的


说真的,万不得已!不,我不是开玩笑

出于某种原因,它将代码格式化得很有趣,但是有一个更新调用,然后是一个执行调用。这个实体周围还有其他插件吗?30分钟太多了。我尝试更改更新方法以使用和更新TargetUpdatePhoneCall的请求,这加快了一些速度,但我平均每次关闭约15秒,加上我在系统中要关闭的200000,意味着连续运行34天。如果我不能加快速度,我会尝试直接进行SQL更新。那只需要几秒钟,而不是一个月。好吧,我已经做了很多,并设置了计时器,看看每个部分需要多长时间。这一次,每个零件在一段时间内的平均值约为7.5秒,因此总共约为15秒。这对我来说仍然很高。