本文整理汇总了C#中Role类的典型用法代码示例。如果您正苦于以下问题:C# Role类的具体用法?C# Role怎么用?C# Role使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Role类属于命名空间,在下文中一共展示了Role类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _Setup
private void _Setup()
{
Role role1 = new Role("Role1");
Role role2 = new Role("Role2");
Role role3 = new Role("Role3");
_roles = new List<Role> {role1, role2, role3};
}
示例2: AddPerson
public bool AddPerson(PersonModel person, Role role, string password)
{
if (person.Email == "")
return false;
return true;
}
示例3: RoleIndexModel
public RoleIndexModel(Role role)
{
this.Role = role;
IFunctionRepository repository = RepositoryFactory.GetRepository<IFunctionRepository, Function>();
IRoleRepository rolerepository = RepositoryFactory.GetRepository<IRoleRepository, Role>();
if (this.Role == null)
return;
this.AssignedFunctions = repository.FindByRole(this.Role).ToHashSet();
//找到父功能的权限
this.Role.Parent = rolerepository.FindParent(this.Role);
if (this.Role.Parent == null)
{
this.UnAssignedFuncitons = repository.FindAll().ToHashSet().Except(this.AssignedFunctions).ToHashSet();
}
else
{
this.UnAssignedFuncitons = repository.FindByRole(this.Role.Parent).ToHashSet().Except(this.AssignedFunctions).ToHashSet();
}
}
示例4: clone
public static Anysim clone(Role toClone, SimDescription actor)
{
Anysim newRole = new Anysim(toClone.Data, actor, toClone.RoleGivingObject);
newRole.StartRole();
return newRole;
}
示例5: Add
void Add(HttpContext context)
{
context.Response.ContentType = "application/json";
string name = context.Request["text"];
string msg = string.Empty;
if (!string.IsNullOrWhiteSpace(name)) {
try {
Guid id= System.Guid.NewGuid() ;
IList<Module> modules = RepositoryFactory<Modules>.Get().GetAll();
var query = from p in modules
select new Right { ModuleId = p.Id , Permission = 0 , RoleId = id };
Role obj = new Role { Id =id, Name = context.Server.UrlDecode(name),Rights=query.ToList() };
RepositoryFactory<RolesRepository>.Get().Add(obj);
context.Response.Write("{\"id\":\"" + obj.Id.ToString() + "\"}");
AppLog.Write("创建角色", AppLog.LogMessageType.Info,"name="+obj.Name,this.GetType());
} catch (Exception ex) {
AppLog.Write("创建角色 出错" , AppLog.LogMessageType.Error , "name=" + name , ex , this.GetType());
msg = ex.Message;
}
} else {
msg = "角色名不能为空";
}
if (!string.IsNullOrWhiteSpace(msg)) {
context.Response.Write("{\"msg\":\""+msg+"\"}");
}
}
示例6: SaveToDB
public void SaveToDB(int matchNo, DateTime matchDay, Location location, Role role, MatchDayShort matchDayShort, char matchType, int round, string row, DrivingInfo drivingInfo, Team homeTeam, Team awayTeam)
{
using (var conn = new MySqlConnection(ConnectionString))
{
conn.Open();
var locationId = GetLocationId(location);
var homeTeamId = GetTeamId(homeTeam);
var awayTeamId = GetTeamId(awayTeam);
var cmd = new MySqlCommand(
"INSERT INTO DbuGrabber_Game " +
"(GameNo, Round, GameDayShort, GameDay, Row, LocationId, HomeTeamId, AwayTeamId, Role, DrivingHours, DrivingMinutes, MatchType) " +
"VALUES " +
"(@GameNo, @Round, @GameDayShort, @GameDay, @Row, @LocationId, @HomeTeamId, @AwayTeamId, @Role, @DrivingHours, @DrivingMinutes, @MatchType)" +
" ON DUPLICATE KEY UPDATE Round = @Round, GameDayShort = @GameDayShort, GameDay = @GameDay, Row = @Row, LocationId = @LocationId, HomeTeamId= @HomeTeamId, AwayTeamId = @AwayTeamId, Role = @Role, DrivingHours = CASE WHEN (DrivingHours <> @DrivingHours) THEN @DrivingHours ELSE DrivingHours END, DrivingMinutes = CASE WHEN (DrivingMinutes <> @DrivingMinutes) THEN @DrivingMinutes ELSE DrivingMinutes END, MatchType= @MatchType, Sent = CASE WHEN (DrivingHours <> @DrivingHours OR DrivingMinutes <> @DrivingMinutes) THEN 0 ELSE Sent END", conn);
cmd.Parameters.AddWithValue("@GameNo", matchNo);
cmd.Parameters.AddWithValue("@Round", round);
cmd.Parameters.AddWithValue("@GameDayShort", matchDayShort.ToString());
cmd.Parameters.AddWithValue("@GameDay", matchDay);
cmd.Parameters.AddWithValue("@Row", row);
cmd.Parameters.AddWithValue("@LocationId", locationId);
cmd.Parameters.AddWithValue("@HomeTeamId", homeTeamId);
cmd.Parameters.AddWithValue("@AwayTeamId", awayTeamId);
cmd.Parameters.AddWithValue("@Role", role.ToString());
cmd.Parameters.AddWithValue("@DrivingHours", drivingInfo.Hours);
cmd.Parameters.AddWithValue("@DrivingMinutes", drivingInfo.Minutes);
cmd.Parameters.AddWithValue("@MatchType", matchType);
cmd.ExecuteNonQuery();
}
}
示例7: Given_all_required_fields_are_available_Then_create_user_method_creates_an_object
public void Given_all_required_fields_are_available_Then_create_user_method_creates_an_object()
{
//Given
Guid userId = Guid.NewGuid();
const long companyId = 33749;
const long siteId = 324234L;
var role = new Role() { Id = new Guid("BACF7C01-D210-4DBC-942F-15D8456D3B92") };
var user = new UserForAuditing() { Id = new Guid("B03C83EE-39F2-4F88-B4C4-7C276B1AAD99") };
var site = new Site() {Id = siteId};
var employeeContactDetail = new EmployeeContactDetail {Email = "[email protected]"};
var employee = new Employee {Forename = "Gary", Surname = "Green",ContactDetails = new List<EmployeeContactDetail> {employeeContactDetail}};
//When
var result = User.CreateUser(userId, companyId, role, site, employee, user);
//Then
Assert.That(result.Id, Is.EqualTo(userId));
Assert.That(result.CompanyId, Is.EqualTo(companyId));
Assert.That(result.Site.Id, Is.EqualTo(siteId));
Assert.That(result.Employee, Is.Not.Null);
Assert.That(result.Employee.Forename, Is.EqualTo("Gary"));
Assert.That(result.Employee.Surname, Is.EqualTo("Green"));
Assert.That(result.Employee.ContactDetails, Is.Not.Null);
Assert.That(result.Employee.ContactDetails.Count, Is.EqualTo(1));
Assert.That(result.Employee.ContactDetails[0].Email, Is.EqualTo("[email protected]"));
}
示例8: btnUpdate_Click
protected void btnUpdate_Click(object sender, EventArgs e)
{
string loginID = "1";
try
{
if (Session["Login"] == null) { Session["PreviousPage"] = HttpContext.Current.Request.Url.AbsoluteUri; Response.Redirect("../LoginPage.aspx"); }
loginID = ((Login)Session["Login"]).LoginID.ToString();
}
catch (Exception ex)
{ }
Role role = new Role();
role = RoleManager.GetRoleByID(Int32.Parse(Request.QueryString["roleID"]));
Role tempRole = new Role();
tempRole.RoleID = role.RoleID;
tempRole.RoleName = txtRoleName.Text;
tempRole.RoleDescription = txtRoleDescription.Text;
tempRole.AddedDate = DateTime.Now;
tempRole.AddedBy = loginID;
tempRole.ModifyDate = DateTime.Now;
tempRole.ModifyBy = loginID;
tempRole.RowStatusID = Int32.Parse(ddlRowStatus.SelectedValue);
bool result = RoleManager.UpdateRole(tempRole);
Response.Redirect("AdminRoleDisplay.aspx");
}
示例9: Get
public static IUser Get(Command cmd, string id, Role role)
{
string table = null;
string columns = null;
switch (role)
{
case Role.Administrator:
table = Administrator.Table;
columns = string.Join(",", Administrator.Properties.Select(p => p.Name).ToArray());
break;
case Role.Teacher:
table = Teacher.Table;
columns = string.Join(",", Teacher.Properties.Select(p => p.Name).ToArray());
break;
case Role.Student:
table = Student.Table;
columns = string.Join(",", Student.Properties.Select(p => p.Name).ToArray());
break;
}
string sql = string.Format(@"select {0} from {1} where lower(Id)=lower(@Id)", columns, table);
cmd.CommandText = sql;
cmd.AddParameter("@Id", id);
SqlCeDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
IUser user = ReaderFactory.Reader(reader, role.ToEntity()) as IUser;
reader.Close();
return user;
}
reader.Close();
return null;
}
示例10: TcpipClient
public TcpipClient(string host, int port, Role? requestRole)
{
this.host = host;
this.port = port;
this.RequestRole = requestRole;
Running = false;
}
示例11: LoginWindow
public LoginWindow(Role[] roles, ApplicationManager appMgr)
{
InitializeComponent();
this.appMgr = appMgr;
this.authRoles = roles;
this.isRoleAuth = true;
}
示例12: User
public User(string username, string password, Role role)
{
this.Username = username;
this.PasswordHash = password;
this.Role = role;
this.Bookings = new List<Booking>();
}
示例13: AddRole
/// <summary>
/// Add Role in database
/// </summary>
/// <param name="pRole"></param>
/// <returns>Role id</returns>
public int AddRole(Role pRole)
{
const string q = @"INSERT INTO [Roles]
([deleted], [code], [description], [role_of_loan], [role_of_saving], [role_of_teller])
VALUES(@deleted, @code, @description, @role_of_loan, @role_of_saving, @role_of_teller)
SELECT SCOPE_IDENTITY()";
using (SqlConnection conn = GetConnection())
{
using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
{
c.AddParam("@deleted", false);
c.AddParam("@code", pRole.RoleName);
c.AddParam("@description", pRole.Description);
c.AddParam("@role_of_loan", pRole.IsRoleForLoan);
c.AddParam("@role_of_saving", pRole.IsRoleForSaving);
c.AddParam("@role_of_teller", pRole.IsRoleForTeller);
pRole.Id = int.Parse(c.ExecuteScalar().ToString());
SaveRoleMenu(pRole);
SaveAllowedActionsForRole(pRole);
}
}
return pRole.Id;
}
示例14: Validate
public static Boolean Validate(String Token, Role pRole)
{
if (Role.ALL == pRole) {
return true;
}
var boolResult = false;
try {
using(var sessionManagerDal = new SessionManagerDAL(Util.GetConnection())) {
var lstObjSessionManager = sessionManagerDal.SessionManagerDAL_ById(Token).ToList();
if (lstObjSessionManager.Count() == 1) {
switch ((Role)lstObjSessionManager[0].UserRole) {
case Role.ADMIN: case Role.CLIENT:
boolResult = true;
break;
case Role.NONE:
boolResult = false;
break;
default:
throw new Exception("Not accessible, unknow userRole");
}
}
}
} catch (Exception ex) {
throw;
}
return boolResult;
}
示例15: AddRole
public void AddRole(Role role)
{
if (RoleExists(role))
throw new ArgumentException(TooManyRole);
entities.Roles.Add(role);
}