怎么写一个动态传值的请假activiti工作流 请假

ASP.NET(10)
请假流程描述
假设:公司有两级领导,一级为主管(Chief),一级为老板(Boss),我们这里只是一个模拟,当然现实生活中情况比这个更加复杂;-)
在某公司中,部门员工休假需要主管(Chief)的批准。
如果休假天数大于10天,则 在部门主管同意后,还必须老板(Boss)批准。
如果是部门主管请假则直接提交老板批准。
在休假被批准之前,申请人可以撤销休假申请。
申请批准后,对休假天数进行修改(也可以是其他业务数据处理)。 每次休假申请结束之后,不管通过未通过或是否取消,都必须记录下来。
流程结束时,系统要把请假的结果信息Email给申请人。
对于大于10天的申请,如果部门主管已批准同意而上级主管还未批准,这时申请人撤销申请后,系统应发Email通知部门主管申请已撤销。
流程定义之processdefinition.xml
processdefinition.xml&&1&?xml&version=&1.0&?&&&2&!--&NOTE:在定义流程时,建议先画出流程图,然后再来定义,这样思维清晰,也不易于出错&&3&&&&关于processdefiniton.xml如何定义,请严格按照nPdl规定&--&&&4&process-definition&&&5&&6&&&!--&===================================&--&&&7&&&!--&==&PROCESS&DEFINITION&PROPERTIES&==&--&&&8&&&!--&===================================&--&&&&&9&&&name&请假DEMO&/name&&10&&&description&该流程模拟公司的请假流程,&Made&By&LuBen&/description&&11&&&responsible&ae&/responsible&&12&13&&&!--&======================&--&&14&&&!--&==&START&&&ENDSTATE&==&--&&15&&&!--&======================&--&&16&&&start-state&name=&start&leave&request&&&17&&&&&description&提交请假单&/description&&18&&&&&!--&定义了role,引擎在该start-state节点执行时,就会把执行者信息赋值给角色对应的属性&requester&&--&&19&&&&&role&requester&/role&&20&&&&&!--&在这里定义start-state的field,它表示该filed相关联的属性,并且在该state,它对属性的访问权利。&21&&&&&&&&&如果需要定义其在web表单上的操作界面,如何进行web表单显示等,需要在webinterface.xml文件对应节点补充该field&--&&22&&&&&field&attribute=&start&date&&access=&write-only-required&&/&&23&&&&&field&attribute=&end&date&&&&access=&write-only-required&&/&&24&&&&&field&attribute=&leave&days&&&&&access=&write-only-required&&/&&25&&&&&field&attribute=&comment&&&&&access=&write-only&&/&&26&&&&&transition&to=&Is&Cancel&Fork&&/&&27&&&/start-state&&28&&&29&&&!--&结束节点除名称外不要定义其他--&&30&&&end-state&name=&end&&/&&31&32&33&&&!--&======================&--&&34&&&!--&==&&&&&&Actions&&&&&==&--&&35&&&!--&======================&--&&36&&&!--&解释:这里定义process-definition节点的action,有效的事件类型为:process-instance-start,&process-instance-end&and&process-instance-cancel&--&&37&&&38&&&!--&此处具体为:在流程结束的时候,&发送E-Mail消息给申请者,记录请假日志&--&&&&&&39&&&action&event=&process-instance-end&&&40&&&&&&&&handler=&NetBpm.Example.LeaveOfAbsence.EmailAction,&NetBpm.Example.LeaveOfAbsence&&&&on-exception=&log&&&41&&&&&&&&&!--定义action参数,供委托类实例化类调用方法时获取使用。如这里的EmailAction的run方法发送邮件,需要知道发给谁,邮件标题等等,那么&42&&&&&&&&&&&&参数可以提供辅助--&&43&&&&&&&&&parameter&name=&to&&previousActor&/parameter&&44&&&&&&&&&parameter&name=&subject&&您提交了请假申请&/parameter&&45&&&&&&&&&parameter&name=&message&&you&requested&a&holiday&from&${start&date}&to&${end&date}&with&comment&${comment}&/parameter&&46&&&&&&&/action&&47&&&&&!--&此处具体为:在流程结束的时候记录请假日志,&此处Log模拟&注意:每个节点可以定义多个action&--&&48&&&&&action&event=&process-instance-end&&&49&&&&&&&&handler=&NetBpm.Example.LeaveOfAbsence.LogLeaveInfoAction,&NetBpm.Example.LeaveOfAbsence&&&&on-exception=&log&&&50&&&&&parameter&name=&LogInfo&&记录请假日志?&:)&&/parameter&&51&&&/action&&52&53&&&!--&================&--&&54&&&!--&==&ATTRIBUTES&==&--&&55&&&!--&================&--&&56&&&!--&解释:定义属性值及其序列化方式。属性值一般包括3类&--&&57&&&!--&one:角色对应的属性&--&&58&&&attribute&name=&requester&&type=&actor&&/&&59&&&attribute&name=&chief&&type=&actor&&/&&60&&&attribute&name=&boss&&type=&actor&&/&&61&&&62&&&!--&two:所有acitivity-state(包括start-state)处需要更新的属性,和用户表单内容对应&--&&63&&&attribute&name=&start&date&&type=&date&&/&&64&&&attribute&name=&end&date&&type=&date&&/&&65&&&attribute&name=&leave&days&&type=&integer&&/&&66&&&attribute&name=&comment&&type=&text&&initial-value=&请假理由或者备注&&/&&67&&&attribute&name=&Chief&evaluation&result&&type=&evaluation&&/&&68&&&attribute&name=&Boss&evaluation&result&&type=&evaluation&&/&&69&&&70&&&!--&three:标识属性,该属性不会在web界面上体现,主来用来存储流程标识信息,供后面的逻辑处理使用&--&&71&&&!--&该属性不会在界面上呈现,&在具体流程路径中被设置以决定Decide&Which&Action如何走&--&&72&&&attribute&name=&RunTrace&&type=&text&&/&&73&&&!--&该属性不会在界面上呈现,&该属性被用来设置流程结束将要发送给用户的邮件信息(邮件标题,&如果需要邮件内容可扩展)&--&&74&&&attribute&name=&ToUserEmailSubject&&type=&text&&/&&75&76&&&!--&===========&--&&77&&&!--&==&NODES&==&--&&78&&&!--&===========&--&&79&&&!--&定义流程包含的所有节点&--&&80&81&&&!--&定义decision节点,&从decision可以流出多条边(transition),这些边可以目的地相同,也可以不同。&82&&&&&&&如下面,虽然decision分出了3条供选择的边,但是边的目的地都是end节点,只是边的名称不同&--&&83&&&decision&name=&Decide&Which&Action&&&84&&handler=&NetBpm.Example.LeaveOfAbsence.WhichWayDecision,&NetBpm.Example.LeaveOfAbsence&&&85&&&&&parameter&name=&attribute&&RunTrace&/parameter&&86&&&&&transition&name=&approve&&&&&to=&end&&&&&&&&&&&87&&&&&&&action&event=&transition&&handler=&NetBpm.Example.LeaveOfAbsence.AutoSetAttributesAction,&NetBpm.Example.LeaveOfAbsence&&on-exception=&log&&&88&&&&&&&&parameter&name=&attribute&&ToUserEmailSubject&/parameter&&89&&&&&&&&parameter&name=&setValue&&您的请假申请已经被批准&holiday&from&${start&date}&to&${end&date}&with&comment&${comment}&/parameter&&&&&&&&&&90&&&&&&&/action&&91&&&&&/transition&&92&93&&&&&transition&name=&disapprove&&to=&end&&&&&&&&&&&&94&&&&&&&action&event=&transition&&handler=&NetBpm.Example.LeaveOfAbsence.AutoSetAttributesAction,&NetBpm.Example.LeaveOfAbsence&&on-exception=&log&&&95&&&&&&&&&&parameter&name=&attribute&&ToUserEmailSubject&/parameter&&96&&&&&&&&&&parameter&name=&setValue&&您的请假申请没有获得批准,&holiday&from&${start&date}&to&${end&date}&with&comment&${comment}&/parameter&&97&&&&&&&/action&&98&&&&&/transition&&99<span style="COLOR: #0&&&&&transition&name=&requestercancel&&to=&end&&&&&&<span style="COLOR: #1&&&&&&&action&event=&transition&&handler=&NetBpm.Example.LeaveOfAbsence.AutoSetAttributesAction,&NetBpm.Example.LeaveOfAbsence&&on-exception=&log&&<span style="COLOR: #2&&&&&&&&&&parameter&name=&attribute&&ToUserEmailSubject&/parameter&<span style="COLOR: #3&&&&&&&&&&parameter&name=&setValue&&您取消了请假申请,&holiday&from&${start&date}&to&${end&date}&with&comment&${comment}&/parameter&&&&&&&&&<span style="COLOR: #4&&&&&&&/action&<span style="COLOR: #5&&&&&&&!--&请假人取消请假的时,&如果主管已经审批了,&则需要发邮件通知他&--&<span style="COLOR: #6&&&&&&&&action&event=&transition&&handler=&NetBpm.Example.LeaveOfAbsence.EmailChiefAction,&NetBpm.Example.LeaveOfAbsence&&on-exception=&log&&<span style="COLOR: #7&&&&&&&&&!---&action的参数只能有3个,&切记切记,&调试的时候搞晕了--&<span style="COLOR: #8&&&&&&&&&parameter&name=&to&&role(chief)&/parameter&<span style="COLOR: #9&&&&&&&&&!--&parameter&name=&cancelMan&&previousActor&/parameter&&--&<span style="COLOR: #0&&&&&&&&&parameter&name=&subject&&请假申请被取消啦&/parameter&<span style="COLOR: #1&&&&&&&&&parameter&name=&message&&&requested&a&holiday&from&${start&date}&to&${end&date}&with&comment&${comment}&/parameter&<span style="COLOR: #2&&&&&&&/action&<span style="COLOR: #3&&&&&/transition&&&&&<span style="COLOR: #4&&&/decision&&&<span style="COLOR: #5<span style="COLOR: #6&&<span style="COLOR: #7&&&!--&======================&--&<span style="COLOR: #8&&&!--&==&CONCURRENT&BLOCK&==&--&<span style="COLOR: #9&&&!--&======================&--&<span style="COLOR: #0&&&!--&解释:定义并发块,concurrent-block一定包括一个fork,一个join,且边不可越出其界。concurrent-block是可以嵌套的&--&<span style="COLOR: #1&&&concurrent-block&<span style="COLOR: #2&&&&&!--&定义fork,若没有定义forkhandler,那么其在fork&flow时将按照默认行为执行&--&<span style="COLOR: #3&&&&&fork&name=&Is&Cancel&Fork&&<span style="COLOR: #4&&&&&&&transition&name=&CancelLeaveRequest&&to=&Request&Cancel&&/&<span style="COLOR: #5&&&&&&&transition&name=&evaluation&&to=&IsChiefDecision&&/&<span style="COLOR: #6&&&&&/fork&<span style="COLOR: #7&&&&<span style="COLOR: #8&&&&&!--&定义join,此处定义了joinhandler,则当有forked&flow到达join时,将根据该委托判断是否要激活父flow,<span style="COLOR: #9&&&&&&&&&若没有定义joinhandler,那么将按照默认行为(AndJoin委托类,也就是所有forked&flow都汇聚到达Join才激活父flow)执行&--&<span style="COLOR: #0&&&&&join&name=&join&before&decided&&handler=&NetBpm.Example.LeaveOfAbsence.AnyOneJoin,&NetBpm.Example.LeaveOfAbsence&&<span style="COLOR: #1&&&&&&&transition&to=&Decide&Which&Action&&/&<span style="COLOR: #2&&&&&/join&<span style="COLOR: #3<span style="COLOR: #4&&&&&activity-state&name=&Request&Cancel&&<span style="COLOR: #5&&&&&&&description&在请假申请被最终审批前,&您可以在这里取消申请.&/description&<span style="COLOR: #6&&&&&&&role&requester&/role&<span style="COLOR: #7&&&&&&&!--&fields&are&optional.&they&limit&the&access&to&attributes&in&an&activity&--&<span style="COLOR: #8&&&&&&&field&attribute=&start&date&&&&&&&&&access=&read-only&&/&<span style="COLOR: #9&&&&&&&field&attribute=&end&date&&&&&&&&&&&access=&read-only&&/&<span style="COLOR: #0<span style="COLOR: #1&&&&&&&&&!--eg。请假理由备注先不被看到&&&&<span style="COLOR: #2&&&&&&&&&field&attribute=&leave&days&&&&&access=&read-only&&/&<span style="COLOR: #3&&&&&&&&&field&attribute=&comment&&&&&&&&&&&&&&access=&read-only&&/&<span style="COLOR: #4&&&&&&&&--&<span style="COLOR: #5&&&&&&&action&event=&perform-of-activity&&handler=&NetBpm.Example.LeaveOfAbsence.AutoSetAttributesAction,&NetBpm.Example.LeaveOfAbsence&&on-exception=&log&&<span style="COLOR: #6&&&&&&&&&parameter&name=&attribute&&RunTrace&/parameter&<span style="COLOR: #7&&&&&&&&&parameter&name=&setValue&&requestercancel&/parameter&<span style="COLOR: #8&&&&&&&/action&<span style="COLOR: #9&&&&&&&transition&to=&join&before&decided&&/&<span style="COLOR: #0&&&&&/activity-state&<span style="COLOR: #1<span style="COLOR: #2&&&&&decision&name=&IsChiefDecision&&handler=&NetBpm.Example.LeaveOfAbsence.IsInRoleDecision,&NetBpm.Example.LeaveOfAbsence&&<span style="COLOR: #3&&&&&&&&&parameter&name=&checkrole&&chief&/parameter&<span style="COLOR: #4&&&&&&&&&transition&name=&isChief&&&&&to=&BossApprove&&/&<span style="COLOR: #5&&&&&&&&&transition&name=&isNotChief&&to=&ChiefApprove&&/&<span style="COLOR: #6&&&&&/decision&<span style="COLOR: #7<span style="COLOR: #8&&&&&activity-state&name=&ChiefApprove&&<span style="COLOR: #9&&&&&&&description&您需要在这里对该请假单进行审批&/description&<span style="COLOR: #0&&&&&&&assignment&handler=&NetBpm.Example.LeaveOfAbsence.AssignmentExpressionResolver,&NetBpm.Example.LeaveOfAbsence&&<span style="COLOR: #1&&&&&&&&&parameter&name=&expression&&&role(requester)-&group(hierarchy)-&role(chief)&/parameter&<span style="COLOR: #2&&&&&&&/assignment&<span style="COLOR: #3&&&&&&&role&chief&/role&&&&&<span style="COLOR: #4&&&&&field&attribute=&requester&&&&&&&&&&access=&read-only&&/&<span style="COLOR: #5&&&&&field&attribute=&start&date&&&&&&&&&access=&read-only&&/&<span style="COLOR: #6&&&&&field&attribute=&end&date&&&&&&&&&&&access=&read-only&&/&<span style="COLOR: #7&&&&&field&attribute=&Chief&evaluation&result&&access=&write-only&&/&<span style="COLOR: #8&&&&&&&action&event=&perform-of-activity&&handler=&NetBpm.Example.LeaveOfAbsence.EvluationResultAction,&NetBpm.Example.LeaveOfAbsence&&on-exception=&log&&<span style="COLOR: #9&&&&&&&&&parameter&name=&attribute&&RunTrace&/parameter&<span style="COLOR: #0&&&&&&&&&parameter&name=&setValueAttribute&&Chief&evaluation&result&/parameter&<span style="COLOR: #1&&&&&&&/action&<span style="COLOR: #2&&&&&&&transition&to=&IsMoreTenDays&&/&<span style="COLOR: #3&&&&&/activity-state&<span style="COLOR: #4<span style="COLOR: #5&&&&&activity-state&name=&BossApprove&&<span style="COLOR: #6&&&&&&&description&您需要在这里对该请假单进行审批&/description&<span style="COLOR: #7&&&&&&&assignment&handler=&NetBpm.Example.LeaveOfAbsence.AssignmentExpressionResolver,&NetBpm.Example.LeaveOfAbsence&&<span style="COLOR: #8&&&&&&&&&parameter&name=&expression&&&role(requester)-&group(hierarchy)-&role(boss)&/parameter&<span style="COLOR: #9&&&&&&&/assignment&<span style="COLOR: #0&&&&&&&role&boss&/role&<span style="COLOR: #1&&&&&field&attribute=&requester&&&&&&&&&&access=&read-only&&/&<span style="COLOR: #2&&&&&field&attribute=&chief&&&&&&&&&&&&&&access=&read-only&&/&<span style="COLOR: #3&&&&&field&attribute=&start&date&&&&&&&&&access=&read-only&&/&<span style="COLOR: #4&&&&&field&attribute=&end&date&&&&&&&&&&&access=&read-only&&/&&&&&<span style="COLOR: #5&&&&&!--&理论上Boss不需要看到主管是否同意,因为不同意就不会到他这里来<span style="COLOR: #6&&&&&field&attribute=&leave&days&&&&&access=&read-only&&/&<span style="COLOR: #7&&&&&field&attribute=&Chief&evaluation&result&&access=&read-only&&/&&<span style="COLOR: #8&&&&--&<span style="COLOR: #9&&&&&field&attribute=&Boss&evaluation&result&&access=&write-only&&/&<span style="COLOR: #0&&&&&&&action&event=&perform-of-activity&&handler=&NetBpm.Example.LeaveOfAbsence.EvluationResultAction,&NetBpm.Example.LeaveOfAbsence&&on-exception=&log&&<span style="COLOR: #1&&&&&&&&&parameter&name=&attribute&&RunTrace&/parameter&<span style="COLOR: #2&&&&&&&&&parameter&name=&setValueAttribute&&Boss&evaluation&result&/parameter&<span style="COLOR: #3&&&&&&&/action&<span style="COLOR: #4&&&&&&&transition&to=&join&before&decided&&/&<span style="COLOR: #5&&&&&/activity-state&<span style="COLOR: #6<span style="COLOR: #7&&&&&decision&name=&IsMoreTenDays&&handler=&NetBpm.Example.LeaveOfAbsence.IsMoreOrLessDecision,&NetBpm.Example.LeaveOfAbsence&&<span style="COLOR: #8&&&&&&&&&parameter&name=&attribute&&leave&days&/parameter&<span style="COLOR: #9&&&&&&&&&parameter&name=&dividingDays&&<span style="COLOR: #&/parameter&<span style="COLOR: #0&&&&&&&&&!--考虑扩展,形成对数值比较类的通用&&parameter&name=&datatype&&float&/parameter&&&&&&&&&<span style="COLOR: #1&&&&&&&&&parameter&name=&compareType&&More&/parameter&&--&<span style="COLOR: #2&&&&&&&&&transition&name=&IsMore&&&&&to=&BossApprove&&/&<span style="COLOR: #3&&&&&&&&&transition&name=&IsnotMore&&to=&join&before&decided&&/&<span style="COLOR: #4&&&&&/decision&<span style="COLOR: #5<span style="COLOR: #6&&&/concurrent-block&<span style="COLOR: #7&&<span style="COLOR: #8&/process-definition&<span style="COLOR: #9
流程定义之webinterface.xml
webinterface.xml&&1&?xml&version=&1.0&?&&&2&&3&!--&关于webinterface.xml如何定义,请严格按照nPdl规定&&4&&&&&只有需要人操作的节点,&也就是activity-state(包括StartState),&在该文件中才在需要进行定义,指定如何显示web表单等&--&&&5&web-interface&&&6&&&&7&&&!--&====================&--&&&8&&&!--&==&PROCESS&IMAGE&&==&--&&&9&&&!--&====================&--&&10&&&!--&定义该流程的流程图片&--&&11&&&image&name=&web/leavedemo.gif&&mime-type=&image/gif&&width=&510&&height=&560&&/&&12&13&&&!--&================&--&&14&&&!--&==&ACTIVITIES&==&--&&15&&&!--&================&--&&16&&&activity-state&name=&start&leave&request&&&17&&&&&!--定义该节点在流程图中的坐标--&&18&&&&&image-coordinates&&19&&&&&&&x1&<span style="COLOR: #5&/x1&&20&&&&&&&y1&<span style="COLOR: #&/y1&&21&&&&&&&x2&<span style="COLOR: #7&/x2&&22&&&&&&&y2&<span style="COLOR: #&/y2&&23&&&&&/image-coordinates&&24&&&&&!--逐个定义该节点fields的web显示方式,htmlformatter是委托类,可以充分利用其委托类的特性--&&25&&&&&field&attribute=&start&date&&&26&&&&&&&name&开始时间&/name&&27&&&&&&&description&在此处填写您想要在何时开始请假&/description&&28&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.DateInput,&NetBpm&&&&29&&&&&&&&&parameter&name=&dateFormat&&dd/MM/yyyy&/parameter&&30&&&&&&&/htmlformatter&&31&&&&&/field&&32&&&&&field&attribute=&end&date&&&33&&&&&&&name&结束时间&/name&&34&&&&&&&description&在此处填写您想要在何时结束请假&/description&&35&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.DateInput,&NetBpm&&&&36&&&&&&&&&parameter&name=&dateFormat&&dd/MM/yyyy&/parameter&&37&&&&&&&/htmlformatter&&38&&&&&/field&&39&&&&&field&attribute=&leave&days&&&40&&&&&&&name&请假天数(单位:天)&/name&&41&&&&&&&description&在此处填写您请假的天数(以后改进为系统自动计算)&/description&&42&&&&&&&htmlformatter&class=&NetBpm.Example.LeaveOfAbsence.TextIntergerInput,&NetBpm.Example.LeaveOfAbsence&&&&43&&&&&&&/htmlformatter&&44&&&&&/field&&45&&&&&field&attribute=&comment&&&46&&&&&&&name&请假理由&/name&&47&&&&&&&description&在此处填写您请假的理由或者其他需要说明的信息&/description&&48&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.TextAreaInput,&NetBpm&&&49&&&&&&&&&parameter&name=&rows&&<span style="COLOR: #&/parameter&&50&&&&&&&&&parameter&name=&cols&&<span style="COLOR: #&/parameter&&51&&&&&&&/htmlformatter&&52&&&&&/field&&53&&&/activity-state&&54&55&&&activity-state&name=&Request&Cancel&&&56&&&&&image-coordinates&&57&&&&&&&x1&<span style="COLOR: #7&/x1&&58&&&&&&&y1&<span style="COLOR: #6&/y1&&59&&&&&&&x2&<span style="COLOR: #0&/x2&&60&&&&&&&y2&<span style="COLOR: #8&/y2&&61&&&&&/image-coordinates&&62&&&&&field&attribute=&start&date&&&63&&&&&&&name&开始时间&/name&&64&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.DateLabel,&NetBpm&&&&65&&&&&&&&&parameter&name=&dateFormat&&dd/MM/yyyy&/parameter&&66&&&&&&&/htmlformatter&&67&&&&&/field&&68&&&&&field&attribute=&end&date&&&69&&&&&&&name&结束时间&/name&&70&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.DateLabel,&NetBpm&&&&71&&&&&&&&&parameter&name=&dateFormat&&dd/MM/yyyy&/parameter&&72&&&&&&&/htmlformatter&&73&&&&&/field&&74&75&&&/activity-state&&76&77&&&activity-state&name=&ChiefApprove&&&78&&&&&image-coordinates&&79&&&&&&&x1&<span style="COLOR: #3&/x1&&80&&&&&&&y1&<span style="COLOR: #0&/y1&&81&&&&&&&x2&<span style="COLOR: #5&/x2&&82&&&&&&&y2&<span style="COLOR: #3&/y2&&83&&&&&/image-coordinates&&84&&&&&field&attribute=&requester&&&85&&&&&&&name&申请人&/name&&86&&&&&&&description&提交请假申请的员工&/description&&87&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.PersonLabel,&NetBpm&&/&&88&&&&&/field&&89&&&&&field&attribute=&start&date&&&90&&&&&&&name&开始时间&/name&&91&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.DateLabel,&NetBpm&&&&92&&&&&&&&&parameter&name=&dateFormat&&dd/MM/yyyy&/parameter&&93&&&&&&&/htmlformatter&&94&&&&&/field&&95&&&&&field&attribute=&end&date&&&96&&&&&&&name&结束时间&/name&&97&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.DateLabel,&NetBpm&&&&98&&&&&&&&&parameter&name=&dateFormat&&dd/MM/yyyy&/parameter&&99&&&&&&&/htmlformatter&<span style="COLOR: #0&&&&&/field&<span style="COLOR: #1&&&&&field&attribute=&Chief&evaluation&result&&<span style="COLOR: #2&&&&&&&name&主管审批意见&/name&<span style="COLOR: #3&&&&&&&description&请审批该员工的请假单&/description&<span style="COLOR: #4&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.EvaluationInput&&/&<span style="COLOR: #5&&&&&/field&<span style="COLOR: #6&&&/activity-state&<span style="COLOR: #7<span style="COLOR: #8&&&&&activity-state&name=&BossApprove&&<span style="COLOR: #9&&&&&image-coordinates&<span style="COLOR: #0&&&&&&&x1&<span style="COLOR: #1&/x1&<span style="COLOR: #1&&&&&&&y1&<span style="COLOR: #6&/y1&<span style="COLOR: #2&&&&&&&x2&<span style="COLOR: #8&/x2&<span style="COLOR: #3&&&&&&&y2&<span style="COLOR: #0&/y2&<span style="COLOR: #4&&&&&/image-coordinates&<span style="COLOR: #5&&&&&field&attribute=&requester&&<span style="COLOR: #6&&&&&&&name&申请人&/name&<span style="COLOR: #7&&&&&&&description&提交请假申请的员工&/description&<span style="COLOR: #8&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.PersonLabel,&NetBpm&&/&<span style="COLOR: #9&&&&&/field&<span style="COLOR: #0&&&&&field&attribute=&chief&&<span style="COLOR: #1&&&&&&&name&主管审批&/name&<span style="COLOR: #2&&&&&&&description&同意该员工请假的主管领导&/description&<span style="COLOR: #3&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.PersonLabel,&NetBpm&&/&<span style="COLOR: #4&&&&&/field&<span style="COLOR: #5&&&&&field&attribute=&start&date&&<span style="COLOR: #6&&&&&&&name&开始时间&/name&<span style="COLOR: #7&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.DateLabel,&NetBpm&&&<span style="COLOR: #8&&&&&&&&&parameter&name=&dateFormat&&dd/MM/yyyy&/parameter&<span style="COLOR: #9&&&&&&&/htmlformatter&<span style="COLOR: #0&&&&&/field&<span style="COLOR: #1&&&&&field&attribute=&end&date&&<span style="COLOR: #2&&&&&&&name&结束时间&/name&<span style="COLOR: #3&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.DateLabel,&NetBpm&&&<span style="COLOR: #4&&&&&&&&&parameter&name=&dateFormat&&dd/MM/yyyy&/parameter&<span style="COLOR: #5&&&&&&&/htmlformatter&<span style="COLOR: #6&&&&&/field&<span style="COLOR: #7&&&&&field&attribute=&Boss&evaluation&result&&<span style="COLOR: #8&&&&&&&name&老板审批意见&/name&<span style="COLOR: #9&&&&&&&description&该员工请假天数大于10天,&请您审批该员工的请假单&/description&<span style="COLOR: #0&&&&&&&htmlformatter&class=&NetBpm.Workflow.Delegation.Impl.Htmlformatter.EvaluationInput&&/&<span style="COLOR: #1&&&&&/field&<span style="COLOR: #2&&&/activity-state&&<span style="COLOR: #3&/web-interface&<span style="COLOR: #4
流程定义之动态委托类
&&&&&&&&委托类包含在lib文件夹下的程序集中。因为委托类数目众多,这里仅贴出几个典型的委托类, 其源码工程若需要请看:&1. NetBpm.Example.LeaveOfAbsence.AutoSetAttributionsAction:该委托类设计为一个通用委托类,这里用来设置表识属性,如流程经过用户取消请假路径,则把RunTrace属性设置为requestercancel,供WhichWayDicision作判断用。
AutoSetAttributesAction&1using&S&2using&System.C&3using&log4&4using&NetBpm.Workflow.O&5using&NetBpm.Workflow.D&6using&NetBpm.Workflow.Delegation.I&7&8namespace&NetBpm.Example.LeaveOfAbsence&9{<span style="COLOR: #&&&&/**////&&summary&&<span style="COLOR: #&&&&///&通用Action类,&改类用来设置属性,&把值(action参数setValue)设置给属性(action参数attribute)<span style="COLOR: #&&&&///&by&Luben<span style="COLOR: #&&&&///&&/summary&<span style="COLOR: #&&&&public&class&AutoSetAttributesAction&:&IActionHandler<span style="COLOR: #&&&&{<span style="COLOR: #&&&&&&&&private&static&readonly&ILog&log&=&LogManager.GetLogger(typeof(AutoSetAttributesAction));<span style="COLOR: #&&&&&&&&private&static&readonly&AttributeExpressionResolver&_attributeExpressionR<span style="COLOR: #<span style="COLOR: #&&&&&&&&static&AutoSetAttributesAction()<span style="COLOR: #&&&&&&&&{<span style="COLOR: #&&&&&&&&&&&&_attributeExpressionResolver&=&AttributeExpressionResolver.I&&&&&&&&&&&&<span style="COLOR: #&&&&&&&&}<span style="COLOR: #<span style="COLOR: #&&&&&&&&public&void&Run(IActionContext&actionContext)<span style="COLOR: #&&&&&&&&{<span style="COLOR: #&&&&&&&&&&&&IDictionary&configuration&=&actionContext.GetConfiguration();<span style="COLOR: #<span style="COLOR: #&&&&&&&&&&&&String&setAttributeName&=&(String)configuration[&attribute&];<span style="COLOR: #&&&&&&&&&&&&String&setValue&=&(String)configuration[&setValue&];<span style="COLOR: #&&&&&&&&&&&&setValue&=&_attributeExpressionResolver.ResolveAttributeExpression(setValue,&actionContext);<span style="COLOR: #<span style="COLOR: #&&&&&&&&&&&&actionContext.SetAttribute(setAttributeName,&setValue);<span style="COLOR: #&&&&&&&&&&&&(&设置属性&&+&setAttributeName&+&&的值为:&&+&setValue);&<span style="COLOR: #&&&&&&&&}<span style="COLOR: #&&&&}<span style="COLOR: #}<span style="COLOR: #<span style="COLOR: #<span style="COLOR: #
&2. NetBpm.Example.LeaveOfAbsence.AnyOneJoin: 该委托主要用来设置激活父flow机制,这里是只要任何一条路径到达了join,则激活父flow,流程往下流。
AnyOneJoin&1using&log4&2using&NetBpm.Workflow.Execution.I&3using&System.C&4using&NetBpm.Workflow.D&5using&N&6&7namespace&NetBpm.Example.LeaveOfAbsence&8{&9&&&&/**////&&summary&<span style="COLOR: #&&&&///&只要任何一个Subflow到达了该Join,&就激活Parent&flow<span style="COLOR: #&&&&///&by&Luben<span style="COLOR: #&&&&///&&/summary&<span style="COLOR: #&&&&public&class&AnyOneJoin&:&IJoinHandler<span style="COLOR: #&&&&{<span style="COLOR: #&&&&&&&&private&static&readonly&ILog&log&=&LogManager.GetLogger(typeof(AnyOneJoin));<span style="COLOR: #<span style="COLOR: #&&&&&&&&public&bool&Join(IJoinContext&joinContext)<span style="COLOR: #&&&&&&&&{<span style="COLOR: #&&&&&&&&&&&&bool&reactivateParent&=&true;<span style="COLOR: #<span style="COLOR: #&&&&&&&&&&&&log.Debug(&flow&&&+&joinContext.GetFlow().Name&+&&&is&joining&:&&&+&reactivateParent);<span style="COLOR: #<span style="COLOR: #&&&&&&&&&&&&//&取消其他并行的flow。这里存在一个同步问题,如果此时在flow的执行者正在performacitivity,那么要考虑flow的锁定<span style="COLOR: #&&&&&&&&&&&&IEnumerator&iter&=&joinContext.GetOtherActiveConcurrentFlows().GetEnumerator();<span style="COLOR: #&&&&&&&&&&&&while&(iter.MoveNext())<span style="COLOR: #&&&&&&&&&&&&{<span style="COLOR: #&&&&&&&&&&&&&&&&FlowImpl&concurrentFlow&=&(FlowImpl)iter.C<span style="COLOR: #&&&&&&&&&&&&&&&&concurrentFlow.ActorId&=&null;<span style="COLOR: #&&&&&&&&&&&&&&&&concurrentFlow.EndNullable&=&System.DateTime.N<span style="COLOR: #&&&&&&&&&&&&}<span style="COLOR: #<span style="COLOR: #&&&&&&&&&&&&return&reactivateP<span style="COLOR: #&&&&&&&&}<span style="COLOR: #&&&&}<span style="COLOR: #}<span style="COLOR: #
&3. NetBpm.Example.LeaveOfAbsence.WhichWayDecision:该委托根据流程实际流过路径,根据标识属性RunTrace等进行走哪条边的抉择,如注释。
WhichWayDecision&1using&S&2using&NetBpm.Workflow.D&3&4&5namespace&NetBpm.Example.LeaveOfAbsence&6{&7&&&&/**////&&summary&&8&&&&///&根据流程走的路径,&&&&&9&&&&///&1)&主管或者老板批准&-&approve&:修改员工休假的总天数,设定发给用户E-Mail的信息。<span style="COLOR: #&&&&///&2)&主管或者老板否决&-&disapprove&:设定发给用户E-Mail的信息。<span style="COLOR: #&&&&///&3)&撤销&-&cancel&-设定发给用户E-Mail的信息。如果主管批准,要发给主管消息说明已经撤销。<span style="COLOR: #&&&&///&判断走哪一条路<span style="COLOR: #&&&&///&by&LuBen<span style="COLOR: #&&&&///&&/summary&<span style="COLOR: #&&&&public&class&WhichWayDecision&:&IDecisionHandler<span style="COLOR: #&&&&{<span style="COLOR: #&&&&&&&&public&String&Decide(IDecisionContext&decisionContext)<span style="COLOR: #&&&&&&&&{<span style="COLOR: #&&&&&&&&&&&&//&默认为apprvoe<span style="COLOR: #&&&&&&&&&&&&String&transitionName&=&&approve&;&&&&&&&&&&&<span style="COLOR: #<span style="COLOR: #&&&&&&&&&&&&//&runtrace是表示属性,在前面的流过的路径action中被设置<span style="COLOR: #&&&&&&&&&&&&String&runtrace&=&(String)decisionContext.GetAttribute(&RunTrace&);<span style="COLOR: #<span style="COLOR: #&&&&&&&&&&&&if&(runtrace.IndexOf(&disapprove&)&!=&-<span style="COLOR: #)<span style="COLOR: #&&&&&&&&&&&&{<span style="COLOR: #&&&&&&&&&&&&&&&&transitionName&=&&disapprove&;<span style="COLOR: #&&&&&&&&&&&&}<span style="COLOR: #&&&&&&&&&&&&else&if&(runtrace.Equals(&requestercancel&))<span style="COLOR: #&&&&&&&&&&&&{<span style="COLOR: #&&&&&&&&&&&&&&&&transitionName&=&&requestercancel&;<span style="COLOR: #&&&&&&&&&&&&}<span style="COLOR: #&&&&&&&&&&&&return&transitionN<span style="COLOR: #&&&&&&&&}<span style="COLOR: #&&&&}<span style="COLOR: #}<span style="COLOR: #<span style="COLOR: #
&&&&本文仅仅是一个示例,给大家提供一个运用nPdl定义NetBPM流程的参考,如果要把该流程投入现实中使用显然还需要做很多优化。该示例更多的是给大家展示流程定义中action可以定义多个, decision出来的transition可以到达同一条目的节点但名字却不一样等等. 示例中委托类的耦合性太高, 很多地方并不需要那样做, 如一个decision里面进行了2个判断: 判断是否大于10天, 判断是否审批同意, 这个完全可以拆分为两个独立的decision来做. 委托类设计成为高度可重用的, 耦合性低的通用类, 才是我们的目标.
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:7248次
排名:千里之外
原创:13篇

我要回帖

更多关于 请假工作流 的文章

 

随机推荐