Ejemplo n.º 1
0
        public static void UpdateCanvasData(int?idEntidad, InscriptionReturn newInscription)
        {
            logger.Info("InscriptionDAL/UpdateCanvasData - Task 'Update inscription data in Canvas' STARTED");

            if (newInscription != null)
            {
                using (var context = new CANVAS_Model_Entities())
                {
                    uniCanvasEnrolamiento newCanvasInscription = context.uniCanvasEnrolamientos.Where(x => x.ID == idEntidad).FirstOrDefault();
                    if (newInscription.error_message == null)
                    {
                        newCanvasInscription.Estado   = CanvasWebApi.Common.ConfigEnum.CanvasState.Sincronizado.GetHashCode();
                        newCanvasInscription.Fecha    = DateTime.Now;
                        newCanvasInscription.IDCanvas = Int32.Parse(newInscription.id);
                    }
                    else
                    {
                        newCanvasInscription.Estado = CanvasWebApi.Common.ConfigEnum.CanvasState.Error.GetHashCode();
                    }

                    newCanvasInscription.Error = newInscription.error_message;
                    context.SaveChanges();
                }
            }
            logger.Info("InscriptionDAL/UpdateCanvasData - Task 'Update inscription data in Canvas' FINISHED");
        }
Ejemplo n.º 2
0
        public static void UpdateCanvasData(int?idEntidad, UserReturn newUser)
        {
            logger.Info("UserDAL/UpdateCanvasData - Task 'Update user data from Canvas' STARTED");
            if (newUser != null)
            {
                using (var context = new CANVAS_Model_Entities())
                {
                    uniCanvasUsuario newCanvasUser = context.uniCanvasUsuarios.Where(x => x.IDAcademico == idEntidad).FirstOrDefault();
                    if (newUser.error_message == null)
                    {
                        newCanvasUser.Estado   = CanvasWebApi.Common.ConfigEnum.CanvasState.Sincronizado.GetHashCode();
                        newCanvasUser.Fecha    = DateTime.Now;
                        newCanvasUser.IDCanvas = Int32.Parse(newUser.id);
                    }
                    else
                    {
                        newCanvasUser.Estado = CanvasWebApi.Common.ConfigEnum.CanvasState.Error.GetHashCode();
                    }

                    newCanvasUser.Error = newUser.error_message;
                    context.SaveChanges();
                }
                logger.Info("UserDAL/UpdateCanvasData - Task 'Update user data from Canvas' FINISHED");
            }
            logger.Info("UserDAL/UpdateCanvasData - Task 'Update user data from Canvas' FINISHED");
        }
Ejemplo n.º 3
0
 public static List <sp_uni_canvas_sincronizacion_Result> SyncToCanvas()
 {
     using (var context = new CANVAS_Model_Entities())
     {
         return(context.sp_uni_canvas_sincronizacion().ToList());
     }
 }
Ejemplo n.º 4
0
        public static void UpdateCanvasData(int?idEntidad, SectionDTO newSection, int?canvasGroupId)
        {
            logger.Info("SectionDAL/SectionsToSync - Task 'Get a list with the sections to sync' STARTED");
            if (newSection != null)
            {
                using (var context = new CANVAS_Model_Entities())
                {
                    uniCanvasCursosSeccione newCanvasCourseSection = context.uniCanvasCursosSecciones.Where(x => x.IDAcademico == idEntidad).FirstOrDefault();
                    if (newSection.error_message == null)
                    {
                        newCanvasCourseSection.Estado        = CanvasWebApi.Common.ConfigEnum.CanvasState.Sincronizado.GetHashCode();
                        newCanvasCourseSection.Fecha         = DateTime.Now;
                        newCanvasCourseSection.IDCanvas      = Int32.Parse(newSection.id);
                        newCanvasCourseSection.IDCanvasGrupo = canvasGroupId;
                    }
                    else
                    {
                        newCanvasCourseSection.Estado = CanvasWebApi.Common.ConfigEnum.CanvasState.Error.GetHashCode();
                        newCanvasCourseSection.Fecha  = DateTime.Now;
                    }

                    newCanvasCourseSection.Error = newSection.error_message;
                    context.SaveChanges();
                }
            }
        }
Ejemplo n.º 5
0
 internal static List <sp_get_uniCanvas_ws_cursos_Result> CoursesToSync()
 {
     using (var context = new CANVAS_Model_Entities())
     {
         int sentEnum = CanvasWebApi.Common.ConfigEnum.CanvasState.Sincronizado.GetHashCode();
         return(context.sp_get_uniCanvas_ws_cursos().ToList());
     }
 }
