本文整理汇总了C#中RoleType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# RoleType.ToString方法的具体用法?C# RoleType.ToString怎么用?C# RoleType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoleType
的用法示例。
在下文中一共展示了RoleType.ToString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShareDocument
public DocumentShare ShareDocument(Guid dlId, Guid usId, string message = "", RoleType linkRole = RoleType.Viewer)
{
if (dlId.Equals(Guid.Empty))
{
throw new ArgumentException("dlId is required but was an empty Guid", "dlId");
}
if (usId.Equals(Guid.Empty))
{
throw new ArgumentException("dlId is required but was an empty Guid", "usId");
}
switch (linkRole)
{
case RoleType.Owner:
case RoleType.Editor:
linkRole = RoleType.Editor;
break;
default:
linkRole = RoleType.Viewer;
break;
}
dynamic postData = new ExpandoObject();
postData.users = usId;
postData.message = message;
postData.baseUrl = ShareUrl;
postData.isPublic = "true";
postData.linkRole = linkRole.ToString().ToLower();
return HttpHelper.Put<DocumentShare>(VVRestApi.GlobalConfiguration.Routes.DocumentsIdShares, "", GetUrlParts(), this.ClientSecrets, this.ApiTokens, postData, dlId, usId);
}
示例2: CheckRole
/// <summary>
/// 检验当前登录用户的权限
/// </summary>
/// <param name="role"></param>
/// <returns></returns>
public bool CheckRole(RoleType role)
{
AdminUser user = GetUser();
CommonLoger.Info(role.ToString() + user.RoleType.ToString());
if (user == null || (int)user.RoleType != (int)role)
return false;
else
return true;
}
示例3: ShareDocument
public List<DocumentShare> ShareDocument(Guid dlId, List<Guid> usIdList, string message = "", RoleType linkRole = RoleType.Viewer)
{
if (dlId.Equals(Guid.Empty))
{
throw new ArgumentException("dlId is required but was an empty Guid", "dlId");
}
switch (linkRole)
{
case RoleType.Owner:
case RoleType.Editor:
linkRole = RoleType.Editor;
break;
default:
linkRole = RoleType.Viewer;
break;
}
var jarray = new JArray();
foreach (var usId in usIdList)
{
jarray.Add(new JObject(new JProperty("id", usId)));
}
dynamic postData = new ExpandoObject();
postData.users = jarray;
postData.message = message;
postData.baseUrl = ShareUrl;
postData.isPublic = "true";
postData.linkRole = linkRole.ToString().ToLower();
return HttpHelper.PutListResult<DocumentShare>(VVRestApi.GlobalConfiguration.Routes.DocumentsIdShares, "", GetUrlParts(), this.ClientSecrets, this.ApiTokens, postData, dlId);
}
示例4: AddPythonRoleCore
/// <summary>
/// Adds the given role to both config files and the service def.
/// </summary>
/// <param name="role"></param>
private void AddPythonRoleCore(RoleInfo role, RoleType type)
{
Dictionary<string, object> parameters = CreateDefaultParameters(role);
string scaffoldPath = Path.Combine(Path.Combine(scaffoldingFolderPath, Resources.PythonScaffolding), type.ToString());
Scaffold.GenerateScaffolding(scaffoldPath, Path.Combine(Paths.RootPath, role.Name), parameters);
}
示例5: AddRoleCore
/// <summary>
/// Adds the given role to both config files and the service def.
/// </summary>
private void AddRoleCore(String Scaffolding, RoleInfo role, RoleType type)
{
Dictionary<string, object> parameters = CreateDefaultParameters(role);
parameters[ScaffoldParams.NodeModules] = General.GetNodeModulesPath();
parameters[ScaffoldParams.NodeJsProgramFilesX86] = General.GetWithProgramFilesPath(Resources.NodeProgramFilesFolderName, false);
string scaffoldPath = Path.Combine(Path.Combine(scaffoldingFolderPath, Scaffolding), type.ToString());
Scaffold.GenerateScaffolding(scaffoldPath, Path.Combine(Paths.RootPath, role.Name), parameters);
}
示例6: GeneratePerson
private void GeneratePerson (XmlElement thisNode, RoleType role, Person lead)
{
XmlElement officerNode = thisNode.OwnerDocument.CreateElement("OFFICER");
thisNode.AppendChild(officerNode);
officerNode.SetAttribute("personid", lead.PersonId.ToString());
officerNode.SetAttribute("type", role.ToString());
if (localCall)
{
officerNode.SetAttribute("email", lead.PartyEmail);
officerNode.SetAttribute("phone", lead.Phone);
officerNode.InnerText = lead.Name;
}
else
{
officerNode.SetAttribute("email", "[email protected]");
officerNode.SetAttribute("phone", "12345678");
officerNode.InnerText = "Hidden for remote call(" + lead.PersonId.ToString() + ")";
}
}
示例7: InitTestUsers
private void InitTestUsers(RoleType currentUserRole)
{
IPrincipal user = Substitute.For<IPrincipal>();
IIdentity identity = Substitute.For<IIdentity>();
user.Identity.Returns(identity);
user.Identity.Name.Returns(CurrentUserLogin);
user.IsInRole(Arg.Is<string>(p => p == currentUserRole.ToString())).Returns(true);
ViewContext.HttpContext.User.ReturnsForAnyArgs(user);
Target.SetFakeControllerContext(ViewContext.HttpContext);
UsersManagement.GetByEmail(CurrentUserLogin).Returns(new User()
{
Email = CurrentUserLogin,
Roles = new Role[] { new Role() { Id = (int)currentUserRole } }
});
}
示例8: CreateGroup
/// <summary>
/// Create group if it's not existed
/// </summary>
/// <param name="collGroup"></param>
/// <param name="groupName"></param>
/// <param name="oWebsite"></param>
/// <param name="clientContext"></param>
/// <param name="roleType"></param>
/// <param name="users"></param>
private static void CreateGroup(GroupCollection collGroup, string groupName, Web oWebsite, ClientContext clientContext, RoleType roleType, List<FieldUserValue> users)
{
try
{
Group grp = collGroup.Where(g => g.Title == groupName).FirstOrDefault();
oWebsite.BreakRoleInheritance(true, false);
if (grp == null)
{
GroupCreationInformation groupCreationInfo = new GroupCreationInformation();
groupCreationInfo.Title = groupName;
groupCreationInfo.Description = "Use this group to grant people " + roleType.ToString() + " permissions to the SharePoint site: " + oWebsite.Title;
grp = oWebsite.SiteGroups.Add(groupCreationInfo);
//clientContext.Load(grp);
//clientContext.ExecuteQuery();
}
// grant role to group
RoleDefinitionBindingCollection collRoleDefinitionBinding = new RoleDefinitionBindingCollection(clientContext);
RoleDefinition oRoleDefinition = oWebsite.RoleDefinitions.GetByType(roleType);
collRoleDefinitionBinding.Add(oRoleDefinition);
oWebsite.RoleAssignments.Add(grp, collRoleDefinitionBinding);
clientContext.Load(grp, group => group.Title);
clientContext.Load(oRoleDefinition, role => role.Name);
clientContext.ExecuteQuery();
// Add users to newly created group or existing group
AddUsertoGroup(grp, clientContext, users);
}
catch (Exception e)
{
Console.Write(e.Message);
}
}
示例9: GetPlayerKey
public static string GetPlayerKey(RoleType roleType, string keyPostfix)
{
return string.Format("{0}_{1}", roleType.ToString().ToLower(), keyPostfix);
}
示例10: AddRoleCore
/// <summary>
/// Adds the given role to both config files and the service def.
/// </summary>
/// <param name="role"></param>
private void AddRoleCore(RoleInfo role, RoleType type)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters[ScaffoldParams.Role] = role;
parameters[ScaffoldParams.Components] = Components;
parameters[ScaffoldParams.RoleName] = role.Name;
parameters[ScaffoldParams.InstancesCount] = role.InstanceCount;
parameters[ScaffoldParams.Port] = Components.GetNextPort();
parameters[ScaffoldParams.Paths] = Paths;
parameters[ScaffoldParams.NodeModules] = General.GetNodeModulesPath();
string scaffoldPath = Path.Combine(Path.Combine(scaffoldingFolderPath, Resources.NodeScaffolding), type.ToString());
Scaffold.GenerateScaffolding(scaffoldPath, Path.Combine(Paths.RootPath, role.Name), parameters);
}
示例11: CreateRole
public int CreateRole (int personId, RoleType roleType, int organizationId, int nodeId)
{
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
DbCommand command = GetDbCommand("CreatePersonRole", connection);
command.CommandType = CommandType.StoredProcedure;
AddParameterWithName(command, "personId", personId);
AddParameterWithName(command, "personRoleType", roleType.ToString());
AddParameterWithName(command, "organizationId", organizationId);
AddParameterWithName(command, "geographyId", nodeId);
return Convert.ToInt32(command.ExecuteScalar());
}
}
示例12: GetPeopleWithRoleType
public BasicPersonRole[] GetPeopleWithRoleType (RoleType r, int[] orgId, int[] geoId) // TODO: Refactor to use ConstructWhereClause
{
List<BasicPersonRole> retlist = new List<BasicPersonRole>();
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
string cmd = "SELECT " + personRoleFieldSequence + " WHERE Name= '" + r.ToString()+"'";
if (orgId.Length > 0)
cmd += " AND OrganzationId IN (" + JoinIds(orgId) + ")";
if (geoId.Length > 0)
cmd += " AND GeographyId IN (" + JoinIds(geoId) + ")";
DbCommand command = GetDbCommand(cmd, connection);
using (DbDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
retlist.Add(ReadPersonRoleFromDataReader(reader));
}
}
}
return retlist.ToArray();
}
示例13: InitTestUser
private void InitTestUser(RoleType currentUserRole, string login)
{
IPrincipal user = Substitute.For<IPrincipal>();
IIdentity identity = Substitute.For<IIdentity>();
user.Identity.Returns(identity);
user.Identity.Name.Returns(login);
user.IsInRole(Arg.Is<string>(p => p == currentUserRole.ToString())).Returns(true);
ViewContext.HttpContext.User.ReturnsForAnyArgs(user);
Target.SetFakeControllerContext(ViewContext.HttpContext);
}