Beispiel #1
0
        public static void SyncToCanvas()
        {
            logger.Info("UserService/SyncToCanvas - Task 'Sync user' STARTED");

            try
            {
                SyncronizationDAL.SyncToCanvas();

                List <sp_get_uniCanvas_ws_usuarios_Result> userSyncList = UserDAL.SyncToCanvas();
                List <string> createdUserList = new List <string>();

                foreach (sp_get_uniCanvas_ws_usuarios_Result userSync in userSyncList)
                {
                    try
                    {
                        UserController userController = new UserController();
                        User           user           = new Common.User();
                        user.user = new Common.UserDTO(userSync);

                        if (!createdUserList.Any(x => x == userSync.Username))
                        {
                            UserReturn newUser = (UserReturn)userController.Create(user);

                            if (newUser != null)
                            {
                                UserDAL.UpdateCanvasData(userSync.IDAcademico, newUser);
                                createdUserList.Add(userSync.Username);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        UserReturn newUser = new UserReturn()
                        {
                            error_message = e.Message
                        };
                        UserDAL.UpdateCanvasData(userSync.IDAcademico, newUser);
                    }
                }
                logger.Info("UserService/SyncToCanvas - Task 'Sync user' FINISHED");
            }
            catch (Exception e)
            {
                logger.Error("UserService/SyncToCanvas - Task 'Sync user' FINISHED WITH ERROR: \n " + "  Message: " + e.Message + "\nInner Exception: " + e.InnerException);
            }
        }
Beispiel #2
0
        public static void SyncToCanvas()
        {
            logger.Info("SectionService/SyncToCanvas - Task 'Sync section' STARTED");

            try
            {
                SyncronizationDAL.SyncToCanvas();

                List <sp_get_uniCanvas_ws_secciones_Result> sectionToSyncList = SectionDAL.SectionsToSync();

                foreach (sp_get_uniCanvas_ws_secciones_Result sectionToSync in sectionToSyncList)
                {
                    try
                    {
                        SectionController sectionController = new SectionController();
                        Section           section           = new Section();

                        section.course_section = new SectionDTO(sectionToSync);

                        SectionDTO newSection = (SectionDTO)sectionController.Create(section, section.course_section.sis_course_id);

                        if (newSection != null)
                        {
                            SectionDAL.UpdateCanvasData((int)sectionToSync.IDAcademico, newSection, newSection.group_id);
                        }
                        logger.Info("SectionService/SyncToCanvas - Task 'Sync section' FINISHED");
                    }
                    catch (Exception e)
                    {
                        logger.Error("SectionService/SyncToCanvas - Task 'Sync section' FINISHED WITH ERROR: \n " + "  Message: " + e.Message + "\nInner Exception: " + e.InnerException);
                        SectionDTO newSection = new SectionDTO()
                        {
                            error_message = e.Message
                        };
                        SectionDAL.UpdateCanvasData((int)sectionToSync.IDAcademico, newSection, newSection.group_id);
                    }
                }
            }
            catch (Exception e)
            {
                return;
            }
        }
Beispiel #3
0
        public static void SyncToCanvas()
        {
            try
            {
                SyncronizationDAL.SyncToCanvas();

                List <sp_get_uniCanvas_ws_cursos_Result> courseToSyncList = CourseDAL.CoursesToSync();
                List <string> createdCoursesList = new List <string>();

                foreach (sp_get_uniCanvas_ws_cursos_Result courseToSync in courseToSyncList)
                {
                    try
                    {
                        CourseController courseController = new CourseController();
                        Course           course           = new Course();
                        course.course = new CourseDTO(courseToSync);

                        CourseReturn newCourse = (CourseReturn)courseController.Create(course);

                        if (newCourse != null)
                        {
                            CourseDAL.UpdateCanvasData(courseToSync.IDAcademico.ToString(), newCourse);
                        }
                    }
                    catch (Exception e)
                    {
                        CourseReturn newCourse = new CourseReturn()
                        {
                            error_message = e.Message
                        };
                        CourseDAL.UpdateCanvasData(courseToSync.IDAcademico.ToString(), newCourse);
                    }
                }
            }
            catch (Exception e)
            {
                return;
            }
        }
Beispiel #4
0
        public static void SyncToCanvas()
        {
            logger.Info("InscriptionService/SyncToCanvas - Task 'Sync inscription' STARTED");

            try
            {
                SyncronizationDAL.SyncToCanvas();

                foreach (CanvasWebApi.Common.ConfigEnum.Enrollment_Operation enrollmentOperation in Enum.GetValues(typeof(CanvasWebApi.Common.ConfigEnum.Enrollment_Operation)))
                {
                    //PRIMERO SE DAN LAS ALTAS Y LUEGO LAS BAJAS
                    List <sp_get_uniCanvas_ws_enrolamientos_Result> inscriptionToSyncList = InscriptionDAL.InscriptionsToSync(enrollmentOperation.ToString());

                    foreach (sp_get_uniCanvas_ws_enrolamientos_Result inscriptionToSync in inscriptionToSyncList)
                    {
                        try
                        {
                            InscriptionController inscriptionController = new InscriptionController();
                            Inscription           inscription           = new Inscription();

                            inscription.enrollment = new InscriptionDTO(inscriptionToSync);

                            if (enrollmentOperation == CanvasWebApi.Common.ConfigEnum.Enrollment_Operation.A)
                            {
                                InscriptionReturn newInscription = (InscriptionReturn)inscriptionController.CreateBySectionId(inscription, inscriptionToSync.IDAcademicoSeccion.ToString(), inscriptionToSync.IDCanvasSeccion);

                                if (newInscription != null)
                                {
                                    InscriptionDAL.UpdateCanvasData((int)inscriptionToSync.ID, newInscription);
                                }
                            }

                            /*
                             * else if (enrollmentOperation == CanvasWebApi.Common.ConfigEnum.Enrollment_Operation.B)
                             * {
                             *  InscriptionReturn newInscription = (InscriptionReturn)inscriptionController.DeleteInscription(inscriptionToSync.IDAcademicoCurso, inscriptionToSync.IDCanvasEnrolamiento);
                             *
                             *  if (newInscription != null)
                             *  {
                             *      InscriptionDAL.UpdateCanvasData((int)inscriptionToSync.ID, newInscription);
                             *  }
                             * }
                             */
                        }
                        catch (Exception e)
                        {
                            InscriptionReturn newInscription = new InscriptionReturn()
                            {
                                error_message = e.Message
                            };
                            InscriptionDAL.UpdateCanvasData((int)inscriptionToSync.ID, newInscription);
                        }
                    }
                    logger.Info("InscriptionService/SyncToCanvas - Task 'Sync inscription' FINISHED");
                }
            }
            catch (Exception e)
            {
                logger.Error("SyncronizationDAL/SyncToCanvas - Task 'Sync user' FINISHED WITH ERROR: \n " + "  Message: " + e.Message + "\nInner Exception: " + e.InnerException);
                return;
            }
        }