Exemple #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());
        }
Exemple #2
0
        void ITeamService.AssociateMemberAccount(Team team, Member member, Account account)
        {
            Assert.IsValid(team);
            Assert.IsValid(member);
            Assert.IsValid(account);
            var memberToAssociateAccount = team.GetMember(member.ID);

            Assert.IsNotNull(memberToAssociateAccount);

            //HACK:为了确保设置成员的关联账号时,账号必须在团队内唯一,所以这里通过锁来进行同步控制
            this._locker.Require <Member>();
            Assert.IsNull(_teamRepository.FindMemberBy(team, account));

            memberToAssociateAccount.Associate(account);
            _teamRepository.Update(team);

            _log.InfoFormat("将团队【id:{0},name:{1}】中的成员【id:{2},name:{3},email:{4}】与账号【id:{5},name:{6}】建立了关联",
                            team.ID,
                            team.Name,
                            member.ID,
                            member.Name,
                            member.Email,
                            account.ID,
                            account.Name);
        }
Exemple #3
0
        private bool IsCreator(Teams.Team team, Teams.Task task, Account a)
        {
            var m = team.GetMember(task.CreatorMemberId);

            //TODO:由于Member可能被删除,teamtask可能找不到创建者?
            if (m == null || !m.AssociatedAccountId.HasValue)
            {
                return(false);
            }
            var account = _accountService.GetAccount(m.AssociatedAccountId.Value);

            return(account != null && account.ID == a.ID);
        }
Exemple #4
0
        private Teams.Member GetMember(Teams.Team team, int memberId)
        {
            var m = team.GetMember(memberId);

            if (m == null)
            {
                throw new CooperknownException(this.Lang().member_not_found);
            }
            if (m.TeamId != team.ID)
            {
                throw new CooperknownException(this.Lang().member_not_match_team);
            }
            return(m);
        }
Exemple #5
0
        void ITeamService.UnassociateMemberAccount(Team team, Member member)
        {
            Assert.IsValid(team);
            Assert.IsValid(member);

            var memberToUnAssociateAccount = team.GetMember(member.ID);

            Assert.IsNotNull(memberToUnAssociateAccount);

            memberToUnAssociateAccount.Associate(null);
            _teamRepository.Update(team);

            _log.InfoFormat("团队【id:{0},name:{1}】中的成员【id:{2},name:{3},email:{4}】的账号关联信息被取消",
                            team.ID,
                            team.Name,
                            member.ID,
                            member.Name,
                            member.Email);
        }