角色:WebWorkflowRole

只有等待与宿主交互的Activity才有Roles属性可以设置

 

WebWorkflowRole使用ASP.NET的用户数据库,但所有数据操作不用人为干预




使用时,要添加对ASP.NET数据库的连接配置

 

App.config

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

 <connectionStrings>

    <add name="SqlServerConnection"

         connectionString="Integrated Security = SSPI;server=WXWINTER\SQLEXPRESS;database=aspnetdb" />

 </connectionStrings>

 <system.web>

         <roleManager enabled="true" defaultProvider="SqlProvider">

                   <providers>

                       <add name="SqlProvider" connectionStringName="SqlServerConnection" applicationName="ConsoleAppSample"

                            type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

              </providers>

         </roleManager>

     </system.web>

</configuration>

 




 

一个例子

外部事件

 

    [Serializable]

    public class 事件参数 : ExternalDataEventArgs

    {   private string 存值;

        public string 自定义属性

        {

            get

            {

                return this.存值;

            }

            set

            {

                this.存值 = value;

            }

        }

      

        public 事件参数() : base(Guid.NewGuid())

        {        }

 

        public 事件参数(Guid instanceId, string 值参数) : base(instanceId)

        {

              this.存值 = 值参数;

 

        }

    }

 

    [ExternalDataExchangeAttribute()]

    public interface 外部事件接口

    {

        event EventHandler<事件参数> 一个外部事件;

    }

 

 

    public class 实现类 : 外部事件接口

    {

        public event EventHandler<事件参数> 一个外部事件;

 

        public void 触发事件(Guid instanceId, string 值参数, IIdentity 用户参数)

        {

            事件参数 e = new 事件参数(instanceId,值参数);

 

            String 安全标置 = null;

          

            WindowsIdentity 用户 = 用户参数 as WindowsIdentity;

 

            if (用户 != null && 用户.User != null)

            {

                安全标置 = 用户.User.Translate(typeof(NTAccount)).ToString();

            }

            else if (用户参数 != null)

            {

                安全标置 = 用户参数.Name;

            }

         

            e.Identity = 安全标置;

 

            Console.WriteLine("外部事件已执行,用户:", 用户参数.Name);

 

            if (一个外部事件 != null)

            {

                一个外部事件("sender:wxwinter", e);

            }

        }

    }

 

 

工作流中为结点设定角色

 Roles属性映射

public WorkflowRoleCollection
角色 = new System.Workflow.Activities.WorkflowRoleCollection();

 

            WebWorkflowRole 要添加的角色 = new WebWorkflowRole("aspnetdb数据库中的角色名");

            角色.Add(要添加的角色);

 

宿主中使用aspnetdb数据库中的用户触发外部事件

 Dim 用户 As System.Security.Principal.GenericIdentity = New Security.Principal.GenericIdentity("aspnetdb数据库中的角色名")

 外部对象.触发事件(当前操作的实例.InstanceId, DateTime.Now.ToString(), 用户)



本例中宿主是EXE程序

本例收于  WWF调试模板(3) 中

posted @ 2006-10-12 22:11  WXWinter(冬)  阅读(2416)  评论(5编辑  收藏  举报