Ejemplo n.º 1
0
 public User(string name, string username, string password, userRole role)
 {
     this.Name     = name;
     this.Username = username;
     this.Password = password;
     this.UserRole = role;
 }
Ejemplo n.º 2
0
        /// <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());
        }
Ejemplo n.º 3
0
        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");
        }
Ejemplo n.º 4
0
 /// <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;
 }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
        /// <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
            }
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
 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());
         }
     }
 }
Ejemplo n.º 10
0
        /// <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);
        }
Ejemplo n.º 11
0
        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());
                }
            }
        }
Ejemplo n.º 12
0
        /// <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);
        }
Ejemplo n.º 13
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);
            }
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
        /// <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);
                }
            }
        }
Ejemplo n.º 16
0
        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"));
            }
        }
Ejemplo n.º 17
0
        /// <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();
        }
Ejemplo n.º 18
0
 /// <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
 }
Ejemplo n.º 19
0
        /// <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);
                }
            }
        }
Ejemplo n.º 20
0
 /// <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));
 }
Ejemplo n.º 21
0
 /// <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;
 }
Ejemplo n.º 22
0
        /// <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;
        }
Ejemplo n.º 23
0
 /// <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
 }
Ejemplo n.º 24
0
 /// <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
 }
Ejemplo n.º 25
0
 /// <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);
 }
Ejemplo n.º 26
0
 /// <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);
 }
Ejemplo n.º 27
0
 /// <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;
 }
Ejemplo n.º 28
0
 /// <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);
 }
Ejemplo n.º 29
0
 /// <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);
 }
Ejemplo n.º 30
0
        /// <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;
        }
Ejemplo n.º 31
0
        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"));
            }
        }
Ejemplo n.º 32
0
 public List<string> getDefaultBadgesForRole(userRole Role)
 {
     return this.roleBadges[Role];
 }
Ejemplo n.º 33
0
 /// <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);
 }
Ejemplo n.º 34
0
 public List <string> getDefaultBadgesForRole(userRole Role)
 {
     return(this.roleBadges[Role]);
 }