1、工作流模板设计文档工作流模板设计文档By Donald zhou2003/2/12一设计目的 设计本工作流的模板,可以方便快速的生成工作流的应用系统,方便系统的升级维护。二设计思想 将特定的工作流系统和工作流系统的流程定义分开工作流系统的流程定义数据库 特定的工作流系统数据库调用流程定义信息三设计概述流程定义数据库(workflowdefine.nsf)1. 概述:对于一个工作流,我们定义其Activity(状态),Relation(状态间的联系),Mailnotify(邮件通知)。2. 表单:(1) WorkflowDefineProfile:是Profile。存储工作流定义数据库的服务器名
2、和路径。如果以后这个工作流定义的数据库位置发生改变,需要修改这个Profile。(具体方法见帮助文件)字段名类型备注ServerNameText , Editable存放工作流定义数据库的服务器名PathText , Editable存放工作流定义数据库的路径(2) Workflow:用来生成一个Workflow的文档,里面存储Workflow系统的信息字段名类型备注WorkflowIdText , EditableWorkflowNameText , EditableWorkflowDescriptionText , Editable(3) Role:可以定义一些角色,比如在外出系统中,需要
3、总务来填写机票的一些信息,那我们可以定义一个角色(Role),将负责订票业务的总务放到里面。如果以后负责订票业务的人员发生变动,我们只要更改这个角色中的人员就可以了。字字段名类型备注WorkflowIdDialog list, Editable选择项公式:ServerName:=GetProfileField(WorkflowDefineProfile;ServerName);Path:=GetProfileField(WorkflowDefineProfile;Path);DbColumn(:nocache;ServerName:Path;AllWorkflow;1)RoleNameText
4、, EditableRoleMemberDialog list, EditableUse address dialog list for choices(4) Activity:定义每一个状态的ID号,名称等。最重要的是定义了Activity的Owner,即能编辑处在这一个状态的文档的人员。字段名类型备注WorkflowIdDialog list, Editable选择项公式为:ServerName:=GetProfileField(WorkflowDefineProfile;ServerName);Path:=GetProfileField(WorkflowDefineProfile;Pat
5、h);DbColumn(:nocache;ServerName:Path;AllWorkflow;1)ActivityIdText, EditableActivityNameText, EditableActivityDescriptionText, EditableActivityOwner选择项公式为:ServerName:=GetProfileField(WorkflowDefineProfile;ServerName);Path:=GetProfileField(WorkflowDefineProfile;Path);AllRoles:=RoleMemberOf+ +DbColumn(
6、;ServerName:Path;AllRoles;1);Field:AllRoles(5) Relation:定义文档由一个Activity转换到另一个Activity的条件,以及要发送的邮件。字段名类型备注WorkflowIdDialog list, Editable选择项公式为:ServerName:=GetProfileField(WorkflowDefineProfile;ServerName);Path:=GetProfileField(WorkflowDefineProfile;Path);DbColumn(:nocache;ServerName:Path;AllWorkflow
7、;1)RelationIdText, EditableConditionText, Editable条件的书写语法与Formula类似MailNotifyIdDialog list, Editable选择项公式为:ServerName:=GetProfileField(WorkflowDefineProfile;ServerName);Path:=GetProfileField(WorkflowDefineProfile;Path);DbColumn(:Nocache;ServerName:Path;MailNotify;2)(6) MailNotify:定义邮件的主题,收件人。字段名类型备注
8、WorkflowIdDialog list, Editable选择项公式为:ServerName:=GetProfileField(WorkflowDefineProfile;ServerName);Path:=GetProfileField(WorkflowDefineProfile;Path);DbColumn(:nocache;ServerName:Path;AllWorkflow;1)MailNotifyIdText, EditableRecipientsDialog list, Editable选择项公式为:ServerName:=GetProfileField(WorkflowDe
9、fineProfile;ServerName);Path:=GetProfileField(WorkflowDefineProfile;Path);AllRoles:=RoleMemberOf+ +DbColumn(;ServerName:Path;AllRoles;1);Field:AllRolesSubjectText, Editable条件的书写语法与Formula类似注:以红颜色标明的字段的选择条件中,提供了两中形式的选择项,rolememberOf 和field 。这是自己定义的“伪公式”,在程序中将对这两种形式的公式进行计算。 3View:视图(Profile)中有一个Action
10、 EditProfile,用来编辑Profile.四设计概述-具体的工作流应用系统。这里以外出系统为例。(1.23.nsf)1. 概述:当员工因公司事务外出时,必须填写因公外出的申请单。外出类型分两种:Loacl 和Other Place。当外出类型是Other Place时,在送交直属主管签核前,需要由总务部门来填写机票和酒店信息。2. subform:(1) WorkflowInfo:存放表示当前文档的状态以及Owner的信息。其中有一个Authors的字段,用来控制谁可以编辑文档。字段名类型备注CurrentActivityIdText, Editable默认值:”01”CurrentA
11、ctivityNameText, Editable默认值:WorkflowId:=GetProfileField(WorkflowProfile;WorkflowId);ServerName:=GetProfileField(WorkflowProfile;ServerName);Path:=GetProfileField(WorkflowProfile;Path);temp:=DbLookup(;ServerName:Path;AllActivity;WorkflowId+-+CurrentActivityId;2);If(IsError(temp);Error;temp)CurrentAc
12、tivityOwnerAuthors, EditablePreviousActivityIdText, Editable前一个状态的IdPreviousActivityNameText, Editable前一个状态的名称(2) ForWrite:用来给员工填写外出的一些信息。字段名类型备注FillerText, Editable填表人。默认值:Name(CN;UserName)。RequesterDialog list, Editable默认值:Name(CN;UserName)+/sernet选择项:Use address dialog list for choicesDepartmentT
13、ext, Editable申请人的部门:默认值:xuser:= requester;xview:=($VIMPeople);temp:=Name(CN; Trim(DbLookup(;Subset(DbName;1):names.nsf;xview;xuser;department);If(IsError(temp);Error;temp)StartDate,StartTime ,EndDate ,EndTime,Date/timeHoursNumber, Editable输入验证:If(hours=0;Failure(假期的时间不能为0);Success)TripTypeRadio butt
14、on,Editable选择项:Local和OtherPlace(3) ForRead:用来显示员工填写的外出信息。字段名类型备注FillerText, ComputedValue:FillerRequesterDialog list, ComputedValue :RequesterDepartmentText, ComputedValue: DepartmentStartDate,StartTime ,EndDate ,EndTime,Date/time, ComputedValue: StartDate,StartTime ,EndDate ,EndTime,HoursNumber, Co
15、mputed Value: HoursTripTypeRadio button,ComputedValue: TripType(4) GSWrite :总务用来填写机票酒店信息。字段名类型备注HotelText, EditableTicketText, Editable(5) GSRead字段名类型备注HotelText, ComputedValue: HotelTicketText, ComputedValue: Ticket3. Form(1) WorkflowProfile:是Profile,用来记录当前系统的编号,以及工作流定义数据库的路径。在使用这个工作流之前,管理员必须填写好该Pr
16、ofile。字段名类型备注WorkflowIdText, Editable表示当前这个工作流的IdServerNameText, Editable表示工作流定义数据库的服务器名PathText, Editable表示工作流定义数据库的路径(2) RequestForm:用来填写申请信息的表单,里面包括子表单和计算子表单。名称类型备注“WorkflowInfo”SubformComputed subform计算公式为:If(CurrentActivityName=FillRequestForm;ForWrite;ForRead)Computed subform计算公式为:If(CurrentAc
17、tivityName=GSOperation;GSWrite;GSRead)Manager1Dialog list,Editable默认值为:xuser:= requester;xview:=($VIMPeople);temp:=Name(CN; Trim(DbLookup(:nocache;Subset(DbName;1):names.nsf;xview;xuser;Manager)+/sernet;If(IsError(temp);Error;temp)转换公式为:Name(CN;Manager1)Manager1OptionRadio button, Editable选择公式为:Yes,
18、No隐藏条件:CurrentActivityName!=Manager1SignManager1OptionReadText,computed计算公式为:Manager1OptionManager2Dialog list,EditableManager2OptionRadio button, Editable选择公式为:Yes,No隐藏条件:CurrentActivityName!=Manager2SignManager2OptionReadText,computed计算公式为:Manager2Option注:A.表单中还有字段Manager2,Manager2Option,anager2Op
19、tionRead,GeneralManager,GeneralManangerOption,GeneralManangerOptionRead与Manager1,Manager1Option,anager1OptionRead设置相似。B.表单中使用计算子表单的目的:我们要求填表人在填写申请单时候,只能填写外出的时间等信息,而机票信息是由总务来填写的。总务在填写机票信息时,不能更改已经由填表人填写好的外出信息。子表单计算公式为:If(CurrentActivityName=FillRequestForm;ForWrite;ForRead)和If(CurrentActivityName=GSOp
20、eration;GSWrite;GSRead)。这样只有在状态为FillRequestForm(填写外出申请单)时候,子表单为ForWrite,这个子表单里面的字段时Editable,其他状态时为ForRead,这个子表单里面的字段为Computed,且值为填写好的外出信息。同样的道理,只有在状态为GSOperation(总务填写外出信息)时候,是包含Editable类型的的字段的子表单(GSWrite),在其他的时候在包含Computed类型的字段的子表单(GSRead)。4. Action:整个系统公用一个Action”送下一步处理”,在读的状态下隐藏。公式:Command(ToolsRu
21、nMacro;ChangActivity);Command(FileSave); Command(FileCloseWindow)。5. Agent:ChangActivity:改变文档的状态.代码:(options):Option DeclareUse ChangeActivity(使用了代码库里的代码)(Declarations)Dim session As notessessionDim CurrentDocument As notesdocumentIntialize:Sub Initialize Dim send As Variant Set session =New notesse
22、ssion Set CurrentDocument=session.documentcontext Call ChangeActivity(session,CurrentDocument)End Sub 6. Script libraries:”ChangeActivity”(options):Option PublicOption Declare(Declarations)Dim CurrentDatabase As notesdatabaseDim WorkflowDefine As notesdatabase工作流定义的数据库Workflow的信息Dim WorkflowId As St
23、ringDim ServerName As StringDim Path As StringChangeActivity:Sub ChangeActivity(Session As notessession,CurrentDocument As notesdocument) By Donald 2003/1/22 功能:完成文档的状态转换 On Error Goto PrintError Dim Profile As notesdocument Dim CurrentActivityId As String Dim RelationCollection As notesdocumentcoll
24、ection Dim Relation As notesdocument Dim i As Integer Dim evaluateResult As Variant Dim ToActivityId As String Dim MailNotifyId As String Dim ToActivityName As String Dim RountCondition As String Dim tempOwner As Variant Dim Ownerlist As Variant Dim Mail As notesdocument 取得工作流的Profile文档,从中得到当前工作流系统的
25、编号以及工作流定义数据库的路径 Set CurrentDatabase=session.currentdatabase Set Profile=CurrentDatabase.GetProfileDocument(WorkflowProfile) WorkflowId=Profile.WorkflowId(0) ServerName=Profile.ServerName(0) Path=Profile.path(0) 取得工作流定义数据库 Set WorkflowDefine=session.getdatabase(ServerName,Path) 取得当前文档的状态编号 CurrentAct
26、ivityId=CurrentDocument.CurrentActivityId(0) 找下一个状态 Set RelationCollection=WorkflowDefine.search(Form=Relation&WorkflowId=+WorkflowId+&left(RelationId;2)=+CurrentActivityId+,Nothing,0) If RelationCollection.count1 Then Msgbox (工作流定义出错) Exit Sub Else For i=1 To RelationCollection.count Set Relation=R
27、elationCollection.getnthdocument(i) RountCondition=Trim(Relation.Condition(0) If RountCondition= Then没有流转条件 ToActivityId=Trim(Right(Relation.RelationId(0),2) MailNotifyId=Relation.MailNotifyId(0) Exit For Else evaluateResult=Evaluate(RountCondition,CurrentDocument) If evaluateResult(0) Then ToActivi
28、tyId=Trim(Right(Relation.RelationId(0),2) MailNotifyId=Relation.MailNotifyId(0) Exit For End If End If Next End If 将本状态的CurrentActivityId放到PreviousActivityId中, 将本状态的CurrentActivityName放到PreviousActivityName CurrentDocument.PreviousActivityId=CurrentDocument.CurrentActivityId(0) CurrentDocument.Previ
29、ousActivityName=CurrentDocument.CurrentActivityName(0) 计算下一个状态的Owner tempOwner=Evaluate(dblookup(;+ServerName+:+Path+;AllActivity;+WorkflowId+-+ToActivityId+;4) Ownerlist=FormulaCalculate(tempOwner(0),CurrentDocument) 将下一个状态的Owner放到CurrentActivityOwner中 下一个状态的ActivityId放到CurrentActivityId中 下一个状态的ActivityName
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1