Example #1
0
        private TeamTaskInfo[] Parse(IEnumerable <Teams.Task> tasks, Teams.Team team)
        {
            var a = this.Context.Current;

            Teams.Member m;
            //TODO:改用automapper做实体映射
            return(this.ParseTasks(() => new TeamTaskInfo(), (task, taskInfo) =>
            {
                var teamTask = task as Teams.Task;
                var teamTaskInfo = taskInfo as TeamTaskInfo;
                //创建人
                if ((m = team.GetMember(teamTask.CreatorMemberId)) != null)
                {
                    teamTaskInfo.Creator = this.Parse(m);
                }
                //执行人
                if (teamTask.AssigneeId.HasValue &&
                    (m = team.GetMember(teamTask.AssigneeId.Value)) != null)
                {
                    teamTaskInfo.Assignee = this.Parse(m);
                }
                //项目列表
                teamTaskInfo.Projects = teamTask.ProjectIds.Select(o => this.Parse(team.GetProject(o.ID))).ToArray();
                //是否可编辑 创建者或被分配者(执行人)
                teamTaskInfo.Editable = this.IsCreator(team, teamTask, a) || this.IsAssignee(teamTaskInfo, a);
                //评论
                teamTaskInfo.Comments = teamTask.Comments.Select(o => this.Parse(o)).ToArray();
            }, tasks.Select(o => o as Task)
                                   .ToArray())
                   .Select(o => o as TeamTaskInfo)
                   .ToArray());
        }
Example #2
0
        private Teams.Project GetProject(Teams.Team team, string projectId)
        {
            int id;
            var p = int.TryParse(projectId, out id) ? team.GetProject(id) : null;

            if (p == null)
            {
                throw new CooperknownException(this.Lang().project_not_found);
            }
            if (p.TeamId != team.ID)
            {
                throw new CooperknownException(this.Lang().project_not_match_team);
            }
            return(p);
        }