Exemplo n.º 1
0
        public async Task <bool> CheckInPeriod(IStObjMap stObjMap, IAuthenticationInfo authenticationInfo)
        {
            var sqlDatabase = stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
            var group       = stObjMap.StObjs.Obtain <CustomGroupTable>();
            int userId      = authenticationInfo.ActualUser.UserId;

            using (var ctx = new SqlStandardCallContext())
            {
                GroupQueries       groupQueries       = new GroupQueries(ctx, sqlDatabase);
                TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, sqlDatabase);

                GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                PeriodData periodData = await timedPeriodQueries.GetCurrentPeriod(groupData.ZoneId);

                DateTime currentDateTime        = DateTime.UtcNow;
                int      shoulbBeLowerOrEqual   = DateTime.Compare(periodData.BegDate, currentDateTime);
                int      shouldBeGreaterOrEqual = DateTime.Compare(periodData.EndDate, currentDateTime);

                if (shoulbBeLowerOrEqual > 0 || shouldBeGreaterOrEqual < 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> DownloadExcel(  )
        {
            var         sqlDatabase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
            ExcelUtilis excel       = new ExcelUtilis();
            int         userId      = _authenticationInfo.ActualUser.UserId;

            using (var ctx = new SqlStandardCallContext())
            {
                GroupQueries   groupQueries   = new GroupQueries(ctx, sqlDatabase);
                ProjectQueries projectQueries = new ProjectQueries(ctx, sqlDatabase);

                GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                AclQueries aclQueries = new AclQueries(ctx, sqlDatabase);

                if (await aclQueries.VerifyGrantLevelByUserId(112, await aclQueries.GetAclIdBySchoolId(groupData.ParentZoneId), userId, Operator.SuperiorOrEqual) == false)
                {
                    Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !");
                    return(this.CreateResult(result));
                }
                List <ProjectInfosJuryData> projectInfosJuries = await projectQueries.getAllProjectsGrade(groupData.ZoneId);

                List <ProjectForumResultData> allProjectsForumResult = GetProjectsOfForum(projectInfosJuries);


                byte[] excelToArray = await excel.CreateExcel(allProjectsForumResult, projectQueries);

                return(File(excelToArray, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> GetEvents()
        {
            int userId      = _authenticationInfo.ActualUser.UserId;
            var sqlDataBase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();

            using (var ctx = new SqlStandardCallContext())
            {
                GroupQueries groupQueries = new GroupQueries(ctx, sqlDataBase);
                EventQueries eventQueries = new EventQueries(ctx, sqlDataBase);

                GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                AclQueries aclQueries = new AclQueries(ctx, sqlDataBase);

                if (!await aclQueries.VerifyGrantLevelByUserId(112, await aclQueries.GetAclIdBySchoolId(groupData.ParentZoneId), userId, Operator.SuperiorOrEqual))
                {
                    Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !");
                    return(this.CreateResult(result));
                }

                List <EventData> events = await eventQueries.GetAllEventsByIdSchool(groupData.ParentZoneId);

                return(Ok(events));
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> GetEventSchoolByName(string eventName, string schoolName)
        {
            var sqlDataBase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
            int userId      = _authenticationInfo.ActualUser.UserId;

            using (var ctx = new SqlStandardCallContext())
            {
                EventQueries       eventQueries       = new EventQueries(ctx, sqlDataBase);
                GroupQueries       groupQueries       = new GroupQueries(ctx, sqlDataBase);
                TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, sqlDataBase);

                GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                EventData eventData;

                if (groupData == null)
                {
                    int idSchool = await groupQueries.GetIdSchoolByName(schoolName);

                    PeriodData periodData = await timedPeriodQueries.GetLastPeriodBySchool(idSchool);

                    eventData = await eventQueries.GetEventSchoolBylNameAndPeriodId(eventName, periodData.ChildId);
                }
                else
                {
                    eventData = await eventQueries.GetEventSchoolBylNameAndPeriodId(eventName, groupData.ZoneId);
                }


                return(Ok(eventData));
            }
        }
Exemplo n.º 5
0
        public async Task <IActionResult> UpdateEvents([FromBody] SchoolEventChangeModel model)
        {
            int userId      = _authenticationInfo.ActualUser.UserId;
            var sqlDataBase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();

            using (var ctx = new SqlStandardCallContext())
            {
                PeriodServices periodServices = new PeriodServices();
                GroupQueries   groupQueries   = new GroupQueries(ctx, sqlDataBase);
                EventQueries   eventQueries   = new EventQueries(ctx, sqlDataBase);

                if (!await periodServices.CheckPeriodGivenDate(_stObjMap, _authenticationInfo, model.BegDate, model.EndDate))
                {
                    Result result = new Result(Status.BadRequest, "Ces Dates ne sont pas comprises dans la periode actuel");
                    return(this.CreateResult(result));
                }

                GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                AclQueries aclQueries = new AclQueries(ctx, sqlDataBase);

                if (!await aclQueries.VerifyGrantLevelByUserId(112, await aclQueries.GetAclIdBySchoolId(groupData.ParentZoneId), userId, Operator.SuperiorOrEqual))
                {
                    Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !");
                    return(this.CreateResult(result));
                }

                await eventQueries.UpdateEvent(model.EventId, model.Name, model.BegDate, model.EndDate);

                List <EventData> events = await eventQueries.GetAllEventsByIdSchool(groupData.ParentZoneId);

                return(Ok(events));
            }
        }
Exemplo n.º 6
0
        public async Task <IActionResult> GetAllGradeProject()
        {
            SqlDefaultDatabase db = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
            int userId            = _authenticationInfo.ActualUser.UserId;

            using (var ctx = new SqlStandardCallContext())
            {
                ProjectQueries     projectQueries     = new ProjectQueries(ctx, db);
                TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, db);
                TimedUserQueries   timedUserQueries   = new TimedUserQueries(ctx, db);
                UserQueries        userQueries        = new UserQueries(ctx, db);
                GroupQueries       groupQueries       = new GroupQueries(ctx, db);

                GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                AclQueries aclQueries = new AclQueries(ctx, db);

                if (await aclQueries.VerifyGrantLevelByUserId(112, await aclQueries.GetAclIdBySchoolId(groupData.ParentZoneId), userId, Operator.SuperiorOrEqual) == false)
                {
                    Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !");
                    return(this.CreateResult(result));
                }

                List <ProjectInfosJuryData> projects = await projectQueries.getAllProjectsGrade(groupData.ZoneId);

                List <ProjectForumResultData> listToSend = GetProjectsOfForum(projects);

                return(Ok(listToSend));
            }
        }
Exemplo n.º 7
0
        public async Task <List <Project> > GetAllProjects()
        {
            int            userId      = _authenticationInfo.ActualUser.UserId;
            var            sqlDatabase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
            List <Project> projectList = new List <Project>();

            using (var ctx = new SqlStandardCallContext())
            {
                ProjectQueries projectQueries = new ProjectQueries(ctx, sqlDatabase);
                GroupQueries   groupQueries   = new GroupQueries(ctx, sqlDatabase);
                GroupData      groupData      = await groupQueries.GetIdSchoolByConnectUser(userId);

                IEnumerable <ProjectData> projects = await projectQueries.GetAllProjectByForum(groupData.ZoneId);

                foreach (ProjectData project in projects)
                {
                    List <string> listGroups = await projectQueries.GetGroupsOfProject(project.ProjectStudentId);

                    listGroups       = listGroups.FindAll(x => x.StartsWith("S0") || x == "IL" || x == "SR");
                    project.Semester = string.Join("-", listGroups.ToArray());
                    if (listGroups[0] == "IL")
                    {
                        project.Semester = string.Join("-", listGroups.ToArray().Reverse());
                    }
                    Project p = new Project(project.ProjectStudentId, project.Name,
                                            project.Semester, project.CoordinatesX, project.CoordinatesY, project.ClassRoom, project.Height, project.Width, project.ForumNumber);
                    projectList.Add(p);
                }
            }
            return(projectList);
        }
Exemplo n.º 8
0
        public async Task <IActionResult> DeleteEvent(int EventId)
        {
            int userId      = _authenticationInfo.ActualUser.UserId;
            var sqlDataBase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
            var eventTable  = _stObjMap.StObjs.Obtain <EventSchoolTable>();

            using (var ctx = new SqlStandardCallContext())
            {
                AclQueries   aclQueries   = new AclQueries(ctx, sqlDataBase);
                GroupQueries groupQueries = new GroupQueries(ctx, sqlDataBase);

                GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                if (!await aclQueries.VerifyGrantLevelByUserId(112, await aclQueries.GetAclIdBySchoolId(groupData.ParentZoneId), userId, Operator.SuperiorOrEqual))
                {
                    Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !");
                    return(this.CreateResult(result));
                }

                EventStruct eventResult = await eventTable.DeleteEvent(ctx, userId, EventId);

                if (eventResult.Status == 1)
                {
                    Result result = new Result(Status.BadRequest, "Cette évenement n'existe plus ou n'a jamais existé ! ");
                    return(this.CreateResult(result));
                }

                return(Ok());
            }
        }
Exemplo n.º 9
0
        public async Task <bool> CheckPeriodGivenDate(IStObjMap stObjMap, IAuthenticationInfo authenticationInfo, DateTime begDate, DateTime endDate)
        {
            var sqlDatabase = stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
            var group       = stObjMap.StObjs.Obtain <CustomGroupTable>();
            int userId      = authenticationInfo.ActualUser.UserId;

            using (var ctx = new SqlStandardCallContext())
            {
                GroupQueries       groupQueries       = new GroupQueries(ctx, sqlDatabase);
                TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, sqlDatabase);

                GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                PeriodData periodData = await timedPeriodQueries.GetCurrentPeriod(groupData.ZoneId);

                int shouldBeGreater = begDate.CompareTo(periodData.BegDate);
                int shouldBeLower   = endDate.CompareTo(periodData.EndDate);

                if (shouldBeGreater >= 0 && shouldBeLower <= 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Exemplo n.º 10
0
        public async Task <IActionResult> AddStudentListCsv(string type)
        {
            var file = Request.Form.Files[0];

            int            userId         = _authenticationInfo.ActualUser.UserId;
            var            sqlDatabase    = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
            PeriodServices periodServices = new PeriodServices();

            using (var ctx = new SqlStandardCallContext())
            {
                GroupQueries groupQueries = new GroupQueries(ctx, sqlDatabase);
                AclQueries   aclQueries   = new AclQueries(ctx, sqlDatabase);
                GroupData    groupData    = await groupQueries.GetIdSchoolByConnectUser(userId);

                // User must have the rights to do this action
                //if( await aclQueries.VerifyGrantLevelByUserId( 112, await aclQueries.GetAclIdBySchoolId( groupData.ParentZoneId ), userId, Operator.SuperiorOrEqual ) == false )
                //{
                //    Result result = new Result( Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !" );
                //    return this.CreateResult( result );
                //}

                bool isInPeriod = await periodServices.CheckInPeriod(_stObjMap, _authenticationInfo);

                // The school in wich the user is need to be in a period when the action is done
                if (!isInPeriod)
                {
                    Result result = new Result(Status.Unauthorized, "A la date d'aujourd'hui votre etablissement n'est dans une aucune periode");
                    return(this.CreateResult(result));
                }

                if (type == "student" || type == "staffMember")
                {
                    CsvStudentMapping <UserList> csvStudentMapping = new CsvStudentMapping <UserList>(_emailer);
                    List <UserList> studentResult = await csvStudentMapping.CSVReader(file);

                    await csvStudentMapping.UserParser(studentResult, _stObjMap, _authenticationInfo, type);
                }
                else if (type == "projectNumber")
                {
                    CsvStudentMapping <ProjectNumbers> csvStudentMapping = new CsvStudentMapping <ProjectNumbers>(_emailer);
                    List <ProjectNumbers> projectNumbers = await csvStudentMapping.CSVReaderProjectNumber(file);

                    await csvStudentMapping.ForumNumberParser(_stObjMap, projectNumbers, _authenticationInfo);
                }
                else if (type == "jury")
                {
                    CsvStudentMapping <JuryInfos> csvStudentMapping = new CsvStudentMapping <JuryInfos>(_emailer);
                    List <JuryInfos> result = await csvStudentMapping.CSVReaderProjectNumber(file);

                    await csvStudentMapping.AssignProjectToJury(_stObjMap, _authenticationInfo, result, type);
                }
            }

            return(Ok());
        }
Exemplo n.º 11
0
        public async Task <IActionResult> BlockedProject([FromBody] BlockedGradeViewModel model)
        {
            int                userId         = _authenticationInfo.ActualUser.UserId;
            EvaluatesTable     evaluatesTable = _stObjMap.StObjs.Obtain <EvaluatesTable>();
            SqlDefaultDatabase db             = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
            PeriodServices     periodServices = new PeriodServices();


            using (var ctx = new SqlStandardCallContext())
            {
                AclQueries   aclQueries   = new AclQueries(ctx, db);
                GroupQueries groupQueries = new GroupQueries(ctx, db);

                if (!await periodServices.CheckInPeriod(_stObjMap, _authenticationInfo))
                {
                    Result result = new Result(Status.Unauthorized, "A la date d'aujourd'hui votre etablissement n'est dans une aucune periode");
                    return(this.CreateResult(result));
                }

                GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                if (!await aclQueries.VerifyGrantLevelByUserId(112, await aclQueries.GetAclIdBySchoolId(groupData.ParentZoneId), userId, Operator.SuperiorOrEqual))
                {
                    Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !");
                    return(this.CreateResult(result));
                }

                int idx = 0;
                foreach (var item in model.IndividualGrade)
                {
                    if (item.Value > 0)
                    {
                        await evaluatesTable.BlockedProjectGrade(ctx, model.JurysId[idx], model.ProjectId, item.Value, true);
                    }
                    else
                    {
                        await evaluatesTable.BlockedProjectGrade(ctx, model.JurysId[idx], model.ProjectId, true);
                    }
                    idx++;
                }

                return(Ok());
            }
        }
Exemplo n.º 12
0
        public async Task <IActionResult> GetAllPublicNote()
        {
            SqlDefaultDatabase db = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
            int userId            = _authenticationInfo.ActualUser.UserId;

            using (var ctx = new SqlStandardCallContext())
            {
                ProjectQueries     projectQueries     = new ProjectQueries(ctx, db);
                TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, db);
                TimedUserQueries   timedUserQueries   = new TimedUserQueries(ctx, db);
                UserQueries        userQueries        = new UserQueries(ctx, db);
                GroupQueries       groupQueries       = new GroupQueries(ctx, db);

                GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                List <ProjectForumResultData> projects = await projectQueries.GetAllPublicsNoteByTimedPeriodId(groupData.ZoneId);

                return(Ok(projects));
            }
        }
Exemplo n.º 13
0
        public async Task ForumNumberParser(IStObjMap stObjMap, List <ProjectNumbers> projectNumbers, IAuthenticationInfo authenticationInfo)
        {
            using (var ctx = new SqlStandardCallContext())
            {
                var             sqlDatabase     = stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
                GroupQueries    projectQueries  = new GroupQueries(ctx, sqlDatabase);
                ForumInfosTable forumInfosTable = stObjMap.StObjs.Obtain <ForumInfosTable>();
                int             userId          = authenticationInfo.ActualUser.UserId;
                GroupData       groupData       = await projectQueries.GetIdSchoolByConnectUser(userId);

                foreach (ProjectNumbers projectNumber in projectNumbers)
                {
                    int projectId = await projectQueries.GetSpecificIdGroupByZoneIdAndGroupName(groupData.ZoneId, projectNumber.ProjectName);

                    if (projectId == 0)
                    {
                        Console.WriteLine("-----" + projectNumber.ProjectName);
                    }
                    await forumInfosTable.CreateForumInfo(ctx, projectId, "", -1, -1, 4, 3, projectNumber.ProjectNumber);
                }
            }
        }
Exemplo n.º 14
0
        public async Task <IActionResult> GetIdSchoolOfUser()
        {
            int userId      = _authenticationInfo.ActualUser.UserId;
            var sqlDatabase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();

            using (var ctx = new SqlStandardCallContext())
            {
                SchoolQueries    schoolQueries    = new SchoolQueries(ctx, sqlDatabase);
                TimedUserQueries timedUserQueries = new TimedUserQueries(ctx, sqlDatabase);
                GroupQueries     groupQueries     = new GroupQueries(ctx, sqlDatabase);

                GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                if (groupData == null || groupData.ParentZoneId == 0)
                {
                    //if user not in school default by school id In'TECH
                    // int idSchool = await groupQueries.GetIdSchoolByName( "IN'TECH" );
                    return(Ok(groupData.ZoneId));
                }

                return(Ok(groupData.ParentZoneId));
            }
        }
Exemplo n.º 15
0
        public async Task <IActionResult> NoteProject([FromBody] NoteProjectViewModel model)
        {
            int userId = _authenticationInfo.ActualUser.UserId;
            TimedUserNoteProjectTable timedUserNoteProjectTable = _stObjMap.StObjs.Obtain <TimedUserNoteProjectTable>();
            TimedUserTable            timedUserTable            = _stObjMap.StObjs.Obtain <TimedUserTable>();
            EvaluatesTable            evaluatesTable            = _stObjMap.StObjs.Obtain <EvaluatesTable>();
            SqlDefaultDatabase        db             = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
            PeriodServices            periodServices = new PeriodServices();

            using (var ctx = new SqlStandardCallContext())
            {
                ProjectQueries     projectQueries     = new ProjectQueries(ctx, db);
                TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, db);
                UserQueries        userQueries        = new UserQueries(ctx, db);
                TimedUserQueries   timedUserQueries   = new TimedUserQueries(ctx, db);
                AclQueries         aclQueries         = new AclQueries(ctx, db);
                GroupQueries       groupQueries       = new GroupQueries(ctx, db);

                //Case Change Grade by Administration ====================================================================================================================
                if (model.User == ViewModels.TypeTimedUser.StaffMember)
                {
                    if (!await periodServices.CheckInPeriod(_stObjMap, _authenticationInfo))
                    {
                        Result result = new Result(Status.Unauthorized, "A la date d'aujourd'hui votre etablissement n'est dans une aucune periode");
                        return(this.CreateResult(result));
                    }

                    GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                    if (!await aclQueries.VerifyGrantLevelByUserId(112, await aclQueries.GetAclIdBySchoolId(groupData.ParentZoneId), userId, Operator.SuperiorOrEqual))
                    {
                        Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !");
                        return(this.CreateResult(result));
                    }

                    await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, model.JuryId, model.ProjectId, model.Grade);

                    return(Ok());
                }
                //=========================================================================================================================================================

                PeriodData periodData = await timedPeriodQueries.GetLastPeriodBySchool(model.SchoolId);

                TimedUserData timedUserData = await timedUserQueries.GetTimedUser(userId, periodData.ChildId);

                if (timedUserData == null)
                {
                    TimedUserStruct timedUser = await timedUserTable.CreateOrUpdateTimedUserAsyncWithType(ctx, Data.TypeTimedUser.Anon, periodData.ChildId, userId);

                    timedUserData = new TimedUserData
                    {
                        TimedUserId = timedUser.TimedUserId
                    };
                    await timedUserNoteProjectTable.AddOrUpdateNote(ctx, timedUserData.TimedUserId, model.ProjectId, model.Grade);

                    return(Ok());
                }

                if (model.User == ViewModels.TypeTimedUser.Jury)
                {
                    await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, model.JuryId, model.ProjectId, model.Grade);
                }
                else
                {
                    await timedUserNoteProjectTable.AddOrUpdateNote(ctx, timedUserData.TimedUserId, model.ProjectId, model.Grade);
                }

                return(Ok());
            }
        }
Exemplo n.º 16
0
        public static async Task <(UserQueries, TimedUserQueries, ProjectStudentStruct, TimedUserData)> SaveProjectPfh(
            ProjectPfh project,
            ProjectStudentTable projectTable,
            int userId,
            SqlDefaultDatabase db,
            SqlStandardCallContext ctx,
            string type,
            ProjectUrlTable projectUrlTable,
            CustomGroupTable CustomGroupTable
            )
        {
            GroupQueries        groupQueries       = new GroupQueries(ctx, db);
            TraitContextQueries traitContext       = new TraitContextQueries(ctx, db);
            TimedUserQueries    timedUserQueries   = new TimedUserQueries(ctx, db);
            TimedPeriodQueries  timedPeriodQueries = new TimedPeriodQueries(ctx, db);
            UserQueries         userQueries        = new UserQueries(ctx, db);

            GroupData school = await groupQueries.GetIdSchoolByConnectUser(userId);

            // PeriodData timePeriod = await timedPeriodQueries.GetLastPeriodBySchool(school.ZoneId);
            TimedUserData timedUser = await timedUserQueries.GetTimedUser(userId, school.ZoneId);

            int traitContextId = await traitContext.GetTraitContextId(type);

            string email = project.team.leader;
            int    leaderId;

            if (email == "None")
            {
                leaderId = 0;
            }
            else
            {
                UserData user = await userQueries.GetUserByEmail(email);

                TimedUserData timedLeader = await timedUserQueries.GetTimedUser(user.UserId, school.ZoneId);

                leaderId = user.UserId;
            }

            project.background.image = GetTomlFromGoogleDrive.GetUrlRessource(project.background.image);

            ProjectStudentStruct ProjectCreate = await projectTable.CreateProjectStudent(
                ctx,
                userId,
                school.ZoneId,
                project.name.project_name,
                traitContextId,
                project.logo.url,
                project.slogan.slogan,
                project.pitch.pitch,
                leaderId,
                type,
                project.background.image
                );

            foreach (var item in project.semester.semester)
            {
                string semester   = "S0" + item.ToString();
                int    idSemester = await groupQueries.GetSpecificIdGroupByZoneIdAndGroupName(school.ZoneId, semester);

                await CustomGroupTable.AddUserAsync(ctx, userId, idSemester, ProjectCreate.ProjectStudentId, true);
            }


            return(userQueries, timedUserQueries, ProjectCreate, timedUser);
        }
Exemplo n.º 17
0
        public static async Task <(UserQueries, TimedUserQueries, ProjectStudentStruct, TimedUserData)> SaveProjectPi(
            ProjectPi project,
            ProjectStudentTable projectTable,
            int userId,
            SqlDefaultDatabase db,
            SqlStandardCallContext ctx,
            string type,
            ProjectUrlTable projectUrlTable,
            CustomGroupTable CustomGroupTable
            )
        {
            GroupQueries        groupQueries       = new GroupQueries(ctx, db);
            TraitContextQueries traitContext       = new TraitContextQueries(ctx, db);
            TimedUserQueries    timedUserQueries   = new TimedUserQueries(ctx, db);
            TimedPeriodQueries  timedPeriodQueries = new TimedPeriodQueries(ctx, db);
            UserQueries         userQueries        = new UserQueries(ctx, db);

            GroupData school = await groupQueries.GetIdSchoolByConnectUser(userId);

            // PeriodData timePeriod = await timedPeriodQueries.GetLastPeriodBySchool(school.ZoneId);
            TimedUserData timedUser = await timedUserQueries.GetTimedUser(userId, school.ZoneId);

            int traitContextId = await traitContext.GetTraitContextId(type);

            string email = project.team.leader;
            int    leaderId;

            if (email == "None")
            {
                leaderId = 0;
            }
            else
            {
                UserData user = await userQueries.GetUserByEmail(email);

                TimedUserData timedLeader = await timedUserQueries.GetTimedUser(user.UserId, school.ZoneId);

                leaderId = user.UserId;
            }


            ProjectStudentStruct ProjectCreate = await projectTable.CreateProjectStudent(
                ctx,
                userId,
                school.ZoneId,
                project.name.project_name,
                traitContextId,
                string.Join(";", project.technologies.technologies),
                project.logo.url,
                project.slogan.slogan,
                project.pitch.pitch,
                leaderId,
                type
                );

            if (project.git.url != "None")
            {
                await projectUrlTable.CreateOrUpdateProjectUrl(ctx, ProjectCreate.ProjectStudentId, project.git.url, "Git");
            }

            foreach (var item in project.semester.semester)
            {
                string semester   = "S0" + item.ToString();
                int    idSemester = await groupQueries.GetSpecificIdGroupByZoneIdAndGroupName(school.ZoneId, semester);

                await CustomGroupTable.AddUserAsync(ctx, userId, idSemester, ProjectCreate.ProjectStudentId, true);
            }

            string[] sector = project.semester.sector.Split(" - ");
            foreach (var item in sector)
            {
                int idSector = await groupQueries.GetSpecificIdGroupByZoneIdAndGroupName(school.ZoneId, item);

                await CustomGroupTable.AddUserAsync(ctx, userId, idSector, ProjectCreate.ProjectStudentId, true);
            }


            return(userQueries, timedUserQueries, ProjectCreate, timedUser);
        }
Exemplo n.º 18
0
        internal async Task AssignProjectToJury(IStObjMap stObjMap, IAuthenticationInfo authenticationInfo, List <JuryInfos> juryInfos, string type)
        {
            using (var ctx = new SqlStandardCallContext())
            {
                var            sqlDatabase    = stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
                var            groupTable     = stObjMap.StObjs.Obtain <CustomGroupTable>();
                var            userTimedTable = stObjMap.StObjs.Obtain <TimedUserTable>();
                EvaluatesTable evaluatesTable = stObjMap.StObjs.Obtain <EvaluatesTable>();

                int          userId       = authenticationInfo.ActualUser.UserId;
                GroupQueries groupQueries = new GroupQueries(ctx, sqlDatabase);
                GroupData    groupData    = await groupQueries.GetIdSchoolByConnectUser(userId);

                string             userName           = Guid.NewGuid().ToString();
                UserQueries        userQueries        = new UserQueries(ctx, sqlDatabase);
                TimedUserQueries   timedUserQueries   = new TimedUserQueries(ctx, sqlDatabase);
                ProjectQueries     projectQueries     = new ProjectQueries(ctx, sqlDatabase);
                TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, sqlDatabase);
                ForumQueries       forumQueries       = new ForumQueries(ctx, sqlDatabase);
                //get the Begdate of the periode
                DateTime begDate = await timedPeriodQueries.GetBegDateOfPeriod(groupData.ZoneId);

                foreach (JuryInfos juryInfo in juryInfos)
                {
                    if (juryInfo.Mail == "*****@*****.**")
                    {
                        Console.WriteLine("ok");
                    }
                    int    enterpriseId  = 0;
                    string groupName     = "Jury " + juryInfo.Jury + "-" + begDate.Year + "/" + begDate.Month;
                    int    timedUserType = 0;
                    //Check if the jury group exists or not at a moment
                    int groupId = await groupQueries.GetSpecificIdGroupByZoneIdAndGroupName(groupData.ZoneId, groupName);

                    if (groupId == 0)
                    {
                        groupId = await groupTable.CreateGroupAsync(ctx, userId, groupData.ZoneId);

                        await groupTable.Naming.GroupRenameAsync(ctx, userId, groupId, groupName);
                    }

                    //Check if the enterprise group exists or not at a moment
                    enterpriseId = await groupQueries.GetSpecificIdGroupByZoneIdAndGroupName(groupData.ZoneId, juryInfo.Entreprise);

                    if (enterpriseId == 0)
                    {
                        enterpriseId = await groupTable.CreateGroupAsync(ctx, userId, groupData.ZoneId);

                        await groupTable.Naming.GroupRenameAsync(ctx, userId, enterpriseId, juryInfo.Entreprise);
                    }

                    //Check if the user exists
                    int idJury = await CheckIfUserExists(stObjMap, authenticationInfo, juryInfo.Mail, userName, juryInfo.Prenom, juryInfo.Nom);

                    await groupTable.AddUserAsync(ctx, userId, groupId, idJury, true);

                    await groupTable.AddUserAsync(ctx, userId, enterpriseId, idJury, true);

                    //get the timed user type
                    timedUserType = GetTimedUserType(type);

                    //check if the timed user exists
                    TimedUserData timedUserData = await userQueries.CheckIfTimedUserExists(idJury, groupData.ZoneId);

                    if (timedUserData == null)
                    {
                        await userTimedTable.CreateOrUpdateTimedUserAsync(ctx, timedUserType, groupData.ZoneId, idJury);
                    }
                    else
                    {
                        bool isJury = await timedUserQueries.IsJury(timedUserData.TimedUserId);

                        if (!isJury)
                        {
                            await userTimedTable.CreateOrUpdateTimedUserAsync(ctx, timedUserType, groupData.ZoneId, idJury);
                        }
                    }

                    //get the project id by forumnumber
                    ProjectData projectId;
                    string      groupName1 = "Vous êtes libre";
                    string      groupName2 = "Vous êtes libre";
                    string      groupName3 = "Vous êtes libre";
                    string      groupName4 = "Vous êtes libre";
                    TimeSpan    timeSpan1  = new TimeSpan(13, 30, 0);
                    TimeSpan    timeSpan2  = new TimeSpan(14, 15, 0);
                    TimeSpan    timeSpan3  = new TimeSpan(15, 00, 0);
                    TimeSpan    timeSpan4  = new TimeSpan(15, 45, 0);

                    if (juryInfo.Groupe1 != 0)
                    {
                        projectId = await projectQueries.GetProjectIdByForumNumberAndPeriod(juryInfo.Groupe1, groupData.ZoneId);

                        begDate = begDate.Date + timeSpan1;
                        if (await forumQueries.IsProjectJudgedByJury(projectId.ProjectStudentId, groupId) == 0)
                        {
                            await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, groupId, projectId.ProjectStudentId, -1, begDate);
                        }
                        groupName1 = projectId.GroupName;
                    }

                    if (juryInfo.Groupe2 != 0)
                    {
                        projectId = await projectQueries.GetProjectIdByForumNumberAndPeriod(juryInfo.Groupe2, groupData.ZoneId);

                        begDate = begDate.Date + timeSpan2;
                        if (await forumQueries.IsProjectJudgedByJury(projectId.ProjectStudentId, groupId) == 0)
                        {
                            await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, groupId, projectId.ProjectStudentId, -1, begDate);
                        }
                        groupName2 = projectId.GroupName;
                    }

                    if (juryInfo.Groupe3 != 0)
                    {
                        projectId = await projectQueries.GetProjectIdByForumNumberAndPeriod(juryInfo.Groupe3, groupData.ZoneId);

                        begDate = begDate.Date + timeSpan3;
                        if (await forumQueries.IsProjectJudgedByJury(projectId.ProjectStudentId, groupId) == 0)
                        {
                            await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, groupId, projectId.ProjectStudentId, -1, begDate);
                        }
                        groupName3 = projectId.GroupName;
                    }
                    if (juryInfo.Groupe4 != 0)
                    {
                        projectId = await projectQueries.GetProjectIdByForumNumberAndPeriod(juryInfo.Groupe4, groupData.ZoneId);

                        begDate = begDate.Date + timeSpan4;
                        if (await forumQueries.IsProjectJudgedByJury(projectId.ProjectStudentId, groupId) == 0)
                        {
                            await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, groupId, projectId.ProjectStudentId, -1, begDate);
                        }
                        groupName4 = projectId.GroupName;
                    }

                    IEnumerable <ForumData> infoMail = await forumQueries.ForumInfoByJury(groupName);

                    int nbProject = infoMail.Count();

                    string subject     = "Votre participation au Forum PI D'IN'TECH";
                    string mailContent = @"
            <table align = 'center' border='0' cellpadding='0' cellspacing='0' height='100%' width='100%' id='bodyTable'>
  
                            </tr>
                            <tr>
                                <td valign = 'top' id='templateBody'><table border = '0' cellpadding='0' cellspacing='0' width='100%' class='mcnTextBlock' style='min-width:100%;'>
    <tbody class='mcnTextBlockOuter'>
        <tr>
            <td valign = 'top' class='mcnTextBlockInner' style='padding-top:9px;'>
                <!--[if mso]>
				<table align = 'left' border='0' cellspacing='0' cellpadding='0' width='100%' style='width:100%;'>
				<tr>
				<![endif]-->
			    
				<!--[if mso]>
				<td valign = 'top' width='600' style='width:600px;'>
				<![endif]-->
                <table align = 'left' border='0' cellpadding='0' cellspacing='0' style='max-width:100%; min-width:100%;' width='100%' class='mcnTextContentContainer'>
                    <tbody><tr>
                        
                        <td valign = 'top' class='mcnTextContent' style='padding-top:0; padding-right:18px; padding-bottom:9px; padding-left:18px;'>
                        
                            <h1>Bonjour " + juryInfo.Prenom + " " + juryInfo.Nom + @"</h1>

<p>Vous participez au forum des projets informatique de l'école IN'TECH le " + begDate.Day + "/0" + begDate.Month + "/" + begDate.Year + @".</p>

<p>Vous appartenez au jury '" + groupName + @"'.<br>
Au cours de cet évènement vous aurez l'occasion de juger les projets suivants:&nbsp;</p>

<ul>
	<li>"     + groupName1 + " à " + timeSpan1 + @"</li>
	<li>"     + groupName2 + " à " + timeSpan2 + @"</li>
	<li>"     + groupName3 + " à " + timeSpan3 + @"</li>
	<li>"     + groupName4 + " à " + timeSpan4 + @"</li>
</ul>
Nous vous remercions de l’intérêt que vous portez à nos évènements.<br>
Bonne continuation.
                        </td>
                    </tr>
                </tbody></table>
				<!--[if mso]>
				</td>
				<![endif]-->
                
				<!--[if mso]>
				</tr>
				</table>
				<![endif]-->
            </td>
        </tr>
    </tbody>
</table></td>
                            </tr>
                            <tr>
                                <td valign = 'top' id= 'templateFooter' >
        <td align = 'center' style='padding-left:9px;padding-right:9px;'>
            <table border = '0' cellpadding='0' cellspacing='0' width='100%' style='min-width:100%;' class='mcnFollowContent'>
                <tbody><tr>
                    <td align = 'center' valign='top' style='padding-top:9px; padding-right:9px; padding-left:9px;'>
                        <table align = 'center' border='0' cellpadding='0' cellspacing='0'>
                            <tbody><tr>
                                <td align = 'center' valign='top'>
                                    <!--[if mso]>
                                    <table align = 'center' border='0' cellspacing='0' cellpadding='0'>
                                    <tr>
                                    <![endif]-->

                                </td>
                            </tr>
                        </tbody></table>
                    </td>
                </tr>
            </tbody></table>
        </td>
    </tr>
</tbody></table>

            </td>
        </tr>
    </tbody>
</table>
    <tbody class='mcnDividerBlockOuter'>
        <tr>
            <td class='mcnDividerBlockInner' style='min-width: 100%; padding: 10px 18px 25px;'>
                <table class='mcnDividerContent' border='0' cellpadding='0' cellspacing='0' width='100%' style='min-width: 100%;border-top: 2px solid #EEEEEE;'>
                    <tbody><tr>
                        <td>
                            <span></span>
                        </td>
                    </tr>
                </tbody></table>
<!--            
                <td class='mcnDividerBlockInner' style='padding: 18px;'>
                <hr class='mcnDividerContent' style='border-bottom-color:none; border-left-color:none; border-right-color:none; border-bottom-width:0; border-left-width:0; border-right-width:0; margin-top:0; margin-right:0; margin-bottom:0; margin-left:0;' />
-->
            </td>
        </tr>
    </tbody>
</table>
    <tbody class='mcnTextBlockOuter'>
        <tr>
            <td valign = 'top' class='mcnTextBlockInner' style='padding-top:9px;'>
			    
				<!--[if mso]>
				<td valign = 'top' width='600' style='width:600px;'>
				<![endif]-->
                <table align = 'left' border='0' cellpadding='0' cellspacing='0' style='max-width:100%; min-width:100%;' width='100%' class='mcnTextContentContainer'>
                    <tbody><tr>
                        
                        <td valign = 'top' class='mcnTextContent' style='padding-top:0; padding-right:18px; padding-bottom:9px; padding-left:18px;'>
                        
                            <br>
<br>
<strong>Notre adresse:</strong><br>
74 bis Avenue Maurice Thorez, 94200 Ivry-sur-Seine<br>
Metro 7: Pierre et Marie Curie<br>
<br>
IN'TECH Paris
                        </td>
                    </tr>
                </tbody></table>
				<!--[if mso]>
				</td>
				<![endif]-->
                
				<!--[if mso]>
				</tr>
				</table>
				<![endif]-->
            </td>
        </tr>
    </tbody>
</table></td>
                            </tr>
                        </table>
                        <!--[if (gte mso 9)|(IE)]>
                        </td>
                        </tr>
                        </table>
                        <![endif]-->
                        <!-- // END TEMPLATE -->
                    </td>
                </tr>
            </table>
        </center>
    </body>
</html>";

                    await _emailSender.SendMessage(juryInfo.Mail, subject, mailContent);
                }
            }
        }
