当客户端运行 Vista 或 Windows 7 时,为什么我的 SharePoint 工作流会失败?

发布于 2024-08-17 07:44:48 字数 618 浏览 1 评论 0原文

我有类似的情况这个问题。

我有一个在 Visual Studio 2008 中开发的自定义顺序 SharePoint 工作流程。它与提交到表单库的 InfoPath 表单相关联。它被配置为在创建项目时自动启动。

有时它会起作用。有时它只是无法启动。

就像上面链接的问题一样,我签入了调试器,问题是当工作流触发时,作为库中的列发布的 InfoPath 字段为空。 (我使用 workflowProperties.Item["fieldName"] 访问这些字段。)但是似乎存在竞争条件,因为这些字段实际上显示在库视图中,并且如果我终止失败的工作流程并手动重新启动它,它工作得很好!

经过大量的绞尽脑汁和测试,我确定如果用户在 Windows XP 上运行任何版本的 IE,工作流程都会成功启动,但是如果同一用户从 Vista 或 Windows 7 客户端计算机提交相同的表单数据,则会失败。

有谁知道为什么会发生这种情况?

I have a similar situation to this question.

I have a custom sequential SharePoint workflow, deleoped in Visual Studio 2008. It is associated with an InfoPath form submitted to a form library. It is configured to automatically start when an item is created.

It works sometimes. Sometimes it just fails to start.

Just like the question linked above, I checked in the debugger, and the issue is that the InfoPath fields published as columns in the library are empty when the workflow fires. (I access the fields with workflowProperties.Item["fieldName"].) But there appears to be a race condition, as those fields actually show up in the library view, and if I terminate the failed workflow and restart it manually, it works fine!

After a lot of head-scratching and testing, I've determined that the workflow will start successfully if the user is running any version of IE on Windows XP, but it fails if the same user submits the same form data from a Vista or Windows 7 client machine.

Does anyone have any idea why this is happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

久随 2024-08-24 07:44:48

我使用了另一种解决方案,该解决方案只会等到 InfoPath 属性可用(或最多 60 秒):

public SPWorkflowActivationProperties workflowProperties =
   new SPWorkflowActivationProperties();

private void onOrderFormWorkflowActivated_Invoked(object sender, ExternalDataEventArgs e)
{
   SPListItem workflowItem;
   workflowItem = workflowProperties.List.GetItemById(workflowProperties.ItemId);

   int waited = 0;
   int maxWait = 60000; // Max wait time in ms
   while (workflowItem["fieldName"] == null && (waited < maxWait))
   {
      System.Threading.Thread.Sleep(1);
      waited ++;
      workflowItem = workflowProperties.List.GetItemById(workflowProperties.ItemId);
   }

   // For testing: Write delay time in Workflow History Event
   SPWorkflow.CreateHistoryEvent(
      workflowProperties.Web,
      workflowProperties.WorkflowId, 
      (int)SPWorkflowHistoryEventType.WorkflowComment,
      workflowProperties.OriginatorUser, TimeSpan.Zero, 
      waited.ToString() + " ms", "Waiting time", "");
}

workflowProperties.Item 将永远不会获取上面代码中的 InfoPath 属性。
workflowProperties.List.GetItemById(workflowProperties.ItemId) 将在延迟一段时间后。

I have used another solution which will only wait until InfoPath property is available (or max 60 seconds):

public SPWorkflowActivationProperties workflowProperties =
   new SPWorkflowActivationProperties();

private void onOrderFormWorkflowActivated_Invoked(object sender, ExternalDataEventArgs e)
{
   SPListItem workflowItem;
   workflowItem = workflowProperties.List.GetItemById(workflowProperties.ItemId);

   int waited = 0;
   int maxWait = 60000; // Max wait time in ms
   while (workflowItem["fieldName"] == null && (waited < maxWait))
   {
      System.Threading.Thread.Sleep(1);
      waited ++;
      workflowItem = workflowProperties.List.GetItemById(workflowProperties.ItemId);
   }

   // For testing: Write delay time in Workflow History Event
   SPWorkflow.CreateHistoryEvent(
      workflowProperties.Web,
      workflowProperties.WorkflowId, 
      (int)SPWorkflowHistoryEventType.WorkflowComment,
      workflowProperties.OriginatorUser, TimeSpan.Zero, 
      waited.ToString() + " ms", "Waiting time", "");
}

workflowProperties.Item will never get the InfoPath property in the code above.
workflowProperties.List.GetItemById(workflowProperties.ItemId) will after some delay.

誰認得朕 2024-08-24 07:44:48

出现这种情况是因为 Vista/7 通过 WebDAV 保存 InfoPath 表单,而 XP 使用另一个协议(抱歉,暂时不记得了)。 SharePoint 在文件实际上传之前捕获“ItemAdded”事件(即,项目已创建,但文件上传当前正在进行中)。

您可以做的解决方法是添加一个延迟活动并等待 10 秒作为工作流程中的第一件事(由于 SPPS 中构建工作流程的方式,实际上会长于 10 秒)。这样,当您执行读取该项目时,上传就已经结束。要通知用户正在发生的情况,您可以在延迟之前添加“logToHistoryList”活动。

This occurs due to the fact that Vista/7 saves InfoPath forms through WebDAV, however XP uses another protocol (sorry, can't remember at the time). SharePoint catches the "ItemAdded" event before the file is actually uploaded (that is, the item is already created, but file upload is currently in progress).

What you can do for a workaround is to add a dealay activity and wait for 10 seconds as the first thing in your workflow (will actually be longer than ten seconds due to the way workflows are built in SPPS). This way the upload will already have ended when you perform to read the item. To inform the users about what's happening, you can add a "logToHistoryList" activity before the delay.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文