Esempio n. 1
0
        //过渡设计,若后期有更多类似变更记录需求则重构
        private void ApplyOtherChanges(Teams.Team team, IEnumerable <ChangeLog> o)
        {
            foreach (var c in o)
            {
                try
                {
                    if (c.Flag == "project")
                    {
                        var p = this.GetProject(team, c.ID);

                        if (c.Name == "name")
                        {
                            p.SetName(c.Value);
                        }
                        else if (c.Name == "description")
                        {
                            p.SetDescription(c.Value);
                        }
                        this._teamService.Update(team);
                    }

                    if (this._log.IsInfoEnabled)
                    {
                        this._log.InfoFormat("执行变更{0}|{1}|{2}|{3}|{4}|{5}", c.Flag, c.Type, c.ID, c.Name, c.Value, c.CreateTime);
                    }
                }
                catch (Exception e)
                {
                    this._log.Error(string.Format("执行变更时异常:{0}|{1}|{2}|{3}|{4}", c.Flag, c.Type, c.ID, c.Name, c.Value), e);
                }
            }
        }
Esempio n. 2
0
        private Teams.Member GetMember(Teams.Team team, string memberId)
        {
            int id;

            int.TryParse(memberId, out id);
            return(this.GetMember(team, id));
        }
Esempio n. 3
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());
        }
Esempio n. 4
0
        private Sort[] ParseSortsByAssignee(Teams.Team team, Teams.Project project, params TaskInfo[] tasks)
        {
            var result = new List <Sort>();
            var sorts  = this.GetSorts(project, SORT_ASSIGNEE);

            var noAssignee = sorts.FirstOrDefault(o => o.Key == "0") ?? new Sort()
            {
                By = "assignee", Key = "0"
            };

            noAssignee.Name = this.Lang().noAssignee;
            this.RepairIndexs(noAssignee, this.Parse(tasks, o => (o as TeamTaskInfo).Assignee == null));
            result.Add(noAssignee);

            foreach (var m in team.Members)
            {
                var sort = sorts.FirstOrDefault(o =>
                                                o.Key == m.ID.ToString()) ?? new Sort()
                {
                    By = "assignee", Key = m.ID.ToString()
                };
                sort.Name = m.Name;
                this.RepairIndexs(sort, this.Parse(tasks
                                                   , o => (o as TeamTaskInfo).Assignee != null &&
                                                   (o as TeamTaskInfo).Assignee.id == m.ID.ToString()));
                result.Add(sort);
            }
            return(result.ToArray());
        }
Esempio n. 5
0
        private bool IsTeamOfCurrentAccount <T>(Teams.Team team) where T : Teams.Member
        {
            var a = this.Context.Current;

            return(team.Members.Any(o =>
                                    o.AssociatedAccountId.HasValue && o.AssociatedAccountId == a.ID && o is T));
        }
Esempio n. 6
0
        private Sort[] GetSorts(Teams.Team team, string tag, string by)
        {
            var key = this.GetSortKey(by, tag);

            return(!string.IsNullOrWhiteSpace(team.Settings[key])
                ? _serializer.JsonDeserialize <Sort[]>(team.Settings[key])
                : _emptySorts);
        }
Esempio n. 7
0
        //获取当前用户对应的成员信息
        private Teams.Member GetCurrentMember(Teams.Team team)
        {
            var m = team.Members.FirstOrDefault(o =>
                                                o.AssociatedAccountId.HasValue && o.AssociatedAccountId.Value == this.Context.Current.ID);

            if (m == null)
            {
                throw new CooperknownException(this.Lang().you_are_not_the_member_of_team);
            }
            return(m);
        }
Esempio n. 8
0
        private IEnumerable <Teams.Task> GetTasksById(Teams.Team team, string taskId)
        {
            long id;

            return(long.TryParse(taskId, out id)
                ? new List <Teams.Task>()
            {
                this._teamTaskService.GetTask(id)
            }
                : new List <Teams.Task>());
        }