Exemplo n.º 19
0
        public async Task <bool> UserParser(List <UserList> studentList, IStObjMap stObjMap, IAuthenticationInfo authenticationInfo, string type)
        {
            using (var ctx = new SqlStandardCallContext())
            {
                var sqlDatabase    = stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
                var userTable      = stObjMap.StObjs.Obtain <CustomUserTable>();
                var userTimedTable = stObjMap.StObjs.Obtain <TimedUserTable>();
                var groupTable     = stObjMap.StObjs.Obtain <CustomGroupTable>();

                GroupQueries groupQueries = new GroupQueries(ctx, sqlDatabase);
                UserQueries  userQueries  = new UserQueries(ctx, sqlDatabase);

                int       currentUserId = authenticationInfo.ActualUser.UserId;
                GroupData groupData     = await groupQueries.GetIdSchoolByConnectUser(currentUserId);

                int zoneId = groupData.ZoneId;


                foreach (var element in studentList)
                {
                    string   userName      = Guid.NewGuid().ToString();
                    string   firstName     = element.FirstName;
                    string   lastName      = element.Name;
                    int      timedUserType = 0;
                    string[] groupName     = new string[1];
                    string   mail          = element.Mail;
                    int      idUser        = await CheckIfUserExists(stObjMap, authenticationInfo, mail, userName, firstName, lastName);

                    timedUserType = GetTimedUserType(type);
                    if (type == "student")
                    {
                        groupName = element.GroupName.Split('-');
                    }
                    else if (type == "staffMember")
                    {
                        groupName[0] = element.GroupName;
                    }
                    int groupId = await groupQueries.GetIdGroupByNameAndPeriod(groupName[0], zoneId);


                    TimedUserData timedUserData = await userQueries.CheckIfTimedUserExists(idUser, zoneId);

                    if (timedUserData == null)
                    {
                        await userTimedTable.CreateOrUpdateTimedUserAsync(ctx, timedUserType, zoneId, idUser);

                        groupTable.AddUser(ctx, currentUserId, groupId, idUser, true);
                        if (type == "student" && groupName[1] != "A")
                        {
                            int sector = await groupQueries.GetIdGroupByNameAndPeriod(groupName[1], zoneId);

                            groupTable.AddUser(ctx, currentUserId, sector, idUser, true);
                        }
                    }
                    else
                    {
                        int isUserInGroup = await groupQueries.GetGroupByNamePeriodUser(groupName[0], idUser, zoneId);

                        if (isUserInGroup == 0)
                        {
                            groupTable.AddUser(ctx, currentUserId, groupId, idUser, true);
                            if (type == "student" && groupName[1] != "A")
                            {
                                int sector = await groupQueries.GetIdGroupByNameAndPeriod(groupName[1], zoneId);

                                groupTable.AddUser(ctx, currentUserId, sector, idUser, true);
                            }
                        }
                    }
                }
            }
            return(true);
        }
