qianqianling 发表于 2015-9-26 14:25:50

[译]Building State Machine Document Approval Workflows for SharePoint Server 2007

  转自:http://msdn.microsoft.com/en-us/library/cc700334.aspx
  翻译:爱谁谁
自己正在学工作流,找到这篇文章,感觉不错,所以边学就边翻译了,与大家分享。水平有限,如有错误,请指正.
2008年12月16日译
  Applies to: 2007 Microsoft Office System, Microsoft Office SharePoint Server 2007, Microsoft Visual Studio 2008
  Mike Rand, 3Sharp
  June 2008







  State machine workflows enable you to model real-world events and business processes in ways that are not available to sequential workflows. By modeling a workflow on states and transitions, a state machine workflow gives you the ability to create powerful business tools. Microsoft Visual Studio 2008 includes templates that provide a great starting point for creating state machine workflows. This Microsoft Office Visual How To describes how to use Visual Studio 2008 to create a state machine document approval workflow for Microsoft Office SharePoint Server 2007.

  The scenario in this Office Visual How To is a simple expense report approval process. An expense report has been submitted and must be approved or rejected. You can manage this process by using states. Table 1 shows a breakdown of the states and transitions.


Table 1. State/Transitions





State Event State

ReportInitialState eventInitWorkflow ReportSubmittedState

ReportSubmittedStateeventReviewReportReportApprovedState

ReportSubmittedStateeventReviewReportReportRejectedState

ReportApprovedStatestateInitApprovedStateReportCompleteState

ReportRejectedStatestateInitReportRejectedStateReportCompleteState  This example uses the Microsoft Office InfoPath 2007 Expense Report form in a modified version. For more information about how to modify this form, see Creating a Custom Approval Workflow for SharePoint Server 2007 Using SharePoint Designer 2007. You will also use a custom task form that is created by following the steps in Building an Expense Report Approval Workflow for SharePoint Server 2007 Using Visual Studio 2008.
  Creating a Visual Studio 2008 State Machine Workflow Project
  First, you create a Visual Studio project to build your workflow.

To create a Visual Studio 2008 State Machine Workflow project
建立一个sharepoint 2007 状态机工作流项目





[*]  Open Visual Studio 2008.
打开vs2008


[*]  On the File menu, point to New, and then click Project.
打开 "文件"-->"新建"-->"项目"


[*]  Under the Office Project type, select the SharePoint 2007 State Machine Workflow project template.
选择"Office"里面的"sharepoint 2007 状态机工作流"


[*]  In the Name text box, type ExpenseReportStateMachineWF, and then click OK.
在"名称"后面的输入框里输入"ExpenseReportStateMachineWF",然后点确定。


[*]  Type a valid SharePoint Server Web URL. This scenario uses http://moss.litwareinc.com/expense. Click Next.
在"有效的sharepoint web url"下面输入你的sharepoint地址,并加上你要附加工作流的文档库名称,例如:http://moss.litwareinc.com/expense
然后点击"下一步"。

[*]  Select a library or list to associate with the workflow, or accept the default. Click Next.
"库或列表"后面的选项是选择你要附加的库或列表,然后点"下一步"。
然后点"完成"。


[*]  Rename the StateMachineWorkflowActivity from the default workflow1.cs to ExpenseReportStateMachineWorkflow.
把workflow1.cs重命名为ExpenseReportStateMachineWorkflow.cs


  Laying Out a State Machine Workflow
设计你的状态机工作流

  Now you can set up your workflow. You start by laying out the workflow in the designer and updating all required properties. Later, you add the code to drive your workflow.
现在,你可以设计你的工作流了。开始是在工作流设计器里面拖放工作流控件,并设置它们的属性。然后就是给你的工作流添加代码了。


To lay out a state machine workflow
开始设计工作流





[*]  By default, the workflow contains a state named Workflow1InitalState. Open the Properties window and rename this state to ReportInitialState. For now, do not worry about the EventDriven activity eventDrivenActivity1; you will return to that later.
工作流里已经默认包含了一个名为"Workflow1InitalState"的状态。在它上面点右键,选"属性",在属性窗口里把名字改成"ReportInitialState"。现在你还不用管它里面的"eventDrivenActivity1",一会儿我们会具体说道它。


[*]  Open the Toolbox. Expand the SharePoint Workflow controls and the Windows Workflow v3.0 controls.
打开工具栏,点开"sharepoint 工作流"控件列表和"Windows Workflow v3.0"控件列表。


