Workflow.ReadWorkflowStageList 方法
读取工作流容器的列表。
命名空间: WebSvcWorkflow
程序集: ProjectServerServices(位于 ProjectServerServices.dll 中)
语法
声明
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Workflow/ReadWorkflowStageList", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Workflow/", _
ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Workflow/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function ReadWorkflowStageList As WorkflowDataSet
用法
Dim instance As Workflow
Dim returnValue As WorkflowDataSet
returnValue = instance.ReadWorkflowStageList()
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Workflow/ReadWorkflowStageList", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Workflow/",
ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Workflow/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public WorkflowDataSet ReadWorkflowStageList()
返回值
类型:WebSvcWorkflow.WorkflowDataSet
备注
每个WorkflowDataSet.WorkflowStageRowWorkflowDataSet.WorkflowStageDataTable中包含一个阶段的信息。
Project Server 权限
权限 |
说明 |
---|---|
允许用户管理的工作流。全局权限。 |
示例
The example uses the SvcWorkflow namespace in the ProjectServerServices.dll proxy assembly. The ConfigClientEndpoints method uses an app.config file for setting the WCF binding, behavior, and endpoint. For information about creating a PSI proxy assembly and an app.config file, see Project 2013 中基于 WCF 的代码示例的先决条件.
下面的示例使用ReadWorkflowStageList读取的现有工作流阶段。生成的数据集, workflowDS,包含的所有阶段和工作流中的步骤,并会写入WorkflowStageList.xml文件。以下是WorkflowStageList.xml文件的一部分。
<?xml version="1.0" standalone="yes"?>
<WorkflowDataSet xmlns="https://schemas.microsoft.com/office/project/server/webservices/WorkflowDataSet/">
<WorkflowPhase>
<PHASE_UID>d8bc257b-c2ec-4186-8a5b-44b5b7f21d82</PHASE_UID>
<PHASE_NAME>Create</PHASE_NAME>
<PHASE_DESCRIPTION>Project information is captured in this phase</PHASE_DESCRIPTION>
</WorkflowPhase>
<WorkflowStage>
<STAGE_UID>a8a158d1-a9b9-41d7-a676-d199118221c7</STAGE_UID>
<STAGE_NAME>TestStage</STAGE_NAME>
<PHASE_UID>d8bc257b-c2ec-4186-8a5b-44b5b7f21d82</PHASE_UID>
<PHASE_NAME>Create</PHASE_NAME>
<STAGE_DESCRIPTION>a test stage</STAGE_DESCRIPTION>
<CHECKIN_REQUIRED>false</CHECKIN_REQUIRED>
<STAGE_SUBMIT_DESCRIPTION />
<STATUS_PDP_UID>a7aa1c62-9577-447c-823e-bdb161f9000d</STATUS_PDP_UID>
</WorkflowStage>
以下是完整的代码示例。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.ServiceModel;
namespace Microsoft.SDK.Project.Samples.WorkFlowTest
{
class WorkFlowProject
{
private static SvcWorkflow.WorkflowClient workFlowClient;
private const string WORK_ENDPOINT = "basicHttp_Workflow";
private const string OUTPUT_FILES = @"C:\Projects\Samples\Output\";
private static string outFilePathWorkFlowStageList;
private static string outFilePathNewWorkFlowStage;
private static string outFilePathStageInfo;
private static string outFilePathUpdatedStage;
static void Main(string[] args)
{
// Configure client endpoints.
ConfigClientEndpoints(WORK_ENDPOINT);
Guid[] workFlowID = new Guid[1];
workFlowID[0] = new Guid("e663d9dc-f78d-4a4e-ac21-b28d22865f58");
// If output directory does not exist, create it.
if (!Directory.Exists(OUTPUT_FILES))
{
Directory.CreateDirectory(OUTPUT_FILES);
}
outFilePathWorkFlowStageList = OUTPUT_FILES + "WorkFlowStageList.xml";
outFilePathNewWorkFlowStage = OUTPUT_FILES + "NewWorkflowStageInfo.xml";
outFilePathStageInfo = OUTPUT_FILES + "StageInfo.xml";
outFilePathUpdatedStage = OUTPUT_FILES + "UpdatedStage.xml";
// Create a workflow dataset.
SvcWorkflow.WorkflowDataSet workFlowDS = new SvcWorkflow.WorkflowDataSet();
// List the workflow stages.
workFlowDS = ListWorkflowStages(workFlowDS);
// Create a new workflow stage.
CreateWorkflowStageTest(workFlowDS);
// Get workflow stage properties for a given stage.
GetStageInfo();
}
// Read and display the properties of a stage, given the stage GUID.
private static void GetStageInfo()
{
SvcWorkflow.WorkflowDataSet stageInfoDS = new SvcWorkflow.WorkflowDataSet();
string stageName = "TestStage10";
Guid stageGuid1 = new Guid("a8a158d1-a9b9-41d7-a676-d199118221c7");
stageInfoDS = workFlowClient.ReadWorkflowStage(stageGuid1);
Console.WriteLine("\nSee XML output of the WorkFlowDataSet at {0}",
outFilePathStageInfo);
// Update the stage name.
UpdateStage(stageInfoDS, stageName, stageGuid1);
// Get the updated stage info.
stageInfoDS = workFlowClient.ReadWorkflowStage(stageGuid1);
stageInfoDS.WriteXml(outFilePathStageInfo);
Console.ReadKey();
}
// Update the stage name.
private static void UpdateStage(SvcWorkflow.WorkflowDataSet stageInfoDS, string stageName, Guid stageGuid1)
{
SvcWorkflow.WorkflowDataSet.WorkflowStageRow sRow;
sRow = stageInfoDS.WorkflowStage.FindBySTAGE_UID(stageGuid1);
sRow.STAGE_NAME = stageName;
Console.WriteLine("Updating the stage name........");
workFlowClient.UpdateWorkflowStage(stageInfoDS);
// Write the updated stage info to an xml file.
stageInfoDS.WriteXml(outFilePathUpdatedStage);
Console.WriteLine("Stage name updated!");
Console.WriteLine("\nSee XML output of the Updated WorkFlowDataSet at {0}",
outFilePathUpdatedStage);
}
// Create a workflow stage.
private static void CreateWorkflowStageTest(SvcWorkflow.WorkflowDataSet workFlowDS)
{
// The GUID of the Create phase.
Guid phaseGuid = new Guid("d8bc257b-c2ec-4186-8a5b-44b5b7f21d82 ");
Guid statusPDPId = new Guid("A7AA1C62-9577-447C-823E-BDB161F9000D");
Guid pdp_uid = new Guid("659FF164-1297-4B64-B813-489566774E27");
Guid stageUid = Guid.NewGuid();
// Create a workflow stage row.
SvcWorkflow.WorkflowDataSet.WorkflowStageRow workflowstageRow =
workFlowDS.WorkflowStage.NewWorkflowStageRow();
workflowstageRow.STAGE_NAME = "Test Stage 5";
workflowstageRow.STAGE_DESCRIPTION = "Adding a test stage row";
workflowstageRow.PHASE_NAME = "Create";
workflowstageRow.PHASE_UID = phaseGuid;
workflowstageRow.CHECKIN_REQUIRED = false;
workflowstageRow.STAGE_UID = stageUid;
workflowstageRow.STATUS_PDP_UID = statusPDPId;
workFlowDS.WorkflowStage.AddWorkflowStageRow(workflowstageRow);
// Add a project details page for the Stage created above.
SvcWorkflow.WorkflowDataSet.WorkflowStagePDPsRow pdpRow =
workFlowDS.WorkflowStagePDPs.NewWorkflowStagePDPsRow();
pdpRow.STAGE_UID = stageUid;
pdpRow.PDP_UID = pdp_uid;
pdpRow.PDP_NAME = "Project Information";
pdpRow.PDP_POSITION = 0;
pdpRow.PDP_ID = 4;
pdpRow.PDP_REQUIRES_ATTENTION = false;
workFlowDS.WorkflowStagePDPs.AddWorkflowStagePDPsRow(pdpRow);
// Create the stage.
workFlowClient.CreateWorkflowStage(workFlowDS);
// Write the dataset with the new Stage to an xml file.
workFlowDS.WriteXml(outFilePathNewWorkFlowStage);
Console.WriteLine("\nSee XML output of the WorkFlowDataSet at {0}",
outFilePathNewWorkFlowStage);
}
// List the workflow stages in the dataset.
private static SvcWorkflow.WorkflowDataSet ListWorkflowStages(SvcWorkflow.WorkflowDataSet workFlowDS)
{
workFlowDS = workFlowClient.ReadWorkflowStageList();
workFlowDS.WriteXml(outFilePathWorkFlowStageList);
Console.WriteLine("\nSee XML output of the WorkFlowDataSet at {0}",
outFilePathWorkFlowStageList);
return workFlowDS;
}
// Configure the custom field client endpoints.
public static void ConfigClientEndpoints(string endpt)
{
workFlowClient = new SvcWorkflow.WorkflowClient(endpt);
}
}
}