示例#1
0
        public IList <sp_get_ProfesoresHs_Result> InfoSNFichadaParaInsertar(SN_Fichadas sNFichada)
        {
            List <sp_get_ProfesoresHs_Result> ProfesoresHsList      = context.sp_get_ProfesoresHs(sNFichada.Planta, sNFichada.Fecha.Value.Date, "", null, null).ToList();
            List <sp_get_ProfesoresHs_Result> ProfesoresHsListFinal = new List <sp_get_ProfesoresHs_Result>();

            ProfesoresHsList = ProfesoresHsList.Where(phl => phl.LegajoProfesor == sNFichada.Tarjeta).ToList();

            ProfesoresHsList = ProfesoresHsList.Where(ph => (ph.NovedadesId.HasValue ? !NovedadesHsTotal(ph.NovedadesId.Value) : true) && ph.Ausente == 0).ToList();

            if (ProfesoresHsList.Count > 1)
            {
                var query =
                    from c in ProfesoresHsList
                    group c by new
                {
                    c.codins,
                    c.FechaPlanificada,
                    c.HoraInicio,
                } into g
                select g;


                foreach (var item in query)
                {
                    if (item.Count() > 1)
                    {
                        int alm = 0;
                        sp_get_ProfesoresHs_Result definitivo = new sp_get_ProfesoresHs_Result();
                        foreach (sp_get_ProfesoresHs_Result item2 in item)
                        {
                            int alm2 = (from uIMD in context.uniInscripcionesMateriasDetalle
                                        join uIM in context.uniInscripcionesMaterias on uIMD.Clave equals uIM.Clave
                                        where uIMD.cursoId == item2.CursoId && uIM.Eliminada.HasValue ? !uIM.Eliminada.Value : true
                                        select uIMD).Count();

                            if (alm2 > alm)
                            {
                                definitivo = item2;
                            }
                        }
                        ProfesoresHsListFinal.Add(definitivo);
                    }
                    else
                    {
                        ProfesoresHsListFinal.Add(item.First());
                    }
                }
            }
            else
            {
                ProfesoresHsListFinal = ProfesoresHsList;
            }

            return(ProfesoresHsListFinal.OrderBy(ph => ph.HoraInicio.Value).ToList());
        }
示例#2
0
        private UniProfesorInstitutoDto CargarDesvio(UniCorreoxEdificio correoxEdificio, sp_get_ProfesoresHs_Result fichadaPlanificada)
        {
            UniProfesorInstitutoDto rtn = new UniProfesorInstitutoDto();

            if (correoxEdificio != null && fichadaPlanificada != null)
            {
                rtn.LegajoProfesor   = fichadaPlanificada.LegajoProfesor;
                rtn.CorreoInstituto  = correoxEdificio.Correo;
                rtn.apellido         = fichadaPlanificada.apellido;
                rtn.ClaseNro         = fichadaPlanificada.ClaseNro;
                rtn.codcur           = fichadaPlanificada.codcur;
                rtn.codins           = fichadaPlanificada.codins;
                rtn.codmat           = fichadaPlanificada.codmat;
                rtn.comision         = fichadaPlanificada.comision;
                rtn.CursoId          = fichadaPlanificada.CursoId.ToString();
                rtn.FechaPlanificada = fichadaPlanificada.FechaPlanificada;
                rtn.HoraFin          = fichadaPlanificada.HoraFin;
                rtn.HoraInicio       = fichadaPlanificada.HoraInicio;
                rtn.LegajoProfesor   = fichadaPlanificada.LegajoProfesor;
                rtn.turno            = fichadaPlanificada.turno;
                rtn.Usuario          = fichadaPlanificada.Usuario;
                rtn.CorreoCopia      = correoxEdificio.CorreoCopia;

                return(rtn);
            }
            return(null);
        }
