예제 #1
0
 public IHttpActionResult SaveTeamUsers(PostProjectTeam team)
 {
     ProjectUsers.Update(new ProjectUsers[] {
         team.AssetActor,
         team.AssetRep,
         team.Finance,
         team.Legal,
         team.PM
     });
     return(Ok());
 }
예제 #2
0
        public void ChangeProjectTeamMembers(string projectId, ProjectTeamMembers projectTeamMembers)
        {
            using (var scope = new TransactionScope())
            {
                #region update ProjectUsers
                var projectUsers = ProjectUsers.Search(e => e.ProjectId == projectId).AsNoTracking().ToList();
                foreach (var projectUser in projectUsers)
                {
                    switch (projectUser.RoleCode)
                    {
                    case ProjectUserRoleCode.AssetActor:
                        if (projectTeamMembers.AssetActor != null)
                        {
                            projectUser.UserAccount  = projectTeamMembers.AssetActor.UserAccount;
                            projectUser.UserNameENUS = projectTeamMembers.AssetActor.UserNameENUS;
                            projectUser.UserNameZHCN = projectTeamMembers.AssetActor.UserNameZHCN;
                        }
                        break;

                    case ProjectUserRoleCode.Finance:
                    case "Finance Team":
                        projectUser.UserAccount  = projectTeamMembers.Finance.UserAccount;
                        projectUser.UserNameENUS = projectTeamMembers.Finance.UserNameENUS;
                        projectUser.UserNameZHCN = projectTeamMembers.Finance.UserNameZHCN;
                        break;

                    case ProjectUserRoleCode.Legal:
                        if (projectTeamMembers.Legal != null)
                        {
                            projectUser.UserAccount  = projectTeamMembers.Legal.UserAccount;
                            projectUser.UserNameENUS = projectTeamMembers.Legal.UserNameENUS;
                            projectUser.UserNameZHCN = projectTeamMembers.Legal.UserNameZHCN;
                        }
                        break;

                    case ProjectUserRoleCode.PM:
                        projectUser.UserAccount  = projectTeamMembers.PM.UserAccount;
                        projectUser.UserNameENUS = projectTeamMembers.PM.UserNameENUS;
                        projectUser.UserNameZHCN = projectTeamMembers.PM.UserNameZHCN;
                        break;

                    case ProjectUserRoleCode.AssetRep:
                        projectUser.UserAccount  = projectTeamMembers.AssetRep.UserAccount;
                        projectUser.UserNameENUS = projectTeamMembers.AssetRep.UserNameENUS;
                        projectUser.UserNameZHCN = projectTeamMembers.AssetRep.UserNameZHCN;
                        break;

                    case ProjectUserRoleCode.AssetManager:
                        projectUser.UserAccount  = projectTeamMembers.AssetMgr.UserAccount;
                        projectUser.UserNameENUS = projectTeamMembers.AssetMgr.UserNameENUS;
                        projectUser.UserNameZHCN = projectTeamMembers.AssetMgr.UserNameZHCN;
                        break;

                    case ProjectUserRoleCode.CM:
                        projectUser.UserAccount  = projectTeamMembers.CM.UserAccount;
                        projectUser.UserNameENUS = projectTeamMembers.CM.UserNameENUS;
                        projectUser.UserNameZHCN = projectTeamMembers.CM.UserNameZHCN;
                        break;
                    }
                }

                ProjectUsers.Update(projectUsers.ToArray());


                #endregion

                #region update project tasks
                var projectTasks = TaskWork.Search(e => e.RefID == projectId &&
                                                   e.Status == TaskWorkStatus.UnFinish &&
                                                   e.ActivityName == "Start").AsNoTracking().ToList();

                foreach (var projectTask in projectTasks)
                {
                    UpdateProjectTaskUser(projectTask, projectTeamMembers);
                }

                UpdateProjectCreateUser(projectTeamMembers);

                TaskWork.Update(projectTasks.ToArray());
                #endregion

                #region update workflow tasks
                var workflowTasks = TaskWork.Search(e => e.RefID == projectId &&
                                                    e.Status == TaskWorkStatus.UnFinish &&
                                                    e.K2SN != null).ToList();

                ChangeProjectApprover(workflowTasks, projectTeamMembers);
                #endregion
                TaskWork.Update(workflowTasks.ToArray());

                scope.Complete();
            }
        }