本文整理汇总了C#中DotNetNuke.Security.Roles.RoleController.GetRoles方法的典型用法代码示例。如果您正苦于以下问题:C# RoleController.GetRoles方法的具体用法?C# RoleController.GetRoles怎么用?C# RoleController.GetRoles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Security.Roles.RoleController
的用法示例。
在下文中一共展示了RoleController.GetRoles方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadAllRoles
private void LoadAllRoles()
{
var rc = new RoleController();
ArrayList roles = rc.GetRoles();
foreach (RoleInfo role in roles)
{
if (role.PortalID == PortalId)
{
var li = new ListItem(role.RoleName, role.RoleID.ToString(CultureInfo.InvariantCulture));
lstItems.Items.Add(li);
}
}
}
示例2: GetUserRoles
private static string GetUserRoles()
{
if (HttpContext.Current != null && HttpContext.Current.User.Identity.IsAuthenticated)
{
var sb = new StringBuilder(128);
UserInfo ui = UserController.GetCurrentUserInfo();
var rc = new RoleController();
// Not sure why DNN methods that return roles don't consistently return RoleInfo objects. hk
if (ui.IsSuperUser)
{
foreach (RoleInfo role in rc.GetRoles())
{
sb.Append("'");
sb.Append(role.RoleName);
sb.Append("',");
}
}
else
{
string[] roles = rc.GetRolesByUser(ui.UserID, ui.PortalID);
foreach (string s in roles)
{
sb.Append("'");
sb.Append(s);
sb.Append("',");
}
}
// trim the last ,
if (sb.Length > 0)
{
sb.Length -= 1;
}
return sb.ToString();
}
return "'Everyone'"; // is this always 'Everyone'?
}
示例3: DisplayRoles
private void DisplayRoles()
{
// Get all the Roles
RoleController RoleController = new RoleController();
ArrayList colArrayList = RoleController.GetRoles();
// Create a ListItemCollection to hold the Roles
ListItemCollection colListItemCollection = new ListItemCollection();
// Add the Roles to the List
foreach (RoleInfo Role in colArrayList)
{
if (Role.PortalID == PortalId)
{
ListItem RoleListItem = new ListItem();
RoleListItem.Text = Role.RoleName;
RoleListItem.Value = Role.RoleID.ToString();
colListItemCollection.Add(RoleListItem);
}
}
// Add the Roles to the ListBox
ddlRole.DataSource = colListItemCollection;
ddlRole.DataBind();
}
示例4: GetRoleName
public static string GetRoleName(int RoleID)
{
if (Convert.ToString(RoleID) == glbRoleAllUsers)
{
return "All Users";
}
else if (Convert.ToString(RoleID) == glbRoleUnauthUser)
{
return "Unauthenticated Users";
}
Hashtable htRoles = null;
if (PerformanceSetting != PerformanceSettings.NoCaching)
{
htRoles = (Hashtable)DataCache.GetCache("GetRoles");
}
if (htRoles == null)
{
RoleController objRoleController = new RoleController();
ArrayList arrRoles;
arrRoles = objRoleController.GetRoles();
htRoles = new Hashtable();
int i;
for (i = 0; i <= arrRoles.Count - 1; i++)
{
RoleInfo objRole;
objRole = (RoleInfo)arrRoles[i];
htRoles.Add(objRole.RoleID, objRole.RoleName);
}
if (PerformanceSetting != PerformanceSettings.NoCaching)
{
DataCache.SetCache("GetRoles", htRoles);
}
}
return Convert.ToString(htRoles[RoleID]);
}
示例5: DisplayAdminRoleDropDown
private void DisplayAdminRoleDropDown()
{
// Get all the Roles
RoleController RoleController = new RoleController();
ArrayList colArrayList = RoleController.GetRoles();
// Create a ListItemCollection to hold the Roles
ListItemCollection colListItemCollection = new ListItemCollection();
// Add the Roles to the List
foreach (RoleInfo Role in colArrayList)
{
if (Role.PortalID == PortalId)
{
ListItem RoleListItem = new ListItem();
RoleListItem.Text = Role.RoleName;
RoleListItem.Value = Role.RoleID.ToString();
colListItemCollection.Add(RoleListItem);
}
}
// Add the Roles to the ListBox
ddlAdminRole.DataSource = colListItemCollection;
ddlAdminRole.DataBind();
// Get Admin Role
string strAdminRoleID = GetAdminRole();
try
{
// Try to set the role
ddlAdminRole.SelectedValue = strAdminRoleID;
}
catch
{
}
}