[*]  In the Windows Workflow v3.0 category, select State, and drag it onto the designer surface.
在"Windows Workflow v3.0"类别中选择"State",并且把它拖拽到设计器中。[注:State就是状态机中的状态。]


[*]  Open the Properties window, and rename this state to ReportSubmittedState.
打开它的属性,并把它的名字改成"ReportSubmittedState"。


[*]  Add three more states to the document surface, and rename them ReportApprovedState, ReportRejectedState, and ReportCompleteState.
再增加三个状态,它们的名字分别是"ReportApprovedState","ReportRejectedState","ReportCompleteState"。


[*]  Next, set your initial state. Right-click ReportInitialState, and then select Set as Initial State.
  This adds a small green circle icon to the state in the upper-left corner, as shown in Figure 1.
接着,设置你的"开始状态"。在它上面点"右键",选"设置为初始状态"。这时你会发现在这个状态的左上角的小图标里多出了一个绿色的标志。
如下图


Figure 1. Initial state icon

[*]  Next, set your completed state. Right-click ReportCompleteState, and select Set as Completed State.
  This adds a small red circle icon to the state in the upper-left corner, as shown in Figure 2.
接下来,设置你的"结束状态"。在"ReportCompleteState"状态上点邮件,选择"设置为已完成状态"。这个时候你会发现在这个状态左上角的小图标里面多了一个红色的图标。如下图



Figure 2. Completed state icon

  Now that you have all of your states on the designer surface, you must add activities to the states.
这样,你的所有用到的状态已经都在设计器中了,下面你该为他们添加activities(行为)了

States support the following activities:
状态支持一下几种activities(行为):



[*]  StateActivity

[*]  EventDrivenActivity

[*]  StateInitializationActivity

[*]  StateFinalizationActivity


  You will work with only the StateInitializationActivity and the EventDrivenActivity.
这里只需要"StateInitializationActivity"和"EventDrivenActivity"两种行为


[*]  Select the eventDrivenActivity1 in the ReportInitialState state.
选择"ReportInitialState"状态下的"eventDrivenActivity1"。


[*]  In the Properties window, select the Name property, and rename it to eventInitWorkflow.
在它的属性里面把它重命名为"eventInitWorkflow"。


[*]  Drag a StateInitialization activity to the ReportSubmittedState state. Rename this activity to stateInitReportSubmittedState.
拖拽一个StateInitialization 到"ReportSubmittedState"状态中。并重命名为"stateInitReportSubmittedState"。


[*]  Repeat this for the ReportApprovedState state and the ReportRejectedState state. Rename these to stateInitReportApprovedState and stateInitReportRejectedState respectively.
在"ReportApprovedState"和"ReportRejectedState"状态中重复上面一步的操作,并把他们重命名为"stateInitReportApprovedState"和"stateInitReportRejectedState"。


[*]  Drag an EventDriven activity to the ReportSubmittedState. Rename it to eventReviewReport.
为"ReportSubmittedState"状态拖拽一个"EventDriven"行为,并把它重命名为"eventReviewReport"







Note:

You cannot drop EventDriven activities above the StateInitialization activity; the designer moves the activity below the StateInitialization activity for you.
注意:你拖拽的"EventDriven"应该放在"StateInitialization"的下面。
  Your workflow designer should look similar to Figure 3.
现在,你的设计器中的工作流应该如下图。


Figure 3. Incomplete workflow layout

  Now, you fill in the details of each state.
下面,该为每个状态填充更详细的内容了。


To add Initial state details
为初始化状态添加详细内容




[*]  To start, double-click the eventInitWorkflow activity in the ReportInitialState state.
双击"ReportInitialState"状态中的"eventInitWorkflow"。

  You should see the following.
你将会看到如下图。


Figure 4. Detail view
  You can use the breadcrumb links across the upper-left part of the designer to return to the state view of the workflow.
你可以通过视图中顶部靠左边的链接回到前面的视图中。


[*]  First, rename the onWorkflowActivated1 activity to onReportWorkflowActivated.
首先,把"onWorkflowActivated1"重命名为"onReportWorkflowActivated"。


[*]  In the Properties window, select the CorrelationToken property. In the drop-down list, select workflowToken, if it is not already selected.
在"属性"窗口里面找到"CorrelationToken"属性,并把它后面的下拉菜单中选择"workflowToken"。


[*]  Click the plus sign (+) to expand the CorrelationToken property. Select the OwnerActivityName under the CorrelationToken property, and in the drop-down list, select ExpenseReportStateMachineWorkflow, if it is not already selected.
点开"CorrelationToken"前面的(+),在"OwnerActivityName"后面选择"ExpenseReportStateMachineWorkflow"。


