如何公开 SharePoint 工作流实例的状态?

发布于 2024-07-12 10:40:26 字数 228 浏览 3 评论 0原文

我有一个相当简单的顺序审批工作流程,其中包含一个几乎涵盖整个工作流程的 EnableModificationActivity。 我的修改表单是一个 ASPX 页面,使用户能够启用/禁用工作流程中尚未发生的审批步骤。 由于工作流程可以多次修改,我希望表单能够反映工作流程的当前状态,这意味着它应该显示当前启用或禁用的活动。

我为此想出了一个笨拙的解决方案,稍后我将分享它,但我必须相信有一个干净的方法来解决这个问题。

I have a fairly straight-forward sequential approval workflow that has an EnableModificationActivity that is in scope for just about the entirety of the workflow. My modification form is an ASPX page that gives the user the ability to enable/disable approval steps that have not occurred yet in the workflow. Since the workflow is able to be modified multiple times, I would like to the form to reflect the current state of the workflow, meaning it should show which activities are currently enabled or disabled.

I have come up with a clunky solution for this that I will share a little later on, but I have got to believe there is a clean way to go about this.

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

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

发布评论

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

评论(1

暖心男生 2024-07-19 10:40:26

因此,这是我最终采用的方法...

  1. 我创建了一个普通旧 CLR 对象 (POCO) 类,专门用于保存我的特定工作流程的状态信息,该工作流程能够进行 XML 序列化。 以后我将其称为“状态对象”。

  2. 我创建了一个名为“WorkflowStateManager”的可重用类,它能够为给定的 SPWorkflow 加载和保存单个状态对象。 此类可通过工作流程和修改表单访问。

    • 保存状态实施:
      1. XML 将对象序列化为字符串
      2. 在 SPWorkflow 列表项的属性包中设置序列化字符串并调用属性包的 Update() 方法
    • 加载状态实现(本质上与保存状态实现相反)
      1. 从 SPWorkflow 列表项的属性包中获取序列化字符串
      2. XML 将字符串反序列化为状态对象
  3. 激活工作流时,我构造一个新的状态对象,初始化其上的各种属性,并使用WorkflowStateManager。

  4. 随着工作流程的进展,我按照以下方式根据需要加载和更新状态对象:

    • 使用 WorkflowStateManager 加载当前状态对象
    • 根据状态对象的值制定工作流决策
    • 对状态对象进行所需的更改
    • 使用 WorkflowStateManager 保存状态对象
  5. 现在,我的修改表单还能够使用 WorkflowStateManager 加载、操作和保存状态对象,进而向用户公开工作流的当前状态。

我希望这对某人有益。

So here is the approach I ended up taking...

  1. I created a Plain Old CLR Object (POCO) class specific for holding state information my particular workflow that is capable of being XML Serialized. I'll call this the "State Object" going forward.

  2. I created a reusable class called "WorkflowStateManager" that is capable of loading and saving single State Objects for a given SPWorkflow. This class is accessible by both the workflow and the modification form.

    • Save State Implementation:
      1. XML serializes the object to a string
      2. Sets the serialized string on the SPWorkflow list item's property bag and calls the property bag's Update() method
    • Load State Implementation (Essentially the reverse of the Save State implementation)
      1. Gets the serialized string from the SPWorkflow list item's property bag
      2. XML Deserialize the string into the State Object
  3. When the workflow is activated, I construct a new State Object, initialize various properties on it, and save it using the WorkflowStateManager.

  4. As the workflow progresses, I load and update the State Object as needed in the following manner:

    • Use the WorkflowStateManager to load the current State Object
    • Make workflow decisions based on the State Object's values
    • Make desired changes to the State Object
    • Use the WorkflowStateManager to save the State Object
  5. Now, my modification form is also able to load, manipulate, and save the State Object using the WorkflowStateManager, and in turn expose the current state of the workflow to the user.

I hope this might be of benefit to someone.

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