示例#1
0
        public rutasDto Get(string Vial)
        {
            using(ctx=new tvEntities()){
                DateTime fecha = DateTime.Now.Date;
                rutasDto rutaDto = new rutasDto();

                detallesplanilla dP = ctx.detallesplanilla.Where(t => t.buses.Vial == Vial && t.planillacontrol.Fecha==fecha).FirstOrDefault();
                rutas ruta = ctx.rutas.Where(t => t.NomRuta == dP.Ruta).FirstOrDefault();

                Mapper.Map(ruta,rutaDto);
                return rutaDto;
            }
        }
示例#2
0
        public List <historialmovimientoDTO> get(entradassalidasDTO eSDto)
        {
            //fecha = fecha.Date;
            //DateTime fechaFin = new DateTime(fecha.Year, fecha.Month, fecha.Day, 23, 59, 59);
            List <historialmovimientoDTO> lHmDto;
            historialmovimientoDTO        hMDto;

            using (ctx = new tvEntities()){
                List <historialmovimiento> lHm = ctx.historialmovimiento
                                                 .OrderBy(t => t.Fecha)
                                                 .Where(t => t.Fecha >= eSDto.Fecha && t.Fecha <= eSDto.FechaFin && t.Placa == eSDto.Placa)
                                                 .ToList();

                detallesplanilla dP = ctx.detallesplanilla
                                      .Where(t => t.planillacontrol.Fecha == eSDto.Fecha.Date && t.PlacaBus == eSDto.Placa)
                                      .FirstOrDefault();

                if (lHm.Count > 0)
                {
                    lHmDto = new List <historialmovimientoDTO>();
                    foreach (historialmovimiento hM in lHm)
                    {
                        hMDto = new historialmovimientoDTO();
                        Mapper.Map(hM, hMDto);
                        hMDto.Ruta = dP.Ruta;
                        lHmDto.Add(hMDto);
                    }

                    return(lHmDto);
                }
                else
                {
                    return(null);
                }
            }
        }
示例#3
0
        private List <List <detallesplanillaDTO> > crearRotacionesBuses(ref string[] nBus, ref int mes, ref DateTime fcha,
                                                                        ref int grupo, ref List <rutagrupo> lrGrupo,
                                                                        ref List <buses> lBus)
        {
            planillacontrol pC;

            int diasMes = DateTime.DaysInMonth(fcha.Year, fcha.Month);
            int d       = 1;
            int k       = 1;
            int daysToToday;

            daysToToday = Convert.ToInt32((fcha - (new DateTime(DateTime.Now.Year, 1, 1))).TotalDays);
            string[] mBus = new string[30];
            List <List <detallesplanillaDTO> > lldP = new List <List <detallesplanillaDTO> >();

            for (int i = 1; i <= mesTurno.GetLength(1); i++)
            {
                mBus[i] = nBus[mesTurno[mes - 1, i - 1]];
            }

            for (int i = 0; i < dia.GetLength(0); i++)
            {
                if (diasMes == lldP.Count)
                {
                    break;
                }

                List <detallesplanillaDTO> ldP = new List <detallesplanillaDTO>();
                for (int j = 0; j < dia.GetLength(1); j++)
                {
                    detallesplanillaDTO dP = new detallesplanillaDTO();
                    dP.Vial     = mBus[dia[i, j]];
                    dP.PlacaBus = lBus.Find(t => t.Vial == dP.Vial).Placa;
                    ldP.Add(dP);
                    k++;
                }

                if (i == dia.GetLength(0) - 1)
                {
                    i = 0;
                }


                lldP.Add(ldP);

                /////////////// Rutas para cada dia //////////////////
                //En el primer objeto de la lista de detallesplanilla
                if ((lldP.Count + daysToToday) % 2 == 0)
                {
                    ldP.ElementAt(0).Ruta = lrGrupo.ElementAt(0).Ruta;
                }
                else
                {
                    try
                    {
                        ldP.ElementAt(0).Ruta = lrGrupo.ElementAt(1).Ruta;
                    }
                    catch (ArgumentOutOfRangeException e)
                    {
                        ldP.ElementAt(0).Ruta = lrGrupo.ElementAt(0).Ruta;
                    }
                }
                /////////////////////////////////////////////////////
            }

            ///Guardar Detalles de Planilla (Rotaciones del mes)
            ///
            using (ctx = new tvEntities()){
                foreach (List <detallesplanillaDTO> lDp in lldP)
                {
                    ////Creo una nueva Planilla control
                    pC       = new planillacontrol();
                    pC.Fecha = new DateTime(DateTime.Now.Year, mes, d);
                    pC.Grupo = grupo;
                    ctx.planillacontrol.Add(pC);
                    ctx.SaveChanges();
                    d++;

                    string ru   = lDp.ElementAt(0).Ruta;
                    rutas  ruta = ctx.rutas.Where(t => t.NomRuta == ru).FirstOrDefault();
                    int    frec = ruta.Frecuencia.Value;
                    time = ctx.horario.Where(t => t.id == ruta.idHorario).FirstOrDefault().hora.Value;

                    foreach (detallesplanillaDTO DpDTO in lDp)
                    {
                        DpDTO.idPlanillaControl = pC.id;
                        DpDTO.Ruta       = lDp.ElementAt(0).Ruta;
                        DpDTO.HoraSalida = time;
                        detallesplanilla dP = new detallesplanilla();
                        Mapper.Map(DpDTO, dP);
                        ctx.detallesplanilla.Add(dP);
                        ctx.SaveChanges();
                        DpDTO.id = dP.id;

                        time = time + new TimeSpan(0, frec, 0);
                    }
                }
            }
            ////////////////////////////////


            return(lldP);
        }