Exemplo n.º 20
0
        public async Task <List <TimedStudentData> > GetAllUserByPeriod([FromBody] BddInfoModel model)
        {
            var sqlDatabase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
            IEnumerable <TimedStudentData> studentList       = new List <TimedStudentData>();
            List <TimedStudentData>        timedStudentDatas = new List <TimedStudentData>();
            int userId = _authenticationInfo.ActualUser.UserId;


            using (var ctx = new SqlStandardCallContext())
            {
                AclQueries aclQueries = new AclQueries(ctx, sqlDatabase);

                if (!await aclQueries.VerifyGrantLevelByUserId(112, 9, userId, Operator.SuperiorOrEqual))
                {
                    Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !");
                }


                TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, sqlDatabase);
                GroupQueries       groupQueries       = new GroupQueries(ctx, sqlDatabase);
                TimedUserQueries   timedUserQueries   = new TimedUserQueries(ctx, sqlDatabase);


                GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                //PeriodData periodData = await timedPeriodQueries.GetLastPeriodBySchool( groupData.ZoneId );
                IEnumerable <GroupData> groupList = await groupQueries.GetAllGroupByPeriod(groupData.ZoneId);

                List <GroupData> groupFinal = groupList.ToList();
                for (int i = 0; i < groupFinal.Count; i++)
                {
                    studentList = await timedUserQueries.GetAllStudentInfosByGroup(groupFinal[i].GroupId, model.TableName, model.TableId);

                    timedStudentDatas.AddRange(studentList);
                }
            }

            var duplicates = timedStudentDatas
                             .GroupBy(x => x.UserId)
                             .Where(g => g.Count() > 1)
                             .Select(g => g.Select(gg => gg));

            var single = timedStudentDatas
                         .GroupBy(x => x.UserId)
                         .Where(g => g.Count() == 1)
                         .SelectMany(g => g.Select(gg => gg));

            List <TimedStudentData> timedStudentDatasClean = new List <TimedStudentData>();

            timedStudentDatasClean = single.ToList();
            for (var i = 0; i < duplicates.Count(); i++)
            {
                var a = duplicates.ElementAt(i);

                if (a.ElementAt(0).GroupName == "S01" || a.ElementAt(0).GroupName == "S02")
                {
                    a.ElementAt(0).GroupName = a.ElementAt(0).GroupName;
                }
                else if (a.ElementAt(1).GroupName == "SR")
                {
                    a.ElementAt(0).GroupName = a.ElementAt(0).GroupName + " - " + a.ElementAt(1).GroupName;
                }
                else
                {
                    a.ElementAt(0).GroupName = a.ElementAt(1).GroupName + " - " + a.ElementAt(0).GroupName;
                }
                timedStudentDatasClean.Add(a.ElementAt(0));
            }
            ;

            return(timedStudentDatasClean);
        }