Beispiel #1
0
        public static void CheckDeadLine()
        {
            List <Project> deadProjects = new List <Project>();

            deadProjects = GetAllProjectsByDeadLine();
            foreach (Project proj in deadProjects)
            {
                User teamHead = new User();
                teamHead = LogicManager.GetUserDetails(proj.IdManager);
                List <User> workers = new List <User>();
                workers = LogicManager.GetAllWorkersByTeamId(proj.IdManager);
                LogicManager.sendMessage(teamHead, $"Hi {teamHead.UserName}, <br/>Project: {proj.ProjectName} is about to reach the deadline tomorrow. This project is under your responsibility, please hurry up!!!", "ATTENTION");
                foreach (User worker in workers)
                {
                    LogicManager.sendMessage(worker, $"Hi {worker.UserName}, <br/>Project: {proj.ProjectName} is about to reach the deadline tomorrow. you are subscribed to this project, please hurry up!!!", "ATTENTION");
                }
            }
        }
Beispiel #2
0
        public static bool AddProject(Project project)
        {
            //TODO:איזה דפרטמנט
            string dateBegin = project.DateBegin.ToString("yyy-MM-dd");
            string dateEnd   = project.DateEnd.ToString("yyy-MM-dd");
            string query     = $"INSERT INTO `task`.`project`(`name`,`startdate`,`Enddate`,`isFinished`,`customerName`,`DevHours`,`QAHours`,`UIUXHours`,`teamheadId`) VALUES('{project.ProjectName}','{dateBegin}','{dateEnd}',{project.IsFinish},'{project.CustomerName}',{project.DevHours},{project.QAHours},{project.UIUXHours},{project.IdManager}); ";

            if (DBAccess.RunNonQuery(query) == 1)
            {
                Project     currentProject = GetProjectDetails(project.ProjectName);
                List <User> workers        = new List <User>();
                workers = LogicManager.GetAllWorkersByTeamId(project.IdManager);
                workers.AddRange(project.workers);
                foreach (var item in workers)
                {
                    query = $"INSERT INTO `task`.`task`(`reservingHours`,`givenHours`,`idProject`,`idUser`)VALUES(0,0,{currentProject.ProjectId},{item.UserId });";
                    DBAccess.RunNonQuery(query);
                }
                return(true);
            }
            return(false);
        }
        public static List <ReportProject> CreateReportsProject(string viewName)
        {
            Func <MySqlDataReader, List <ReportProject> > func = (reader) =>
            {
                List <ReportProject> reportProject = new List <ReportProject>();
                while (reader.Read())
                {
                    reportProject.Add(ConvertReport.ConvertDBtoReport(reader));
                }
                return(reportProject);
            };
            List <ReportProject> reportProjects = DBAccess.RunReader(func, "report", new List <string>()
            {
                viewName
            }, new List <string>()
            {
                "viewName"
            });

            foreach (var item in reportProjects)
            {
                item.Project.workers = new List <UserWithoutPassword>();
                List <ProjectWorker> workerInProject = LogicManager.getUsersBelongProjects(item.Project.ProjectId);
                var workerInProjectGroup             = workerInProject.GroupBy(p => p.User.DepartmentId);

                foreach (var departmentWorkers in workerInProjectGroup)
                {
                    item.DepartmentUser.Add(new DepartmentUser()
                    {
                        Id = departmentWorkers.Key, Users = departmentWorkers.Select(p => p.User).ToList(), Department = departmentWorkers.First().User.DepartmentUser.Department
                    });
                }
            }

            return(reportProjects);
        }