WEB开发网
开发学院软件开发C语言 在WF中使用角色 阅读

在WF中使用角色

 2010-10-01 08:24:44 来源:WEB开发网   
核心提示: 2.事件接口如下:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Workflow.Activities;namespaceCaryWFRole{[External

2.事件接口如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Workflow.Activities;

namespace CaryWFRole
{
  [ExternalDataExchangeAttribute()]
  public interface ISearchBookService
  {
    event EventHandler<BookEventArgs> SearchBook;
  }
}

3.实现该接口,代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Principal;

namespace CaryWFRole
{
  public class SearchBookService:ISearchBookService
  {
    public event EventHandler<BookEventArgs> SearchBook;

    public void OnSearchRequest(Guid instanceId, string id,string name,string author, IIdentity identity)
    {
      BookEventArgs args = new BookEventArgs(instanceId, id, name, author);
      String securityIdentifier = null;
      WindowsIdentity windowsIdentity = identity as WindowsIdentity;

      if (windowsIdentity != null && windowsIdentity.User != null)
        securityIdentifier = windowsIdentity.User.Translate(typeof(NTAccount)).ToString();
      else if (identity != null)
        securityIdentifier = identity.Name;

      args.Identity = securityIdentifier;
      Console.WriteLine("return book by: {0}", identity.Name);

      if (SearchBook != null)
        SearchBook(null, args);
    }
  }
}

上一页  1 2 3 4  下一页

Tags:WF 使用 角色

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接