コード例 #1
0
        // Total personas en fecha y hora
        public int totalPersonasMomento(DateTime fecha)
        {
            var cursoController   = new CursoController(contextSAAC);
            var periodoController = new PeriodoAcademicoController(contextSAAC);
            var periodoActual     = periodoController.GetPeriodoFecha(fecha);

            if (periodoActual == null)
            {
                return(0);
            }
            var tipoSemana = periodoController.getTipoSemanaEnPeriodo(new InDataFecha {
                fecha = fecha
            });
            string examen = periodoController.tipoExamen(fecha);

            var query =
                from horario in contextSAAC.TBL_HORARIO
                join curso in contextSAAC.TBL_CURSO on horario.intIdCurso equals curso.intIdCurso
                where curso.intIdPeriodo == periodoActual.intIdPeriodoAcademico &&
                horario.intDia == (int)fecha.DayOfWeek &&
                horario.strExamen == examen &&
                horario.chTipo == tipoSemana.tipo &&
                horario.tsHoraInicio <= fecha.TimeOfDay &&
                horario.tsHoraFin > fecha.TimeOfDay
                group curso by curso.intIdPeriodo into grupo
                select new
            {
                idPeriodo   = grupo.Key,
                numPersonas = grupo.Sum(x => x.intNumRegistrados + 1)     // +1 por el profesor
            };

            return(query.Sum(x => x.numPersonas).Value);
        }
コード例 #2
0
        // Cantidad de Personas por bloque
        public IQueryable CantidadDePersonasPorBloque(DateTime fecha)
        {
            var periodoController = new PeriodoAcademicoController(contextSAAC);
            var periodoActual     = periodoController.GetPeriodoFecha(fecha);
            var tipoSemana        = periodoController.getTipoSemanaEnPeriodo(new InDataFecha {
                fecha = fecha
            });
            string examen = periodoController.tipoExamen(fecha);

            var query =
                from lugar in contextSAAC.TBL_LUGAR_ESPOL
                join places in contextSAAC.TBL_LUGAR_ESPOL on lugar.intIdLugarPadre equals places.intIdLugarEspol
                join horario in contextSAAC.TBL_HORARIO on lugar.intIdLugarEspol equals horario.intIdAula
                join curso in contextSAAC.TBL_CURSO on horario.intIdCurso equals curso.intIdCurso
                where curso.intIdPeriodo == periodoActual.intIdPeriodoAcademico &&
                lugar.strTipo == "A"
                //&& lugar.strEstado == "V" //Descomentar en caso de que se necesite solo tener en cuenta los lugares vigentes
                && places.strTipo == "E" &&
                curso.strEstado == "A" &&
                horario.intDia == (int)fecha.DayOfWeek &&
                horario.strExamen == examen &&
                horario.chTipo == tipoSemana.tipo &&
                horario.tsHoraInicio <= fecha.TimeOfDay &&
                horario.tsHoraFin > fecha.TimeOfDay
                group new { places, curso } by places.intIdLugarEspol into grupo
                select new
            {
                lugar       = grupo.Key,
                nombre      = grupo.Select(x => x.places.strDescripcion).First(),
                numPersonas = grupo.Sum(x => x.curso.intNumRegistrados + 1)     // +1 por el profesor
            };

            return(query.OrderByDescending(x => x.numPersonas));
        }
