public User(string name, string username, string password, userRole role) { this.Name = name; this.Username = username; this.Password = password; this.UserRole = role; }
/// <summary> /// Returns a string with every fuse right followed by char 2, for a certain user role. The fuserights for users with a club subscription are added if required. /// </summary> /// <param name="Role">The userRole enum value of the role to get the rights of.</param> /// <param name="hasClub">If the user has club subscription, then supply true.</param> public string getRightsForRole(userRole Role, bool hasClub) { StringBuilder ret = new StringBuilder(); try { List <string> rolesRights = this.roleRights[Role]; foreach (string Right in rolesRights) { ret.Append(Right); ret.Append("\x02"); } if (hasClub) { foreach (string Right in this.clubRights) { ret.Append(Right); ret.Append("\x02"); } } } catch {} return(ret.ToString()); }
protected void RadButtonCreate_Click(object sender, EventArgs e) { DALPortalDataContext dc = new DALPortalDataContext(); string username = (string)Session["username"]; string name = (string)Session["name"]; string[] items = new string[RadListBoxDestination.Items.Count]; for (int i = 0; RadListBoxDestination.Items.Count > i; i++) //RadListBoxItem item in RadListBoxDestination.Items) { items[i] = RadListBoxDestination.Items[i].Value; } Guid userId2 = dc.Users.Where(c => c.UserName.Equals(username)).Select(c => c.UserId).SingleOrDefault(); List <userRole> roles = dc.userRoles.Where(c => c.userId.Equals(userId2)).ToList(); for (int i = 0; roles.Count() > i; i++) { if (!items.Contains(roles[i].roleCode)) { // roles.RemoveAt(i); dc.userRoles.DeleteOnSubmit(roles[i]); } } for (int i = 0; items.Count() > i; i++) { if (!roles.Any(c => c.roleCode.Equals(items[i]))) { userRole roleUser = new userRole { userId = userId2, roleCode = items[i] }; dc.userRoles.InsertOnSubmit(roleUser); } } userSetting userSetting = dc.userSettings.Where(c => c.userId.Equals(userId2)).SingleOrDefault(); if (userSetting == null) { userSetting = new userSetting { userId = userId2 }; userSetting.companyCode = "ZW"; userSetting.defaultCultureCode = "nl"; userSetting.name = TextBoxName.Text; userSetting.siteAdmin = adminCheckBox.Checked; dc.userSettings.InsertOnSubmit(userSetting); } else { userSetting.siteAdmin = adminCheckBox.Checked; userSetting.name = TextBoxName.Text; userSetting.companyCode = companyDDL.SelectedValue; } dc.SubmitChanges(); Response.Redirect("~/Pages/UserAccounts.aspx"); }
/// <summary> /// Creates the inittial user when login in to the system /// </summary> /// <param name="userName"></param> /// <param name="userId"></param> /// <param name="userRole"></param> public clsUser(string userName, int userId, userRole userRole) { _username = userName; _userID = userId; _role = userRole; _logintime = DateTime.Now; currentUser = this; }
public void loadRoles() { Logging.Log("Initializing user roles..."); Database Database = new Database(true, false); DataTable dTable = new DataTable(); if (Database.Ready) { for (int roleID = 0; roleID <= 6; roleID++) { userRole Role = (userRole)roleID; Logging.Log("Role '" + Role.ToString() + "'"); // Role rights List <string> tmpList = new List <string>(); dTable = Database.getTable("SELECT fuseright FROM users_roles_fuserights WHERE minrole <= '" + roleID + "'"); foreach (DataRow dRow in dTable.Rows) { string Right = (string)dRow["fuseright"]; tmpList.Add(Right); //Logging.Log(" - FUSE right: " + Right); } this.roleRights.Add(Role, tmpList); // Role badges tmpList = new List <string>(); dTable = Database.getTable("SELECT badge FROM users_roles_badges WHERE minrole <= '" + roleID + "'"); foreach (DataRow dRow in dTable.Rows) { string Badge = (string)dRow["badge"]; tmpList.Add(Badge); //Logging.Log(" - Badge: " + Badge); } this.roleBadges.Add(Role, tmpList); //ObjectTree.Application.GUI.logSacredText(null); } //Logging.Log("FUSE rights for users with Club subscription:"); // Club rights dTable = Database.getTable("SELECT fuseright FROM users_club_fuserights"); foreach (DataRow dRow in dTable.Rows) { string Right = (string)dRow["fuseright"]; this.clubRights.Add(Right); //Logging.Log("- " + Right); } //ObjectTree.Application.GUI.logSacredText(null); Logging.Log("Initialized user roles."); } else { Logging.Log("Failed to initialize user roles, database was not contactable!", Logging.logType.commonWarning); } }
/// <summary> /// Returns a boolean that indicates if a given user role contains a certain fuse right. /// </summary> /// <param name="Role">The userRole enum value of the role to lookup.</param> /// <param name="hasClub">Indicates if to include rights for club subscribers.</param> /// <param name="Right">The fuse right to check.</param> public bool roleHasRight(userRole Role, bool hasClub, string Right) { bool Aye = this.roleRights[Role].Contains(Right); if (Aye == false && hasClub) { Aye = this.clubRights.Contains(Right); } return(Aye); }
/// <summary> /// Returns true if a given user role has access to this room. /// </summary> /// <param name="Role">A value of the Woodpecker.Game.Users.Roles.userRole enum representing the role to check.</param> public bool userRoleHasAccess(userRole Role) { roomCategoryInformation Category = ObjectTree.Game.Rooms.getRoomCategory(this.Information.categoryID); if (Category != null) { return(Category.userRoleHasAccess(Role)); } else { return(Role == userRole.Administrator); // Category does not exist, only administrator has access } }
public static userRole ToDto(UserRoleVM vm) { userRole dto = new userRole() { code = vm.Code, description = vm.Description, functionIds = string.Join(",", vm.FunctionIds), id = vm.Id, name = vm.Name, }; return(dto); }
public void addPrivateBadgesToList(int userID, userRole Role, ref List<string> lBadges) { Database db = new Database(false, true); db.addParameterWithValue("userid", userID); db.Open(); if (db.Ready) { DataTable dTable = db.getTable("SELECT badge FROM users_badges WHERE userid = @userid"); foreach (DataRow dRow in dTable.Rows) { lBadges.Add(dRow["badge"].ToString()); } } }
/// <summary> /// Returns a List of the type roomCategoryInformation with all the available flat categories for a given user role. /// </summary> /// <param name="Role">A value of the Woodpecker.Game.Users.Roles.userRole enum.</param> public List <roomCategoryInformation> getAvailableFlatCategories(userRole Role) { List <roomCategoryInformation> Categories = new List <roomCategoryInformation>(); foreach (roomCategoryInformation lCategory in mCategories.Values) { if (lCategory.userRoleCanPutFlat(Role)) { Categories.Add(lCategory); } } return(Categories); }
public void addPrivateBadgesToList(int userID, userRole Role, ref List <string> lBadges) { Database db = new Database(false, true); db.addParameterWithValue("userid", userID); db.Open(); if (db.Ready) { DataTable dTable = db.getTable("SELECT badge FROM users_badges WHERE userid = @userid"); foreach (DataRow dRow in dTable.Rows) { lBadges.Add(dRow["badge"].ToString()); } } }
/// <summary> /// Create a new user object. /// </summary> /// <param name="userName"></param> /// <param name="pwd"></param> /// <param name="userRole"></param> public static int addUser(string userName, string pwd, userRole userRole) { SqlCeCommand com = new SqlCeCommand("INSERT INTO tblUser VALUES(@p1,@p2,@p3,@p4)", connection.CON); com.Parameters.AddWithValue("@p1", getNextUserId()); com.Parameters.AddWithValue("@p2", userName); com.Parameters.AddWithValue("@p3", pwd); com.Parameters.AddWithValue("@p4", userRole); try { return(com.ExecuteNonQuery()); } catch (Exception e) { clsMessages.showMessage(clsMessages.msgType.error, e.Message); } return(0); }
public void leaveProject(int projectId) { int id = (int)Session["id"]; userRole role = (userRole)Session["userRole"]; if (role == userRole.projectManager) { this.leaveProjectPm(projectId); } else if (role == userRole.teamLeader) { this.Te_LeaveProject(projectId); } else if (role == userRole.juniorEngineer) { this.Je_LeaveProject(id, projectId); } }
public static UserRoleVM FromDto(userRole dto) { var vm = new UserRoleVM() { Code = dto.code, Description = dto.description, Id = dto.id, Name = dto.name, }; if (dto.functionIds != null && dto.functionIds.Length > 0) { var ids = dto.functionIds.Split(','); foreach (var id in ids) { vm.FunctionIds.Add(id); } } return(vm); }
/// <summary> /// Casts a room kick at the room, removing & alerting all the users below the caster rank from the room. /// </summary> /// <param name="casterRole">The Woodpecker.Game.Users.userRole enum value representing the role of the caster of the roomkick. All room users with a lower role will be removed from the room.</param> /// <param name="Message">The alert to sent to users that will be removed. No alert will be sent if this argument is supplied as a blank string.</param> public void castRoomKick(userRole casterRole, string Message) { int iCasterRole = (int)casterRole; lock (roomUsers) { List <Session> Victims = new List <Session>(); foreach (roomUser lRoomUser in roomUsers.Values) { if ((int)lRoomUser.Session.User.Role < iCasterRole) { Victims.Add(lRoomUser.Session); } } foreach (Session Victim in Victims) { Victim.kickFromRoom(Message); } } }
public ActionResult CreateUser(user_Info userInfo) { if (ModelState.IsValid) // this is check validity { using (Appoinment_Entities appoinment_Entities_db = new Appoinment_Entities()) { userLogin userLogin = new userLogin(); doctorDetail doctorDetails = new doctorDetail(); userRole userRole = new userRole(); appoinment_Entities_db.user_Info.Add(userInfo); appoinment_Entities_db.SaveChanges(); userLogin.FullName = userInfo.first_Name + userInfo.last_Name; userLogin.RoleID = userInfo.role_Id; var userName = appoinment_Entities_db.userRoles.Where( i => i.role_Id == userLogin.RoleID).SingleOrDefault().role_Name; userLogin.UserID = userInfo.user_Id; userLogin.UserName = userInfo.email_Address; userLogin.Password = userInfo.first_Name + "@123"; appoinment_Entities_db.userLogins.Add(userLogin); appoinment_Entities_db.SaveChanges(); if (userInfo.role_Id == 2) { doctorDetails.doctor_Id = userInfo.user_Id; doctorDetails.startTime = userInfo.doctorDetail.startTime; doctorDetails.endTime = userInfo.doctorDetail.endTime; appoinment_Entities_db.doctorDetails.Add(doctorDetails); appoinment_Entities_db.SaveChanges(); } } ViewBag.Message = "User Created Succesfully"; return(View("DisplayMessage")); } else { return(RedirectToAction("CreateUser", "Home")); } }
/// <summary> /// Returns a string with every fuse right followed by char 2, for a certain user role. The fuserights for users with a club subscription are added if required. /// </summary> /// <param name="Role">The userRole enum value of the role to get the rights of.</param> /// <param name="hasClub">If the user has club subscription, then supply true.</param> public string getRightsForRole(userRole Role, bool hasClub) { StringBuilder ret = new StringBuilder(); try { List<string> rolesRights = this.roleRights[Role]; foreach(string Right in rolesRights) { ret.Append(Right); ret.Append("\x02"); } if (hasClub) { foreach (string Right in this.clubRights) { ret.Append(Right); ret.Append("\x02"); } } } catch {} return ret.ToString(); }
/// <summary> /// Returns true if a given user role is allowed to put self-created user flats on this on this room category. /// </summary> /// <param name="Role">A value of the Woodpecker.Game.Users.Roles.userRole enum representing the role to check.</param> public bool userRoleCanPutFlat(userRole Role) { return(!this.isNode && !this.forPublicSpaces && Role >= minimumSetFlatCatRole); // This category is not just a node, not for public spaces and the user has the right to place rooms on this category }
/// <summary> /// Casts a room kick at the room, removing & alerting all the users below the caster rank from the room. /// </summary> /// <param name="casterRole">The Woodpecker.Game.Users.userRole enum value representing the role of the caster of the roomkick. All room users with a lower role will be removed from the room.</param> /// <param name="Message">The alert to sent to users that will be removed. No alert will be sent if this argument is supplied as a blank string.</param> public void castRoomKick(userRole casterRole, string Message) { int iCasterRole = (int)casterRole; lock (roomUsers) { List<Session> Victims = new List<Session>(); foreach (roomUser lRoomUser in roomUsers.Values) { if ((int)lRoomUser.Session.User.Role < iCasterRole) Victims.Add(lRoomUser.Session); } foreach (Session Victim in Victims) { Victim.kickFromRoom(Message); } } }
/// <summary> /// Returns a boolean that indicates if a give user role has access to a given badge. /// </summary> /// <param name="Role">The userRole enum value of the role to lookup.</param> /// <param name="Badge">The badge to check.</param> public bool roleHasBadge(userRole Role, string Badge) { return(this.roleBadges[Role].Contains(Badge)); }
/// <summary> /// Sets the minimum access role for this page. /// </summary> /// <param name="Role">A value of the Woodpecker.Game.Users.Roles.userRole enum.</param> public void setMinimumAccessRole(userRole Role) { minimumAccessRole = Role; }
/// <summary> /// Returns a List of the type roomCategoryInformation with all the available flat categories for a given user role. /// </summary> /// <param name="Role">A value of the Woodpecker.Game.Users.Roles.userRole enum.</param> public List<roomCategoryInformation> getAvailableFlatCategories(userRole Role) { List<roomCategoryInformation> Categories = new List<roomCategoryInformation>(); foreach(roomCategoryInformation lCategory in _Categories.Values) { if (lCategory.userRoleCanPutFlat(Role)) Categories.Add(lCategory); } return Categories; }
/// <summary> /// Returns true if a given user role has access to this room. /// </summary> /// <param name="Role">A value of the Woodpecker.Game.Users.Roles.userRole enum representing the role to check.</param> public bool userRoleHasAccess(userRole Role) { roomCategoryInformation Category = ObjectTree.Game.Rooms.getRoomCategory(this.Information.categoryID); if (Category != null) return Category.userRoleHasAccess(Role); else return (Role == userRole.Administrator); // Category does not exist, only administrator has access }
/// <summary> /// Returns true if a given user role is allowed to put self-created user flats on this on this room category. /// </summary> /// <param name="Role">A value of the Woodpecker.Game.Users.Roles.userRole enum representing the role to check.</param> public bool userRoleCanPutFlat(userRole Role) { return (!this.isNode && !this.forPublicSpaces && Role >= this.minimumSetFlatCatRole); // This category is not just a node, not for public spaces and the user has the right to place rooms on this category }
/// <summary> /// Returns true if a given user role has access to this room category and it's rooms. /// </summary> /// <param name="Role">A value of the Woodpecker.Game.Users.Roles.userRole enum representing the role to check.</param> public bool userRoleHasAccess(userRole Role) { return(Role >= minimumAccessRole); }
/// <summary> /// Returns true if a given user role has access to this room category and it's rooms. /// </summary> /// <param name="Role">A value of the Woodpecker.Game.Users.Roles.userRole enum representing the role to check.</param> public bool userRoleHasAccess(userRole Role) { return (Role >= this.minimumAccessRole); }
/// <summary> /// Sets the minimum access role for this page. /// </summary> /// <param name="Role">A value of the Woodpecker.Game.Users.Roles.userRole enum.</param> public void setMinimumAccessRole(userRole Role) { this.minimumAccessRole = Role; }
/// <summary> /// Returns a boolean that indicates if a give user role has access to a given badge. /// </summary> /// <param name="Role">The userRole enum value of the role to lookup.</param> /// <param name="Badge">The badge to check.</param> public bool roleHasBadge(userRole Role, string Badge) { return this.roleBadges[Role].Contains(Badge); }
/// <summary> /// Returns a boolean indicating if a given user role has access to this catalogue page. /// </summary> /// <param name="Role">The user role to check as a value of the Woodpecker.Game.Users.Roles.userRole enum.</param> public bool roleHasAccess(userRole Role) { return ((int)Role >= (int)this.minimumAccessRole); }
/// <summary> /// Returns a boolean that indicates if a given user role contains a certain fuse right. /// </summary> /// <param name="Role">The userRole enum value of the role to lookup.</param> /// <param name="hasClub">Indicates if to include rights for club subscribers.</param> /// <param name="Right">The fuse right to check.</param> public bool roleHasRight(userRole Role, bool hasClub, string Right) { bool Aye = this.roleRights[Role].Contains(Right); if (Aye == false && hasClub) Aye = this.clubRights.Contains(Right); return Aye; }
public ActionResult Create(ExpandedUserDTO paramExpandedUserDTO) { try { if (paramExpandedUserDTO == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var Email = paramExpandedUserDTO.Email.Trim(); var UserName = paramExpandedUserDTO.Email.Trim(); var Password = paramExpandedUserDTO.Password.Trim(); if (Email == "") { throw new Exception("No Email"); } if (Password == "") { throw new Exception("No Password"); } // UserName is LowerCase of the Email UserName = Email.ToLower(); // Create user ApplicationDbContext db = new ApplicationDbContext(); var objNewAdminUser = new ApplicationUser { UserName = UserName, Email = Email }; var AdminUserCreateResult = UserManager.Create(objNewAdminUser, Password); if (AdminUserCreateResult.Succeeded == true) { string strNewRole = Convert.ToString(Request.Form["Roles"]); if (strNewRole != "0") { // Put user in role userRole userRole = new userRole(); userRole.userKey = objNewAdminUser.Id; userRole.roleKey = strNewRole; db.userRoles.Add(userRole); db.SaveChanges(); UserManager.AddToRole(objNewAdminUser.Id, strNewRole); } return(Redirect("~/Admin")); } else { ViewBag.Roles = GetAllRolesAsSelectList(); ModelState.AddModelError(string.Empty, "Error: Failed to create the user. Check password requirements."); return(View(paramExpandedUserDTO)); } } catch (Exception ex) { ViewBag.Roles = GetAllRolesAsSelectList(); ModelState.AddModelError(string.Empty, "Error: " + ex); return(View("Create")); } }
public List<string> getDefaultBadgesForRole(userRole Role) { return this.roleBadges[Role]; }
/// <summary> /// Returns a boolean indicating if a given user role has access to this catalogue page. /// </summary> /// <param name="Role">The user role to check as a value of the Woodpecker.Game.Users.Roles.userRole enum.</param> public bool roleHasAccess(userRole Role) { return((int)Role >= (int)minimumAccessRole); }
public List <string> getDefaultBadgesForRole(userRole Role) { return(this.roleBadges[Role]); }