[*]  Select the WorkflowProperties property, and on the far right, click the ellipsis (…) button.
找到"WorkflowProperties "属性,点他后面的(...)。


[*]  In the Binding dialog box, select the Bind to an existing member tab. Select workflowProperties, and then click OK.
在新弹出的对话框中,选择"绑定到现有成员"选项卡,然后选择下面的"workflowProperties",点"确定"。


[*]  The last thing you need to do is right-click the onReportWorkflowActivated activity, and then select Generate Handlers. This takes you to the code-behind class, to an autogenerated method stub. Return to the designer.
最后,你可以在"onReportWorkflowActivated"上点右键,选择"生成处理程序"。它可以在后置代码断里自动生成一个方法,用来写你自己的代码。然后回到设计器中。


[*]  Drag a CreateTask activity under the onReportWorkflowActivated activity. Rename it to createReportTask.
拖拽一个"CreateTask "到"onReportWorkflowActivated"下面,并把它重命名为"createReportTask"。


[*]  In the Properties window, select the CorrelationToken property, and type taskToken.
在它的属性窗口里面找到"CorrelationToken"属性,输入"taskToken"。


[*]  Click the plus sign (+) to expand the CorrelationToken property. Select the OwnerActivityName beneath the CorrelationToken property, and in the drop-down list, select ExpenseReportStateMachineWorkflow.
点击"CorrelationToken"前面的(+),找到"OwnerActivityName",选择"ExpenseReportStateMachineWorkflow"。


[*]  Select the TaskId property, and then click the ellipsis (…) button on the far right.
找到"TaskId",点击后面的(...)。


[*]  In the Binding dialog box, select the Bind to a new member tab. Type taskId. Select the Create Field option, and click OK.
在新弹出的"绑定"对话框中,选择"绑定到新成员"选项卡,输入"taskId",选择下面的"创建字段",然后点"确定"。


[*]  Next, select the TaskProperties property, and click the ellipsis (…) button on the far right. In the Binding dialog box, select the Bind to a new member tab.
接下来,选择"TaskProperties"属性,点击后面的(...)按键,在"绑定"对话框中选择"绑定到新成员"选项卡。


[*]  Type taskProperties. Select the Create Field option, and click OK.
输入"taskProperties",选择"创建字段",然后点"确定"。


[*]  The last thing you have to do for this is right-click the createReportTask activity, and select Generate Handlers. This takes you to the code-behind class, to an autogenerated method stub. Return to the designer.
最后,你也可以在"createReportTask"上点右键,选"生成处理程序",在后置代码中自动生成一个方法。


[*]  Drag a SetState activity beneath the createReportTask activity.
拖拽一个"SetState"到"createReportTask"下面。







Note:

There are two SetState activities that are included with Visual Studio 2008. In this example, you only use the SetState activity in the Windows Workflow v3.0 Toolbox category.
注:在vs2008中有两个"SetState"。这里我们用到的是"Windows Workflow v3.0"下面的。

[*]  Rename this to setStateSubmitted.
把它重命名为"setStateSubmitted"。


[*]  Select the TargetStateName property, and in the drop-down list, select ReportSubmittedState.
找到它的"TargetStateName"属性,选择"ReportSubmittedState"。


[*]  In the upper-left corner, click the ExpenseReportStateMachineWorkflow link to return to the State view.
点击视图顶部左边的"ExpenseReportStateMachineWorkflow"链接,回到状态视图中。



To add Submitted state details
为Submitted 状态添加详细内容





[*]  Double-click the stateInitReportSubmittedState activity in the ReportSubmittedState to open the detail view of this activity.
双击"ReportSubmittedState"状态下的"stateInitReportSubmittedState"来打开详细视图。


[*]  Drag a LogToHistoryListActivity activity to the design surface. Rename it to logToHistoryReportSubmittedState.
拖拽一个"LogToHistoryListActivity"行为到设计界面,并重命名为" logToHistoryReportSubmittedState"。


[*]  Right-click logToHistoryReportSubmittedState, and select Generate Handlers. Return to the designer.
右击"logToHistoryReportSubmittedState",选择"生成处理程序"。然后回到设计视图中。


[*]  Return to the State view. Double-click the eventReviewReport activity in the ReportSubmittedState to open the detail view of this activity.
回到状态视图,双击"ReportSubmittedState"里面的"eventReviewReport"。