コード例 #3
0
        // Cantidad de lugares usados (Aulas, labs, canchas)
        public int cantLugaresUsadosFecha(DateTime fecha)
        {
            var periodoController = new PeriodoAcademicoController(contextSAAC);
            var periodoActual     = periodoController.GetPeriodoFecha(fecha);

            if (periodoActual == null)
            {
                return(0);
            }
            var tipoSemana = periodoController.getTipoSemanaEnPeriodo(new InDataFecha {
                fecha = fecha
            });
            string examen = periodoController.tipoExamen(fecha);

            var query =
                from lugar in contextSAAC.TBL_LUGAR_ESPOL
                join horario in contextSAAC.TBL_HORARIO on lugar.intIdLugarEspol equals horario.intIdAula
                join curso in contextSAAC.TBL_CURSO on horario.intIdCurso equals curso.intIdCurso
                where curso.intIdPeriodo == periodoActual.intIdPeriodoAcademico &&
                lugar.strTipo == "A" &&
                curso.strEstado == "A" &&
                horario.intDia == (int)fecha.DayOfWeek &&
                horario.strExamen == examen &&
                horario.chTipo == tipoSemana.tipo &&
                horario.tsHoraInicio <= fecha.TimeOfDay &&
                horario.tsHoraFin > fecha.TimeOfDay
                group curso by lugar.intIdLugarEspol into grupo
                select new
            {
                lugar       = grupo.Key,
                numPersonas = grupo.Sum(x => x.intNumRegistrados + 1)     // +1 por el profesor
            };

            return(query.Count(x => x.lugar > 0));
        }
コード例 #4
0
        public IQueryable lugaresOcupados([FromBody] InDataFecha data)
        {
            var periodoController = new PeriodoAcademicoController(context);
            var tipoSemana        = periodoController.getTipoSemanaEnPeriodo(new InDataFecha {
                fecha = data.fecha
            });
            var    periodoActual = periodoController.GetPeriodoFecha(data.fecha);
            string examen        = periodoController.tipoExamen(data.fecha);
            int    dia           = (int)data.fecha.DayOfWeek;


            var lugaresOcupados =
                from horario in context.TBL_HORARIO
                where horario.strExamen == examen
                join curso in context.TBL_CURSO on horario.intIdCurso equals curso.intIdCurso
                join lugar in context.TBL_LUGAR_ESPOL on horario.intIdAula equals lugar.intIdLugarEspol
                join padre in context.TBL_LUGAR_ESPOL on lugar.intIdLugarPadre equals padre.intIdLugarEspol
                where lugar.strTipo == "A" &&
                curso.intIdPeriodo == periodoActual.intIdPeriodoAcademico &&
                horario.intDia == dia &&
                horario.chTipo == tipoSemana.tipo &&
                horario.tsHoraInicio <= data.fecha.TimeOfDay &&
                horario.tsHoraFin > data.fecha.TimeOfDay
                select new
            {
                idLugar     = lugar.intIdLugarEspol,
                nombreLugar = lugar.strDescripcion,
                idPadre     = padre.intIdLugarEspol,
                nombrePadre = padre.strDescripcion
            };

            return(lugaresOcupados.Distinct());
        }