Esempio n. 9
0
 private TeamInfo Parse(Teams.Team team)
 {
     return(new TeamInfo()
     {
         id = team.ID.ToString(),
         name = team.Name,
         projects = team.Projects.Select(o => this.Parse(o)).ToArray(),
         members = team.Members.Select(o => this.Parse(o)).ToArray(),
         //TODO:Team.Tags获取方式优化
         tags = this._teamService.GetTagsByTeam(team).ToArray()
     });
 }
Esempio n. 10
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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        public ActionResult CreateTeam(string name, string memberName, string memberEmail)
        {
            var a = this.Context.Current;
            var t = new Teams.Team(name);

            this._teamService.Create(t);

            //HACK:创建team同时将当前用户加入到该team
            var m = this._teamService.AddFullMember(
                !string.IsNullOrWhiteSpace(memberName) ? memberName : a.Name
                , !string.IsNullOrWhiteSpace(memberEmail) ? memberEmail : memberEmail
                , t, a);

            return(Json(t.ID));
        }
Esempio n. 13
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);
        }
Esempio n. 14
0
 private Sort[] ParseSortsByDueTime(Teams.Team team, Account account, params TaskInfo[] tasks)
 {
     return(this.ParseSortsByDueTime(this.GetSorts(account, team, SORT_DUETIME), tasks));
 }
Esempio n. 15
0
 private Sort[] ParseSortsByPriority(Teams.Team team, string tag, params TaskInfo[] tasks)
 {
     return(this.ParseSortsByPriority(this.GetSorts(team, tag, SORT_PRIORITY), tasks));
 }
Esempio n. 16
0
 private Sort[] ParseSortsByPriority(Teams.Team team, Account account, params TaskInfo[] tasks)
 {
     return(this.ParseSortsByPriority(this.GetSorts(account, team, SORT_PRIORITY), tasks));
 }
Esempio n. 17
0
 IEnumerable <Task> ITaskService.GetTrashedTasks(Team team)
 {
     return(_repository.FindTrashedTasksBy(team));
 }
Esempio n. 18
0
 private IEnumerable <Teams.Task> GetIncompletedTasksByKey(Teams.Team team, string key)
 {
     return(this._teamTaskService.GetIncompletedTasksByKey(team, key));
 }
Esempio n. 19
0
 IEnumerable <Task> ITaskService.GetIncompletedTasksByAccount(Team team, Account account)
 {
     return(_repository.FindBy(team, account, false));
 }
Esempio n. 20
0
 //判断当前用户是否是指定团队的成员
 private bool IsTeamOfCurrentAccount(Teams.Team team)
 {
     return(this.IsTeamOfCurrentAccount <Teams.Member>(team));
 }
Esempio n. 21
0
 private Sort[] ParseSortsByDueTime(Teams.Team team, string tag, params TaskInfo[] tasks)
 {
     return(this.ParseSortsByDueTime(this.GetSorts(team, tag, SORT_DUETIME), tasks));
 }
Esempio n. 22
0
 private Sort[] ParseTaskKeySortsByDueTime(Teams.Team team, string taskKey, params TaskInfo[] tasks)
 {
     return(this.ParseSortsByDueTime(_emptySorts, tasks));
 }
Esempio n. 23
0
 private IEnumerable <Teams.Task> GetIncompletedTasksByAccount(Teams.Team team, Account account)
 {
     return(this._teamTaskService.GetIncompletedTasksByAccount(team, account));
 }
Esempio n. 24
0
 private Sort[] GetSorts(Account a, Teams.Team team, string by)
 {
     return(this.GetSorts(a, this.GetSortKey(team, by)));
 }
Esempio n. 25
0
 private IEnumerable <Teams.Task> GetIncompletedTasksByTag(Teams.Team team, string tag)
 {
     return(this._teamTaskService.GetIncompletedTasksByTag(team, tag));
 }
Esempio n. 26
0
 private string GetSortKey(Teams.Team team, string by)
 {
     return(by + "_" + team.ID);
 }
Esempio n. 27
0
 IEnumerable <Task> ITaskService.GetTasksByAccount(Team team, Account account)
 {
     return(_repository.FindBy(team, account));
 }