이렇게하는 것은 간단합니다. 나는 대략적으로 해결책에 근거하여이 방법을 Ruurd Boeke's blog에 썼다. 가능한 이벤트 목록을 얻은 다음 사용자 역할에 의해 실행될 수 있는지 확인합니다. 그것은 주위의 일이지만, 여전히 잘 작동합니다.
public string[] GetTransistions(string strUser)
{
string[] strRoles = System.Web.Security.Roles.GetRolesForUser(strUser);
List<string> strActivity = new List<string>();
ReadOnlyCollection<WorkflowQueueInfo> queues = workflowInstance.GetWorkflowQueueData();
foreach (WorkflowQueueInfo info in queues)
{
if (!info.QueueName.Equals("SetStateQueue"))
{
foreach (string subscribedActivity in info.SubscribedActivityNames)
{
HandleExternalEventActivity heea = workflowInstance.GetWorkflowDefinition().GetActivityByName(subscribedActivity) as HandleExternalEventActivity;
#region check roles
if (heea.Roles != null)
{
foreach (WorkflowRole workflowRole in heea.Roles)
{
foreach (string strRole in strRoles)
{
if (workflowRole.Name.Equals(strRole))
{
strActivity.Add(heea.EventName);
//permissionLog += workflowRole.Name + " can perform " + heea.EventName + " Activity. ";
}
}
}
}
#endregion
}
}
}
return strActivity.ToArray();
}