コード例 #5
0
        public IQueryable obtenerLugaresDisponibles([FromBody] InDataFecha data)
        {
            var periodoController = new PeriodoAcademicoController(context);
            var tipoSemana        = periodoController.getTipoSemanaEnPeriodo(new InDataFecha {
                fecha = data.fecha
            });
            var    periodoActual = periodoController.GetPeriodoFecha(data.fecha);
            string examen        = periodoController.tipoExamen(data.fecha);


            var lugaresOcupados =
                from horario in context.TBL_HORARIO
                where horario.strExamen == examen
                join curso in context.TBL_CURSO on horario.intIdCurso equals curso.intIdCurso
                join lugar in context.TBL_LUGAR_ESPOL on horario.intIdAula equals lugar.intIdLugarEspol
                join padre in context.TBL_LUGAR_ESPOL on lugar.intIdLugarPadre equals padre.intIdLugarEspol
                where lugar.strTipo == "A" &&
                horario.chTipo == tipoSemana.tipo &&
                horario.tsHoraInicio <= data.fecha.TimeOfDay &&
                horario.tsHoraFin > data.fecha.TimeOfDay
                select new
            {
                idLugar     = lugar.intIdLugarEspol,
                nombreLugar = lugar.strDescripcion,
                idPadre     = padre.intIdLugarEspol,
                nombrePadre = padre.strDescripcion
            };

            var lugaresOcupadosRecuperaciones =
                from horario in context.TBL_HORARIO_CONTENIDO
                join lugar in context.TBL_LUGAR_ESPOL on horario.intIdLugarEspol equals lugar.intIdLugarEspol
                join padre in context.TBL_LUGAR_ESPOL on lugar.intIdLugarPadre equals padre.intIdLugarEspol
                where lugar.strTipo == "A" &&
                horario.dtFecha == data.fecha.Date &&
                horario.tsHoraInicio <= data.fecha.TimeOfDay &&
                horario.tsHoraFin <= data.fecha.TimeOfDay
                select new
            {
                idLugar     = lugar.intIdLugarEspol,
                nombreLugar = lugar.strDescripcion,
                idPadre     = padre.intIdLugarEspol,
                nombrePadre = padre.strDescripcion
            };

            var infoLugares =
                from lugar in context.TBL_LUGAR_ESPOL
                join padre in context.TBL_LUGAR_ESPOL on lugar.intIdLugarPadre equals padre.intIdLugarEspol
                where lugar.strTipo == "A" && lugar.strEstado == "V"
                select new
            {
                idLugar     = lugar.intIdLugarEspol,
                nombreLugar = lugar.strDescripcion,
                idPadre     = padre.intIdLugarEspol,
                nombrePadre = padre.strDescripcion
            };

            return(infoLugares.Except(lugaresOcupados.Union(lugaresOcupadosRecuperaciones)).Distinct().OrderBy(x => x.nombreLugar));;
        }
コード例 #6
0
        // Cantidad de profesores con un curso este semestre
        public int cantProfesoresPeriodo(DateTime fecha)
        {
            var periodoController = new PeriodoAcademicoController(contextSAAC);
            var periodoActual     = periodoController.GetPeriodoFecha(fecha);

            var query =
                from persona in contextSAAC.TBL_PERSONA
                join curso in contextSAAC.TBL_CURSO on persona.intIdPersona equals curso.intIdProfesor
                where curso.intIdPeriodo == periodoActual.intIdPeriodoAcademico && curso.strEstado == "A" && persona.strEstadoPersona == "A"
                select new
            {
                persona
            };

            return(query.Distinct().Count());
        }
コード例 #7
0
        // Cantidad de estudiantes/Cantidad registrados en periodo
        public int cantRegistrados(DateTime fecha)
        {
            var periodoController = new PeriodoAcademicoController(contextSAAC);
            var periodoActual     = periodoController.GetPeriodoFecha(fecha);

            var query =
                from persona in contextSAAC.TBL_PERSONA
                join historia in contextSAAC.HISTORIA_ANIO on persona.strCodEstudiante equals historia.strCodEstudiante
                join curso in contextSAAC.TBL_CURSO on historia.intIdCurso equals curso.intIdCurso
                where curso.intIdPeriodo == periodoActual.intIdPeriodoAcademico
                group persona by persona.intIdPersona into grupo
                select new {
                grupo,
                idPersona = grupo.Key,
                cantidad  = grupo.Count()
            };


            return(query.Count());
        }
