每次更新1条记录,每次记录更新之间的延迟时间为x分钟

时间:2013-06-25 13:59:31

标签: dynamics-crm-2011 dynamics-crm

我知道我可以在一个过程中使用'等待'来创建延迟;但是,我需要在每个RECORD更新之间延迟,而不是在整个数据集上的每个ACTION之间延迟。

简单地说:如果我有100条记录并且想要更新记录001,请等待5分钟,然后更新记录002,然后等待5分钟...更新记录100.(我有一个标志来识别已经更新的记录)

1 个答案:

答案 0 :(得分:0)

由于您按需启动工作流程,因此无法在您选择的每条记录之间设置延迟。

一种可能的解决方案是编写一个控制台应用程序,该应用程序将检索记录并以延迟启动工作流程。

这样的事情:

EntityCollection results = service.RetrieveMultiple(retrieveQuery);
foreach (Entity result in results.Entities)
{
    ExecuteWorkflowRequest requestExecuteWorkflow = new ExecuteWorkflowRequest();
    ExecuteWorkflowResponse responseExecuteWorkflow = new ExecuteWorkflowResponse();
    requestExecuteWorkflow.WorkflowId = workflow.Id; // Workflow Guid;
    requestExecuteWorkflow.EntityId = result.Id;
    responseExecuteWorkflow = (ExecuteWorkflowResponse)service.Execute(requestExecuteWorkflow);
    Thread.Sleep(5 * 1000 * 60);
}
相关问题