开发者学堂课程【低代码氚云应用开发课程:氚云丨开发课— 08 流程操作及组织机构管理】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/894/detail/14285
氚云丨开发课— 08 流程操作及组织机构管理
流程操作及组织机构管理
结束流程时执行特定的业务逻辑
示例:protected override void OnWorkflowInstanceStateChanged(H3.Workf
low.Instance.WorkflowInstanceState oldState, H3.Workflow.Instance.
WorkflowInstanceState newState)
//流程审批结束事件(先执行业务规则,在执行该方法)。if(oldState == H3.Workilow.Instance.WorkflowInstanceState.Run
ning && newState == H3.Workflow.Instance.WorkflowInstanceState.
Finished)
//执行业务代码逻辑
//流程审批结束后,重新激活事件(先执行业务规则,在执行该方
法)。if(oldState == H3.Workflow.Instance.WorkflowInstanceState.Fini
shed && newState == H3.Workflow.Instance.WorkflowInstanceState.
Running)
//执行业务代码逻辑base.OnWorkflowInstanceStateChanged(oldState, newState);
ected override void OnLoad(H3.SmartForm.LoadSmartFormResponse response)
base.OnLoad(response);
ected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartFormResponse response)
base.OnSubmit(actionName, postvalue, response);
ected override void OnWorkflowInstanceStateChanged(H3.Workflow.Instance.WorkflowInstanceState
e oldstate, H3.Workflow.Instance.WorkflowInstanceState newState)
//流程审批结束事件(先执行业务规则,在执行该方法)。if(oldstate == H3.Workflow.Instance.WorkflowInstanceState.Running && newState == H3.Workflow.Instance.WorkflowInstanceState.Finished)
//H3.DataModel.BizObject targetBiz=new H3.DataModel.BizObject(this.Engine,this.Engine.BizObjectManager.GetPublishedSchema("D60159908452
//targetBiz["userName"]-this.Request.BizObject["userName"];
//targetBiz["money"]-this.Request.BizObject["money"];
// targetBiz.Status=H3.DataModel.BizObjectStatus.Effective;
1/ targetBiz.Create();
if(double.Parse("0"* this.Request,Biz0bject["moner"1)f 100)
this.Request.BizObject.Remove();
//流程审批结束后,重新激活事件(先执行业务规则,在执行该方法)。if(oldstate =- H3.Workflow.Instance.WorkflowInstanceState.Finished && newState == H3.Workflow.Instance.WorkflowInstanceState.Running)
//执行业务代码逻辑base.OnWorkflowInstanceStatechanged(oldstate, newState);
流程操作
重新激活流程
示例:H3.Workflow.Messages.ActivatelnstanceMessage activiteinstanceMessage = new
H3.Workflow.Messages,ActivatelnstanceMessage(this.Request.Instanceld);
//传递参数为流
程实例 ID[this.Request.Engine.WorkflowInstanceManager.SendMessage(activiteinstanceMessage);
//
只会激活流程,并不会触发运行的节点
激活某个活动节点
示例:[H3.Workflow.Messages.ActivateActivityMessage activiteMessage = new
H3.Workflow.Messages.ActivateActivityMessage(this.Request.Instanceld,
"Activity3", H3.Workflow.Instance.Token.Unspecifiedld, new string0 0,
hull, false, H3.Workflow.Workltem.ActionEventType.Adjust);
//参数对应描述:流程实
例 ID,活动节点编码,令牌 ID,参与者,前驱令牌,是否检测入口条件,激活类型[this.Request.Engine.WorkflowlnstanceManager.SendMessage(activiteMessage);
//1.
不会取消正在运行的节点。2.进行中的流程才能激活调整。
取消某个活动节点
示例:H3.Workflow.Messages.CancelActivityMessage cancelMessage = new
3.Workflow.Messages.CancelActivityMessage(this.Request.Instanceld,
"Activity3", false);
this.Request.Engine.WorkilowInstanceManager.SendMessage(cancelMessage);
取消流程
示例:H3.Workflow.Messages.CancellnstanceMessage cancelMessage = new
H3.Workflow.Messages.CancellnstanceMessage(this.Request.Instanceld,false);
this.Request.Engine.WorkflowInstanceManager.SendMessage(cancelMessage)
结束流程
示例:H3.Workflow.Instance.WorkflowInstance instance = this.Request.Engin
e.WorkflowInstanceManager.GetWorkflowInstance(this.Request.Instan
celd);
//获取当前流程实例对象H3.Workflow.Messages.FinishInstanceMessage cancelMessage = new
H3.Workflow.Messages.FinishInstanceMessage(this.Request.Instancel
a,(inyinstance.rinaiokenia);
this,Beauest.Enaine.WorkflowInstanceManaaer,SendMessaae(cancelprotected override void OnLoad(H3.SmartForm.LoadSmartFormResponse response)
base.OnLoad(response);
protected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartFormResponse response)
if(actionName =="Submit"&& this.Request.Bizobject.Status =H3.DataModel.Bizobjectstatus.Effective)
base.Onsubmit(actionName, postValue, response);
protected override void OnWorkflowInstanceStateChanged(H3.Workflow.Instance.Workf1owInstanceState
oldState, H3.Workflow.Instance.WorkflowInstanceState newState)
//流程审批结束事件(先执行业务规则,在执行该方法)。if(oldState == H3.Workflow.Instance.WorkflowInstanceState.Running && newState == H3.Workflow.Instance.WorkflowInstanceState.Finished)
// H3.DataModel.BizObject targetBiz=new H3.DataModel.Biz0bject(this.Engine,this.Engine,BizObjectManager.GetpublishedSchema("D0015990845285c574547399f4b42e95d272;
// targetBiz["userName"]-this.Request.BizObject["userName"];
// targetBiz["money"]-this,Request.BizObject["money"];
// targetBiz.Status=H3.DataModel.BizObjectStatus.Effective;
// targetBiz.Create();
/1if(double.Parse("6"+ this.Request.BizObject["money"])< 100)
组织单元
查找组织单元
获取组织机构中角色清单及员工所在部门、员工拥有哪些角色等。如:选择员工后,自动查询员工所在部门并赋值给其他字段。
示例:
//获取所有角色分组H3.Organization.OrgRoleGroup[ groups = this.Request.Engine.Organi
zation.GetAllRoleGroups0;
//获取公司所有角色H3.Organization.OrgRolell allRoles = this.Request.Engine.Organizati
on.GetAlIRoles0;
//获取用户所在部门H3.Organization.Unit unit = this Request.Engine.Organization.GetPar
entUnit(this.Request.UserContext.Userld);
//获取用户所有角色H3.Organization.OrgRolell roles = this.Request.Engine.Organization.
GetUserRoles(this.Request.UserContext.Userld,true);
// 获取公司所有有效用户string[ userlds = this.Request.Engine.Organization.GetChildren(this.
Request.Engine.Organization.Company.Companyld, H3.Organization.
UnitType.User, true, H3.Organization.State.Active);
//根据用户 ID 获取用户对象H3.Organization.User user = Engine.Organization.GetUnit(this.Reque
st.UserContext.Userld) as H3.Organization.User;
//根据人员ld查询其所有的部门 ldH3.Organization.User user =(H3.Organization.User) this.Engine.Organ
ization.GetUnit("用户Id");
string0 plds = user.Parentlds;
//根据人员 id 第 N 级父部门,0是第一级,1是第二级,以此类推H3.Organization.Unit unit = this.Engine.Trganization.GetParentUnitBy
Level("用户Id", 1);
//根据部门 Id 获取其第 N 级父部门,0是第一级,1是第二级,以此类推H3.Organization.Unit unit = this.Engine.Organization.GetParentUnitBy
Level("部门ld", 1);
//判断一个部门是否是另一个部门的祖先部门,返回 true 表示是祖先部门bool isAncestor = this.Engine.Organization.IsAncestor("子孙部门ld",
“祖先部门ld");
//根据人员/部门 ID 获取人员/部门名称string.name=this,Engine.Organization.GetName(string id, H3.Organiz
ation,NameType type);
id:人员/部门的 ID
type:名称的类型H3.Organization.NameType.Name
名称H3.Organization.NameType.Path
组织路径,/Company/0U1/0U2
这种格式
H3.Organizatign.NameType.FullName 全名称,如果是用户则是:用户
名[用户编码];如果是 OU,则是:/Company/OU1/OU2 这种格式!protected override void Onsubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.Submit5martFormResponse response)
iflactionName =.IBedestT.
//不同意if(actionName.=="Submit"&&this.Reques!
Actitvity2"
//同意base.OnSubmit(actionName, postValue,_response);
oldState, H3.Workflow.Instance.WorkflowInstanceState newState)
//流程审批结束患件(先执行业务规则,在执行该方法2;if(oldstate == H3.Workflow.Instance.Workflowingtancestate.Running && newState == H3.Workflow.Instance.WorkflowInstanceState.Finished)
// H3.DataModel.Biz0bject targetBiz-new H3.DataModel.Biz0bject(this.Engine,this.Engine.Biz0bjectManager.GetPublishedSchema("D8015990845285c574547399f4b42e95d
// targetBiz["userName"]-this.Request.BizObject["userName"];
// targetBiz["money"]-this.Request.BizObject["money"];
ected sympol
"n class, struct, or interface member declarationlgof
ected symbol if in class, struct, or_interface member declaration[24]
ected symbol
{' in class, struct, or interface member declaration[29]
unexpected symbol,
[==' in class, struct, or interface member declaratign
'Unexpected symbol,'==',in class, struct, or interface member declaration
Unexpected symbol
'' in class, struct, or interface member declaration
结束流程
示例:H3.Workflow.Instance.Workflowlnstance instance = this.Request.Engin
e.WorkflowInstanceManager.GetWorkflowInstance(this.Request.Instan
celd);
//获取当前流程实例对象H3.Workflow.Messages.FinishInstanceMessage cancelMessage = new
H3.Workflow.Messages.FinishInstanceMessage(this.Request.Instancel
d(int)instance.FinalTokenld);
this. Request.Engine.WorkflowInstanceManager.SendMessage(cancelM
essage);
结束流程时执行特定的业务逻辑
示例:protected override void OnWorkflowInstanceStateChanged(H3.Workf
low.Instance.WorkflowInstanceState oldState, H3.Workflow.Instance.