コード例 #8
0
        public IQueryable datosMapa([FromBody] InDataFecha data)
        {
            var periodoController = new PeriodoAcademicoController(contextSAAC);
            var periodoActual     = periodoController.GetPeriodoFecha(data.fecha);
            var tipoSemana        = periodoController.getTipoSemanaEnPeriodo(new InDataFecha {
                fecha = data.fecha
            });
            string examen = periodoController.tipoExamen(data.fecha);
            int    dia    = (int)data.fecha.DayOfWeek;
            var    query  =
                from horario in contextSAAC.TBL_HORARIO
                where horario.strExamen == examen
                join curso in contextSAAC.TBL_CURSO on horario.intIdCurso equals curso.intIdCurso
                join lugar in contextSAAC.TBL_LUGAR_ESPOL on horario.intIdAula equals lugar.intIdLugarEspol
                where horario.intDia == dia &&
                curso.intIdPeriodo == periodoActual.intIdPeriodoAcademico &&
                horario.chTipo == tipoSemana.tipo &&
                horario.tsHoraInicio <= data.fecha.TimeOfDay &&
                horario.tsHoraFin > data.fecha.TimeOfDay
                select new
            {
                idHorario        = horario.intIdHorario,
                fecha            = horario.dtFecha,
                horaInicio       = horario.tsHoraInicio,
                horaFin          = horario.tsHoraFin,
                tipoHorario      = horario.chTipo,
                numRegistrados   = curso.intNumRegistrados + 1,   // Por el profesor
                tipoCurso        = curso.strTipoCurso,
                idLugar          = lugar.intIdLugarEspol,
                descripcionLugar = lugar.strDescripcion,
                latitud          = lugar.strLatitud,
                longitud         = lugar.strLongitud,
                tipoLugar        = lugar.strTipo
            };

            var query2 =
                from horario in contextSAAC.TBL_HORARIO_CONTENIDO
                join curso in contextSAAC.TBL_CURSO on horario.intIdCurso equals curso.intIdCurso
                join lugar in contextSAAC.TBL_LUGAR_ESPOL on horario.intIdLugarEspol equals lugar.intIdLugarEspol
                where data.fecha == horario.dtFecha &&
                horario.strEstadoRecuperacion == "AP" &&
                horario.intIdLugarEspol != null &&
                horario.tsHoraInicio <= data.fecha.TimeOfDay &&
                horario.tsHoraFin > data.fecha.TimeOfDay
                select new
            {
                idHorario        = horario.intIdHorarioContenido,
                fecha            = horario.dtFecha,
                horaInicio       = horario.tsHoraInicioPlanificado,
                horaFin          = horario.tsHoraFinPlanificado,
                tipoHorario      = horario.strTipo,
                numRegistrados   = curso.intNumRegistrados + 1,   // Por el profesor
                tipoCurso        = curso.strTipoCurso,
                idLugar          = lugar.intIdLugarEspol,
                descripcionLugar = lugar.strDescripcion,
                latitud          = lugar.strLatitud,
                longitud         = lugar.strLongitud,
                tipoLugar        = lugar.strTipo
            };

            return(query.Concat(query2));
        }
