Beispiel #1
0
        //return all names of users and userprojects under teamleader
        public static List <UserProjectHelp> GetAllUserProjectUnderTeamLeaderWithNames(int idTeamLeader)
        {
            string         query = $"SELECT up.* FROM truth_time_ct.users_projects up join truth_time_ct.projects p on up.idProject=p.idProject and p.idTeamLeader={idTeamLeader} where p.active=true;";
            List <User>    allUsersUnderTeamLeader               = LogicUsers.GetAllUsersUnderTeamLeader(idTeamLeader);
            List <Project> allProjectUnderTeamLeader             = LogicProjects.GetProjectsUnderTeamLeader(idTeamLeader);
            Func <MySqlDataReader, List <UserProjectHelp> > func = (reader) =>
            {
                List <UserProjectHelp> users_projects_help = new List <UserProjectHelp>();
                while (reader.Read())
                {
                    users_projects_help.Add(new UserProjectHelp
                    {
                        IdUserProject    = (int)reader[0],
                        HoursProjectUser = (int)reader[1],
                        IdProject        = (int)reader[2],
                        IdUser           = (int)reader[3],
                        NameProject      = allProjectUnderTeamLeader.FirstOrDefault(p => p.IdProject == (int)reader[2]).ProjectName,
                        NameUser         = allUsersUnderTeamLeader.FirstOrDefault(p => p.IdUser == (int)reader[3]).UserName
                    });
                }
                return(users_projects_help);
            };

            return(DBUse.RunReader(query, func));
        }
Beispiel #2
0
        //get dictionary of users and hours that worked
        public static Dictionary <UserProject, double> GetUsersAndHoursThatWorkedOnProject(int idProject)
        {
            List <User> UsersOfProject = LogicUsers.GetUsersOfProject(idProject);
            Dictionary <UserProject, double> UsersAndHoursWorkedOnProject = new Dictionary <UserProject, double>();

            foreach (User user in UsersOfProject)
            {
                UserProject userProject = LogicUserProject.GetSpesipicUserProject(user.IdUser, idProject);
                UsersAndHoursWorkedOnProject.Add(userProject, GetDictionaryOfHoursThatUserWorkedOnProjectInPrecent(user.IdUser)[userProject]);
            }
            return(UsersAndHoursWorkedOnProject);
        }
Beispiel #3
0
        //add usersProjects To Specipic Project
        public static void CreateUsersProjectList(int idProject, int idTeamLeader)
        {
            List <User> allUsersUnderTeamLeader = LogicUsers.GetAllUsersUnderTeamLeader(idTeamLeader);
            UserProject userProject;

            foreach (User user in allUsersUnderTeamLeader)
            {
                userProject = new UserProject()
                {
                    IdProject        = idProject,
                    IdUser           = user.IdUser,
                    HoursProjectUser = 0
                };
                AddUserProject(userProject);
            }
        }
Beispiel #4
0
        //get all data on projects
        public static Dictionary <ProjectObject, List <UserObject> > GetAllDataOnProject(int idProject)
        {
            List <User>       UsersUnderSpecipicProject = LogicUsers.GetUsersOfProject(idProject);
            List <UserObject> userObjects   = new List <UserObject>();
            Project           project       = GetProjectByIdProject(idProject);
            ProjectObject     projectObject = new ProjectObject()
            {
                ProjectObjectHoursAllocatedProject = project.HoursForDevelopers + project.HoursForQA + project.HoursForUI_UX, ProjectObjectName = project.ProjectName
            };
            UserObject userObject = new UserObject();
            Dictionary <ProjectObject, List <UserObject> > allDataOnSpecipicProject = new Dictionary <ProjectObject, List <UserObject> >();

            foreach (var item in GetUsersAndHoursThatWorkedOnProject(idProject))
            {
                userObject.UserObjectName     = UsersUnderSpecipicProject.Find(p => p.IdUser == item.Key.IdUser).UserName;
                userObject.UserObjectSumHours = item.Value;
                userObject.UserObjectHoursAllocatedProject = item.Key.HoursProjectUser;
                userObjects.Add(userObject);
            }
            allDataOnSpecipicProject.Add(projectObject, userObjects);
            return(allDataOnSpecipicProject);
        }
Beispiel #5
0
        //graf of status hours that updated by users on all their projects by getting the teamLeader
        public static Dictionary <User, ObjectOfHours> GetUsersAndHoursThatUsersWorkedUnderTheirTeamLeader(int idTeamLeader)
        {
            List <User> UsersUnderTeamLeader = LogicUsers.GetAllUsersUnderTeamLeader(idTeamLeader);
            Dictionary <User, ObjectOfHours> TheUsersAndTheTimeThatWorked = new Dictionary <User, ObjectOfHours>();
            double sumHoursuserWorked = 0, sumHoursuserHadToWorked = 0;

            foreach (User user in UsersUnderTeamLeader)
            {
                sumHoursuserWorked      = 0;
                sumHoursuserHadToWorked = 0;
                foreach (var item in GetDictionaryOfHoursThatUserWorkedOnProjectInPrecent(user.IdUser))
                {
                    sumHoursuserWorked      += item.Value;
                    sumHoursuserHadToWorked += item.Key.HoursProjectUser;
                }
                TheUsersAndTheTimeThatWorked.Add(user, new ObjectOfHours()
                {
                    sumHoursuserHadToWorked = sumHoursuserHadToWorked, sumHoursuserWorked = sumHoursuserWorked
                });
            }
            return(TheUsersAndTheTimeThatWorked);
        }