查询所有 Sharepoint 工作流程的内部状态

发布于 2024-09-11 04:57:24 字数 227 浏览 3 评论 0原文

我正在尝试获取所有共享点工作流程的内部状态。

是否有办法以编程方式查询所有工作流程并获取其状态?通过 CAML 查询还是对象模型?

我意识到我可以迭代 sharepoint 中的所有项目,并查看是否附加了工作流程,然后获取状态。然而,这有点过分了,因为有 100,000 个项目,而且只有一小部分有工作流程。我想运行定期报告来获取所有工作流程的状态,而不会让服务器崩溃。

谢谢!
戴夫

I'm trying to get the internal status of all sharepoint workflows.

Is there anyway to programmatically query for all workflows, and get their status? Either through a CAML query or the the object model?

I realize that I can iterate over all items in sharepoint, and see if there is a workflow attached, and then get the status. However, that is overkill, as there are 100,000s of items, and only a small subset have workflows. I want to run a periodic report to fetch the status of all workflows, without bringing the server to it's knees.

Thanks!
Dave

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

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

发布评论

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

评论(2

谁把谁当真 2024-09-18 04:57:24

视图的核心是 CAML 查询。如果您不想遍历所有项目,@pst 的评论是一个不错的选择;只需从显示工作流状态列的任何视图的视图定义中滑动 CAML。尽管我通常在服务器上使用 PowerShell 来提取视图定义,但 Lists.asmx Web 服务在这里可能会派上用场。

如果您确实迭代对象模型中的项目,请使用以下代码片段:

using (var site = new SPSite(url))
using (var web = site.OpenWeb())
{
    var manager = site.WorkflowManager;
    var list = web.Lists[listname];
    if (list == null || list.Hidden)
    {
        return "Cannot work under these conditions.";
    }

    foreach (SPListItem item in list.Items)
    {
        foreach (SPWorkflow workflow in item.Workflows)
        {
            if ((workflow.InternalState & SPWorkflowState.Faulting) == SPWorkflowState.Faulting)
            {
                Console.WriteLine(SPWorkflowState.Faulting.ToString());
            }

            // ...
        }
    }
}

A view is, at its heart, a CAML query. The comment from @pst is a good choice if you don't want to iterate through all the items; just swipe the CAML from the view definition of any view that shows the workflow status column. The Lists.asmx Web service could come in handy here, though I usually use PowerShell on the server to extract view definitions.

If you do iterate through the items in the object model, here's a snippet to get rolling:

using (var site = new SPSite(url))
using (var web = site.OpenWeb())
{
    var manager = site.WorkflowManager;
    var list = web.Lists[listname];
    if (list == null || list.Hidden)
    {
        return "Cannot work under these conditions.";
    }

    foreach (SPListItem item in list.Items)
    {
        foreach (SPWorkflow workflow in item.Workflows)
        {
            if ((workflow.InternalState & SPWorkflowState.Faulting) == SPWorkflowState.Faulting)
            {
                Console.WriteLine(SPWorkflowState.Faulting.ToString());
            }

            // ...
        }
    }
}
抱猫软卧 2024-09-18 04:57:24

看一下 SPSite.WorkflowManager。这将允许您检查工作流定义并在整个网站集中运行实例。 CountWorkflows 方法可能就是您想要的。

http://msdn.microsoft.com/en- us/library/microsoft.sharepoint.spsite.workflowmanager.aspx

-Oisin

Take a look at SPSite.WorkflowManager. This will let you examine workflow definitions and running instances across an entire site collection. The CountWorkflows method is probably what you want.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsite.workflowmanager.aspx

-Oisin

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