用vs2008制作sharepoint的状态机审批工.doc

上传人:本田雅阁 文档编号:2786227 上传时间:2019-05-16 格式:DOC 页数:18 大小:53.80KB
返回 下载 相关 举报
用vs2008制作sharepoint的状态机审批工.doc_第1页
第1页 / 共18页
用vs2008制作sharepoint的状态机审批工.doc_第2页
第2页 / 共18页
用vs2008制作sharepoint的状态机审批工.doc_第3页
第3页 / 共18页
用vs2008制作sharepoint的状态机审批工.doc_第4页
第4页 / 共18页
用vs2008制作sharepoint的状态机审批工.doc_第5页
第5页 / 共18页
点击查看更多>>
资源描述

《用vs2008制作sharepoint的状态机审批工.doc》由会员分享,可在线阅读,更多相关《用vs2008制作sharepoint的状态机审批工.doc(18页珍藏版)》请在三一文库上搜索。

1、用vs2008制作sharepoint的状态机审批工己正在学工作流,找到这篇文章,感觉不错,所以边学就边翻译了,与大家分享。水平有限,如有错误,请指正.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 p

2、rocesses in ways that are not available to sequential workflows.By modeling aworkflow 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 agreat starting point for creating state machi

3、ne workflows.This Microsoft Office Visual How To describes how to use Visual Studio 2008 to create astate machine document approval workflow for Microsoft Office SharePoint Server 2007.The scenario in this Office Visual How To is asimple expense report approval process.An expense report has been sub

4、mitted and must be approved or rejected.You can manage this process by using states.Table 1shows abreakdown of the states and transitions.Table 1.State/Transiti ons State Event State ReportInitialState eventInitWorkflow ReportSubmittedState ReportSubmittedStateeventReviewReportReportApprovedState Re

5、portSubmittedStateeventReviewReportReportRejectedState ReportApprovedStatestateInitApprovedStateReportCompleteState ReportRejectedStatestateInitReportRejectedStateReportCompleteState This example uses the Microsoft Office InfoPath 2007 Expense Report form in amodified version.For more information ab

6、out how to modify this form,see Creating aCustom Approval Workflow for SharePoint Server 2007 Using SharePoint Designer 2007.You will also use acustom task form that is created by following the steps in Building an Expense Report Approval Workflow for SharePoint Server 2007 Using Visual Studio 2008.

7、Creating aVisual Studio 2008 State Machine Workflow Project First,you create aVisual Studio project to build your workflow.To create aVisual Studio 2008 State Machine Workflow project建立一个sharepoint 2007状态机工作流项目Open Visual Studio 2008.打开vs2008 On the File menu,point to New,and then click Project.打开文件

8、-新建-项目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 avalid SharePoint Server Web URL.This scen

9、ario uses Click Next.在有效的sharepoint web url下面输入你的sharepoint地址,并加上你要附加工作流的文档库名称,例如:然后点击下一步。Select alibrary or list to associate with the workflow,or accept the default.Click Next.库或列表后面的选项是选择你要附加的库或列表,然后点下一步。然后点完成。Rename the StateMachineWorkflowActivity from the default workflow1.cs to ExpenseReportS

10、tateMachineWorkflow.把workflow1.cs重命名为ExpenseReportStateMachineWorkflow.cs Laying Out aState 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.现在,你可以设计你的工作流

11、了。开始是在工作流设计器里面拖放工作流控件,并设置它们的属性。然后就是给你的工作流添加代码了。To lay out astate machine workflow开始设计工作流By default,the workflow contains astate named Workflow1InitalState.Open the Properties window and rename this state to ReportInitialState.For now,do not worry about the EventDriven activity eventDrivenActivity1;y

12、ou 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控件列

13、表。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

14、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 asmall green circle icon to th

15、e 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 asmall red circle icon to the state in the upper-

16、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

17、 support the following activities:状态支持一下几种activities(行为):StateActivity EventDrivenActivity StateInitializationActivity StateFinalizationActivity You will work with only the StateInitializationActivity and the EventDrivenActivity.这里只需要StateInitializationActivity和EventDrivenActivity两种行为Select the even

18、tDrivenActivity1 in the ReportInitialState state.选择ReportInitialState状态下的eventDrivenActivity1。In the Properties window,select the Name property,and rename it to eventInitWorkflow.在它的属性里面把它重命名为eventInitWorkflow。Drag aStateInitialization activity to the ReportSubmittedState state.Rename this activity