[*]  Drag an onTaskChanged activity to the design surface. Rename it to onTaskChangedReportReviewed.
拖拽一个"onTaskChanged"到设计视图中,并改名为"onTaskChangedReportReviewed"


[*]  In the Properties window, select the CorrelationToken property, and in the drop-down list, select taskToken.
在属性窗口中找到"CorrelationToken",在下拉菜单中选择"taskToken"。


[*]  Select the AfterProperties property, and click the ellipsis (…) button at the far right.
找到"AfterProperties"属性,点开它后面的(...)。


[*]  In the Binding dialog box, select the Bind to a new member tab.
在"绑定"对话框中,选择"绑定到新成员"选项卡。


[*]  Type afterProperties. Select the Create Field option, and then click OK.
输入"afterProperties",选择"创建字段",然后点"确定"。


[*]  Repeat Steps 7–9 for the BeforeProperties property, but replace the word "after" with "before."
重复3-5步来设置BeforeProperties。


[*]  Select the TaskId property, and click the ellipsis (…) button at the far right.
找到"TaskId"属性,点击后面的(...)。


[*]  In the Binding dialog box, the Bind to an existing member tab should be selected. If it is not selected, select it now, and then select the taskId property that you created earlier. Click OK.
在"绑定"对话框中,选择"绑定到现有成员"选项卡,选择下面的"taskId",然后点"确定"。


[*]  Right-click onTaskChangedReportReviewed, and then select Generate Handlers. This takes you to the code-behind class. Return to the designer.
可以通过右击"onTaskChangedReportReviewed",选择"生成处理程序"来写自己的处理代码。然后返回设计视图。


[*]  Now drag an IfElse activity underneath the onTaskChangedReportReviewed activity. Rename it to ifElseReportReview.
拖拽"IfElse"到"onTaskChangedReportReviewed"下面,并重命名为"ifElseReportReview"。


[*]  Rename the first ifElseBranch to ifElseReportApproved.
把左边的if分支重命名为"ifElseReportApproved"。


[*]  In the Properties window, select the Condition property. In the drop-down list, select Code Condition.
在它的属性里找到Condition属性,在后面的下拉菜单中选择"代码条件"。


[*]  Expand the Condition property. There is a sub-property also named Condition. Type IsReportApproved, and then press ENTER.
点卡Condition前面的(+),在下面的Condition后面输入"IsReportApproved",然后按回车。


[*]  This opens the code behind class, which contains a method stub for IsReportApproved. Return to the designer.
这时系统会自动建立一个空的方法,名为"IsReportApproved",然后回到设计界面。


[*]  Rename the second ifElseBranch to ifElseReportRejected.
把第二个if分支重命名为"ifElseReportRejected"


[*]  In the Properties window, select the Condition property. In the drop-down list, select Code Condition.
在它的属性里找到Condition属性,在后面的下拉菜单中选择"代码条件"。


[*]  Expand the Condition property. There is a sub-property also named Condition. Type IsReportRejected, and then press ENTER.
  Again, you are taken to the code-behind class. Return to the designer.
点卡Condition前面的(+),在下面的Condition后面输入"IsReportRejected",然后按回车。


[*]  Now, drag a SetState activity onto the ifElseReportApproved activity.
  Rename it to setStateReportApproved.
拖拽一个"SetState"到if的第一分支上,也就是"ifElseReportApproved",然后重命名为"setStateReportApproved"


[*]  In the Properties window, select the TargetStateName property, and in the drop-down list, select ReportApprovedState.
在它的属性里,找到"TargetStateName"属性,在它后面的下拉菜单中选择"ReportApprovedState"。


[*]  Drag a SetState activity onto the ifElseReportRejected activity, and rename it to setStateReportRejected.
拖拽一个"SetState"到if的第二个分支上,然后重命名为"setStateReportRejected"。


[*]  Select the TargetStateName property, and in the drop-down list, select ReportRejectedState.
设置"TargetStateName"属性为"ReportRejectedState"。


[*]  Click the ExpenseReportStateMachineWorkflow link in the upper–left corner to return to the State view.
点击设计视图左上角的"ExpenseReportStateMachineWorkflow"链接,回到状态视图。



To add Approved state and Rejected state details
为通过审批状态和没通过审批状态添加详细内容




[*]  Double-click the stateInitReportApprovedState activity in the ReportApprovedState state.
双击"ReportApprovedState"中的"StateInitReportApprovedState"。


