本文整理汇总了C#中Role.GetActionItems方法的典型用法代码示例。如果您正苦于以下问题:C# Role.GetActionItems方法的具体用法?C# Role.GetActionItems怎么用?C# Role.GetActionItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Role
的用法示例。
在下文中一共展示了Role.GetActionItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveAllowedActionsForRole
private void SaveAllowedActionsForRole(Role pRole)
{
foreach (KeyValuePair<ActionItemObject, bool> kvp in pRole.GetActionItems())
{
string q = @"SELECT allowed
FROM AllowedRoleActions
WHERE action_item_id = @actionId
AND role_id = @roleId";
using (SqlConnection conn = GetConnection())
{
using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
{
c.AddParam("@roleId", pRole.Id);
c.AddParam("@actionId", kvp.Key.Id);
using (OpenCbsReader r = c.ExecuteReader())
{
if (r != null)
{
if (!r.Empty)
{
r.Read();
bool oldValue = r.GetBool("allowed");
if (oldValue != kvp.Value)
{
menuItemManager.UpdateAllowedItem(pRole.Id, kvp.Key.Id, kvp.Value);
}
}
else
{
menuItemManager.AddAllowedItem(pRole.Id, kvp.Key.Id, kvp.Value);
}
}
}
}
}
}
}
示例2: _SaveAllowedActionsForRole
private void _SaveAllowedActionsForRole(Role pRole)
{
foreach (KeyValuePair<ActionItemObject, bool> kvp in pRole.GetActionItems())
{
string sqlText = @"SELECT allowed FROM AllowedRoleActions
WHERE action_item_id [email protected] AND role_id = @roleId";
using (SqlCommand sqlCommand = new SqlCommand(sqlText, DefaultConnection))
{
DatabaseHelper.InsertInt32Param("@roleId", sqlCommand, pRole.Id);
DatabaseHelper.InsertInt32Param("@actionId", sqlCommand, kvp.Key.Id);
SqlDataReader reader = sqlCommand.ExecuteReader();
if (reader != null)
{
if (reader.HasRows)
{
reader.Read();
bool oldValue = DatabaseHelper.GetBoolean("allowed", reader);
reader.Close();
if (oldValue != kvp.Value)
{
UpdateAllowedActionItem(pRole.Id, kvp.Key.Id, kvp.Value);
}
}
else
{
reader.Close();
AddAllowedActionItem(pRole.Id, kvp.Key.Id, kvp.Value);
}
}
}
}
}