Workflow.UpdateWorkflowStage 方法
命名空间: WebSvcWorkflow
程序集: ProjectServerServices(位于 ProjectServerServices.dll 中)
语法
声明
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Workflow/UpdateWorkflowStage", 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 UpdateWorkflowStage ( _
workflowDS As WorkflowDataSet _
) As WorkflowDataSet
用法
Dim instance As Workflow
Dim workflowDS As WorkflowDataSet
Dim returnValue As WorkflowDataSet
returnValue = instance.UpdateWorkflowStage(workflowDS)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Workflow/UpdateWorkflowStage", 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 UpdateWorkflowStage(
WorkflowDataSet workflowDS
)
参数
workflowDS
类型:WebSvcWorkflow.WorkflowDataSet包含用于更新工作流容器的信息。
返回值
类型: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 的代码示例的先决条件.
本示例中,修改阶段名称TestStage2为TestStage10,并通过调用UpdateWorkflowStage方法更新工作流。更新的数据集, stageInfoDS,写入UpdatedStage.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>
<WorkflowPhase>
<PHASE_UID>e4df25db-9587-4308-b504-48f985698074</PHASE_UID>
<PHASE_NAME>Select</PHASE_NAME>
<PHASE_DESCRIPTION>A subset of projects are selected in this phase</PHASE_DESCRIPTION>
</WorkflowPhase>
<WorkflowPhase>
<PHASE_UID>4c997519-d9ca-468d-a609-b0015f0d7345</PHASE_UID>
<PHASE_NAME>Plan</PHASE_NAME>
<PHASE_DESCRIPTION> For the selected projects, an execution plan will be detailed out in this workflow phase</PHASE_DESCRIPTION>
</WorkflowPhase>
<WorkflowPhase>
<PHASE_UID>d22d56e5-b4ad-4a59-b1d2-cc1fd9945e64</PHASE_UID>
<PHASE_NAME>Finished</PHASE_NAME>
<PHASE_DESCRIPTION>The workflow is finished</PHASE_DESCRIPTION>
</WorkflowPhase>
<WorkflowPhase>
<PHASE_UID>8c1b13e8-e4d6-4b62-8663-ffb1c22d7653</PHASE_UID>
<PHASE_NAME>Manage</PHASE_NAME>
<PHASE_DESCRIPTION>Projects in execution are monitored in this phase</PHASE_DESCRIPTION>
</WorkflowPhase>
<WorkflowStage>
<STAGE_UID>a8a158d1-a9b9-41d7-a676-d199118221c7</STAGE_UID>
<STAGE_NAME>TestStage10</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>
<WorkflowStageStrategicImpact>
<STAGE_UID>a8a158d1-a9b9-41d7-a676-d199118221c7</STAGE_UID>
<BEHAVIOR>1</BEHAVIOR>
</WorkflowStageStrategicImpact>
<WorkflowStagePDPs>
<STAGE_UID>a8a158d1-a9b9-41d7-a676-d199118221c7</STAGE_UID>
<PDP_UID>659ff164-1297-4b64-b813-489566774e27</PDP_UID>
<PDP_ID>4</PDP_ID>
<PDP_NAME>Project Information</PDP_NAME>
<PDP_POSITION>0</PDP_POSITION>
<PDP_REQUIRES_ATTENTION>false</PDP_REQUIRES_ATTENTION>
</WorkflowStagePDPs>
</WorkflowDataSet>
以下是完整的代码示例。
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 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 that was created previously.
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);
}
}
}