示例#3
0
        public void CalcularHoras(UniProfesoresHs mProfesoresHs, sp_get_ProfesoresHs_Result profesoresHs, int toleranciaEntrada, int toleranciaSalida, bool toleranciaAcumuladaDisponible)
        {
            bool toleranciaEntradaDisponible = toleranciaEntrada > 0;
            bool toleranciaSalidaDisponible  = toleranciaSalida > 0;
            int  toleranciaAcumulable        = toleranciaEntrada + toleranciaSalida;

            if (mProfesoresHs.Salida.Value.Date != DateTime.MinValue.Date && mProfesoresHs.Entrada.Value.Date != DateTime.MinValue.Date)
            {
                TimeSpan _tiempoDictado     = (mProfesoresHs.Salida.Value - mProfesoresHs.Entrada.Value);
                DateTime entradaReal        = mProfesoresHs.Entrada.Value;
                DateTime entradaPlanificada = profesoresHs.HoraInicio.Value;
                DateTime salidaReal         = mProfesoresHs.Salida.Value;
                DateTime salidaPlanificada  = profesoresHs.HoraFin.Value;

                // --E--|-------|--S--
                if (entradaReal.TimeOfDay <= entradaPlanificada.TimeOfDay && salidaReal.TimeOfDay >= salidaPlanificada.TimeOfDay)
                {
                    _tiempoDictado = (profesoresHs.HoraFin.Value.TimeOfDay - profesoresHs.HoraInicio.Value.TimeOfDay);
                }
                // --E--|-----S--|----
                else if (entradaReal.TimeOfDay <= entradaPlanificada.TimeOfDay && salidaReal.TimeOfDay <= salidaPlanificada.TimeOfDay)
                {
                    if (toleranciaEntradaDisponible || toleranciaAcumuladaDisponible)
                    {
                        // Se toma en cuenta la tolerancia de entrada
                        if (toleranciaEntradaDisponible && salidaReal.TimeOfDay >= entradaPlanificada.TimeOfDay)
                        {
                            TimeSpan _tiempoFaltante = (profesoresHs.HoraFin.Value.TimeOfDay - mProfesoresHs.Salida.Value.TimeOfDay);
                            if ((_tiempoFaltante.Hours * 60) + _tiempoFaltante.Minutes <= toleranciaSalida)
                            {
                                _tiempoDictado = (profesoresHs.HoraFin.Value.TimeOfDay - profesoresHs.HoraInicio.Value.TimeOfDay);
                            }
                            else
                            {
                                _tiempoDictado = (mProfesoresHs.Salida.Value.TimeOfDay - profesoresHs.HoraInicio.Value.TimeOfDay);
                            }
                        }
                        else if (toleranciaAcumuladaDisponible && salidaReal.TimeOfDay >= entradaPlanificada.TimeOfDay)
                        {
                            TimeSpan _tiempoFaltante = (profesoresHs.HoraFin.Value.TimeOfDay - mProfesoresHs.Salida.Value.TimeOfDay);
                            if ((_tiempoFaltante.Hours * 60) + _tiempoFaltante.Minutes <= toleranciaAcumulable)
                            {
                                toleranciaAcumulable = toleranciaAcumulable - ((_tiempoFaltante.Hours * 60) + _tiempoFaltante.Minutes);
                                _tiempoDictado       = (profesoresHs.HoraFin.Value.TimeOfDay - profesoresHs.HoraInicio.Value.TimeOfDay);
                            }
                            else
                            {
                                _tiempoDictado = (mProfesoresHs.Salida.Value.TimeOfDay - profesoresHs.HoraInicio.Value.TimeOfDay);
                            }
                        }
                        else
                        {
                            _tiempoDictado = (DateTime.MinValue.TimeOfDay - DateTime.MinValue.TimeOfDay);
                        }
                    }
                    else
                    {
                        // No se toma en cuenta la tolerancia de entrada
                        _tiempoDictado = (mProfesoresHs.Salida.Value.TimeOfDay - profesoresHs.HoraInicio.Value.TimeOfDay);
                    }
                }
                // ----|--E-----|--S--
                else if (entradaReal.TimeOfDay >= entradaPlanificada.TimeOfDay && salidaReal.TimeOfDay >= salidaPlanificada.TimeOfDay)
                {
                    if (toleranciaSalidaDisponible || toleranciaAcumuladaDisponible)
                    {
                        // Se toma en cuenta la tolerancia de salida
                        if (toleranciaSalidaDisponible && entradaReal.TimeOfDay <= salidaPlanificada.TimeOfDay)
                        {
                            TimeSpan _tiempoFaltante = (mProfesoresHs.Entrada.Value.TimeOfDay - profesoresHs.HoraInicio.Value.TimeOfDay);
                            if ((_tiempoFaltante.Hours * 60) + _tiempoFaltante.Minutes <= toleranciaEntrada)
                            {
                                _tiempoDictado = (profesoresHs.HoraFin.Value.TimeOfDay - profesoresHs.HoraInicio.Value.TimeOfDay);
                            }
                            else
                            {
                                _tiempoDictado = (profesoresHs.HoraFin.Value.TimeOfDay - mProfesoresHs.Entrada.Value.TimeOfDay);
                            }
                        }
                        else if (toleranciaAcumuladaDisponible && entradaReal.TimeOfDay <= salidaPlanificada.TimeOfDay)
                        {
                            TimeSpan _tiempoFaltante = (mProfesoresHs.Entrada.Value.TimeOfDay - profesoresHs.HoraInicio.Value.TimeOfDay);
                            if ((_tiempoFaltante.Hours * 60) + _tiempoFaltante.Minutes <= toleranciaAcumulable)
                            {
                                _tiempoDictado = (profesoresHs.HoraFin.Value.TimeOfDay - profesoresHs.HoraInicio.Value.TimeOfDay);
                            }
                            else
                            {
                                _tiempoDictado = (profesoresHs.HoraFin.Value.TimeOfDay - mProfesoresHs.Entrada.Value.TimeOfDay);
                            }
                        }
                        else
                        {
                            _tiempoDictado = (DateTime.MinValue.TimeOfDay - DateTime.MinValue.TimeOfDay);
                        }
                    }
                    else
                    {
                        // No se toma en cuenta la tolerancia de salida
                        _tiempoDictado = (profesoresHs.HoraFin.Value.TimeOfDay - mProfesoresHs.Entrada.Value.TimeOfDay);
                    }
                }
                // ----|--E---S--|----
                else if (entradaReal.TimeOfDay >= entradaPlanificada.TimeOfDay && salidaReal.TimeOfDay <= salidaPlanificada.TimeOfDay)
                {
                    TimeSpan _tiempoFaltanteEntrada = (mProfesoresHs.Entrada.Value.TimeOfDay - profesoresHs.HoraInicio.Value.TimeOfDay);
                    TimeSpan _tiempoFaltanteSalida  = (profesoresHs.HoraFin.Value.TimeOfDay - mProfesoresHs.Salida.Value.TimeOfDay);

                    if ((_tiempoFaltanteEntrada.Hours * 60) + _tiempoFaltanteEntrada.Minutes <= toleranciaEntrada || (_tiempoFaltanteEntrada.Hours * 60) + _tiempoFaltanteEntrada.Minutes <= toleranciaAcumulable)
                    {
                        // El profesor tiene tolerancia en la entrada
                        if ((_tiempoFaltanteSalida.Hours * 60) + _tiempoFaltanteSalida.Minutes <= toleranciaSalida || (_tiempoFaltanteSalida.Hours * 60) + _tiempoFaltanteSalida.Minutes <= toleranciaAcumulable)
                        {
                            // El profesor tiene tolerancia en la salida
                            _tiempoDictado = (profesoresHs.HoraFin.Value.TimeOfDay - profesoresHs.HoraInicio.Value.TimeOfDay);
                        }
                        else
                        {
                            // El profesor NO tiene tolerancia en la salida
                            _tiempoDictado = (mProfesoresHs.Salida.Value.TimeOfDay - profesoresHs.HoraInicio.Value.TimeOfDay);
                        }
                    }
                    else
                    {
                        // El profesor NO tiene tolerancia en la entrada
                        if (toleranciaAcumuladaDisponible)
                        {
                            toleranciaEntrada = toleranciaAcumulable - (_tiempoFaltanteEntrada.Hours * 60) + _tiempoFaltanteEntrada.Minutes;
                        }
                        if ((_tiempoFaltanteSalida.Hours * 60) + _tiempoFaltanteSalida.Minutes <= toleranciaSalida || (_tiempoFaltanteSalida.Hours * 60) + _tiempoFaltanteSalida.Minutes <= toleranciaAcumulable)
                        {
                            // El profesor tiene tolerancia en la salida
                            _tiempoDictado = (profesoresHs.HoraFin.Value.TimeOfDay - mProfesoresHs.Entrada.Value.TimeOfDay);
                        }
                        else
                        {
                            // El profesor NO tiene tolerancia en la salida
                            _tiempoDictado = (mProfesoresHs.Salida.Value.TimeOfDay - mProfesoresHs.Entrada.Value.TimeOfDay);
                        }
                    }
                }
                else
                {
                    _tiempoDictado = (DateTime.MinValue.TimeOfDay - DateTime.MinValue.TimeOfDay);
                }

                double hsCalculadas = _tiempoDictado.Hours + _tiempoDictado.Minutes * 0.01;
                mProfesoresHs.HsEfectivas = (decimal)hsCalculadas;

                if (mProfesoresHs.HsEfectivas > mProfesoresHs.HsPlanificadas)
                {
                    mProfesoresHs.HsEfectivas = mProfesoresHs.HsPlanificadas;
                }
            }
            //return mProfesoresHs;
        }
