在WF中使用角色
2010-10-01 08:24:44 来源:WEB开发网4.工作流设计如下:
通过设置检索事件(HandleExternalEventActivity)活动的的Roles属性来控制,只有该角色集合的用户才有权限。在工作流中我们只允许会员才可以做
检索,代码如下:
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace CaryWFRole
{
public sealed partial class BookWorkflow : SequentialWorkflowActivity
{
public BookWorkflow()
{
InitializeComponent();
}
private WorkflowRoleCollection sAllowRoles = new WorkflowRoleCollection();
public WorkflowRoleCollection AllowRoles
{
get { return sAllowRoles; }
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
WebWorkflowRole role = new WebWorkflowRole("会员");
AllowRoles.Add(role);
}
private void handleExternalEventActivity1_Invoked(object sender, ExternalDataEventArgs e)
{
Console.WriteLine("查询成功");
}
}
}
更多精彩
赞助商链接