在WF中使用角色
2010-10-01 08:24:44 来源:WEB开发网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);
}
}
}
更多精彩
赞助商链接