如何获取状态机工作流程中给定角色的可能转换列表?

发布于 2024-07-14 18:17:04 字数 201 浏览 3 评论 0原文

在给定的状态机工作流程中,我们如何找出给定角色的可能转换。 在我的场景中,只有某些角色有权执行某些活动。 我必须拿到那个清单。 辅助类 StateMachineWorkflowInstance 在这里没有帮助,因为它只是返回所有可能的转换,而忽略了参与者的角色。

任何帮助将不胜感激。

谢谢, 苏格拉底。

On a given state machine workflow, how do we find out the possible transitions for a given role. In my scenario, only certain roles have the permission to perform certain activities. I have to get that list. The helper class StateMachineWorkflowInstance isn't helpful here as it just returns all the possible transitions, ignoring the role of the actor.

Any help here would be appreciated.

Thanks,
Socratees.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风和你 2024-07-21 18:17:05

看起来没有直接的方法可以做到这一点。 我大致根据 Ruurd Boeke 的博客 上的解决方案编写了此方法。 我正在获取可能事件的列表,然后查看它们是否可以由用户角色执行。 这是一个解决办法,但仍然工作得很好。

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();
}

Looks like there is no straight forward way to do this. I wrote this method based roughly on the solution at Ruurd Boeke's blog . I'm getting the list of possible events, and then looking if they can be executed by the user role. It's a work around, but still works fine.

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();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文