[*]  Drag a LogToHistoryListActivity activity to the design surface, and rename it to logToHistoryReportApprovedState.
拖拽一个"LogToHistoryListActivity"到设计界面中,并重命名为"logToHistoryReportApprovedState"。


[*]  Right-click logToHistoryReportApprovedState, and select Generate Handlers. Return to the designer.
右击"logToHistoryReportApprovedState",选择"生成处理程序"。然后回到设计界面。


[*]  Drag a CompleteTask activity below the logToHistoryReportApprovedState activity. Rename it to completeTaskReportApproved.
拖拽一个"CompleteTask"到"logToHistoryReportApprovedState"下面,并重命名为"completeTaskReportApproved"。


[*]  In the Properties window, select the CorrelationToken property, and in the drop-down list, select taskToken.
设置它的CorrelationToken属性为"taskToken"。


[*]  Select the TaskId property, and then click the ellipsis (…) button at the far right.
点击它的TaskId属性后面的(...)。


[*]  In the Binding dialog box, the Bind to an existing member tab should be selected for you. If it is not selected, select it now. Select the taskId property that you created earlier, and then click OK.
在"绑定"对话框中,选择"绑定到现有成员"选项卡,然后选择下面的"taskId",然后点"确定"。


[*]  Right-click completeTaskReportApproved, and select Generate Handlers. Return to the designer.
右击"completeTaskReportApproved",选择"生成处理程序"。然后返回到设计视图。


[*]  Drag a SetState activity under the completeTaskReportApproved activity. Rename it to setStateReportApprovedComplete.
拖拽一个"SetState"到"completeTaskReportApproved"下面,并把它重命名为"setStateReportApprovedComplete"。


[*]  Select the TargetStateName property, and in the drop-down list, select ReportCompleteState.
设置它的"TargetStateName"属性为"ReportCompleteState"。

  
Repeat these same steps for the ReportRejectedState, replacing the word "approved" with "rejected." When you are finished, your workflow should look like the following figure.
重复上面步骤来设置ReportRejectedState。
logToHistoryReportrejectedState
completeTaskReportrejected
setStateReportrejectedComplete




Figure 5. Complete workflow layout

  Adding Code to the Workflow
添加代码

Now that you have designed your workflow, you must add code to provide the logic.

To add code to the workflow




[*]  Add your own fields, as follows.
添加你的字段







C#

Copy Code


// Status.
private bool isReportApproved;
// Report Information.
private string employeeName;
private string mngrEmail;
private string mngrName;
private double reportTotal;
private string domain;
[*]  Add properties for each field. You do not have to provide setters; getters are sufficient.
给每个字段添加属性
  Add some code to your onReportWorkflowActivated_Invoked method, as follows.
把下面代码添加到"onReportWorkflowActivated_Invoked"中







C#

Copy Code


    // Read in Expense Report form values.
employeeName = workflowProperties.Item["Employee Name"].ToString();
mngrName = workflowProperties.Item["Manager Name"].ToString();
mngrEmail = workflowProperties.Item["Manager Email Address"].ToString();
reportTotal = (double)workflowProperties.Item["Report Total"];
domain = workflowProperties.Item["Domain"].ToString();








The Domain field was added to the Expense Report form. For information about modifying the InfoPath Expense Report form see the Visual How To, Creating a Custom Approval Workflow for SharePoint Server 2007 Using SharePoint Designer 2007.
关于如何设置infopath表单字段域,请看Creating a Custom Approval Workflow for SharePoint Server 2007 Using SharePoint Designer 2007

[*]  Next, add code to the createReportTask_MethodInvoking method, as shown here.
把下面代码添加到createReportTask_MethodInvoking中







C#

Copy Code


// Create unique Task Id.
taskId = Guid.NewGuid();
// Set task properties.
taskProperties.TaskType = 1;
taskProperties.Title = "Expense Report Approval";
taskProperties.StartDate = DateTime.Today;
taskProperties.PercentComplete = 0.0f;
taskProperties.AssignedTo = Domain + "\\" + ManagerName;
[*]  Add code to the onTaskChangedReportReviewed_Invoked method.
把下面代码添加到"onTaskChangedReportReviewed_Invoked"中







C#

Copy Code


// Retrieve report approval value from task form.
string selVal =   afterProperties.ExtendedProperties["optApproval"].ToString();
int val = 0;
if (!String.IsNullOrEmpty(selVal))
{
if (Int32.TryParse(selVal, out val))
{
if (val == 1)
{
isReportApproved = true;
}
}
}
// Show that the task is in progress.
taskProperties.PercentComplete = 50;
[*]  Next, code the logic methods. Add the following code to the IsReportRejected method.
把下面代码添加到"IsReportRejected"方法中







