Visual studio 如何访问工作流&x27;MS Sharepoint中的历史结果?

Visual studio 如何访问工作流&x27;MS Sharepoint中的历史结果?,visual-studio,sharepoint,workflow,Visual Studio,Sharepoint,Workflow,我目前正在使用Microsoft Visual Studio为MS Sharepoint创建一个Web部件。请问我如何访问执行工作流的库/列表,以在工作流完成时获取工作流历史记录和结果 目前,我有代码访问各个字段,即获取列表的不同列: SPSite site = new SPSite("http://win7:8000/RIDepartment/"); SPWeb oweb = site.OpenWeb(); SPList tasklist = oweb.Lists["Innovation wo

我目前正在使用Microsoft Visual Studio为MS Sharepoint创建一个Web部件。请问我如何访问执行工作流的库/列表,以在工作流完成时获取工作流历史记录和结果

目前,我有代码访问各个字段,即获取列表的不同列:

SPSite site = new SPSite("http://win7:8000/RIDepartment/");
SPWeb oweb = site.OpenWeb();
SPList tasklist = oweb.Lists["Innovation workflow list"];
然后,为了获取第一项,我使用任务列表[0]。但是我无法从中获取工作流历史记录,谢谢


Melvin

请查看各种工作流教程

您需要通过
SPListItem.Workflows
获取列表项上的工作流。从返回的
SPWorkflowCollection
中获取正确的
SPWorkflow
后,您可以通过
HistoryListId
TaskListId
属性()获取相关的历史记录列表和任务列表

因此,基本上类似这样的方法应该是可行的:

SPListItem item = tasklist[0];
SPWorkflow workflow = item.Workflows[0];
SPList historyList = workflow.HistoryList;
SPList taskList = workflow.TaskList;
但是,这段代码非常糟糕,所以只需将其作为起点,而且您不应该使用[0],而是获得您真正想要的工作流(例如,通过知道其名称)