コード例 #9
0
        public IQueryable obtenerLugaresDisponiblesRango([FromBody] InDataFechasReunion data)
        {
            var periodoController = new PeriodoAcademicoController(context);
            var tipoSemana        = periodoController.getTipoSemanaEnPeriodo(new InDataFecha {
                fecha = data.fechaInicio
            });
            var    periodoActual = periodoController.GetPeriodoFecha(data.fechaInicio.Date);
            string examen        = periodoController.tipoExamen(data.fechaInicio.Date);

            /*List<int> diasTomarEnCuenta = new List<int>();
             * var fechaIni = data.fechaInicio.Date;
             * var fechaFin = data.fechaFin.Date;
             * while (fechaIni < fechaFin)
             * {
             *  if (!diasTomarEnCuenta.Contains((int)data.fechaInicio.DayOfWeek)) diasTomarEnCuenta.Add((int)fechaIni.DayOfWeek);
             *  fechaIni.AddDays(1);
             * }
             * if (!diasTomarEnCuenta.Contains((int)data.fechaFin.DayOfWeek)) diasTomarEnCuenta.Add((int)fechaFin.DayOfWeek);
             * var dias = diasTomarEnCuenta.AsEnumerable();*/

            var lugaresOcupados =
                from horario in context.TBL_HORARIO
                where horario.strExamen == examen
                join curso in context.TBL_CURSO on horario.intIdCurso equals curso.intIdCurso
                join lugar in context.TBL_LUGAR_ESPOL on horario.intIdAula equals lugar.intIdLugarEspol
                where lugar.strTipo == "A" && lugar.intIdLugarPadre != null
                join padre in context.TBL_LUGAR_ESPOL on lugar.intIdLugarPadre equals padre.intIdLugarEspol
                //join dia in dias on horario.intDia equals (short)dia
                where horario.chTipo == tipoSemana.tipo &&
                horario.strExamen == examen &&
                horario.intDia == (int)data.fechaInicio.DayOfWeek &&
                curso.intIdPeriodo == periodoActual.intIdPeriodoAcademico

                /*&& (
                 *  (data.fechaInicio.Date.Add(horario.tsHoraInicio.GetValueOrDefault(new TimeSpan(0, 0, 0))) > data.fechaInicio && data.fechaInicio.Date.Add(horario.tsHoraInicio.GetValueOrDefault(new TimeSpan(0, 0, 0))) < data.fechaFin)
                 || (data.fechaInicio.Date.Add(horario.tsHoraFin.GetValueOrDefault(new TimeSpan(0, 0, 0))) > data.fechaInicio && data.fechaInicio.Date.Add(horario.tsHoraFin.GetValueOrDefault(new TimeSpan(0, 0, 0))) < data.fechaFin)
                 || (data.fechaInicio.Date.Add(horario.tsHoraInicio.GetValueOrDefault(new TimeSpan(0, 0, 0))) < data.fechaInicio && data.fechaFin.Date.Add(horario.tsHoraFin.GetValueOrDefault(new TimeSpan(0, 0, 0))) > data.fechaFin)
                 ||)*/
                && (
                    (horario.tsHoraInicio >= data.fechaInicio.TimeOfDay && horario.tsHoraInicio < data.fechaFin.TimeOfDay) ||
                    (horario.tsHoraFin > data.fechaInicio.TimeOfDay && horario.tsHoraFin <= data.fechaFin.TimeOfDay) ||
                    (horario.tsHoraInicio <= data.fechaInicio.TimeOfDay && horario.tsHoraFin >= data.fechaFin.TimeOfDay)
                    )
                select new
            {
                idLugar     = lugar.intIdLugarEspol,
                nombreLugar = lugar.strDescripcion,
                idPadre     = padre.intIdLugarEspol,
                nombrePadre = padre.strDescripcion
            };

            var lugaresOcupadosRecuperaciones =
                from horario in context.TBL_HORARIO_CONTENIDO
                join lugar in context.TBL_LUGAR_ESPOL on horario.intIdLugarEspol equals lugar.intIdLugarEspol
                join padre in context.TBL_LUGAR_ESPOL on lugar.intIdLugarPadre equals padre.intIdLugarEspol
                where lugar.strTipo == "A" &&
                (horario.dtFecha >= data.fechaInicio.Date && horario.dtFecha <= data.fechaFin.Date) &&
                (
                    (horario.tsHoraInicio >= data.fechaInicio.TimeOfDay && horario.tsHoraInicio < data.fechaFin.TimeOfDay) ||
                    (horario.tsHoraFin > data.fechaInicio.TimeOfDay && horario.tsHoraFin <= data.fechaFin.TimeOfDay) ||
                    (horario.tsHoraInicio <= data.fechaInicio.TimeOfDay && horario.tsHoraFin >= data.fechaFin.TimeOfDay)
                )
                select new
            {
                idLugar     = lugar.intIdLugarEspol,
                nombreLugar = lugar.strDescripcion,
                idPadre     = padre.intIdLugarEspol,
                nombrePadre = padre.strDescripcion
            };

            var infoLugares =
                from lugar in context.TBL_LUGAR_ESPOL
                join padre in context.TBL_LUGAR_ESPOL on lugar.intIdLugarPadre equals padre.intIdLugarEspol
                where lugar.strTipo == "A" && lugar.strEstado == "V"
                select new
            {
                idLugar     = lugar.intIdLugarEspol,
                nombreLugar = lugar.strDescripcion,
                idPadre     = padre.intIdLugarEspol,
                nombrePadre = padre.strDescripcion
            };

            return(infoLugares.Except(lugaresOcupados.Union(lugaresOcupadosRecuperaciones)).Distinct().OrderBy(x => x.nombreLugar));
        }