19、to stateInitReportSubmittedState.拖拽一个StateInitialization到ReportSubmittedState状态中。并重命名为stateInitReportSubmittedState。Repeat this for the ReportApprovedState state and the ReportRejectedState state.Rename these to stateInitReportApprovedState and stateInitReportRejectedState respectively.在ReportApprov

20、edState和ReportRejectedState状态中重复上面一步的操作,并把他们重命名为stateInitReportApprovedState和stateInitReportRejectedState。Drag an EventDriven activity to the ReportSubmittedState.Rename it to eventReviewReport.为ReportSubmittedState状态拖拽一个EventDriven行为,并把它重命名为eventReviewReport Note:You cannot drop EventDriven activit

21、ies 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 det

22、ails 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 acr

23、oss 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

24、.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 ExpenseRepo

25、rtStateMachineWorkflow,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

26、 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 meth

27、od stub.Return to the designer.最后,你可以在onReportWorkflowActivated上点右键,选择生成处理程序。它可以在后置代码断里自动生成一个方法,用来写你自己的代码。然后回到设计器中。Drag aCreateTask activity under the onReportWorkflowActivated activity.Rename it to createReportTask.拖拽一个CreateTask到onReportWorkflowActivated下面,并把它重命名为createReportTask。In the Properties

28、 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 ExpenseReportStateMachineWorkflo

29、w.点击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 anew member tab.Type taskId.Select the Create Field option,and click OK.在新

30、弹出的绑定对话框中,选择绑定到新成员选项卡,输入taskId,选择下面的创建字段,然后点确定。Next,select the TaskProperties property,and click the ellipsis()button on the far right.In the Binding dialog box,select the Bind to anew member tab.接下来,选择TaskProperties属性,点击后面的(.)按键,在绑定对话框中选择绑定到新成员选项卡。Type taskProperties.Select the Create Field option,

31、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上点右键,选生成处理程序,在后置代码中自动生成一个

32、方法。Drag aSetState 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。这里我

33、们用到的是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 r

34、eturn to the State view.点击视图顶部左边的ExpenseReportStateMachineWorkflow链接,回到状态视图中。收藏分享评分回复引用订阅TOP 2#发表于2008-12-16 15:50|只看该作者To add Submitted state details为Submitted状态添加详细内容Double-click the stateInitReportSubmittedState activity in the ReportSubmittedState to open the detail view of this activity.双击Repor

35、tSubmittedState状态下的stateInitReportSubmittedState来打开详细视图。Drag aLogToHistoryListActivity activity to the design surface.Rename it to logToHistoryReportSubmittedState.拖拽一个LogToHistoryListActivity行为到设计界面,并重命名为logToHistoryReportSubmittedState。Right-click logToHistoryReportSubmittedState,and select Genera

36、te 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 a

37、ctivity 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 AfterPropertie

38、s property,and click the ellipsis()button at the far right.找到AfterProperties属性,点开它后面的(.)。In the Binding dialog box,select the Bind to anew member tab.在绑定对话框中,选择绑定到新成员选项卡。Type afterProperties.Select the Create Field option,and then click OK.输入afterProperties,选择创建字段,然后点确定。Repeat Steps 7 9for the Befor

39、eProperties 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

40、 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,选择生成处理程序来写自己的处理代码。然后返回设

41、计视图。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 th

42、e Condition property.In the drop-down list,select Code Condition.在它的属性里找到Condition属性,在后面的下拉菜单中选择代码条件。Expand the Condition property.There is asub-property also named Condition.Type IsReportApproved,and then press ENTER.点卡Condition前面的(+),在下面的Condition后面输入IsReportApproved,然后按回车。This opens the code behi

43、nd class,which contains amethod 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 Cod

44、e Condition.在它的属性里找到Condition属性,在后面的下拉菜单中选择代码条件。Expand the Condition property.There is asub-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

45、aSetState 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.在它的属性里,找到TargetSt

46、ateName属性,在它后面的下拉菜单中选择ReportApprovedState。Drag aSetState 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.设置TargetStateN

47、ame属性为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 acti

48、vity in the ReportApprovedState state.双击ReportApprovedState中的StateInitReportApprovedState。Drag aLogToHistoryListActivity 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 aCompleteTask activity below the logToHistoryReportApprovedState activity.Rename it to completeTaskRepo

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1