角色:WebWorkflowRole

來源:互聯網
上載者:User
文章目錄
  • 一個例子
只有等待與宿主互動的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) 中

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.