示例#1
0
        private void AuthorityCheck(PermissionObjectType objectType, string guid, string treeNodeName, string userName = null)
        {
            var projectSeries = new ProjectSeries();

            if (objectType == PermissionObjectType.Task)
            {
                var task    = m_dbAdapter.Task.GetTask(guid);
                var project = m_dbAdapter.Project.GetProjectById(task.ProjectId);
                projectSeries = m_dbAdapter.ProjectSeries.GetById(project.ProjectSeriesId.Value);
                CheckIsAdmin(projectSeries, userName);
            }
            if (objectType == PermissionObjectType.TaskGroup)
            {
                var taskGroup = m_dbAdapter.TaskGroup.GetByGuid(guid);
                var project   = m_dbAdapter.Project.GetProjectById(taskGroup.ProjectId);
                projectSeries = m_dbAdapter.ProjectSeries.GetById(project.ProjectSeriesId.Value);
                CheckIsAdmin(projectSeries, userName);
            }
            if (objectType == PermissionObjectType.Project)
            {
                var project = m_dbAdapter.Project.GetProjectByGuid(guid);
                projectSeries = m_dbAdapter.ProjectSeries.GetById(project.ProjectSeriesId.Value);
                CheckIsAdmin(projectSeries, userName);
            }
            if (objectType == PermissionObjectType.ProjectSeries)
            {
                projectSeries = m_dbAdapter.ProjectSeries.GetByGuid(guid);
                CheckIsAdmin(projectSeries, userName);
            }
            CommUtils.Assert(projectSeries.CreateUserName.Equals(CurrentUserName, StringComparison.CurrentCultureIgnoreCase) ||
                             projectSeries.PersonInCharge.Equals(CurrentUserName, StringComparison.CurrentCultureIgnoreCase),
                             "当前用户[" + CurrentUserName + "]没有修改[" + treeNodeName + "]的权限");
        }
        public void SetPermission(ProjectSeries projectSeries, Project project, string uid, PermissionObjectType objectType)
        {
            var adminUsernames = new List <string> {
                projectSeries.CreateUserName, projectSeries.PersonInCharge
            };

            adminUsernames = adminUsernames.Distinct(StringComparer.OrdinalIgnoreCase).ToList();

            var projectId   = project.ProjectId;
            var teamMembers = m_dbAdapter.TeamMember.GetByProjectId(projectId);
            var teamAdmins  = m_dbAdapter.TeamAdmin.GetByProjectId(projectId);

            //给[负责人和创建者]添加所有权限。
            foreach (var adminUsername in adminUsernames)
            {
                SetPermission(adminUsername, uid, objectType, new List <Permission>(), true, true, true);
            }

            //给[项目管理员]添加所有权限。
            foreach (var teamAdmin in teamAdmins)
            {
                SetPermission(teamAdmin.UserName, uid, objectType, new List <Permission>(), true, true, true);
            }

            //给[项目成员]添加其拥有的权限权限。
            foreach (var teamMember in teamMembers)
            {
                SetPermission(teamMember.UserName, uid, objectType, new List <Permission>(), teamMember.Read, teamMember.Write, teamMember.Execute);
            }
        }
示例#3
0
        private List <PermissionTree> GetProjectSeriesTreeData(ProjectSeries projectSeries)
        {
            var result = new List <PermissionTree>();

            result.Add(new PermissionTree
            {
                title    = projectSeries.Name,
                key      = projectSeries.Guid,
                type     = PermissionObjectType.ProjectSeries.ToString(),
                children = m_dbAdapter.Project.GetByProjectSeriesId(projectSeries.Id).ConvertAll(x => new PermissionTree
                {
                    title    = x.Name,
                    key      = x.ProjectGuid,
                    type     = PermissionObjectType.Project.ToString(),
                    children = m_dbAdapter.TaskGroup.GetByProjectId(x.ProjectId).ConvertAll(y =>
                                                                                            new PermissionTree
                    {
                        title    = y.Name,
                        key      = y.Guid,
                        type     = PermissionObjectType.TaskGroup.ToString(),
                        children = m_dbAdapter.Task.GetByTaskGroupId(y.Id).ConvertAll(task =>
                                                                                      new PermissionTree
                        {
                            title    = task.Description,
                            key      = task.ShortCode,
                            type     = PermissionObjectType.Task.ToString(),
                            children = new List <PermissionTree>()
                        })
                    })
                })
            });
            return(result);
        }
示例#4
0
 private void CheckIsAdmin(ProjectSeries projectSeries, string userName)
 {
     if (userName != null)
     {
         CommUtils.Assert(projectSeries.CreateUserName != userName && projectSeries.PersonInCharge != userName,
                          "检测到[{0}]是产品创建者/负责人,无法对其权限进行任何操作", userName);
     }
 }
示例#5
0
        public int RemoveByGuid(string guid)
        {
            var record = SelectSingle <ABSMgrConn.TableProjectSeries>("project_series_guid", guid);
            var obj    = new ProjectSeries(record);

            obj.RecordStatus = RecordStatus.Deleted;
            return(UpdateProjectSeries(obj));
        }
 public ProjectSeriesLogicModel(string userName, ProjectSeries projectSeries)
     : base(userName, null)
 {
     m_projectSeries = projectSeries;
 }
 public PermissionLogicModel(string userName, ProjectSeries projectSeries)
     : base(userName, null)
 {
     m_currentUserName = userName;
     m_projectSeries   = projectSeries;
 }
 //判断某个用户是否拥有修改权限的权限
 private bool IsAdmin(ProjectSeries projectSeries, string userName)
 {
     return(projectSeries.CreateUserName.Equals(userName, StringComparison.CurrentCultureIgnoreCase) ||
            projectSeries.PersonInCharge.Equals(userName, StringComparison.CurrentCultureIgnoreCase));
 }
 ////判断当前用户是否拥有修改权限的权限
 private bool IsAdmin(ProjectSeries projectSeries)
 {
     return(IsAdmin(projectSeries, CurrentUserName));
 }
示例#10
0
        public int UpdateProjectSeries(ProjectSeries projectSeries)
        {
            var projectSeriesTable = projectSeries.GetTableObject();

            return(m_db.Update(m_defaultTableName, m_defaultPrimaryKey, projectSeriesTable, projectSeries.Id));
        }