示例#4
0
        public void TransformarSNFichadasEnProceso(int toleranceSeconds, int toleranciaEntrada, int toleranciaSalida, bool toleranciaAcumuladaDisponible)
        {
            IList <SN_Fichadas> snfichadasIList      = sNFichadasService.GetFichadasEnProceso();
            IList <SN_Fichadas> snfichadasIListFinal = sNFichadasService.EliminarRegistrosSucesivos(snfichadasIList, toleranceSeconds);

            foreach (SN_Fichadas snfichada in snfichadasIListFinal)
            {
                IList <sp_get_ProfesoresHs_Result> infoFichadas = sNFichadasService.InfoSNFichadaParaInsertar(snfichada);
                if (infoFichadas.Count == 1)
                {
                    sp_get_ProfesoresHs_Result infoF           = infoFichadas.FirstOrDefault();
                    UniProfesoresHs            uniProfesoresHs = uniProfesoresHsService.GetByCursoClaseLegajo((int)infoF.CursoId, infoF.ClaseNro, infoF.LegajoProfesor);

                    if (uniProfesoresHs != null)
                    {
                        if (uniProfesoresHs.Entrada.HasValue)
                        {
                            TimeSpan diff = snfichada.Fecha.Value - uniProfesoresHs.Entrada.Value;

                            //if (diff.TotalSeconds < toleranceSeconds)
                            //    break;

                            if (!uniProfesoresHs.Salida.HasValue)
                            {
                                uniProfesoresHs.Salida            = snfichada.Fecha.Value;
                                uniProfesoresHs.SalidaEditada     = snfichada.Fecha.Value;
                                uniProfesoresHs.FechaModificacion = DateTime.Today;
                                //diff = uniProfesoresHs.Salida.Value - uniProfesoresHs.Entrada.Value;
                                //decimal hours = (decimal)diff.TotalHours;
                                //uniProfesoresHs.HsEfectivas = hours;
                                uniProfesoresHsService.CalcularHoras(uniProfesoresHs, infoF, toleranciaEntrada, toleranciaSalida, toleranciaAcumuladaDisponible);
                            }
                            else
                            {
                                diff = snfichada.Fecha.Value - uniProfesoresHs.Salida.Value;

                                if (diff.TotalSeconds < toleranceSeconds)
                                {
                                    break;
                                }
                            }
                        }
                        else
                        {
                            uniProfesoresHs.Entrada           = snfichada.Fecha.Value;
                            uniProfesoresHs.EntradaEditada    = snfichada.Fecha.Value;
                            uniProfesoresHs.FechaModificacion = DateTime.Today;
                            if (!uniProfesoresHs.NovedadesId.HasValue || uniProfesoresHs.NovedadesId.Value == 0)
                            {
                                uniProfesoresHs.NovedadesId = TipoNovedadesEnum.HS_CATEDRA.GetHashCode();
                            }
                        }
                        uniProfesoresHsService.Update(uniProfesoresHs);
                    }
                    else
                    {
                        uniProfesoresHs                   = new UniProfesoresHs();
                        uniProfesoresHs.Ausente           = false;
                        uniProfesoresHs.ClaseNro          = infoF.ClaseNro;
                        uniProfesoresHs.Comentarios       = "";
                        uniProfesoresHs.CursoId           = infoF.CursoId;
                        uniProfesoresHs.Entrada           = snfichada.Fecha;
                        uniProfesoresHs.EntradaEditada    = snfichada.Fecha;
                        uniProfesoresHs.FechaCreacion     = DateTime.Now;
                        uniProfesoresHs.FechaModificacion = DateTime.Now;
                        uniProfesoresHs.HsEfectivas       = null;

                        TimeSpan diff  = infoF.HoraFin.Value - infoF.HoraInicio.Value;
                        decimal  hours = (decimal)diff.TotalHours;

                        uniProfesoresHs.HsPlanificadas          = hours;
                        uniProfesoresHs.LegajoProfesor          = snfichada.legajo == 0 ? snfichada.Tarjeta.Value : snfichada.legajo;
                        uniProfesoresHs.LegajoProfesorReemplazo = 0;
                        uniProfesoresHs.NoPlanificado           = false;
                        uniProfesoresHs.NovedadesId             = TipoNovedadesEnum.HS_CATEDRA.GetHashCode();
                        uniProfesoresHs.Revision      = false;
                        uniProfesoresHs.Salida        = null;
                        uniProfesoresHs.SalidaEditada = null;
                        uniProfesoresHs.Usuario       = "UKSync";
                        uniProfesoresHs.Version       = 1;

                        uniProfesoresHsService.Create(uniProfesoresHs);
                    }
                }
                else
                {
                    bool notFound = true;
                    foreach (sp_get_ProfesoresHs_Result infoFichada in infoFichadas)
                    {
                        if (notFound)
                        {
                            UniProfesoresHs uniProfesoresHs = uniProfesoresHsService.GetByCursoClaseLegajo((int)infoFichada.CursoId, infoFichada.ClaseNro, infoFichada.LegajoProfesor);
                            if (uniProfesoresHs != null)
                            {
                                TimeSpan diff = snfichada.Fecha.Value - uniProfesoresHs.Entrada.Value;

                                if (diff.TotalSeconds < toleranceSeconds)
                                {
                                    notFound = true;
                                }
                                else if (!uniProfesoresHs.Salida.HasValue)
                                {
                                    uniProfesoresHs.Salida        = snfichada.Fecha;
                                    uniProfesoresHs.SalidaEditada = snfichada.Fecha;
                                    //diff = uniProfesoresHs.Salida.Value - uniProfesoresHs.Entrada.Value;
                                    //decimal hours = (decimal)diff.TotalHours;
                                    //uniProfesoresHs.HsEfectivas = hours;
                                    uniProfesoresHsService.CalcularHoras(uniProfesoresHs, infoFichada, toleranciaEntrada, toleranciaSalida, toleranciaAcumuladaDisponible);
                                    uniProfesoresHs.FechaModificacion = DateTime.Today;
                                    notFound = false;
                                    uniProfesoresHsService.Update(uniProfesoresHs);
                                }
                                else
                                {
                                    diff = snfichada.Fecha.Value - uniProfesoresHs.Salida.Value;

                                    if (diff.TotalSeconds < toleranceSeconds)
                                    {
                                        notFound = true;
                                    }
                                }
                            }
                            else
                            {
                                uniProfesoresHs                   = new UniProfesoresHs();
                                uniProfesoresHs.Ausente           = false;
                                uniProfesoresHs.ClaseNro          = infoFichada.ClaseNro;
                                uniProfesoresHs.Comentarios       = "";
                                uniProfesoresHs.CursoId           = infoFichada.CursoId;
                                uniProfesoresHs.Entrada           = snfichada.Fecha;
                                uniProfesoresHs.EntradaEditada    = snfichada.Fecha;
                                uniProfesoresHs.FechaCreacion     = DateTime.Now;
                                uniProfesoresHs.FechaModificacion = DateTime.Now;
                                uniProfesoresHs.HsEfectivas       = null;

                                TimeSpan diff  = infoFichada.HoraFin.Value - infoFichada.HoraInicio.Value;
                                decimal  hours = (decimal)diff.TotalHours;

                                uniProfesoresHs.HsPlanificadas          = hours;
                                uniProfesoresHs.LegajoProfesor          = snfichada.legajo == 0 ? snfichada.Tarjeta.Value : snfichada.legajo;;
                                uniProfesoresHs.LegajoProfesorReemplazo = 0;
                                uniProfesoresHs.NoPlanificado           = false;
                                uniProfesoresHs.NovedadesId             = TipoNovedadesEnum.HS_CATEDRA.GetHashCode();
                                uniProfesoresHs.Revision      = false;
                                uniProfesoresHs.Salida        = null;
                                uniProfesoresHs.SalidaEditada = null;
                                uniProfesoresHs.Usuario       = "UKSync";
                                uniProfesoresHs.Version       = 1;

                                uniProfesoresHsService.Create(uniProfesoresHs);
                                notFound = false;
                            }
                        }
                    }
                }
                sNFichadasService.EstadoSincroAEnviado(snfichada);
            }
        }