Beispiel #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");
        }
Beispiel #2
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;
            }
        }