Ejemplo n.º 6
0
        //TODO: Obtener los datos desde la SP de cursos a concluir y  modificar el circuito desde el controlador hasta la DAL
        internal static List <uniCanvasCurso> CoursesToConclude(string termino)
        {
            using (var context = new CANVAS_Model_Entities())
            {
                // http://localhost:52519/API/COURSE/ConcludeCourse?termino=3er%20cuat%202017
                // espacio en url es %20

                int estadoSincronizado = ConfigEnum.CanvasState.Sincronizado.GetHashCode();
                return(context.uniCanvasCursos.Where(x => x.Termino == termino && (!x.Concluido.HasValue || !x.Concluido.Value) && x.Estado == estadoSincronizado).ToList());
            }
        }
Ejemplo n.º 7
0
        internal static string GetSubjectName(string id)
        {
            using (var context = new CANVAS_Model_Entities())
            {
                uniMateria subject = context.uniMaterias.Where(x => x.codmat == id).FirstOrDefault();

                if (subject != null)
                {
                    return(subject.nombre);
                }

                return(null);
            }
        }
Ejemplo n.º 8
0
 public static List <sp_uni_canvas_sincronizacion_Result> SyncToCanvas()
 {
     logger.Info("SectionDAL/SyncToCanvas - Task 'Sync section' STARTED");
     using (var context = new CANVAS_Model_Entities())
     {
         try
         {
             List <sp_uni_canvas_sincronizacion_Result> rtn = context.sp_uni_canvas_sincronizacion().ToList();
             logger.Info("SectionDAL/SyncToCanvas - Task 'Sync section' FINISHED");
             return(rtn);
         }
         catch (Exception e)
         {
             logger.Error("SectionDAL/SyncToCanvas - Task 'Sync section' FINISHED WITH ERROR: \n " + "  Message: " + e.Message + "\nInner Exception: " + e.InnerException);
             return(new List <sp_uni_canvas_sincronizacion_Result>());
         }
     }
 }
Ejemplo n.º 9
0
        public static List <sp_get_uniCanvas_ws_usuarios_Result> SyncToCanvas()
        {
            logger.Info("UserDAL/SyncToCanvas - Task 'Sync user' STARTED");

            using (var context = new CANVAS_Model_Entities())
            {
                try
                {
                    List <sp_get_uniCanvas_ws_usuarios_Result> rtn = context.sp_get_uniCanvas_ws_usuarios().ToList();
                    logger.Info("UserDAL/SyncToCanvas - Task 'Sync user' FINISHED");
                    return(rtn);
                }
                catch (Exception e)
                {
                    logger.Error("UserDAL/SyncToCanvas - Task 'Sync user' FINISHED WITH ERROR: \n " + "  Message: " + e.Message + "\nInner Exception: " + e.InnerException);
                    return(new List <sp_get_uniCanvas_ws_usuarios_Result>());
                }
            }
        }
Ejemplo n.º 10
0
 internal static List <sp_get_uniCanvas_ws_secciones_Result> SectionsToSync()
 {
     logger.Info("SectionDAL/SectionsToSync - Task 'Get a list with the sections to sync' STARTED");
     using (var context = new CANVAS_Model_Entities())
     {
         try
         {
             int sentEnum = CanvasWebApi.Common.ConfigEnum.CanvasState.Sincronizado.GetHashCode();
             List <sp_get_uniCanvas_ws_secciones_Result> rtn = context.sp_get_uniCanvas_ws_secciones().ToList();
             logger.Info("SectionDAL/SectionsToSync - Task 'Get a list with the sections to sync' FINISHED");
             return(rtn);
         }
         catch (Exception e)
         {
             logger.Error("SectionDAL/SectionsToSync - Task 'Get a list with the sections to sync' FINISHED WITH ERROR: \n " + "  Message: " + e.Message + "\nInner Exception: " + e.InnerException);
             return(new List <sp_get_uniCanvas_ws_secciones_Result>());
         }
     }
 }
Ejemplo n.º 11
0
        internal static List <sp_get_uniCanvas_ws_enrolamientos_Result> InscriptionsToSync(string operation)
        {
            logger.Info("InscriptionDAL/InscriptionsToSync - Task 'Get the list of inscriptions to sync' STARTED");

            using (var context = new CANVAS_Model_Entities())
            {
                try
                {
                    int sentEnum = CanvasWebApi.Common.ConfigEnum.CanvasState.Sincronizado.GetHashCode();
                    List <sp_get_uniCanvas_ws_enrolamientos_Result> rtn = context.sp_get_uniCanvas_ws_enrolamientos(operation).ToList();
                    logger.Info("InscriptionDAL/UpdateCanvasData - Task 'Sync inscription' FINISHED");
                    return(rtn);
                }
                catch (Exception e)
                {
                    logger.Error("InscriptionDAL/InscriptionsToSync - Task 'Get the list of inscriptions to sync' FINISHED WITH ERROR: \n " + "  Message: " + e.Message + "\nInner Exception: " + e.InnerException);
                    return(new List <sp_get_uniCanvas_ws_enrolamientos_Result>());
                }
            }
        }