C#

Copy Code


    // Check to see if report is rejected.
if (!isReportApproved)
{
e.Result = true;
}
[*]  Add the following code to the IsReportApproved method.
把下面代码添加到"IsReportApproved"方法中






C#

Copy Code


    // Check to see if report is approved.
if (isReportApproved)
{
e.Result = true;
}
[*]  Add the following code to the completeTaskReportApproved_MethodInvoking and the completeTaskReportRejected_MethodInvoking methods.
把下面代码添加到"completeTaskReportApproved_MethodInvoking"和"completeTaskReportRejected_MethodInvoking"方法中







C#

Copy Code


// Complete the task.
taskProperties.PercentComplete = 100;
[*]  Next, add your logging code. Add the following code to the logToHistoryReportSubmittedState_MethodInvoking method.
现在添加日志代码。把下面代码添加到"logToHistoryReportSubmittedState_MethodInvoking"方法中。







C#

Copy Code


LogToHistoryListActivity log = (LogToHistoryListActivity)sender;
if (log != null)
{
log.HistoryDescription = "Report Submitted";
}
[*]  Repeat these steps for the logToHistroyReportApprovedState_MethodInvoking and logToHistoryReportRejectedState_MethodInvoking methods. Change the text to "Report Approved" and "Report Rejected" respectively.
重复上面的步骤,把上面代码添加到"logToHistroyReportApprovedState_MethodInvoking"和"logToHistoryReportRejectedState_MethodInvoking"方法中,修改"Report Submitted"为"Report Approved"或者"Report Rejected"。


  Updating the Workflow.xml File
修改Workflow.xml文件

  Next, you must make sure that the Workflow.xml file is updated to include your Expense Report Approval task form.
你要确定在Workflow.xml中包含你的费用报销流程表单

To update Workflow.xml




[*]  Add the following element as a child to the MetaData element.
添加下面的元素作为"MetaData"的子元素。






Xml

Copy Code


<Task1_FormURN>urn:schemas-microsoft-com:office:infopath:

ExpenseReportApprovalForm:
-myXSD-2008-04-09T15-47-41</Task1_FormURN>
[*]  Replace the URN above with the URN from your Expense Report Approval task form. To find the URN of an InfoPath form, open the form in design view. Click File, and then click Properties. The URN is in the ID text box.
用你自己的费用报销表单的URN替换上面的URN。
你可以通过,在设计器中打开你的表单,然后点"文件"-->"属性"查看。


[*]  Add the TaskListContentTypeId attribute to the Workflow element.
添加"TaskListContentTypeId"属性到Workflow元素中。






Xml

Copy Code


TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160"






Note:

It is critical that you type this number exactly as shown. If your task form does not show up, verify whether this number is correct.
如果你的表单不能正确显示,请检查上面的编号是否正确。

[*]  Update the CodeBesideClass attribute from the default value of ExpenseReportStateMachineWF.workflow1 to ExpenseReportStateMachineWF.ExpenseReportStateMachineWorkflow.
把CodeBesideClass的值为"ExpenseReportStateMachineWF.ExpenseReportStateMachineWorkflow"。


  Updating the Feature.xml File
修改Feature.xml文件
  Next, you must ensure that the Feature.xml file is updated to include the Expense Report Approval task form.
你要确保Feature.xml中包含你的费用报销表单。

To update Feature.xml
修改Feature.xml




[*]  Add the following element as a child to the ElementManifests element.
把下面代码作为"ElementManifests"的子元素






Xml

Copy Code


<ElementFile Location=" ExpenseReportApprovalFormStateMachineWF.xsn" />
  Running the Workflow Project from Visual Studio 2008
在vs2008中运行工作流
  All you have to do now is press F5 and run your project. Visual Studio 2008 lets you debug your workflows by placing breakpoints in code. Visual Studio 2008 also handles the details of deploying your workflow to SharePoint Server. You may still need to manually add the workflow to your Document Library in Office SharePoint Server.


Figure 6. Build Output
  

  State machine workflows enable you to model real-world events and business processes. Visual Studio 2008 makes creating and debugging these workflows easier than ever. Visual Studio also gives you the ability to package your workflow features and deploy them easily. For more information see Configuring and Deploying Workflows to SharePoint Server 2007 Using Solution Packages.



页: [1]
查看完整版本: [译]Building State Machine Document Approval Workflows for SharePoint Server 2007