欢迎来到三一文库! | 帮助中心 三一文库31doc.com 一个上传文档投稿赚钱的网站
三一文库
全部分类
  • 研究报告>
  • 工作总结>
  • 合同范本>
  • 心得体会>
  • 工作报告>
  • 党团相关>
  • 幼儿/小学教育>
  • 高等教育>
  • 经济/贸易/财会>
  • 建筑/环境>
  • 金融/证券>
  • 医学/心理学>
  • ImageVerifierCode 换一换
    首页 三一文库 > 资源分类 > DOC文档下载  

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

    • 资源ID:2786227       资源大小:53.80KB        全文页数:18页
    • 资源格式: DOC        下载积分:4
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录   微博登录  
    二维码
    微信扫一扫登录
    下载资源需要4
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

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

    用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 processes 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 machine 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 submitted 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 ReportSubmittedStateeventReviewReportReportRejectedState ReportApprovedStatestateInitApprovedStateReportCompleteState ReportRejectedStatestateInitReportRejectedStateReportCompleteState This example uses the Microsoft Office InfoPath 2007 Expense Report form in amodified version.For more information about 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.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.打开文件-新建-项目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 scenario 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 ExpenseReportStateMachineWorkflow.把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.现在,你可以设计你的工作流了。开始是在工作流设计器里面拖放工作流控件,并设置它们的属性。然后就是给你的工作流添加代码了。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;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 asmall 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 asmall 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 aStateInitialization 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 aCreateTask 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 anew 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 anew 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 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。这里我们用到的是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链接,回到状态视图中。收藏分享评分回复引用订阅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.双击ReportSubmittedState状态下的stateInitReportSubmittedState来打开详细视图。Drag aLogToHistoryListActivity 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 anew member tab.在绑定对话框中,选择绑定到新成员选项卡。Type afterProperties.Select the Create Field option,and then click OK.输入afterProperties,选择创建字段,然后点确定。Repeat Steps 7 9for 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 asub-property also named Condition.Type IsReportApproved,and then press ENTER.点卡Condition前面的(+),在下面的Condition后面输入IsReportApproved,然后按回车。This opens the code behind 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 Code 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 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.在它的属性里,找到TargetStateName属性,在它后面的下拉菜单中选择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.设置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 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

    注意事项

    本文(用vs2008制作sharepoint的状态机审批工.doc)为本站会员(本田雅阁)主动上传,三一文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




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

    三一文库
    收起
    展开