Ejemplo n.º 12
0
        internal static List <uniCanvasUsuario> UsersToSync()
        {
            logger.Info("UserDAL/UsersToSync - Task 'Get the list of users to sync' STARTED");

            using (var context = new CANVAS_Model_Entities())
            {
                try
                {
                    int sentEnum = CanvasWebApi.Common.ConfigEnum.CanvasState.Sincronizado.GetHashCode();
                    List <uniCanvasUsuario> rtn = context.uniCanvasUsuarios.Where(x => x.Estado != sentEnum).ToList();
                    logger.Info("UserDAL/SyncToCanvas - Task 'Get the list of users to sync' FINISHED");
                    return(rtn);
                }
                catch (Exception e)
                {
                    logger.Error("UserDAL/UsersToSync - Task 'Get the list of users to sync' FINISHED WITH ERROR: \n " + "  Message: " + e.Message + "\nInner Exception: " + e.InnerException);
                    return(new List <uniCanvasUsuario>());
                }
            }
        }
Ejemplo n.º 13
0
 public static void UpdateConcludedCourseCanvasData(uniCanvasCurso aux)
 {
     // TODO: Enviar solo el ID como parametro
     using (var context = new CANVAS_Model_Entities())
     {
         try
         {
             uniCanvasCurso courseToConclude = context.uniCanvasCursos.Where(x => x.IDAcademico == aux.IDAcademico).FirstOrDefault();
             if (courseToConclude != null)
             {
                 courseToConclude.Concluido = true;
                 context.SaveChanges();
             }
         }
         catch
         {
             //TODO: Loguear la falta del curso en la staging
             logger.Error("Error al marcar el curso " + aux.IDAcademico + " como concluido.");
         }
     }
 }
Ejemplo n.º 14
0
        public static void UpdateCanvasData(string idEntidad, CourseReturn newCourse)
        {
            if (newCourse != null)
            {
                using (var context = new CANVAS_Model_Entities())
                {
                    uniCanvasCurso newCanvasCourse = context.uniCanvasCursos.Where(x => x.IDAcademico == idEntidad).FirstOrDefault();
                    if (newCourse.error_message == null)
                    {
                        newCanvasCourse.Estado   = CanvasWebApi.Common.ConfigEnum.CanvasState.Sincronizado.GetHashCode();
                        newCanvasCourse.Fecha    = DateTime.Now;
                        newCanvasCourse.IDCanvas = Int32.Parse(newCourse.id);
                    }
                    else
                    {
                        newCanvasCourse.Estado = CanvasWebApi.Common.ConfigEnum.CanvasState.Error.GetHashCode();
                    }

                    newCanvasCourse.Error = newCourse.error_message;
                    context.SaveChanges();
                }
            }
        }
Ejemplo n.º 15
0
        public static void SyncToCanvas()
        {
            logger.Info("SyncronizationDAL/SyncToCanvas - Task 'Sync user' STARTED");
            try
            {
                using (var context = new CANVAS_Model_Entities())
                {
                    int ciclo  = Int32.Parse(WebConfigurationManager.AppSettings["CurrentYear"]);
                    int cuatri = Int32.Parse(WebConfigurationManager.AppSettings["CurrentQuarter"]);

                    context.Database.CommandTimeout = 180;

                    context.sp_ins_uniCanvas_cursos_secciones(false);
                    logger.Info("SyncronizationDAL/SyncToCanvas - Task 'Sync user' INFO: CURSOS Y SECCIONES SINCRONIZADAS");
                    context.sp_ins_uniCanvas_usuarios_enrolamientos(ciclo, cuatri);
                    logger.Info("SyncronizationDAL/SyncToCanvas - Task 'Sync user' INFO: USUARIOS Y ENROLAMIENTOS SINCRONIZADOS");
                }
                logger.Info("SyncronizationDAL/SyncToCanvas - Task 'Sync user' FINISHED");
            }
            catch (Exception e)
            {
                logger.Error("SyncronizationDAL/SyncToCanvas - Task 'Sync user' FINISHED WITH ERROR: \n " + "  Message: " + e.Message + "\nInner Exception: " + e.InnerException);
            }
        }