我正在寻找用户服务并找到了一个可爱的方法:
public void SaveUserType(IUserType userType, bool raiseEvents = true)
需要IUserType
。我可以在Github上看到的实现:
是内部的。
如何在Umbraco中以编程方式创建新的UserType
?
我也尝试过:
Roles.Provider.CreateRole("Test User Type");
答案 0 :(得分:0)
创建自己的类版本:
请务必添加参考:System.Runtime.Serialization
;
[Serializable]
[DataContract(IsReference = true)]
public class ProvisioningUserType : Entity, IUserType
{
[DataMember]
public string Alias { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public IEnumerable<string> Permissions { get; set; }
}
实例化并使用SaveUserType
方法
如果您收到此错误:字符串或二进制数据将是 截短的
然后您可能使用了错误的权限值。这些似乎 工作:
public class UserTypes
{
public const string CultureAndHostNames = "I";//"Culture and Hostnames";
public const string AuditTrail = "Z";//"Audit Trail";
public const string BrowseNode = "F";//"Browse Node";
public const string ChangeDocumentType = "7";//"Change Document Type";
public const string Copy = "O";//"Copy";
public const string Delete = "D";//"Delete";
public const string Move = "M";//"Move";
public const string Create = "C";//"Create";
public const string PublicAccess = "P";//"Public access";
public const string Publish = "U";//"Publish";
public const string Permissions = "R";//"Permissions";
public const string Rollback = "K";//"Rollback";
public const string SendToTranslation = "5";//"Send To Translation";
public const string Sort = "S";//"Sort";
public const string SendToPublish = "H";//"Send To Publish";
public const string Translate = "4";//"Translate";
public const string Update = "A";//"Update";
public const string UserGroupPermission = "œ";//"User Group Permissions";
}